r63195 - in /trunk/libtext-csv-perl: Changes MANIFEST META.yml README debian/changelog debian/control debian/copyright lib/Text/CSV.pm lib/Text/CSV_PP.pm t/45_eol.t t/46_eol_si.t t/65_allow.t t/70_rt.t t/71_pp.t

ansgar-guest at users.alioth.debian.org ansgar-guest at users.alioth.debian.org
Sat Oct 2 18:03:24 UTC 2010


Author: ansgar-guest
Date: Sat Oct  2 18:02:53 2010
New Revision: 63195

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=63195
Log:
* New upstream release.
* Bump Recommends on libtext-csv-xs-perl to >= 0.74.
* debian/copyright: Refer to /usr/share/common-licenses/GPL-1; refer to
  "Debian systems" instead of "Debian GNU/Linux systems".
* Bump Standards-Version to 3.9.1.

Added:
    trunk/libtext-csv-perl/t/46_eol_si.t
      - copied unchanged from r63194, branches/upstream/libtext-csv-perl/current/t/46_eol_si.t
Modified:
    trunk/libtext-csv-perl/Changes
    trunk/libtext-csv-perl/MANIFEST
    trunk/libtext-csv-perl/META.yml
    trunk/libtext-csv-perl/README
    trunk/libtext-csv-perl/debian/changelog
    trunk/libtext-csv-perl/debian/control
    trunk/libtext-csv-perl/debian/copyright
    trunk/libtext-csv-perl/lib/Text/CSV.pm
    trunk/libtext-csv-perl/lib/Text/CSV_PP.pm
    trunk/libtext-csv-perl/t/45_eol.t
    trunk/libtext-csv-perl/t/65_allow.t
    trunk/libtext-csv-perl/t/70_rt.t
    trunk/libtext-csv-perl/t/71_pp.t

Modified: trunk/libtext-csv-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-perl/Changes?rev=63195&op=diff
==============================================================================
--- trunk/libtext-csv-perl/Changes (original)
+++ trunk/libtext-csv-perl/Changes Sat Oct  2 18:02:53 2010
@@ -1,4 +1,12 @@
 Revision history for Perl extension Text::CSV.
+
+1.19  Sat Oct  2 14:15:59 2010
+	- getline didn't work correctly with 0 or null containing lines
+	    (pointed by Bernhard Prott)
+	- updated the compatibility for Text::CSV_XS version 0.74
+	    * real eol support for parsing streams (beyond \n, \r and \r\n)
+	    * clarify doc for always_quote to not quote undef fields
+	       and XS and PP incompatibility of UTF8 process for print and combine
 
 1.18  Sat Jun 19 10:34:07 2010
 	- fixed a combine bug with quote_space reported and patched by rt#58356

Modified: trunk/libtext-csv-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-perl/MANIFEST?rev=63195&op=diff
==============================================================================
--- trunk/libtext-csv-perl/MANIFEST (original)
+++ trunk/libtext-csv-perl/MANIFEST Sat Oct  2 18:02:53 2010
@@ -18,6 +18,7 @@
 t/40_misc.t		Binary mode tests
 t/41_null.t		NULL test in combination with line endings
 t/45_eol.t		Embedded EOL
+t/46_eol_si.t		Embedded EOL using scalar io (perlio)
 t/50_utf8.t		Unicode stress tests
 t/55_combi.t		Different CSV character combinations
 t/60_samples.t		Miscellaneous problems from the modules history.

Modified: trunk/libtext-csv-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-perl/META.yml?rev=63195&op=diff
==============================================================================
--- trunk/libtext-csv-perl/META.yml (original)
+++ trunk/libtext-csv-perl/META.yml Sat Oct  2 18:02:53 2010
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               Text-CSV
-version:            1.18
+version:            1.19
 abstract:           comma-separated values manipulator (using XS or PurePerl)
 author:
     - Makamaka Hannyaharamitu, E<lt>makamaka[at]cpan.orgE<gt>

