r65349 - in /trunk/libtext-csv-xs-perl: CSV_XS.pm CSV_XS.xs ChangeLog MANIFEST META.yml debian/changelog files/macosx.csv t/45_eol.t t/80_diag.t

ansgar at users.alioth.debian.org ansgar at users.alioth.debian.org
Sun Nov 28 12:05:07 UTC 2010


Author: ansgar
Date: Sun Nov 28 12:04:31 2010
New Revision: 65349

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=65349
Log:
New upstream release.

Added:
    trunk/libtext-csv-xs-perl/files/macosx.csv
      - copied unchanged from r65348, branches/upstream/libtext-csv-xs-perl/current/files/macosx.csv
Modified:
    trunk/libtext-csv-xs-perl/CSV_XS.pm
    trunk/libtext-csv-xs-perl/CSV_XS.xs
    trunk/libtext-csv-xs-perl/ChangeLog
    trunk/libtext-csv-xs-perl/MANIFEST
    trunk/libtext-csv-xs-perl/META.yml
    trunk/libtext-csv-xs-perl/debian/changelog
    trunk/libtext-csv-xs-perl/t/45_eol.t
    trunk/libtext-csv-xs-perl/t/80_diag.t

Modified: trunk/libtext-csv-xs-perl/CSV_XS.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/CSV_XS.pm?rev=65349&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/CSV_XS.pm (original)
+++ trunk/libtext-csv-xs-perl/CSV_XS.pm Sun Nov 28 12:04:31 2010
@@ -30,7 +30,7 @@
 use Carp;
 
 use vars   qw( $VERSION @ISA );
-$VERSION = "0.76";
+$VERSION = "0.79";
 @ISA     = qw( DynaLoader );
 bootstrap Text::CSV_XS $VERSION;
 

Modified: trunk/libtext-csv-xs-perl/CSV_XS.xs
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/CSV_XS.xs?rev=65349&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/CSV_XS.xs (original)
+++ trunk/libtext-csv-xs-perl/CSV_XS.xs Sun Nov 28 12:04:31 2010
@@ -316,17 +316,17 @@
 #define _pretty_str(csv,xse)	cx_pretty_str (aTHX_ csv, xse)
 static char *cx_pretty_str (pTHX_ byte *s, STRLEN l)
 {
-    SV *dsv = newSVpvs ("");
+    SV *dsv = sv_2mortal (newSVpvs (""));
     return (pv_pretty (dsv, (char *)s, l, 0, NULL, NULL,
 	    (PERL_PV_PRETTY_DUMP | PERL_PV_ESCAPE_UNI_DETECT)));
     } /* _pretty_str */
 
 #define _cache_show_byte(trim,idx) \
-    c = cp[idx]; (void)fprintf (stderr, "  %-20s %02x:%3d\n", trim, c, c)
+    c = cp[idx]; warn ("  %-20s %02x:%3d\n", trim, c, c)
 #define _cache_show_char(trim,idx) \
-    c = cp[idx]; (void)fprintf (stderr, "  %-20s %02x:%s\n",  trim, c, _pretty_str (&c, 1))
-#define _cache_show_str(trim,l,s) \
-    (void)fprintf (stderr, "  %-20s %02d:%s\n",  trim, l, _pretty_str (s, l))
+    c = cp[idx]; warn ("  %-20s %02x:%s\n",  trim, c, _pretty_str (&c, 1))
+#define _cache_show_str(trim,l,str) \
+    warn ("  %-20s %02d:%s\n",  trim, l, _pretty_str (str, l))
 #define _cache_show_cstr(trim,l,idx) _cache_show_str (trim, l, cp + idx)
 
 #define xs_cache_diag(hv)	cx_xs_cache_diag (aTHX_ hv)
@@ -336,12 +336,12 @@
     byte *cp, c;
 
     unless ((svp = hv_fetchs (hv, "_CACHE", FALSE)) && *svp) {
-	(void)fprintf (stderr, "CACHE: invalid\n");
+	warn ("CACHE: invalid\n");
 	return;
 	}
 
     cp = (byte *)SvPV_nolen (*svp);
-    (void)fprintf (stderr, "CACHE:\n");
+    warn ("CACHE:\n");
     _cache_show_char ("quote",			CACHE_ID_quote_char);
     _cache_show_char ("escape",			CACHE_ID_escape_char);
     _cache_show_char ("sep",			CACHE_ID_sep_char);
@@ -566,17 +566,13 @@
 	    csv->is_bound = 0;
 	}
 
