r48506 - in /trunk/libtext-csv-perl: Changes META.yml README debian/changelog lib/Text/CSV.pm lib/Text/CSV_PP.pm t/12_acc.t t/15_flags.t

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Wed Dec 9 21:27:59 UTC 2009


Author: jawnsy-guest
Date: Wed Dec  9 21:27:53 2009
New Revision: 48506

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

Modified:
    trunk/libtext-csv-perl/Changes
    trunk/libtext-csv-perl/META.yml
    trunk/libtext-csv-perl/README
    trunk/libtext-csv-perl/debian/changelog
    trunk/libtext-csv-perl/lib/Text/CSV.pm
    trunk/libtext-csv-perl/lib/Text/CSV_PP.pm
    trunk/libtext-csv-perl/t/12_acc.t
    trunk/libtext-csv-perl/t/15_flags.t

Modified: trunk/libtext-csv-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-perl/Changes?rev=48506&op=diff
==============================================================================
--- trunk/libtext-csv-perl/Changes (original)
+++ trunk/libtext-csv-perl/Changes Wed Dec  9 21:27:53 2009
@@ -1,4 +1,9 @@
 Revision history for Perl extension Text::CSV.
+
+1.16  Tue Dec  8 19:02:58 2009
+	- updated the compatibility for Text::CSV_XS version 0.70
+	    * Added quote_space attribute
+	    * Forbad \r and \n in sep_char, quote_char, and escape_char
 
 1.15  Thu Oct 15 17:23:39 2009
 	- updated the compatibility for Text::CSV_XS version 0.69

Modified: trunk/libtext-csv-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-perl/META.yml?rev=48506&op=diff
==============================================================================
--- trunk/libtext-csv-perl/META.yml (original)
+++ trunk/libtext-csv-perl/META.yml Wed Dec  9 21:27:53 2009
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               Text-CSV
-version:            1.15
+version:            1.16
 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=48506&op=diff
==============================================================================
--- trunk/libtext-csv-perl/README (original)
+++ trunk/libtext-csv-perl/README Wed Dec  9 21:27:53 2009
@@ -1,4 +1,4 @@
-Text::CSV version 1.15
+Text::CSV version 1.16
 ========================
 
 comma-separated values manipulator