Modified: trunk/libtext-csv-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-perl/README?rev=63195&op=diff
==============================================================================
--- trunk/libtext-csv-perl/README (original)
+++ trunk/libtext-csv-perl/README Sat Oct  2 18:02:53 2010
@@ -1,4 +1,4 @@
-Text::CSV version 1.16
+Text::CSV version 1.19
 ========================
 
 comma-separated values manipulator
@@ -31,7 +31,7 @@
 COPYRIGHT AND LICENSE
 
         Copyright (C) 1997 Alan Citterman. All rights reserved.
-        Copyright (C) 2007-2009 Makamaka Hannyaharamitu. All rights reserved.
+        Copyright (C) 2007-2010 Makamaka Hannyaharamitu. All rights reserved.
 
         This library is free software; you can redistribute it and/or modify
         it under the same terms as Perl itself.

Modified: trunk/libtext-csv-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-perl/debian/changelog?rev=63195&op=diff
==============================================================================
--- trunk/libtext-csv-perl/debian/changelog (original)
+++ trunk/libtext-csv-perl/debian/changelog Sat Oct  2 18:02:53 2010
@@ -1,3 +1,13 @@
+libtext-csv-perl (1.19-1) unstable; urgency=low
+
+  * New upstream release.
+  * Bump Recommends on libtext-csv-xs-perl to >= 0.74.
+  * debian/copyright: Refer to /usr/share/common-licenses/GPL-1; refer to
+    "Debian systems" instead of "Debian GNU/Linux systems".
+  * Bump Standards-Version to 3.9.1.
+
+ -- Ansgar Burchardt <ansgar at 43-1.org>  Sat, 02 Oct 2010 20:02:27 +0200
+
 libtext-csv-perl (1.18-1) unstable; urgency=low
 
   * New upstream release

Modified: trunk/libtext-csv-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-perl/debian/control?rev=63195&op=diff
==============================================================================
--- trunk/libtext-csv-perl/debian/control (original)
+++ trunk/libtext-csv-perl/debian/control Sat Oct  2 18:02:53 2010
@@ -9,7 +9,7 @@
  Brian Cassidy <brian.cassidy at gmail.com>, Jonathan Yu <jawnsy at cpan.org>,
  Franck Joncourt <franck at debian.org>,
  Salvatore Bonaccorso <salvatore.bonaccorso at gmail.com>
-Standards-Version: 3.8.4
+Standards-Version: 3.9.1
 Homepage: http://search.cpan.org/dist/Text-CSV/
 Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libtext-csv-perl/
 Vcs-Browser: http://svn.debian.org/viewsvn/pkg-perl/trunk/libtext-csv-perl/
@@ -17,7 +17,7 @@
 Package: libtext-csv-perl
 Architecture: all
 Depends: ${misc:Depends}, ${perl:Depends}
-Recommends: libtext-csv-xs-perl (>= 0.72)
+Recommends: libtext-csv-xs-perl (>= 0.74)
 Description: comma-separated values manipulator (using XS or PurePerl)
  Text::CSV provides facilities for the composition and decomposition of files
  containing comma-separated value records. An instance of the Text::CSV class

Modified: trunk/libtext-csv-perl/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-perl/debian/copyright?rev=63195&op=diff
==============================================================================
--- trunk/libtext-csv-perl/debian/copyright (original)
+++ trunk/libtext-csv-perl/debian/copyright Sat Oct  2 18:02:53 2010
@@ -26,8 +26,8 @@
  This program is free software; you can redistribute it and/or modify
  it under the terms of the Artistic License, which comes with Perl.
  .
- On Debian GNU/Linux systems, the complete text of the Artistic License
- can be found in `/usr/share/common-licenses/Artistic'
+ On Debian systems, the complete text of the Artistic License can be
+ found in `/usr/share/common-licenses/Artistic'.
 
 License: GPL-1+
  This program is free software; you can redistribute it and/or modify
@@ -35,5 +35,5 @@
  the Free Software Foundation; either version 1, or (at your option)
  any later version.
  .
