r23741 - in /branches/upstream/libtext-csv-perl/current: Changes META.yml README lib/Text/CSV.pm lib/Text/CSV_PP.pm t/75_hashref.t

ansgar-guest at users.alioth.debian.org ansgar-guest at users.alioth.debian.org
Sun Aug 3 10:03:40 UTC 2008


Author: ansgar-guest
Date: Sun Aug  3 10:03:36 2008
New Revision: 23741

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=23741
Log:
[svn-upgrade] Integrating new upstream version, libtext-csv-perl (1.07)

Modified:
    branches/upstream/libtext-csv-perl/current/Changes
    branches/upstream/libtext-csv-perl/current/META.yml
    branches/upstream/libtext-csv-perl/current/README
    branches/upstream/libtext-csv-perl/current/lib/Text/CSV.pm
    branches/upstream/libtext-csv-perl/current/lib/Text/CSV_PP.pm
    branches/upstream/libtext-csv-perl/current/t/75_hashref.t

Modified: branches/upstream/libtext-csv-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-perl/current/Changes?rev=23741&op=diff
==============================================================================
--- branches/upstream/libtext-csv-perl/current/Changes (original)
+++ branches/upstream/libtext-csv-perl/current/Changes Sun Aug  3 10:03:36 2008
@@ -1,4 +1,10 @@
 Revision history for Perl extension Text::CSV.
