r54583 - in /trunk/libtext-csv-xs-perl: CSV_XS.pm CSV_XS.xs ChangeLog META.yml debian/changelog examples/csv-check examples/csv2xls t/12_acc.t t/41_null.t t/70_rt.t

franck at users.alioth.debian.org franck at users.alioth.debian.org
Fri Mar 19 18:08:34 UTC 2010


Author: franck
Date: Fri Mar 19 18:08:21 2010
New Revision: 54583

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=54583
Log:
Integrating new upstream version into trunk

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/META.yml
    trunk/libtext-csv-xs-perl/debian/changelog
    trunk/libtext-csv-xs-perl/examples/csv-check
    trunk/libtext-csv-xs-perl/examples/csv2xls
    trunk/libtext-csv-xs-perl/t/12_acc.t
    trunk/libtext-csv-xs-perl/t/41_null.t
    trunk/libtext-csv-xs-perl/t/70_rt.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=54583&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/CSV_XS.pm (original)
+++ trunk/libtext-csv-xs-perl/CSV_XS.pm Fri Mar 19 18:08:21 2010
@@ -30,7 +30,7 @@
 use Carp;
 
 use vars   qw( $VERSION @ISA );
-$VERSION = "0.71";
+$VERSION = "0.72";
 @ISA     = qw( DynaLoader );
 bootstrap Text::CSV_XS $VERSION;
 
@@ -60,6 +60,7 @@
     eol			=> '',
     always_quote	=> 0,
     quote_space		=> 1,
+    quote_null		=> 1,
     binary		=> 0,
     keep_meta_info	=> 0,
     allow_loose_quotes	=> 0,
@@ -150,6 +151,7 @@
     empty_is_undef	=> 23,
     auto_diag		=> 24,
     quote_space		=> 25,
+    quote_null		=> 31,
     _is_bound		=> 26,	# 26 .. 29
     );
 
@@ -236,6 +238,13 @@
     @_ and $self->_set_attr_X ("quote_space", shift);
     $self->{quote_space};
     } # quote_space