- On Debian GNU/Linux systems, the complete text of the GNU General
- Public License can be found in `/usr/share/common-licenses/GPL'
+ On Debian systems, the complete text of version 1 of the GNU General
+ Public License can be found in `/usr/share/common-licenses/GPL-1'.

Modified: trunk/libtext-csv-perl/lib/Text/CSV.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-perl/lib/Text/CSV.pm?rev=63195&op=diff
==============================================================================
--- trunk/libtext-csv-perl/lib/Text/CSV.pm (original)
+++ trunk/libtext-csv-perl/lib/Text/CSV.pm Sat Oct  2 18:02:53 2010
@@ -6,14 +6,14 @@
 use vars qw( $VERSION $DEBUG );
 
 BEGIN {
-    $VERSION = '1.18';
+    $VERSION = '1.19';
     $DEBUG   = 0;
 }
 
 # if use CSV_XS, requires version
 my $Module_XS  = 'Text::CSV_XS';
 my $Module_PP  = 'Text::CSV_PP';
-my $XS_Version = '0.72';
+my $XS_Version = '0.74';
 
 my $Is_Dynamic = 0;
 
@@ -287,13 +287,13 @@
 
 =head1 VERSION
 
-    1.17
-
-This module is compatible with Text::CSV_XS B<0.72> and later.
+    1.19
+
+This module is compatible with Text::CSV_XS B<0.74> and later.
 
 =head2 Embedded newlines
 
-B<Important Note>: The default behavior is to only accept ascii characters.
+B<Important Note>: The default behavior is to only accept ASCII characters.
 This means that fields can not contain newlines. If your data contains
 newlines embedded in fields, or characters above 0x7e (tilde), or binary data,
 you *must* set C<< binary => 1 >> in the call to C<new ()>.  To cover the widest
@@ -308,7 +308,7 @@
      $csv->parse ($_);
      my @fields = $csv->fields ();
 
-will break, as the while might read broken lines, as that doesn't care
+will break, as the while might read broken lines, as that does not care
 about the quoting. If you need to support embedded newlines, the way to go
 is either
 
@@ -328,9 +328,6 @@
 On parsing (both for C<getline ()> and C<parse ()>), if the source is
 marked being UTF8, then all fields that are marked binary will also be
 be marked UTF8.
-
-On combining (C<print ()> and C<combine ()>), if any of the combining
-fields was marked UTF8, the resulting string will be marked UTF8.
 
 For complete control over encoding, please use L<Text::CSV::Encoded>:
 
@@ -348,6 +345,19 @@
     # combine () and print () accept UTF8 marked data
     # parse () and getline () return UTF8 marked data
 
+On combining (C<print ()> and C<combine ()>), if any of the combining
+fields was marked UTF8, the resulting string will be marked UTF8.
+
+Note however if the backend module is Text::CSV_XS,
+that all fields C<before> the first field that was marked UTF8
+and contained 8-bit characters that were not upgraded to UTF8, these
+will be bytes in the resulting string too, causing errors. If you pass
+data of different encoding, or you don't know if there is different
+encoding, force it to be upgraded before you pass them on:
+
+    # backend = Text::CSV_XS
+    $csv->print ($fh, [ map { utf8::upgrade (my $x = $_); $x } @data ]);
+
 =head1 SPECIFICATION
 
 See to L<Text::CSV_XS/SPECIFICATION>.
@@ -453,7 +463,7 @@
 
  (1, undef, undef, " ", 2)
 
-Note that this only effects fields that are I<realy> empty, not fields
+Note that this only effects fields that are I<really> empty, not fields
 that are empty after stripping allowed whitespace. YMMV.
 
 =item quote_char
@@ -542,8 +552,8 @@
 
 By default the generated fields are quoted only, if they need to, for
 example, if they contain the separator. If you set this attribute to
-a TRUE value, then all fields will be quoted. This is typically easier
-to handle in external applications.
+a TRUE value, then all defined fields will be quoted. This is typically
+easier to handle in external applications.
 
 =item quote_space
 
@@ -589,7 +599,7 @@
 where, the line ending is a very specific "#\r\n", and the sep_char
 is a ^ (caret). None of the fields is quoted, but embedded binary
 data is likely to be present. With the specific line ending, that
