r22676 - in /branches/upstream/libtext-csv-xs-perl/current: CSV_XS.pm ChangeLog META.yml t/75_hashref.t

gregoa at users.alioth.debian.org gregoa at users.alioth.debian.org
Wed Jul 2 21:29:25 UTC 2008


Author: gregoa
Date: Wed Jul  2 21:29:25 2008
New Revision: 22676

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

Modified:
    branches/upstream/libtext-csv-xs-perl/current/CSV_XS.pm
    branches/upstream/libtext-csv-xs-perl/current/ChangeLog
    branches/upstream/libtext-csv-xs-perl/current/META.yml
    branches/upstream/libtext-csv-xs-perl/current/t/75_hashref.t

Modified: branches/upstream/libtext-csv-xs-perl/current/CSV_XS.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-xs-perl/current/CSV_XS.pm?rev=22676&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/CSV_XS.pm (original)
+++ branches/upstream/libtext-csv-xs-perl/current/CSV_XS.pm Wed Jul  2 21:29:25 2008
@@ -30,7 +30,7 @@
 use Carp;
 
 use vars   qw( $VERSION @ISA );
-$VERSION = "0.51";
+$VERSION = "0.52";
 @ISA     = qw( DynaLoader );
 
 sub PV { 0 }
@@ -416,15 +416,15 @@
     if (@keys == 1 && ref $keys[0] eq "ARRAY") {
 	@keys = @{$keys[0]};
 	}
-    elsif (join "", map { defined $_ ? ref $_ : "UNDEF" } @keys) {
+    elsif (join "", map { defined $_ ? ref $_ : "" } @keys) {
 	croak ($self->SetDiag (3001));
 	}
 
-    $self->{_is_bound} && @keys != $self->{_is_bound} and
+    $self->{_BOUND_COLUMNS} && @keys != @{$self->{_BOUND_COLUMNS}} and
 	croak ($self->SetDiag (3003));
 
-    $self->{_COLUMN_NAMES} = [ @keys ];
-    @keys;
+    $self->{_COLUMN_NAMES} = [ map { defined $_ ? $_ : "\cAUNDEF\cA" } @keys ];
+    @{$self->{_COLUMN_NAMES}};
     } # column_names
 
 sub bind_columns
@@ -445,7 +445,7 @@
     $self->_set_attr_N ("_is_bound", scalar @refs);
     $self->{_BOUND_COLUMNS} = [ @refs ];
     @refs;
-    } # column_names
+    } # bind_columns
 
 sub getline_hr
 {
@@ -990,6 +990,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
@@ -1250,14 +1260,12 @@
 
 =item More Errors & Warnings
 
-At current, it is hard to tell where or why an error occured (if
-at all). New extensions ought to be clear and concise in reporting
-what error occurred where and why, and possibly also tell a remedy
-to the problem. error_diag is a (very) good start, but there is more
-work to be done here.
-
-Basic calls should croak or warn on illegal parameters. Errors
-should be documented.
+New extensions ought to be clear and concise in reporting what error
+occurred where and why, and possibly also tell a remedy to the problem.
+error_diag is a (very) good start, but there is more work to be done here.
+
+Basic calls should croak or warn on illegal parameters. Errors should be
+documented.
 
 =item eol
 

Modified: branches/upstream/libtext-csv-xs-perl/current/ChangeLog
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-xs-perl/current/ChangeLog?rev=22676&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/ChangeLog (original)
+++ branches/upstream/libtext-csv-xs-perl/current/ChangeLog Wed Jul  2 21:29:25 2008
@@ -1,3 +1,8 @@
+2008-06-28  0.52 - H.Merijn Brand   <h.m.brand at xs4all.nl>
+
+	* Using undef for hash keys is a bad plan
+	* Fix, tests, and documentation for column_names ()
+
 2008-06-17  0.51 - H.Merijn Brand   <h.m.brand at xs4all.nl>
 
 	* Allow UTF8 even without binary => 1

Modified: branches/upstream/libtext-csv-xs-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-xs-perl/current/META.yml?rev=22676&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/META.yml (original)
+++ branches/upstream/libtext-csv-xs-perl/current/META.yml Wed Jul  2 21:29:25 2008
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:              Text-CSV_XS
-version:           0.51
+version:           0.52
 abstract:          Comma-Separated Values manipulation routines
 license:           perl
 author:              
@@ -10,7 +10,7 @@
 provides:
     Text::CSV_XS:
         file:      CSV_XS.pm
-        version:   0.51
+        version:   0.52
 requires:     
     perl:          5.005
     DynaLoader:    0

Modified: branches/upstream/libtext-csv-xs-perl/current/t/75_hashref.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-xs-perl/current/t/75_hashref.t?rev=22676&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/t/75_hashref.t (original)
+++ branches/upstream/libtext-csv-xs-perl/current/t/75_hashref.t Wed Jul  2 21:29:25 2008
@@ -4,7 +4,7 @@
 $^W = 1;
 
 #use Test::More "no_plan";
- use Test::More tests => 62;
+ use Test::More tests => 68;
 
 BEGIN {
     use_ok "Text::CSV_XS", ();
@@ -93,8 +93,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");
@@ -109,4 +109,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