-    csv->eolx = 0;
-    if (csv->eol_len) {
-	if (csv->verbatim)
-	    csv->eolx = 1;
-	else
-	for (len = 0; len < csv->eol_len; len++) {
-	    if (csv->eol[len] == CH_NL || csv->eol[len] == CH_CR) continue;
-	    csv->eolx = 1;
-	    break;
-	    }
-	}
+    csv->eolx = csv->eol_len 
+	? csv->verbatim || csv->eol_len >= 2
+	    ? 1
+	    : csv->eol[0] == CH_CR || csv->eol[0] == CH_NL
+		? 0
+		: 1
+	: 0;
     } /* SetupCsv */
 
 #define Print(csv,dst)		cx_Print (aTHX_ csv, dst)
@@ -687,7 +683,7 @@
 		    else {
 			SvREFCNT_inc (*svp);
 			unless (hv_store (csv->self, "_ERROR_INPUT", 12, *svp, 0))
-			    SvREFCNT_dec (*svp);
+/* uncovered */		    SvREFCNT_dec (*svp);
 			(void)SetDiag (csv, 2110);
 			return FALSE;
 			}
@@ -741,13 +737,13 @@
 
     if (csv->tmp && csv->eol_pos >= 0) {
 	csv->eol_pos = -2;
-	sv_setpvn (csv->tmp, csv->eol, csv->eol_len);
+	sv_setpvn (csv->tmp, (char *)csv->eol, csv->eol_len);
 	csv->bptr = SvPV (csv->tmp, csv->size);
 	csv->used = 0;
 	return CH_EOLX;
 	}
 