-shouldn't be too hard to detect.
+shouldn not be too hard to detect.
 
 By default, Text::CSV' parse function however is instructed to only
 know about "\n" and "\r" to be legal line endings, and so has to deal
@@ -674,7 +684,7 @@
  $status = $csv->print (\*FILE, $colref);
 
 as in perl 5.005 and older, the glob C<\*FILE> is not an object, thus it
-doesn't have a print method. The solution is to use an IO::File object or
+does not have a print method. The solution is to use an IO::File object or
 to hide the glob behind an IO::Wrap object. See L<IO::File> and L<IO::Wrap>
 for details.
 
@@ -847,7 +857,7 @@
 
 For each field, a meta_info field will hold flags that tell something about
 the field returned by the C<fields ()> method or passed to the C<combine ()>
-method. The flags are bitwise-or'd like:
+method. The flags are bit-wise-or'd like:
 
 =over 4
 

Modified: trunk/libtext-csv-perl/lib/Text/CSV_PP.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-perl/lib/Text/CSV_PP.pm?rev=63195&op=diff
==============================================================================
--- trunk/libtext-csv-perl/lib/Text/CSV_PP.pm (original)
+++ trunk/libtext-csv-perl/lib/Text/CSV_PP.pm Sat Oct  2 18:02:53 2010
@@ -11,7 +11,7 @@
 use vars qw($VERSION);
 use Carp ();
 
-$VERSION = '1.26';
+$VERSION = '1.27';
 
 sub PV  { 0 }
 sub IV  { 1 }
@@ -58,7 +58,7 @@
         3003 => "EHR - bind_columns () and column_names () fields count mismatch",
         3004 => "EHR - bind_columns () only accepts refs to scalars",
         3006 => "EHR - bind_columns () did not pass enough refs for parsed fields",
-        3007 => "EHR - bind_columns needs refs to writeable scalars",
+        3007 => "EHR - bind_columns needs refs to writable scalars",
         3008 => "EHR - unexpected error in bound fields",
 
         0    => "",
@@ -361,7 +361,6 @@
     my $re_quot_char    = $self->{_re_quot_char}->{$quot}            ||= qr/\Q$quot\E/;
     my $re_esc          = $self->{_re_esc}->{$quot}->{$esc}          ||= qr/\Q$esc\E(\Q$quot\E|\Q$esc\E|0)/;
     my $re_invalid_quot = $self->{_re_invalid_quot}->{$quot}->{$esc} ||= qr/^$re_quot_char|[^\Q$re_esc\E]$re_quot_char/;