Modified: trunk/libtext-csv-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-perl/debian/changelog?rev=48506&op=diff
==============================================================================
--- trunk/libtext-csv-perl/debian/changelog (original)
+++ trunk/libtext-csv-perl/debian/changelog Wed Dec  9 21:27:53 2009
@@ -1,3 +1,9 @@
+libtext-csv-perl (1.16-1) UNRELEASED; urgency=low
+
+  * New upstream release
+
+ -- Jonathan Yu <jawnsy at cpan.org>  Wed, 09 Dec 2009 13:18:32 -0500
+
 libtext-csv-perl (1.15-1) unstable; urgency=low
 
   * New upstream release

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=48506&op=diff
==============================================================================
--- trunk/libtext-csv-perl/lib/Text/CSV.pm (original)
+++ trunk/libtext-csv-perl/lib/Text/CSV.pm Wed Dec  9 21:27:53 2009
@@ -5,14 +5,14 @@
 use Carp ();
 
 BEGIN {
-    $Text::CSV::VERSION = '1.15';
+    $Text::CSV::VERSION = '1.16';
     $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.69';
+my $XS_Version = '0.70';
 
 my $Is_Dynamic = 0;
 
@@ -25,7 +25,7 @@
     version types quote_char escape_char sep_char eol always_quote binary allow_whitespace
     keep_meta_info allow_loose_quotes allow_loose_escapes verbatim meta_info is_quoted is_binary eof
     getline print parse combine fields string error_diag error_input status blank_is_undef empty_is_undef
-    getline_hr column_names bind_columns auto_diag
+    getline_hr column_names bind_columns auto_diag quote_space
     PV IV NV
 /;
 #
@@ -286,9 +286,9 @@
 
 =head1 VERSION
 
-    1.15
-
-This module is compatible with Text::CSV_XS B<0.69> and later.
+    1.16
+
+This module is compatible with Text::CSV_XS B<0.70> and later.
 
 =head2 Embedded newlines
 
@@ -543,6 +543,13 @@
 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.
+
+=item quote_space
+
+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.
 
 =item keep_meta_info
 
@@ -611,6 +618,7 @@
      sep_char            => ',',
      eol                 => $\,
      always_quote        => 0,
+     quote_space         => 1,
      binary              => 0,
      keep_meta_info      => 0,
      allow_loose_quotes  => 0,

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=48506&op=diff
==============================================================================
--- trunk/libtext-csv-perl/lib/Text/CSV_PP.pm (original)
+++ trunk/libtext-csv-perl/lib/Text/CSV_PP.pm Wed Dec  9 21:27:53 2009
@@ -11,7 +11,7 @@
 use vars qw($VERSION);
 use Carp ();
 
-$VERSION = '1.23';
+$VERSION = '1.24';
 
 sub PV  { 0 }
 sub IV  { 1 }
@@ -26,6 +26,7 @@
         1000 => "INI - constructor failed",
         1001 => "sep_char is equal to quote_char or escape_char",
         1002 => "INI - allow_whitespace with escape_char or quote_char SP or TAB",
+        1003 => "INI - \r or \n in main attr not allowed",
 
         2010 => "ECR - QUO char inside quotes followed by CR not part of EOL",
         2011 => "ECR - Characters after end of quoted field",
@@ -84,6 +85,7 @@
     blank_is_undef      => 0,
     empty_is_undef      => 0,
     auto_diag           => 0,
+    quote_space         => 1,
 
     _EOF                => 0,
     _STATUS             => undef,
@@ -137,6 +139,28 @@
 ################################################################################
 # new
 ################################################################################
+
+sub _check_sanity {
+    my ( $self ) = @_;
+
+    for ( qw( sep_char quote_char escape_char ) ) {
+        ( exists $self->{$_} && defined $self->{$_} && $self->{$_} =~ m/[\r\n]/ ) and return 1003;
+    }
+
+    if ( $self->{allow_whitespace} and
+           ( defined $self->{quote_char}  && $self->{quote_char}  =~ m/^[ \t]$/ ) 
+           ||
+           ( defined $self->{escape_char} && $self->{escape_char} =~ m/^[ \t]$/ )
+    ) {
+       #$last_new_error = "INI - allow_whitespace with escape_char or quote_char SP or TAB";
+       #$last_new_err_num = 1002;
+       return 1002;
+    }
+
+    return 0;
+}
+
+
 sub new {
     my $proto = shift;
     my $attr  = @_ > 0 ? shift : {};
@@ -156,6 +180,18 @@
         }
         $self->{$prop} = $attr->{$prop};
     }
+
+    my $ec = _check_sanity( $self );
+
+    if ( $ec ) {
+        $last_new_error   = $ERRORS->{ $ec };
+        $last_new_err_num = $ec;
+        return;
+        #$class->SetDiag ($ec);
+    }
+
+
+=pod
 
     if ( $self->{allow_whitespace} and
            ( defined $self->{quote_char}  && $self->{quote_char}  =~ m/^[ \t]$/ ) 
@@ -167,6 +203,8 @@
        return;
     }
 
+=cut
+
     $last_new_error = '';
 
     defined $\ and $self->{eol} = $\;
@@ -247,15 +285,16 @@
     $self->{_STRING}      = '';
     $self->{_STATUS}      = 0;
 
-    my ($always_quote, $binary, $quot, $sep, $esc, $empty_is_undef)
-            = @{$self}{qw/always_quote binary quote_char sep_char escape_char empty_is_undef/};
+    my ($always_quote, $binary, $quot, $sep, $esc, $empty_is_undef, $quote_space)
+            = @{$self}{qw/always_quote binary quote_char sep_char escape_char empty_is_undef quote_space/};
 
     if(!defined $quot){ $quot = ''; }
 
     return $self->_set_error_diag(1001) if ($sep eq $esc or $sep eq $quot);
 
     my $re_esc = $self->{_re_comb_escape}->{$quot}->{$esc} ||= qr/(\Q$quot\E|\Q$esc\E)/;
