Skip Menu |
 

This queue is for tickets about the Text-VCardFast CPAN distribution.

Report information
The Basics
Id: 120083
Status: new
Priority: 0/
Queue: Text-VCardFast

People
Owner: Nobody in particular
Requestors: corion [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.11

Attachments


Subject: strndup is not available on many platforms
Download (untitled) / with headers
text/plain 632b
The source code uses strndup, which is not available on Windows and likely other platforms as well. This post on Stackoverflow suggests an LGPL implementation: http://stackoverflow.com/questions/6062822/whats-wrong-with-strndup by Apple at http://opensource.apple.com/source/gcc/gcc-5575.11/libiberty/strndup.c I couldn't find a BSD-licensed implementation of it, but it is likely not that hard to write. Further discussion https://www.postgresql.org/message-id/20050929152652.GA62140@winnie.fuhr.org It would be great if you could elide the use of strncopy from your module as that prevents me from using Net::CalDAVTalk.
Download (untitled) / with headers
text/plain 197b
There is a public domain implementation at https://github.com/clibs/strndup This could be pasted into the source code potentially hidden behind a #define to make the routein available everywhere.
Download (untitled) / with headers
text/plain 365b
See the attached patch which adds the MIT-licensed strncopy. It doesn't try to load a system-supplied copy first, which will likely need compiler-probing or hardcoding the OSes where the replacement is needed. Adding this patch makes the module compile and install and Net::CalDAVTalk install and test. If you want, I can publish this as a git (github) repository
Subject: 0001-Unconditionally-load-our-own-strndup.patch
From 19de9ce6dab9dd788423c9e297d174f9a7eef1b1 Mon Sep 17 00:00:00 2001 From: Max Maischein <corion@corion.net> Date: Fri, 3 Feb 2017 17:42:33 +0100 Subject: [PATCH 1/2] Unconditionally load our own strndup() --- VCardFast.xs | 1 + strndup.c | 16 ++++++++++++++++ strndup.h | 6 ++++++ 3 files changed, 23 insertions(+) create mode 100644 strndup.c create mode 100644 strndup.h diff --git a/VCardFast.xs b/VCardFast.xs index 9813c5a..9fb77c6 100644 --- a/VCardFast.xs +++ b/VCardFast.xs @@ -5,6 +5,7 @@ #include "ppport.h" #include "vparse.h" +#include "strndup.h" // hv_store to array, create if not exists - from XML::Fast 0.11 #define hv_store_aa( hv, kv, kl, sv ) \ diff --git a/strndup.c b/strndup.c new file mode 100644 index 0000000..d02657d --- /dev/null +++ b/strndup.c @@ -0,0 +1,16 @@ +#ifndef HAVE_STRNDUP + +#include <stdlib.h> +#include <string.h> + +char *strndup(const char *s, size_t n) +{ + char* new = malloc(n+1); + if (new) { + strncpy(new, s, n); + new[n] = '\0'; + } + return new; +} + +#endif /* HAVE_STRNDUP */ diff --git a/strndup.h b/strndup.h new file mode 100644 index 0000000..2f49b76 --- /dev/null +++ b/strndup.h @@ -0,0 +1,6 @@ +#ifndef HAVE_STRNDUP +#define HAVE_STRNDUP + +char *strndup(const char *s, size_t n); + +#endif /* HAVE_STRNDUP */ -- 2.5.0.windows.1
Subject: 0002-Sort-MANIFEST.patch
From f2695eddc957563ec8d3cef8a90a85b9a205c8d3 Mon Sep 17 00:00:00 2001 From: Max Maischein <corion@corion.net> Date: Fri, 3 Feb 2017 17:42:37 +0100 Subject: [PATCH 2/2] Sort MANIFEST --- MANIFEST | 56 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/MANIFEST b/MANIFEST index 3bbfbfc..7c379bd 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,41 +1,43 @@ +benchmark/bench.pl Changes +lib/Text/VCardFast.pm Makefile.PL MANIFEST +META.json Module JSON meta-data (added by MakeMaker) +META.yml Module YAML meta-data (added by MakeMaker) ppport.h README -VCardFast.xs -vparse.c -vparse.h -benchmark/bench.pl -lib/Text/VCardFast.pm -t/Text-VCardFast.t -t/Errors.t +strndup.c +strndup.h t/Cases.t -t/Create.t -t/Trailing.t -t/cases/wp-v3.vcf -t/cases/trailingslash.vcf -t/cases/fm.json -t/cases/rfcex1-v3.json t/cases/ex-apple.json +t/cases/ex-apple.vcf t/cases/ex-cobook.json -t/cases/ex2-v4.vcf t/cases/ex-cobook.vcf -t/cases/wp-v3.json +t/cases/ex-google.json +t/cases/ex-google.vcf t/cases/ex-memotoo.json -t/cases/wp-v4.vcf -t/cases/ex-apple.vcf -t/cases/wp-v4.json -t/cases/ex-v4.json t/cases/ex-memotoo.vcf +t/cases/ex-v4.json +t/cases/ex-v4.vcf +t/cases/ex2-v4.json +t/cases/ex2-v4.vcf +t/cases/fm.json +t/cases/fm.vcf +t/cases/rfcex1-v3.json +t/cases/rfcex1-v3.vcf t/cases/trailingslash.json +t/cases/trailingslash.vcf t/cases/unicode.json -t/cases/rfcex1-v3.vcf t/cases/unicode.vcf -t/cases/ex2-v4.json -t/cases/ex-google.json -t/cases/ex-v4.vcf -t/cases/ex-google.vcf -t/cases/fm.vcf -META.yml Module YAML meta-data (added by MakeMaker) -META.json Module JSON meta-data (added by MakeMaker) +t/cases/wp-v3.json +t/cases/wp-v3.vcf +t/cases/wp-v4.json +t/cases/wp-v4.vcf +t/Create.t +t/Errors.t +t/Text-VCardFast.t +t/Trailing.t +VCardFast.xs +vparse.c +vparse.h -- 2.5.0.windows.1
Download (untitled) / with headers
text/plain 529b
Am Fr 03. Feb 2017, 11:46:37, CORION schrieb: Show quoted text
> See the attached patch which adds the MIT-licensed strncopy. It > doesn't try to load a system-supplied copy first, which will likely > need compiler-probing or hardcoding the OSes where the replacement is > needed. > > Adding this patch makes the module compile and install and > Net::CalDAVTalk install and test. > > If you want, I can publish this as a git (github) repository
Also see https://github.com/Corion/Text-VCardFast/commit/18164cd636a074e8fac877bc40818b4aadbe5215


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.