-    my $re_rs           = $self->{_re_rs}->{$/} ||= qr{\Q$/\E?$}; # $/ .. input record separator
 
     if ($allow_whitespace) {
         $re_split = $self->{_re_split_allow_sp}->{$quot}->{$esc}->{$sep}
@@ -620,12 +619,13 @@
 
     my $quot = $self->{quote_char};
     my $sep  = $self->{sep_char};
-    my $re   = defined $quot ? qr/(?:\Q$quot\E)/ : '';
-
-    local $/ = "\r" if $self->{_AUTO_DETECT_CR};
+    my $re   =  defined $quot ? qr/(?:\Q$quot\E)/ : undef;
+
+    my $eol  = $self->{eol};
+
+    local $/ = $eol if ( defined $eol and $eol ne '' );
 
     my $line = $io->getline();
-    my $eol  = $self->{eol};
 
     # AUTO DETECTION EOL CR
     if ( defined $line and defined $eol and $eol eq '' and $line =~ /[^\r]\r[^\r\n]/ and eof ) {
@@ -635,24 +635,22 @@
         return $self->getline( $io );
     }
 
-    if ( defined $line and $line =~ /${re}0/ ) { # null containing line
-        my $auto_diag = $self->auto_diag;
-        $self->auto_diag( 0 ) if ( $auto_diag ); # stop auto error diag
-
-        while ( not $self->_parse($line) and !eof($io) ) {
-            $line .= $io->getline();
-        }
-
-        $self->auto_diag( $auto_diag ) if ( $auto_diag ); # restore
-
-        return $self->_return_getline_result;
-    }
-
-    $line .= $io->getline() while ( defined $line and scalar(my @list = $line =~ /$re/g) % 2 and !eof($io) );
-
-    if ( $self->{verbatim} and defined $eol and defined $line ) { # VERBATIM MODE
-        $line =~ s/\Q$eol\E$//;
-    }
+    if ( $re and defined $line ) {
+        LOOP: {
+            my $is_continued   = scalar(my @list = $line =~ /$re/g) % 2; # if line is valid, quot is even
+
+            if ( $line =~ /${re}0/ ) { # null suspicion case
+                $is_continued = $line =~ /^($re(?:$re$re|${re}0|[^$re])+$re[^0])+$/  ? 0 : 1;
+            }
+
+            if ( $is_continued and !eof($io) ) {
+                $line .= $io->getline();
+                goto LOOP;
+            }
+        }
+    }
+
+    $line =~ s/\Q$eol\E$// if ( defined $line and defined $eol and $eol ne '' );
 
     $self->_parse($line);
 
@@ -981,9 +979,9 @@
 
 =head1 VERSION
 
-    1.24
-
-This module is compatible with Text::CSV_XS B<0.68> and later.
+    1.27
+
+This module is compatible with Text::CSV_XS B<0.74> and later.
 
 =head2 Unicode (UTF8)
 
@@ -1186,8 +1184,8 @@
 
 By default the generated fields are quoted only, if they need to, for
 example, if they contain the separator. If you set this attribute to
-a TRUE value, then all fields will be quoted. This is typically easier
-to handle in external applications.
+a TRUE value, then all defined fields will be quoted. This is typically
+easier to handle in external applications.
 
 =item quote_space
 
@@ -1654,7 +1652,7 @@
 
 =item 3006 "EHR - bind_columns () did not pass enough refs for parsed fields"
 
-=item 3007 "EHR - bind_columns needs refs to writeable scalars"
+=item 3007 "EHR - bind_columns needs refs to writable scalars"
 
 =item 3008 "EHR - unexpected error in bound fields"
 

Modified: trunk/libtext-csv-perl/t/45_eol.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-perl/t/45_eol.t?rev=63195&op=diff
==============================================================================
--- trunk/libtext-csv-perl/t/45_eol.t (original)
+++ trunk/libtext-csv-perl/t/45_eol.t Sat Oct  2 18:02:53 2010
@@ -3,7 +3,7 @@
 use strict;
 $^W = 1;
 
-use Test::More tests => 278;
+use Test::More tests => 546;
 
 BEGIN {
     $ENV{PERL_TEXT_CSV} = 0;
@@ -171,4 +171,30 @@
     }
 $/ = $def_rs;
 
+foreach my $eol ("!", "!!", "!\n", "!\n!") {
+    (my $s_eol = $eol) =~ s/\n/\\n/g;
+    ok (1, "EOL $s_eol");
+    ok (my $csv = Text::CSV->new ({ eol => $eol }), "new csv with eol => $s_eol");
+    open  FH, ">_eol.csv";
+    ok ($csv->print (*FH, [1, 2, 3]), "print");
+    ok ($csv->print (*FH, [4, 5, 6]), "print");
+    close FH;
+
+    foreach my $rs (undef, "", "\n", $eol, "!", "!\n", "\n!", "!\n!", "\n!\n") {
+	local $/ = $rs;
+	(my $s_rs = defined $rs ? $rs : "-- undef --") =~ s/\n/\\n/g;
+	ok (1, "with RS $s_rs");
+	open FH, "<_eol.csv";
+	ok (my $row = $csv->getline (*FH),	"getline 1");
+	is (scalar @$row, 3,			"# fields");
+	is_deeply ($row, [ 1, 2, 3],		"fields 1");
+	ok (   $row = $csv->getline (*FH),	"getline 2");
+	is (scalar @$row, 3,			"# fields");
+	is_deeply ($row, [ 4, 5, 6],		"fields 2");
+	close FH;
+	}
+    unlink "_eol.csv";
+    }
+$/ = $def_rs;
+
 1;

Modified: trunk/libtext-csv-perl/t/65_allow.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-perl/t/65_allow.t?rev=63195&op=diff
==============================================================================
--- trunk/libtext-csv-perl/t/65_allow.t (original)
+++ trunk/libtext-csv-perl/t/65_allow.t Sat Oct  2 18:02:53 2010
@@ -341,14 +341,12 @@
 	my @fld = $csv->fields;
 	is (@fld, 4,				"#\\r\\n $gc fields");
 	is ($fld[2], "Abe",			"#\\r\\n $gc fld 2");
-#	is ($fld[3], "Timmerman#\r\n",		"#\\r\\n $gc fld 3");
 	is ($fld[3], $gc ? "Timmerman#\r\n"
 			 : "Timmerman#",	"#\\r\\n $gc fld 3");
 
 	ok ($csv->parse ($str[1]),		"#\\r\\n $gc parse");
 	@fld = $csv->fields;
 	is (@fld, 3,				"#\\r\\n $gc fields");
-#	is ($fld[2], "Abe\nTimmerman#\r\n",	"#\\r\\n $gc fld 2");
 	is ($fld[2], $gc ? "Abe\nTimmerman#\r\n"
 			 : "Abe",		"#\\r\\n $gc fld 2");
 	}