+
+1.07  Fri Aug  1 11:13:06 2008
+	- updated the compatibility for Text::CSV_XS version 0.52
+	    modified column_names()
+	- fixed a parsing bug with quote_char being undef
+	    pointed by Matt (rt#38083)
 
 1.06  Wed Jun 18 14:35:40 2008
 	- updated the compatibility for Text::CSV_XS version 0.51

Modified: branches/upstream/libtext-csv-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-perl/current/META.yml?rev=23741&op=diff
==============================================================================
--- branches/upstream/libtext-csv-perl/current/META.yml (original)
+++ branches/upstream/libtext-csv-perl/current/META.yml Sun Aug  3 10:03:36 2008
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:                Text-CSV
-version:             1.06
+version:             1.07
 abstract:            comma-separated values manipulator (using XS or PurePerl)
 license:             ~
 author:              

Modified: branches/upstream/libtext-csv-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-perl/current/README?rev=23741&op=diff
==============================================================================
--- branches/upstream/libtext-csv-perl/current/README (original)
+++ branches/upstream/libtext-csv-perl/current/README Sun Aug  3 10:03:36 2008
@@ -1,4 +1,4 @@
-Text::CSV version 1.06
+Text::CSV version 1.07
 ========================
 
 comma-separated values manipulator

Modified: branches/upstream/libtext-csv-perl/current/lib/Text/CSV.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-perl/current/lib/Text/CSV.pm?rev=23741&op=diff
==============================================================================
--- branches/upstream/libtext-csv-perl/current/lib/Text/CSV.pm (original)
+++ branches/upstream/libtext-csv-perl/current/lib/Text/CSV.pm Sun Aug  3 10:03:36 2008
@@ -5,14 +5,14 @@
 use Carp ();
 
 BEGIN {
-    $Text::CSV::VERSION = '1.06';
+    $Text::CSV::VERSION = '1.07';
     $Text::CSV::DEBUG   = 0;
 }
 
 # if use CSV_XS, requires version
 my $Module_XS  = 'Text::CSV_XS';
 my $Module_PP  = 'Text::CSV_PP';
-my $XS_Version = '0.51';
+my $XS_Version = '0.52';
 
 my $Is_Dynamic = 0;
 
@@ -270,9 +270,9 @@
 
 =head1 VERSION
 
-    1.06
-
-This module is compatible with Text::CSV_XS B<0.51> or later.
+    1.07
+
+This module is compatible with Text::CSV_XS B<0.52> or later.
 
 =head2 BINARY MODE
 
@@ -641,6 +641,16 @@
 
   $csv->column_names ($csv->getline ($io));
 
+C<column_names ()> does B<no> checking on duplicates at all, which might
+lead to unwanted results. Undefined entries will be replaced with the
+string C<"\cAUNDEF\cA">, so
+
+  $csv->column_names (undef, "", "name", "name");
+  $hr = $csv->getline_hr ($io);
+
+Will set C<$hr->{"\cAUNDEF\cA"}> to the 1st field, C<$hr->{""}> to the
+2nd field, and C<$hr->{name}> to the 4th field, discarding the 2rd field.
+
 C<column_names ()> croaks on invalid arguments.
 
 =head2 bind_columns

Modified: branches/upstream/libtext-csv-perl/current/lib/Text/CSV_PP.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-perl/current/lib/Text/CSV_PP.pm?rev=23741&op=diff
==============================================================================
--- branches/upstream/libtext-csv-perl/current/lib/Text/CSV_PP.pm (original)
+++ branches/upstream/libtext-csv-perl/current/lib/Text/CSV_PP.pm Sun Aug  3 10:03:36 2008
@@ -11,7 +11,7 @@
 use vars qw($VERSION);
 use Carp ();
 
-$VERSION = '1.14';
+$VERSION = '1.15';
 
 sub PV  { 0 }
 sub IV  { 1 }
@@ -478,7 +478,12 @@
 
 sub _make_regexp_split_column {
     my ($esc, $quot, $sep) = @_;
-    qr/(
+
+    if ( $quot eq '' ) {
+        return qr/([^\Q$sep\E]*)\Q$sep\E/s;
+    }
+
+   qr/(
         \Q$quot\E
             [^\Q$quot$esc\E]*(?:\Q$esc\E[\Q$quot$esc\E0][^\Q$quot$esc\E]*)*
         \Q$quot\E
@@ -492,6 +497,11 @@
 
 sub _make_regexp_split_column_allow_sp {
     my ($esc, $quot, $sep) = @_;
+
+    if ( $quot eq '' ) {
+        return qr/[\x20\x09]*([^\Q$sep\E]?)[\x20\x09]*\Q$sep\E[\x20\x09]*/s;
+    }
+
     qr/[\x20\x09]*
        (
         \Q$quot\E
@@ -589,25 +599,24 @@
 # column_names
 ################################################################################
 sub column_names {
-    my ( $self, @clumns ) = @_;
-
-    @clumns or return defined $self->{_COLUMN_NAMES} ? @{$self->{_COLUMN_NAMES}} : undef;
-    @clumns == 1 && ! defined $clumns[0] and return $self->{_COLUMN_NAMES} = undef;
-
-    if ( @clumns == 1 && ref $clumns[0] eq "ARRAY" ) {
-        @clumns = @{ $clumns[0] };
-    }
-    elsif ( join "", map { defined $_ ? ref $_ : "UNDEF" } @clumns ) {
+    my ( $self, @columns ) = @_;
+
+    @columns or return defined $self->{_COLUMN_NAMES} ? @{$self->{_COLUMN_NAMES}} : undef;
+    @columns == 1 && ! defined $columns[0] and return $self->{_COLUMN_NAMES} = undef;
+
+    if ( @columns == 1 && ref $columns[0] eq "ARRAY" ) {
+        @columns = @{ $columns[0] };
+    }
+    elsif ( join "", map { defined $_ ? ref $_ : "" } @columns ) {
         $self->SetDiag( 3001 );
     }
 
-    if ( $self->{_is_bound} && @clumns != $self->{_is_bound} ) {
+    if ( $self->{_BOUND_COLUMNS} && @columns != @{$self->{_BOUND_COLUMNS}} ) {
         $self->SetDiag( 3003 );
     }
 
-    $self->{_COLUMN_NAMES} = [ @clumns ];
-
-    @clumns;
+    $self->{_COLUMN_NAMES} = [ map { defined $_ ? $_ : "\cAUNDEF\cA" } @columns ];
+    @{ $self->{_COLUMN_NAMES} };
 }
 ################################################################################
 # bind_columns
@@ -1149,6 +1158,16 @@
 
   $csv->column_names ($csv->getline ($io));
 
+C<column_names ()> does B<no> checking on duplicates at all, which might
+lead to unwanted results. Undefined entries will be replaced with the
+string C<"\cAUNDEF\cA">, so
+
+  $csv->column_names (undef, "", "name", "name");
+  $hr = $csv->getline_hr ($io);
+
+Will set C<$hr->{"\cAUNDEF\cA"}> to the 1st field, C<$hr->{""}> to the
+2nd field, and C<$hr->{name}> to the 4th field, discarding the 2rd field.
+
 C<column_names ()> croaks on invalid arguments.
 
 =head2 bind_columns

Modified: branches/upstream/libtext-csv-perl/current/t/75_hashref.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-perl/current/t/75_hashref.t?rev=23741&op=diff
==============================================================================
--- branches/upstream/libtext-csv-perl/current/t/75_hashref.t (original)
+++ branches/upstream/libtext-csv-perl/current/t/75_hashref.t Sun Aug  3 10:03:36 2008
@@ -4,7 +4,7 @@
 $^W = 1;
 
 #use Test::More "no_plan";
- use Test::More tests => 62;
+ use Test::More tests => 68;
 
 BEGIN {
     $ENV{PERL_TEXT_CSV} = 0;
@@ -96,8 +96,8 @@
 ok ($csv->bind_columns (@bcr, \$foo),		"bind too many columns");
 ($code, $name, $price, $desc, $foo) = (101 .. 105);
 ok ($csv->getline (*FH),			"fetch less than expected");
-is_deeply ( [ $code, $name, $price, $desc, $foo ],
-	    [ 2, "Drinks", "82.78", "Drinks", 105 ],	"unfetched not reset");
+is_deeply ([ $code, $name, $price, $desc, $foo ],
+	   [ 2, "Drinks", "82.78", "Drinks", 105 ],	"unfetched not reset");
 
 my @foo = (0) x 0x012345;
 ok ($csv->bind_columns (\(@foo)),		"bind a lot of columns");
@@ -112,4 +112,17 @@
 
 close FH;
 
+open  FH, "<_test.csv";
+
+is ($csv->column_names (undef), undef,		"reset column headers");
+is ($csv->bind_columns (undef), undef,		"reset bound columns");
+is_deeply ([ $csv->column_names (undef, "", "name", "name") ],
+	   [ "\cAUNDEF\cA", "", "name", "name" ],	"undefined column header");
+ok ($hr = $csv->getline_hr (*FH),		"getline_hr ()");
+is (ref $hr, "HASH",				"returned a hashref");
+is_deeply ($hr, { "\cAUNDEF\cA" => "code", "" => "name", "name" => "description" },
+    "Discarded 3rd field");
+
+close FH;
+
 unlink "_test.csv";




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