+
+sub quote_null
+{
+    my $self = shift;
+    @_ and $self->_set_attr_X ("quote_null", shift);
+    $self->{quote_null};
+    } # quote_null
 
 sub binary
 {
@@ -354,7 +363,7 @@
     my $context = wantarray;
     unless (defined $context) {	# Void context, auto-diag
 	if ($diag[0] && $diag[0] != 2012) {
-	    my $msg = "# CSV_XS ERROR: $diag[0] - $diag[1]\n";
+	    my $msg = "# CSV_XS ERROR: $diag[0] - $diag[1] \@ pos $diag[2]\n";
 	    if ($self && ref $self) {	# auto_diag
 
 		my $lvl = $self->{auto_diag};
@@ -933,7 +942,14 @@
 By default, a space in a field would trigger quotation. As no rule
 exists this to be forced in CSV, nor any for the opposite, the default
 is true for safety. You can exclude the space from this trigger by
-setting this option to 0.
+setting this attribute to 0.
+
+=item quote_null
+
+By default, a NULL byte in a field would be escaped. This attribute
+enables you to treat the NULL byte as a simple binary character in
+binary mode (the C<{ binary => 1 }> is set). The default is true.
+You can prevent NULL escapes by setting this attribute to 0.
 
 =item keep_meta_info
 
@@ -982,7 +998,7 @@
 Set to true will cause C<error_diag ()> to be automatically be called
 in void context upon errors.
 
-In case of error C<2012 - EOF>), this call will be void.
+In case of error C<2012 - EOF>, this call will be void.
 
 If set to a value greater than 1, it will die on errors instead of
 warn.
@@ -1006,6 +1022,7 @@
      eol                 => $\,
      always_quote        => 0,
      quote_space         => 1,
+     quote_null	         => 1,
      binary              => 0,
      keep_meta_info      => 0,
      allow_loose_quotes  => 0,

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=54583&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/CSV_XS.xs (original)
+++ trunk/libtext-csv-xs-perl/CSV_XS.xs Fri Mar 19 18:08:21 2010
@@ -57,6 +57,7 @@
 #define CACHE_ID_quote_space		25
 #define CACHE_ID__is_bound		26
 #define CACHE_ID__has_ahead		30
+#define CACHE_ID_quote_null		31
 
 #define CSV_FLAGS_QUO	0x0001
 #define CSV_FLAGS_BIN	0x0002
@@ -105,6 +106,7 @@
     byte	auto_diag;
 
     byte	quote_space;
+    byte	quote_null;
     byte	first_safe_char;
 
     long	is_bound;
@@ -271,6 +273,7 @@
          idx == CACHE_ID_keep_meta_info		||
          idx == CACHE_ID_always_quote		||
          idx == CACHE_ID_quote_space		||
+         idx == CACHE_ID_quote_null		||
          idx == CACHE_ID_allow_loose_quotes	||
          idx == CACHE_ID_allow_loose_escapes	||
          idx == CACHE_ID_allow_double_quoted	||
@@ -279,7 +282,7 @@
 	 idx == CACHE_ID_empty_is_undef		||
 	 idx == CACHE_ID_verbatim		||
 	 idx == CACHE_ID_auto_diag) {
-	cp[idx] = SvIV (val);
+	cp[idx] = (byte)SvIV (val);
 	return;
 	}
 
@@ -346,6 +349,7 @@
     _cache_show_byte ("allow_whitespace",	CACHE_ID_allow_whitespace);
     _cache_show_byte ("always_quote",		CACHE_ID_always_quote);
     _cache_show_byte ("quote_space",		CACHE_ID_quote_space);
+    _cache_show_byte ("quote_null",		CACHE_ID_quote_null);
     _cache_show_byte ("auto_diag",		CACHE_ID_auto_diag);
     _cache_show_byte ("blank_is_undef",		CACHE_ID_blank_is_undef);
     _cache_show_byte ("empty_is_undef",		CACHE_ID_empty_is_undef);
@@ -407,6 +411,7 @@
 	csv->always_quote		= csv->cache[CACHE_ID_always_quote	];
 	csv->auto_diag			= csv->cache[CACHE_ID_auto_diag	];
 	csv->quote_space		= csv->cache[CACHE_ID_quote_space	];
+	csv->quote_null			= csv->cache[CACHE_ID_quote_null	];
 
 	csv->allow_loose_quotes		= csv->cache[CACHE_ID_allow_loose_quotes];
 	csv->allow_loose_escapes	= csv->cache[CACHE_ID_allow_loose_escapes];
@@ -497,6 +502,7 @@
 	csv->keep_meta_info		= bool_opt ("keep_meta_info");
 	csv->always_quote		= bool_opt ("always_quote");
 	csv->quote_space		= bool_opt_def ("quote_space", 1);
+	csv->quote_null			= bool_opt_def ("quote_null", 1);
 	csv->allow_loose_quotes		= bool_opt ("allow_loose_quotes");
 	csv->allow_loose_escapes	= bool_opt ("allow_loose_escapes");
 	csv->allow_double_quoted	= bool_opt ("allow_double_quoted");
@@ -519,6 +525,7 @@
 	csv->cache[CACHE_ID_keep_meta_info]		= csv->keep_meta_info;
 	csv->cache[CACHE_ID_always_quote]		= csv->always_quote;
 	csv->cache[CACHE_ID_quote_space]		= csv->quote_space;
+	csv->cache[CACHE_ID_quote_null]			= csv->quote_null;
 
 	csv->cache[CACHE_ID_allow_loose_quotes]		= csv->allow_loose_quotes;
 	csv->cache[CACHE_ID_allow_loose_escapes]	= csv->allow_loose_escapes;
@@ -673,7 +680,7 @@
 		if (c == csv->escape_char && csv->escape_char)
 		    e = 1;
 		else
-		if (c == (char)0) {
+		if (c == (char)0          && csv->quote_null) {
 		    e = 1;
 		    c = '0';
 		    }

Modified: trunk/libtext-csv-xs-perl/ChangeLog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/ChangeLog?rev=54583&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/ChangeLog (original)
+++ trunk/libtext-csv-xs-perl/ChangeLog Fri Mar 19 18:08:21 2010
@@ -1,3 +1,12 @@
+2010-03-16 0.72 - H.Merijn Brand   <h.m.brand at xs4all.nl>
+
+    * Introduce quote_null attribute (RT#55200)
+    * examples/csv-check can be used for Text::CSV_PP
+    * examples/csv-check more options for sep_, escape_ and quote_char
+    * examples/csv2xls more options for sep_, escape_ and quote_char
+    * examples/csv2xls added auto_diag and verbosity
+    * Dropped YAML spec to 1.0
+
 2010-02-15 0.71 - H.Merijn Brand   <h.m.brand at xs4all.nl>
 
     * Upped copyright to 2010

Modified: trunk/libtext-csv-xs-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/META.yml?rev=54583&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/META.yml (original)
+++ trunk/libtext-csv-xs-perl/META.yml Fri Mar 19 18:08:21 2010
@@ -1,6 +1,6 @@
---- #YAML:1.1
+--- #YAML:1.0
 name:                    Text-CSV_XS
-version:                 0.71
+version:                 0.72
 abstract:                Comma-Separated Values manipulation routines
 license:                 perl
 author:              
@@ -10,7 +10,7 @@
 provides:
     Text::CSV_XS:
         file:            CSV_XS.pm
-        version:         0.71
+        version:         0.72
 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=54583&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/debian/changelog (original)
+++ trunk/libtext-csv-xs-perl/debian/changelog Fri Mar 19 18:08:21 2010
@@ -1,3 +1,9 @@
+libtext-csv-xs-perl (0.72-1) UNRELEASED; urgency=low
+
+  * New upstream release
+
+ -- Franck Joncourt <franck at debian.org>  Fri, 19 Mar 2010 19:07:56 +0100
+
 libtext-csv-xs-perl (0.71-1) unstable; urgency=low
 
   * New upstream release

Modified: trunk/libtext-csv-xs-perl/examples/csv-check
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/examples/csv-check?rev=54583&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/examples/csv-check (original)
+++ trunk/libtext-csv-xs-perl/examples/csv-check Fri Mar 19 18:08:21 2010
@@ -1,7 +1,7 @@
 #!/pro/bin/perl
 
 # csv-check: Check validity of CSV file and report
-#	   (m)'09 [12 Oct 2009] Copyright H.M.Brand 2007-2010
+#	   (m)'10 [10 Mar 2010] Copyright H.M.Brand 2007-2010
 
 # This code requires the defined-or feature and PerlIO
 
@@ -11,16 +11,22 @@
 use Data::Peek;
 use Encode qw( decode );
 
-our $VERSION = "1.4";	# 2009-10-12
+our $VERSION = "1.5";	# 2010-03-10
 
 sub usage
 {
     my $err = shift and select STDERR;
     print <<EOU;
-usage: csv-check [-s <sep>] [-q <quot>] [-u] [file.csv]
+usage: csv-check [-s <sep>] [-q <quot>] [-e <esc>] [-u] [--pp] [file.csv]
        -s <sep>   use <sep>   as seperator char. Auto-detect, default = ','
+                  The string "tab" is allowed.
+       -e <esc>   use <sep>   as seperator char. Auto-detect, default = ','
+                  The string "undef" is allowed.
        -q <quot>  use <quot>  as quotation char. Default = '"'
+                  The string "undef" will disable quotation.
        -u         check if all fields are valid unicode
+
+       --pp       use Text::CSV_PP instead (cross-check)
 EOU
     exit $err;
     } # usage
@@ -28,16 +34,29 @@
 use Getopt::Long qw(:config bundling nopermute passthrough);
 my $sep;	# Set after reading first line in a flurry attempt to auto-detect
 my $quo = '"';
+my $esc = '"';
 my $opt_u = 0;
+my $opt_p = 0;
 GetOptions (
     "help|?"	=> sub { usage (0); },
 
     "c|s=s"	=> \$sep,
     "q=s"	=> \$quo,
+    "e=s"	=> \$esc,
     "u"		=> \$opt_u,
+
+    "pp!"	=> \$opt_p,
     ) or usage (1);
 
-use Text::CSV_XS;
+my  $csvmod = "Text::CSV_XS";
+if ($opt_p) {
+    require Text::CSV_PP;
+    $csvmod = "Text::CSV_PP";
+    }
+else {
+    require Text::CSV_XS;
+    }
+$csvmod->import ();
 
 my $fn = $ARGV[0] // "-";
 my $data = do { local $/; <> } or die "No data to analyze\n";
@@ -54,9 +73,10 @@
     $data =~ m/([\r\n]+)\Z/ and $eol = DDisplay "$1";
     }
 
-my $csv = Text::CSV_XS-> new ({
-    sep_char       => $sep,
-    quote_char     => $quo,
+my $csv = $csvmod->new ({
+    sep_char       => $sep eq "tab"   ? "\t"  : $sep,
+    quote_char     => $quo eq "undef" ? undef : $quo,
+    escape_char    => $esc eq "undef" ? undef : $esc,
     binary         => 1,
     keep_meta_info => 1,
     auto_diag      => 1,
@@ -66,7 +86,7 @@
 {
     (my $file = $ARGV // "") =~ s{(\S)$}{$1 };
     (my $prog = $0) =~ s{.*/}{};
-    print "Checked $file with $prog $VERSION using Text::CSV_XS $Text::CSV_XS::VERSION\n";
+    print "Checked $file with $prog $VERSION using $csvmod @{[$csvmod->VERSION]}\n";
     my @diag = $csv->error_diag;
     if ($diag[0] == 2012 && $csv->eof) {
 	my @coll = sort { $a <=> $b } keys %cols;
@@ -75,6 +95,13 @@
 	defined $eol or $eol = $csv->eol || "--unknown--";
 	print "OK: rows: $rows, columns: $cols\n";
 	print "    sep = <$sep>, quo = <$quo>, bin = <$bin>, eol = <$eol>\n";
+	if (@coll > 1) {
+	    print "WARN: multiple column lengths:\n";
+	    printf " %6d line%s with %4d field%s\n",
+		$cols{$_}, $cols{$_} == 1 ? " " : "s",
+		$_,        $_        == 1 ? ""  : "s"
+		    for @coll;
+	    }
 	exit 0;
 	}
 

Modified: trunk/libtext-csv-xs-perl/examples/csv2xls
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/examples/csv2xls?rev=54583&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/examples/csv2xls (original)
+++ trunk/libtext-csv-xs-perl/examples/csv2xls Fri Mar 19 18:08:21 2010
@@ -1,12 +1,12 @@
 #!/pro/bin/perl
 
 # csv2xls: Convert csv to xls
-#	   (m)'08 [22 May 2008] Copyright H.M.Brand 2007-2010
+#	   (m)'10 [15 Mar 2008] Copyright H.M.Brand 2007-2010
 
 use strict;
 use warnings;
 
-our $VERSION = "1.61";
+our $VERSION = "1.62";
 
 sub usage
 {
@@ -14,8 +14,12 @@
     print <<EOU;
 usage: csv2xls [-s <sep>] [-q <quot>] [-w <width>] [-d <dtfmt>]
                [-o <xls>] [file.csv]
-       -s <sep>   use <sep>   as seperator char. Auto-detect, default = ';'
+       -s <sep>   use <sep>   as seperator char. Auto-detect, default = ','
+                  The string "tab" is allowed.
+       -e <esc>   use <sep>   as seperator char. Auto-detect, default = ','
+                  The string "undef" is allowed.
        -q <quot>  use <quot>  as quotation char. Default = '"'
+                  The string "undef" will disable quotation.
        -w <width> use <width> as default minimum column width (4)
        -o <xls>   write output to file named <xls>, defaults
                   to input file name with .csv replaced with .xls
@@ -25,6 +29,7 @@
        -f         force usage of <xls> if already exists (unlink before use)
        -d <dtfmt> use <dtfmt> as date formats.   Default = 'dd-mm-yyyy'
        -u         CSV is UTF8
+       -v [<lvl>] verbosity (default = 1)
 EOU
     exit $err;
     } # usage
@@ -32,24 +37,28 @@
 use Getopt::Long qw(:config bundling nopermute passthrough);
 my $sep;	# Set after reading first line in a flurry attempt to auto-detect
 my $quo = '"';
+my $esc = '"';
 my $wdt = 4;	# Default minimal column width
 my $xls;	# Excel out file name
 my $frc = 0;	# Force use of file
 my $utf = 0;	# Data is encoded in Unicode
 my $frm = 0;	# Allow formula's
 my $dtf = "dd-mm-yyyy";	# Date format
+my $opt_v = 1;
 
 GetOptions (
     "help|?"	=> sub { usage (0); },
 
     "c|s=s"	=> \$sep,
     "q=s"	=> \$quo,
+    "e=s"	=> \$esc,
     "w=i"	=> \$wdt,
     "o|x=s"	=> \$xls,
     "d=s"	=> \$dtf,
     "f"		=> \$frc,
     "F"		=> \$frm,
     "u"		=> \$utf,
+    "v:1"	=> \$opt_v,
     ) or usage (1);
 
 my $title = @ARGV && -f $ARGV[0] ? $ARGV[0] : "csv2xls";
@@ -109,14 +118,27 @@
 	}
     }
 $csv = Text::CSV_XS-> new ({
-    sep_char       => $sep,
-    quote_char     => $quo,
+    sep_char       => $sep eq "tab"   ? "\t"  : $sep,
+    quote_char     => $quo eq "undef" ? undef : $quo,
+    escape_char    => $esc eq "undef" ? undef : $esc,
     binary         => 1,
     keep_meta_info => 1,
+    auto_diag      => 1,
     });
 if ($firstline) {
     $csv->parse ($firstline) or die $csv->error_diag ();
     $row = [ $csv->fields ];
+    }
+if ($opt_v > 3) {
+    foreach my $k (qw( sep_char quote_char escape_char )) {
+	my $c = $csv->$k () || "undef";
+	$c =~ s/\t/\\t/g;
+	$c =~ s/\r/\\r/g;
+	$c =~ s/\n/\\n/g;
+	$c =~ s/\0/\\0/g;
+	$c =~ s/([\x00-\x1f\x7f-\xff])/sprintf"\\x{%02x}",ord$1/ge;
+	printf STDERR "%-11s = %s\n", $k, $c;
+	}
     }
 while ($row && @$row or $row = $csv->getline (*ARGV)) {
     my @row = @$row;
@@ -162,9 +184,9 @@
 	    $wks->write ($h, $c, $val);
 	    }
 	}
-    ++$h % 100 or printf STDERR "%6d x %6d\r", $w, $h;
+    ++$h % 100 or $opt_v && printf STDERR "%6d x %6d\r", $w, $h;
     } continue { $row = undef }
-printf STDERR "%6d x %6d\n", $w, $h;
+$opt_v && printf STDERR "%6d x %6d\n", $w, $h;
 
 $wks->set_column ($_, $_, $w[$_]) for 0 .. $#w;
 $wbk->close ();

Modified: trunk/libtext-csv-xs-perl/t/12_acc.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/t/12_acc.t?rev=54583&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/t/12_acc.t (original)
+++ trunk/libtext-csv-xs-perl/t/12_acc.t Fri Mar 19 18:08:21 2010
@@ -3,7 +3,7 @@
 use strict;
 $^W = 1;	# use warnings core since 5.6
 
-use Test::More tests => 107;
+use Test::More tests => 113;
 
 BEGIN {
     use_ok "Text::CSV_XS";
@@ -27,6 +27,8 @@
 is ($csv->empty_is_undef,		0,		"empty_is_undef");
 is ($csv->auto_diag,			0,		"auto_diag");
 is ($csv->verbatim,			0,		"verbatim");
+is ($csv->quote_space,			1,		"quote_space");
+is ($csv->quote_null,			1,		"quote_null");
 
 is ($csv->binary (1),			1,		"binary (1)");
 my @fld = ( 'txt =, "Hi!"', "Yes", "", 2, undef, "1.09", "\r", undef );
@@ -49,10 +51,15 @@
 is ($csv->empty_is_undef (1),		1,		"empty_is_undef (1)");
 is ($csv->auto_diag (1),		1,		"auto_diag (1)");
 is ($csv->verbatim (1),			1,		"verbatim (1)");
+is ($csv->quote_space (1),		1,		"quote_space (1)");
+is ($csv->quote_null (1),		1,		"quote_null (1)");
 is ($csv->escape_char ("\\"),		"\\",		"escape_char (\\)");
 ok ($csv->combine (@fld),				"combine");
 is ($csv->string,
     qq{=txt \\=, "Hi!"=;=Yes=;==;=2=;;=1.09=;=\r=;\r},	"string");
+
+is ($csv->quote_space (0),		0,		"quote_space (1)");
+is ($csv->quote_null (0),		0,		"quote_null (1)");
 
 # Funny settings, all three translate to \0 internally
 ok ($csv = Text::CSV_XS->new ({

Modified: trunk/libtext-csv-xs-perl/t/41_null.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/t/41_null.t?rev=54583&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/t/41_null.t (original)
+++ trunk/libtext-csv-xs-perl/t/41_null.t Fri Mar 19 18:08:21 2010
@@ -3,7 +3,7 @@
 use strict;
 $^W = 1;
 
-use Test::More tests => 62;
+use Test::More tests => 128;
 use Text::CSV_XS;
 
 my @pat = (
@@ -38,6 +38,7 @@
     $x =~ s/\n/\\n/g;
     ($_ => $x);
     } @pat;
+my $line = ["", undef, "0\n", "", "\0\0\n0"];
 
 my $csv = Text::CSV_XS->new ({
     eol			=> "\n",
@@ -45,6 +46,9 @@
     auto_diag		=> 1,
     blank_is_undef	=> 1,
     });
+
+ok ($csv->combine (@$line), "combine [ ... ]");
+is ($csv->string, qq{,,"0\n",,""0"0\n0"\n}, "string");
 
 open FH, ">__test.csv" or die $!;
 binmode FH;
@@ -55,7 +59,6 @@
 
 $csv->always_quote (1);
 
-my $line = ["", undef, "0\n", "", "\0\n0"];
 ok ($csv->print (*FH, $line), "print [ ... ]");
 
 close FH;
@@ -68,10 +71,46 @@
     is ($row->[0], $pat, "data $exp{$pat}");
     }
 
-my $row = $csv->getline (*FH);
-
-is_deeply ($row, $line, "read [ ... ]");
+is_deeply ($csv->getline (*FH), $line, "read [ ... ]");
 
 close FH;
 
 unlink "__test.csv";
+
+$csv = Text::CSV_XS->new ({
+    eol			=> "\n",
+    binary		=> 1,
+    auto_diag		=> 1,
+    blank_is_undef	=> 1,
+    quote_null		=> 0,
+    });
+
+ok ($csv->combine (@$line), "combine [ ... ]");
+is ($csv->string, qq{,,"0\n",,"\0\0\n0"\n}, "string");
+
+open FH, ">__test.csv" or die $!;
+binmode FH;
+
+for (@pat) {
+    ok ($csv->print (*FH, [ $_ ]), "print $exp{$_}");
+    }
+
+$csv->always_quote (1);
+
+ok ($csv->print (*FH, $line), "print [ ... ]");
+
+close FH;
+
+open FH, "<__test.csv" or die $!;
+binmode FH;
+
+foreach my $pat (@pat) {
+    ok (my $row = $csv->getline (*FH), "getline $exp{$pat}");
+    is ($row->[0], $pat, "data $exp{$pat}");
+    }
+
+is_deeply ($csv->getline (*FH), $line, "read [ ... ]");
+
+close FH;
+
+unlink "__test.csv";

Modified: trunk/libtext-csv-xs-perl/t/70_rt.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/t/70_rt.t?rev=54583&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/t/70_rt.t (original)
+++ trunk/libtext-csv-xs-perl/t/70_rt.t Fri Mar 19 18:08:21 2010
@@ -4,7 +4,7 @@
 $^W = 1;
 
 #use Test::More "no_plan";
- use Test::More tests => 367;
+ use Test::More tests => 380;
 
 BEGIN {
     use_ok "Text::CSV_XS", ();
@@ -16,7 +16,7 @@
 
 my ($rt, %input, %desc);
 while (<DATA>) {
-    if (s/^«(\d+)»\s*-?\s*//) {
+    if (s/^«(x?[0-9]+)»\s*-?\s*//) {
 	chomp;
 	$rt = $1;
 	$desc{$rt} = $_;
@@ -249,6 +249,35 @@
 
 	ok ($csv->parse ("  \t  \t  "), "parse ()");
 	is_deeply ([$csv->fields],["","",""],"3 empty fields");
+	}
+    }
+
+{   # Detlev reported an inconsistent difference between _XS and _PP
+    $rt = "x1000";
+    SKIP: {
+	open  FH, ">$csv_file";
+	print FH @{$input{$rt}};
+	close FH;
+	my ($c1, $c2);
+	ok (my $csv = Text::CSV_XS->new ({
+	    binary      => 1, 
+	    eol         => "\n", 
+	    sep_char    => "\t",
+	    escape_char => undef,
+	    quote_char  => undef,
+	    binary => 1 }), "RT-$rt: $desc{$rt}");
+	open  FH, "<$csv_file";
+	for (1 .. 4) {
+	    ok (my $row = $csv->getline (*FH), "getline ()");
+	    is (scalar @$row, 27, "Line $_: 27 columns");
+	    }
+	for (5 .. 6) {
+	    ok (my $row = $csv->getline (*FH), "getline ()");
+	    is (scalar @$row,  1, "Line $_:  1 column");
+	    }
+	$csv->error_diag ();
+	close FH;
+	unlink $csv_file;
 	}
     }
 
@@ -287,3 +316,10 @@
 «43927» - Is bind_columns broken or am I using it wrong?
 1,2
 «44402» - Unexpected results parsing tab-separated spaces
+«x1000» - Detlev reported inconsisten behavior between XS and PP
+B:033_02_	-drop, +drop	animal legs	@p 02-033.bmp	@p 02-033.bmp				\x{A}		1	:c/b01:!1	!	13	!6.!6			:b/b01:0						B:033_02_	R#012a	2	
+B:034_02c	diagonal, trac	-bound up	@p 02-034c.bmp	@p 02-034c.bmp			Found through e_sect2.pdf as U+F824 ( ,) and U+2E88 (⺈,) but won't display	\x{A}		1	:c/b01:!1	!	11	!10			:b/b01:0				2E88		B:034_02c	R#018b	2	
+B:035_02_	+drop, -drop	fission	丷				Aufgrund folgender Fälle definiere ich einen neuen Baustein, der simp. mit "horns&" identisch ist.\x{A}隊队 (jap.: pinnacle, horns&sow)\x{A}曾曾å
Ό
‘\x{A}über "golden calf":\x{A}送送			1	:c/b01:!1	!	11	!10			:b/b01:0				4E37		B:035_02_		2	
+B:035_03_	fission, one	horns	@p 03-035.bmp	@p 03-035.bmp			obsolete Heising explanation for form without the horizontal line: Variante von "horns", die erscheint, wenn darunter keine horizontale Linie steht\x{A}\x{A}Found through e_sect2.pdf as U+F7EA (??,) but won't display	\x{A}		1	:c/b01:!1	!	11	!10			:b/b01:0						B:035_03_		3	
+
+--------------090302050909040309030109--




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