@@ -367,13 +365,10 @@
 	ok ($row = $csv->getline (*FH),		"#\\r\\n $gc getline");
 	is (@$row, 4,				"#\\r\\n $gc fields");
 	is ($row->[2], "Abe",			"#\\r\\n $gc fld 2");
-#	is ($row->[3], "Timmerman",		"#\\r\\n $gc fld 3");
-	is ($row->[3], $gc ? "Timmerman"
-			   : "Timmerman#",	"#\\r\\n $gc fld 3");
+	is ($row->[3], "Timmerman",		"#\\r\\n $gc fld 3");
 
 	ok ($row = $csv->getline (*FH),		"#\\r\\n $gc parse");
 	is (@$row, 3,				"#\\r\\n $gc fields");
-#	is ($row->[2], "Abe\nTimmerman",	"#\\r\\n $gc fld 2");
 	is ($row->[2], $gc ? "Abe\nTimmerman"
 			   : "Abe",		"#\\r\\n $gc fld 2");
 	}

Modified: trunk/libtext-csv-perl/t/70_rt.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-perl/t/70_rt.t?rev=63195&op=diff
==============================================================================
--- trunk/libtext-csv-perl/t/70_rt.t (original)
+++ trunk/libtext-csv-perl/t/70_rt.t Sat Oct  2 18:02:53 2010
@@ -4,7 +4,7 @@
 $^W = 1;
 
 #use Test::More "no_plan";
- use Test::More tests => 380;
+ use Test::More tests => 397;
 
 BEGIN {
     $ENV{PERL_TEXT_CSV} = 0;
@@ -154,10 +154,12 @@
     $str = $input{$rt}[1];
     is ($csv->parse ($str), 0,		"parse () badly escaped NULL");
     my @diag = $csv->error_diag;
-#    is ($diag[0], 2023,			"Error 2023");
-#    is ($diag[2],   23,			"Position 23");
-    is ($diag[0], 2025,                        "Error 2025 but 2023 in XS");
-    is ($diag[2],   24,                        "Position 24 but 23 in XS");
+
+    SKIP: {
+        skip "incompatible between PP and XS", 2;
+        is ($diag[0], 2023,                   "Error 2023");
+        is ($diag[2],   23,                   "Position 23");
+    }
     $csv->allow_loose_escapes (1);
     ok ($csv->parse ($str),		"parse () badly escaped NULL");
     }