-    my $re_sp  = $self->{_re_comb_sp}->{$sep}              ||= qr/[\s\Q$sep\E]/;
+#    my $re_sp  = $self->{_re_comb_sp}->{$sep}              ||= qr/[\s\Q$sep\E]/;
+    my $re_sp  = $self->{_re_comb_sp}->{$sep}->{$quote_space} ||= ( $quote_space ? qr/[\s\Q$sep\E]/ : qr/[\Q$sep\E]/ );
 
     my $must_be_quoted;
     for my $column (@part) {
@@ -281,7 +320,7 @@
             $must_be_quoted++;
         }
         if($column =~ /$re_sp/){
-            $must_be_quoted++;
+            $must_be_quoted++ if $quote_space;
         }
 
         if($binary){
@@ -289,8 +328,8 @@
             $must_be_quoted++ if ( $column =~ s/\0/${esc}0/g || $column =~ /[\x00-\x1f\x7f-\xa0]/ );
         }
 
-        if ( $empty_is_undef and defined $column and not length $column ) {
-        }
+        #if ( $empty_is_undef and defined $column and not length $column ) {
+        #}
         #elsif($always_quote or $must_be_quoted){
         if($always_quote or $must_be_quoted){
             $column = $quot . $column . $quot;
@@ -807,8 +846,8 @@
 ################################################################################
 
 BEGIN {
-    for my $method ( qw/sep_char always_quote binary keep_meta_info allow_loose_quotes allow_loose_escapes
-                            verbatim blank_is_undef empty_is_undef auto_diag/ ) {
+    for my $method ( qw/always_quote binary keep_meta_info allow_loose_quotes allow_loose_escapes
+                            verbatim blank_is_undef empty_is_undef auto_diag quote_space/ ) {
         eval qq|
             sub $method {
                 \$_[0]->{$method} = defined \$_[1] ? \$_[1] : 0 if (\@_ > 1);
@@ -819,12 +858,24 @@
 }
 
 
+
+sub sep_char {
+    my $self = shift;
+    if ( @_ ) {
+        $self->{sep_char} = $_[0];
+        my $ec = _check_sanity( $self );
+        $ec and Carp::croak( $self->SetDiag( $ec ) );
+    }
+    $self->{sep_char};
+}
+
+
 sub quote_char {
     my $self = shift;
     if ( @_ ) {
-        my $qc = shift;
-        defined $qc && $qc =~ m/^[ \t]$/ && $self->{allow_whitespace} and Carp::croak( $self->SetDiag(1002) );
-        $self->{quote_char} = $qc;
+        $self->{quote_char} = $_[0];
+        my $ec = _check_sanity( $self );
+        $ec and Carp::croak( $self->SetDiag( $ec ) );
     }
     $self->{quote_char};
 }
@@ -833,9 +884,9 @@
 sub escape_char {
     my $self = shift;
     if ( @_ ) {
-        my $es = shift;
-        defined $es && $es =~ m/^[ \t]$/ && $self->{allow_whitespace} and Carp::croak( $self->SetDiag(1002) );
-        $self->{escape_char} = $es;
+        $self->{escape_char} = $_[0];
+        my $ec = _check_sanity( $self );
+        $ec and Carp::croak( $self->SetDiag( $ec ) );
     }
     $self->{escape_char};
 }
@@ -943,7 +994,7 @@
 
 =head1 VERSION
 
-    1.22
+    1.24
 
 This module is compatible with Text::CSV_XS B<0.68> and later.
 
@@ -1150,6 +1201,13 @@
 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.
+
+=item quote_space
+
+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.
 
 =item keep_meta_info
 
@@ -1218,6 +1276,7 @@
      sep_char            => ',',
      eol                 => $\,
      always_quote        => 0,
+     quote_space         => 1,
      binary              => 0,
      keep_meta_info      => 0,
      allow_loose_quotes  => 0,
@@ -1551,6 +1610,11 @@
 Using C<allow_whitespace> when either C<escape_char> or C<quote_char> is
 equal to SPACE or TAB is too ambiguous to allow.
 
+=item 1003 "INI - \r or \n in main attr not allowed"
+
+Using default C<eol> characters in either C<sep_char>, C<quote_char>, or
+C<escape_char> is not allowed.
+
 =item 2010 "ECR - QUO char inside quotes followed by CR not part of EOL"
 
 =item 2011 "ECR - Characters after end of quoted field"

Modified: trunk/libtext-csv-perl/t/12_acc.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-perl/t/12_acc.t?rev=48506&op=diff
==============================================================================
--- trunk/libtext-csv-perl/t/12_acc.t (original)
+++ trunk/libtext-csv-perl/t/12_acc.t Wed Dec  9 21:27:53 2009
@@ -3,7 +3,7 @@
 use strict;
 $^W = 1;	# use warnings core since 5.6
 
-use Test::More tests => 86;
+use Test::More tests => 107;
 
 BEGIN {
     $ENV{PERL_TEXT_CSV} = 0;
@@ -96,6 +96,21 @@
 like ((Text::CSV::error_diag)[1], qr{^INI - allow_whitespace}, "Wrong combo - error message");
 is   ( (Text::CSV::error_diag)[0], 1002, "Wrong combo - numeric error");
 
+# Test 1003 in constructor
+foreach my $x ("\r", "\n", "\r\n", "x\n", "\rx") {
+    foreach my $attr (qw( sep_char quote_char escape_char )) {
+	eval { $csv = Text::CSV->new ({ $attr => $x }) };
+	is ((Text::CSV::error_diag)[0], 1003, "eol in $attr");
+	}
+    }
+# Test 1003 in methods
+foreach my $attr (qw( sep_char quote_char escape_char )) {
+    ok ($csv = Text::CSV->new, "New");
+    eval { ok ($csv->$attr ("\n"), "$attr => \\n") };
+    is (($csv->error_diag)[0], 1003, "not allowed");
+    }
+
+
 # And test erroneous calls
 
 is (Text::CSV::new (0),		   undef,	"new () as function");

Modified: trunk/libtext-csv-perl/t/15_flags.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-perl/t/15_flags.t?rev=48506&op=diff
==============================================================================
--- trunk/libtext-csv-perl/t/15_flags.t (original)
+++ trunk/libtext-csv-perl/t/15_flags.t Wed Dec  9 21:27:53 2009
@@ -3,7 +3,7 @@
 use strict;
 $^W = 1;	# use warnings core since 5.6
 
-use Test::More tests => 185;
+use Test::More tests => 197;
 
 BEGIN {
     $ENV{PERL_TEXT_CSV} = 0;
@@ -211,11 +211,11 @@
     ok (!$csv->parse (qq{"+\r\n"}),	"Quo ESC CR NL");
     }
 
+ok (1, "Testing always_quote");
 {   my $csv = Text::CSV->new ({ always_quote => 0 });
     ok ($csv->combine (1..3),		"Combine");
     is ($csv->string, q{1,2,3},		"String");
     is ($csv->always_quote, 0,		"Attr 0");
-    ok ($csv->combine (1..3),		"Combine");
     ok ($csv->always_quote (1),		"Attr 1");
     ok ($csv->combine (1..3),		"Combine");
     is ($csv->string, q{"1","2","3"},	"String");
@@ -225,3 +225,18 @@
     is ($csv->string, q{1,2,3},		"String");
     is ($csv->always_quote, 0,		"Attr 0");
     }
+
+ok (1, "Testing quote_space");
+{   my $csv = Text::CSV->new ({ quote_space => 1 });
+    ok ($csv->combine (1, " ", 3),	"Combine");
+    is ($csv->string, q{1," ",3},	"String");
+    is ($csv->quote_space, 1,		"Attr 1");
+    is ($csv->quote_space (0), 0,	"Attr 0");
+    ok ($csv->combine (1, " ", 3),	"Combine");
+    is ($csv->string, q{1, ,3},		"String");
+    is ($csv->quote_space, 0,		"Attr 0");
+    is ($csv->quote_space (1), 1,	"Attr 1");
+    ok ($csv->combine (1, " ", 3),	"Combine");
+    is ($csv->string, q{1," ",3},	"String");
+    is ($csv->quote_space, 1,		"Attr 1");
+    }




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