-    {	int		result, rslen;
+    {	STRLEN		result, rslen;
 	const char	*rs;
 
 	dSP;
@@ -755,9 +751,9 @@
 	require_IO_Handle;
 
 	csv->eol_pos = -1;
-	if (csv->eolx) {
+	if (csv->eolx || csv->eol_is_cr) {
 	    rs = SvPOK (PL_rs) || SvPOKp (PL_rs) ? SvPV_const (PL_rs, rslen) : NULL;
-	    sv_setpvn (PL_rs, csv->eol, csv->eol_len);
+	    sv_setpvn (PL_rs, (char *)csv->eol, csv->eol_len);
 	    }
 	PUSHMARK (sp);
 	EXTEND (sp, 1);
@@ -766,7 +762,7 @@
 	result = call_sv (m_getline, G_SCALAR | G_METHOD);
 	SPAGAIN;
 	csv->tmp = result ? POPs : NULL;
-	if (csv->eolx) {
+	if (csv->eolx || csv->eol_is_cr) {
 	    if (rs)
 		sv_setpvn (PL_rs, rs, rslen);
 	    else
@@ -1065,10 +1061,10 @@
 
 		if (csv->useIO && csv->eol_len == 0 && !is_csv_binary (c2)) {
 		    set_eol_is_cr (csv);
-		    c = CH_NL;
 		    csv->used--;
 		    csv->has_ahead++;
-		    goto restart;
+		    AV_PUSH;
+		    return TRUE;
 		    }
 
 		csv->used--;
@@ -1214,14 +1210,6 @@
 
 			if (c3 == CH_NL || c3 == CH_EOLX) {
 			    AV_PUSH;
-			    return TRUE;
-			    }
-
-			if (csv->useIO && csv->eol_len == 0 && !is_csv_binary (c3)) {
-			    set_eol_is_cr (csv);
-			    AV_PUSH;
-			    csv->used--;
-			    csv->has_ahead++;
 			    return TRUE;
 			    }
 			}

Modified: trunk/libtext-csv-xs-perl/ChangeLog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/ChangeLog?rev=65349&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/ChangeLog (original)
+++ trunk/libtext-csv-xs-perl/ChangeLog Sun Nov 28 12:04:31 2010
@@ -1,3 +1,17 @@
+2010-11-26 0.79 - H.Merijn Brand   <h.m.brand at xs4all.nl>
+    * Use correct type for STRLEN (HP-UX/PA-RISC/32)
+    * More code coverage
+    * EOF unreliable when line-end missing at eof
+
+2010-11-26 0.78 - H.Merijn Brand   <h.m.brand at xs4all.nl>
+    * Version 0.77 broke MacOS exported CSV files with only \r
+
+2010-10-23 0.77 - H.Merijn Brand   <h.m.brand at xs4all.nl>
+    * Internals now use warn () instead of (void)fprintf (stderr, ...)
+      Now the test in t/80_diag also passes on Windows
+    * Better parsing for eol = \r and set as such (RT#61525)
+    * Workaround for AIX cpp bug (RT#62388, Jan Dubois)
+
 2010-10-09 0.76 - H.Merijn Brand   <h.m.brand at xs4all.nl>
     * Windows doesn't support STDERR redirection as used in t/80_diag
 

Modified: trunk/libtext-csv-xs-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/MANIFEST?rev=65349&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/MANIFEST (original)
+++ trunk/libtext-csv-xs-perl/MANIFEST Sun Nov 28 12:04:31 2010
@@ -36,4 +36,5 @@
 examples/csvdiff	Script to shoff diff between sorted CSV files
 examples/parser-xs.pl	Parse CSV stream, be forgiving on bad lines
 examples/speed.pl	Small benchmark script
+files/macosx.csv	A CSV files exported on MacOSX
 files/utf8.csv		A UTF-8 encode test file

Modified: trunk/libtext-csv-xs-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/META.yml?rev=65349&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/META.yml (original)
+++ trunk/libtext-csv-xs-perl/META.yml Sun Nov 28 12:04:31 2010
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:                    Text-CSV_XS
-version:                 0.76
+version:                 0.79
 abstract:                Comma-Separated Values manipulation routines
 license:                 perl
 author:              
@@ -10,7 +10,7 @@
 provides:
     Text::CSV_XS:
         file:            CSV_XS.pm
-        version:         0.76
+        version:         0.79
 requires:     
     perl:                5.005
     DynaLoader:          0

Modified: trunk/libtext-csv-xs-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/debian/changelog?rev=65349&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/debian/changelog (original)
+++ trunk/libtext-csv-xs-perl/debian/changelog Sun Nov 28 12:04:31 2010
@@ -1,9 +1,8 @@
-libtext-csv-xs-perl (0.76-1) UNRELEASED; urgency=low
-
-  IGNORE-VERSION: 0.76-1
-  Fix test on Windows.
-
- -- Ansgar Burchardt <ansgar at debian.org>  Wed, 13 Oct 2010 17:56:57 +0200
+libtext-csv-xs-perl (0.79-1) unstable; urgency=low
+
+  * New upstream release.
+
+ -- Ansgar Burchardt <ansgar at debian.org>  Sun, 28 Nov 2010 13:03:48 +0100
 
 libtext-csv-xs-perl (0.75-1) unstable; urgency=low
 

Modified: trunk/libtext-csv-xs-perl/t/45_eol.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/t/45_eol.t?rev=65349&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/t/45_eol.t (original)
+++ trunk/libtext-csv-xs-perl/t/45_eol.t Sun Nov 28 12:04:31 2010
@@ -3,7 +3,7 @@
 use strict;
 $^W = 1;
 
-use Test::More tests => 546;
+use Test::More tests => 1065;
 
 BEGIN {
     require_ok "Text::CSV_XS";
@@ -168,8 +168,12 @@
     }
 $/ = $def_rs;
 
-foreach my $eol ("!", "!!", "!\n", "!\n!") {
+foreach my $eol ("!", "!!", "!\n", "!\n!", "!!!!!!!!", "!!!!!!!!!!",
+		 "\n!!!!!\n!!!!!", "!!!!!\n!!!!!\n", "%^+_\n\0!X**",
+		 "\r\n", "\r") {
     (my $s_eol = $eol) =~ s/\n/\\n/g;
+    $s_eol =~ s/\r/\\r/g;
+    $s_eol =~ s/\0/\\0/g;
     ok (1, "EOL $s_eol");
     ok (my $csv = Text::CSV_XS->new ({ eol => $eol }), "new csv with eol => $s_eol");
     open  FH, ">_eol.csv";
@@ -183,10 +187,10 @@
 	ok (1, "with RS $s_rs");
 	open FH, "<_eol.csv";
 	ok (my $row = $csv->getline (*FH),	"getline 1");
-	is (scalar @$row, 3,			"# fields");
+	is (scalar @$row, 3,			"field count");
 	is_deeply ($row, [ 1, 2, 3],		"fields 1");
 	ok (   $row = $csv->getline (*FH),	"getline 2");
-	is (scalar @$row, 3,			"# fields");
+	is (scalar @$row, 3,			"field count");
 	is_deeply ($row, [ 4, 5, 6],		"fields 2");
 	close FH;
 	}
@@ -194,4 +198,58 @@
     }
 $/ = $def_rs;
 
+{   open FH, "<files/macosx.csv" or die "Ouch $!";
+    ok (1, "MacOSX exported file");
+    ok (my $csv = Text::CSV_XS->new ({ auto_diag => 1, binary => 1 }), "new csv");
+    diag ();
+    ok (my $row = $csv->getline (*FH),	"getline 1");
+    is (scalar @$row, 15,		"field count");
+    is ($row->[7], "",			"field 8");
+    ok (   $row = $csv->getline (*FH),	"getline 2");
+    is (scalar @$row, 15,		"field count");
+    is ($row->[6], "Category",		"field 7");
+    ok (   $row = $csv->getline (*FH),	"getline 3");
+    is (scalar @$row, 15,		"field count");
+    is ($row->[5], "Notes",		"field 6");
+    ok (   $row = $csv->getline (*FH),	"getline 4");
+    is (scalar @$row, 15,		"field count");
+    is ($row->[7], "Points",		"field 8");
+    ok (   $row = $csv->getline (*FH),	"getline 5");
+    is (scalar @$row, 15,		"field count");
+    is ($row->[7], 11,			"field 8");
+    ok (   $row = $csv->getline (*FH),	"getline 6");
+    is (scalar @$row, 15,		"field count");
+    is ($row->[8], 34,			"field 9");
+    ok (   $row = $csv->getline (*FH),	"getline 7");
+    is (scalar @$row, 15,		"field count");
+    is ($row->[7], 12,			"field 8");
+    ok (   $row = $csv->getline (*FH),	"getline 8");
+    is (scalar @$row, 15,		"field count");
+    is ($row->[8], 2,			"field 9");
+    ok (   $row = $csv->getline (*FH),	"getline 9");
+    is (scalar @$row, 15,		"field count");
+    is ($row->[3], "devs",		"field 4");
+    ok (   $row = $csv->getline (*FH),	"getline 10");
+    is (scalar @$row, 15,		"field count");
+    is ($row->[3], "",			"field 4");
+    ok (   $row = $csv->getline (*FH),	"getline 11");
+    is (scalar @$row, 15,		"field count");
+    is ($row->[6], "Mean",		"field 7");
+    ok (   $row = $csv->getline (*FH),	"getline 12");
+    is (scalar @$row, 15,		"field count");
+    is ($row->[6], "Median",		"field 7");
+    ok (   $row = $csv->getline (*FH),	"getline 13");
+    is (scalar @$row, 15,		"field count");
+    is ($row->[6], "Mode",		"field 7");
+    ok (   $row = $csv->getline (*FH),	"getline 14");
+    is (scalar @$row, 15,		"field count");
+    is ($row->[6], "Min",		"field 7");
+    ok (   $row = $csv->getline (*FH),	"getline 15");
+    is (scalar @$row, 15,		"field count");
+    is ($row->[6], "Max",		"field 7");
+    ok (   $row = $csv->getline (*FH),	"getline 16");
+    is (scalar @$row, 15,		"field count");
+    is ($row->[0], "",			"field 1");
+    }
+
 1;

Modified: trunk/libtext-csv-xs-perl/t/80_diag.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/t/80_diag.t?rev=65349&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/t/80_diag.t (original)
+++ trunk/libtext-csv-xs-perl/t/80_diag.t Sun Nov 28 12:04:31 2010
@@ -3,7 +3,7 @@
 use strict;
 $^W = 1;
 
- use Test::More tests => 122;
+ use Test::More tests => 124;
 #use Test::More "no_plan";
 
 my %err;
@@ -116,22 +116,25 @@
     like ($@, qr '^# CSV_XS ERROR: 2027 -', "2 - error message");
     }
 
-SKIP: {
-    $^O =~ m/MSWin/i and skip "Windows does not support STDERR redirection as used in these tests", 23;
-
-    my $diag_file = "_$$.out";
-    open  EH,     ">&STDERR";
-    open  STDERR, ">$diag_file";
-    ok ($csv->_cache_diag,	"Cache debugging output");
-    close STDERR;
-    open  STDERR, ">&EH";
-    open  EH,     "<$diag_file";
-    is (scalar <EH>, "CACHE:\n",	"Title");
-    while (<EH>) {
-	like ($_, qr{^  \w+\s+[0-9a-f]+:(?:".*"|\s*[0-9]+)$}, "Content");
-	}
-    close EH;
-    unlink $diag_file;
+{   my @warn;
+    local $SIG{__WARN__} = sub { push @warn, @_ };
+    Text::CSV_XS->new ()->_cache_diag ();
+    ok (@warn == 1, "Got warn");
+    is ($warn[0], "CACHE: invalid\n", "Uninitialized cache");
     }
 
+my $diag_file = "_$$.out";
+open  EH,     ">&STDERR";
+open  STDERR, ">$diag_file";
+ok ($csv->_cache_diag,	"Cache debugging output");
+close STDERR;
+open  STDERR, ">&EH";
+open  EH,     "<$diag_file";
+is (scalar <EH>, "CACHE:\n",	"Title");
+while (<EH>) {
+    like ($_, qr{^  \w+\s+[0-9a-f]+:(?:".*"|\s*[0-9]+)$}, "Content");
+    }
+close EH;
+unlink $diag_file;
+
 1;




More information about the Pkg-perl-cvs-commits mailing list