@@ -189,96 +191,129 @@
 {   # http://rt.cpan.org/Ticket/Display.html?id=43927
     # 43927: Is bind_columns broken or am I using it wrong?
     $rt = 43927;
-    SKIP: {
-	open  FH, ">$csv_file";
-	print FH @{$input{$rt}};
-	close FH;
-	my ($c1, $c2);
-	ok (my $csv = Text::CSV->new ({ binary => 1 }), "RT-$rt: $desc{$rt}");
-	ok ($csv->bind_columns (\$c1, \$c2), "bind columns");
-	open  FH, "<$csv_file";
-	ok (my $row = $csv->getline (*FH), "getline () with bound columns");
-	$csv->error_diag ();
-	close FH;
-	unlink $csv_file;
-	is_deeply ($row, [], "should return empty ref");
-	is_deeply ([ $c1, $c2], [ 1, 2 ], "fields ()");
-	}
+    open  FH, ">$csv_file";
+    print FH @{$input{$rt}};
+    close FH;
+    my ($c1, $c2);
+    ok (my $csv = Text::CSV->new ({ binary => 1 }), "RT-$rt: $desc{$rt}");
+    ok ($csv->bind_columns (\$c1, \$c2), "bind columns");
+    open  FH, "<$csv_file";
+    ok (my $row = $csv->getline (*FH), "getline () with bound columns");
+    $csv->error_diag ();
+    close FH;
+    unlink $csv_file;
+    is_deeply ($row, [], "should return empty ref");
+    is_deeply ([ $c1, $c2], [ 1, 2 ], "fields ()");
     }
 
 {   # http://rt.cpan.org/Ticket/Display.html?id=44402
     # 44402 - Unexpected results parsing tab-separated spaces
     $rt = 44402;
-    SKIP: {
-	open  FH, ">$csv_file";
-	my @ws = ("", " ", "  ");
-	foreach my $f1 (@ws) {
-	    foreach my $f2 (@ws) {
-		foreach my $f3 (@ws) {
-		    print FH "$f1\t$f2\t$f3\r\n";
-		    }
+    open  FH, ">$csv_file";
+    my @ws = ("", " ", "  ");
+    foreach my $f1 (@ws) {
+	foreach my $f2 (@ws) {
+	    foreach my $f3 (@ws) {
+		print FH "$f1\t$f2\t$f3\r\n";
 		}
 	    }
-	close FH;
-
-	my $csv;
-	ok ($csv = Text::CSV->new ({
-	    sep_char => "\t",
-	    }), "RT-$rt: $desc{$rt}");
-	open  FH, "<$csv_file";
-	while (my $row = $csv->getline (*FH)) {
-	    ok ($row, "getline $.");
-	    my @row = @$row;
-	    is ($#row, 2, "Got 3 fields");
-	    like ($row[$_], qr{^ *$}, "field $_ with only spaces") for 0..2;
-	    }
-	ok ($csv->eof, "read complete file");
-	close FH;
-
-	ok ($csv = Text::CSV->new ({
-	    sep_char         => "\t",
-	    allow_whitespace => 1,
-	    }), "RT-$rt: $desc{$rt}");
-	open  FH, "<$csv_file";
-	while (my $row = $csv->getline (*FH)) {
-	    ok ($row, "getline $.");
-	    my @row = @$row;
-	    is ($#row, 2, "Got 3 fields");
-	    is ($row[$_], "", "field $_ empty") for 0..2;
-	    }
-	ok ($csv->eof, "read complete file");
-	close FH;
-	unlink $csv_file;
-
-	ok ($csv->parse ("  \t  \t  "), "parse ()");
-	is_deeply ([$csv->fields],["","",""],"3 empty fields");
-	}
+	}
+    close FH;
+
+    my $csv;
+    ok ($csv = Text::CSV->new ({
+	sep_char => "\t",
+	}), "RT-$rt: $desc{$rt}");
+    open  FH, "<$csv_file";
+    while (my $row = $csv->getline (*FH)) {
+	ok ($row, "getline $.");
+	my @row = @$row;
+	is ($#row, 2, "Got 3 fields");
+	like ($row[$_], qr{^ *$}, "field $_ with only spaces") for 0..2;
+	}
+    ok ($csv->eof, "read complete file");
+    close FH;
+
+    ok ($csv = Text::CSV->new ({
+	sep_char         => "\t",
+	allow_whitespace => 1,
+	}), "RT-$rt: $desc{$rt}");
+    open  FH, "<$csv_file";
+    while (my $row = $csv->getline (*FH)) {
+	ok ($row, "getline $.");
+	my @row = @$row;
+	is ($#row, 2, "Got 3 fields");
+	is ($row[$_], "", "field $_ empty") for 0..2;
+	}
+    ok ($csv->eof, "read complete file");
+    close FH;
+    unlink $csv_file;
+
+    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->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;
+    }
+
+{   # http://rt.cpan.org/Ticket/Display.html?id=58356
+    # 58356 - Incorrect CSV generated if "quote_space => 0"
+    $rt = "58356";
+    ok (my $csv = Text::CSV->new ({
+	binary      => 1,
+	quote_space => 0 }), "RT-$rt: $desc{$rt}");
+    my @list = ("a a", "b,b", "c ,c");
+    ok ($csv->combine (@list), "combine ()");
+    is ($csv->string, q{a a,"b,b","c ,c"}, "string ()");
+    }
+
+{   # http://rt.cpan.org/Ticket/Display.html?id=61525
+    $rt = "61525";
+    foreach my $eol ("\n", "!") {
+	ok (my $csv = Text::CSV->new ({
+	    binary      => 1,
+	    sep_char    => ":",
+	    quote_char  => '"',
+	    escape_char => '"',
+	    eol         => $eol,
+	    auto_diag   => 1,
+	    }), "RT-$rt: $desc{$rt}");
+
 	open  FH, ">$csv_file";
-	print FH @{$input{$rt}};
+	print FH join $eol => qw( "a":"b" "c":"d" "e":"x!y" "!!":"z" );
 	close FH;
-	my ($c1, $c2);
-	ok (my $csv = Text::CSV->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 ();
+	is_deeply ($csv->getline (*FH), [ "a",  "b"   ], "Pair 1");
+	is_deeply ($csv->getline (*FH), [ "c",  "d"   ], "Pair 2");
+	is_deeply ($csv->getline (*FH), [ "e",  "x!y" ], "Pair 3");
+	is_deeply ($csv->getline (*FH), [ "!!", "z"   ], "Pair 4");
+	is ($csv->getline (*FH), undef, "no more pairs");
+	ok ($csv->eof, "EOF");
 	close FH;
 	unlink $csv_file;
 	}
@@ -326,3 +361,5 @@
 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--
+«58356» - Incorrect CSV generated if "quote_space => 0"
+«61525» - eol not working for values other than "\n"?

Modified: trunk/libtext-csv-perl/t/71_pp.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-perl/t/71_pp.t?rev=63195&op=diff
==============================================================================
--- trunk/libtext-csv-perl/t/71_pp.t (original)
+++ trunk/libtext-csv-perl/t/71_pp.t Sat Oct  2 18:02:53 2010
@@ -5,7 +5,7 @@
 use strict;
 $^W = 1;
 
-use Test::More tests => 55;
+use Test::More tests => 58;
 
 
 BEGIN { $ENV{PERL_TEXT_CSV} = $ARGV[0] || 0; }
@@ -173,3 +173,25 @@
 ok( $csv->combine( @list ) );
 is( $csv->string, q{a a,"b,b","c ,c"} );
 
+
+# 2010-06-22 reported
+{
+    $csv = Text::CSV->new ({ binary => 1, sep_char => ';', always_quote => 1 });
+
+    open( FH, '>__test.csv' ) or die $!;
+    binmode FH;
+
+    ok( $csv->print( *FH, [ 0, qq{t"t"\n} ] ) );
+    close( FH );
+
+    open( FH, "__test.csv" ) or die $!;
+    binmode FH;
+
+    my $col = $csv->getline( *FH );
+
+    is( $col->[0], "0" );
+    is( $col->[1], qq{t"t"\n} );
+    close( FH );
+
+    unlink( '__test.csv' );
+}




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