r45918 - in /branches/upstream/libtext-csv-perl/current: Changes META.yml README lib/Text/CSV.pm lib/Text/CSV_PP.pm t/45_eol.t t/65_allow.t
jawnsy-guest at users.alioth.debian.org
jawnsy-guest at users.alioth.debian.org
Sat Oct 17 14:09:37 UTC 2009
Author: jawnsy-guest
Date: Sat Oct 17 14:09:32 2009
New Revision: 45918
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=45918
Log:
[svn-upgrade] Integrating new upstream version, libtext-csv-perl (1.15)
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/45_eol.t
branches/upstream/libtext-csv-perl/current/t/65_allow.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=45918&op=diff
==============================================================================
--- branches/upstream/libtext-csv-perl/current/Changes (original)
+++ branches/upstream/libtext-csv-perl/current/Changes Sat Oct 17 14:09:32 2009
@@ -1,4 +1,9 @@
Revision history for Perl extension Text::CSV.
+
+1.15 Thu Oct 15 17:23:39 2009
+ - updated the compatibility for Text::CSV_XS version 0.69
+ * Auto detection of eol => "\r" in streams
+ (but incomplete correspondence. I will rewrite CSV_PP in the future)
1.14 Thu Oct 8 15:02:24 2009
- updated the compatibility for Text::CSV_XS version 0.68
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=45918&op=diff
==============================================================================
--- branches/upstream/libtext-csv-perl/current/META.yml (original)
+++ branches/upstream/libtext-csv-perl/current/META.yml Sat Oct 17 14:09:32 2009
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: Text-CSV
-version: 1.14
+version: 1.15
abstract: comma-separated values manipulator (using XS or PurePerl)
author:
- Makamaka Hannyaharamitu, E<lt>makamaka[at]cpan.orgE<gt>
Modified: branches/upstream/libtext-csv-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-perl/current/README?rev=45918&op=diff
==============================================================================
--- branches/upstream/libtext-csv-perl/current/README (original)
+++ branches/upstream/libtext-csv-perl/current/README Sat Oct 17 14:09:32 2009
@@ -1,4 +1,4 @@
-Text::CSV version 1.13
+Text::CSV version 1.15
========================
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=45918&op=diff
==============================================================================
--- branches/upstream/libtext-csv-perl/current/lib/Text/CSV.pm (original)
+++ branches/upstream/libtext-csv-perl/current/lib/Text/CSV.pm Sat Oct 17 14:09:32 2009
@@ -5,14 +5,14 @@
use Carp ();
BEGIN {
- $Text::CSV::VERSION = '1.14';
+ $Text::CSV::VERSION = '1.15';
$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.68';
+my $XS_Version = '0.69';
my $Is_Dynamic = 0;
@@ -286,9 +286,9 @@
=head1 VERSION
- 1.14
-
-This module is compatible with Text::CSV_XS B<0.68> and later.
+ 1.15
+
+This module is compatible with Text::CSV_XS B<0.69> and later.
=head2 Embedded newlines
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=45918&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 Sat Oct 17 14:09:32 2009
@@ -11,7 +11,7 @@
use vars qw($VERSION);
use Carp ();
-$VERSION = '1.22';
+$VERSION = '1.23';
sub PV { 0 }
sub IV { 1 }
@@ -474,9 +474,7 @@
else {
if (!$self->{verbatim} and $col =~ /\r\n|\n/) {
- unless (defined $eol and !$allow_eol{$eol}) {
- $col =~ s/(?:\r\n|\n).*//sm;
- }
+ $col =~ s/(?:\r\n|\n).*$//sm;
}
if ($col =~ /\Q$esc\E\r$/) { # for t/15_flags : test 165 'ESC CR' at line 203
@@ -594,14 +592,24 @@
$self->{_EOF} = eof($io) ? 1 : '';
- my $line = $io->getline();
my $quot = $self->{quote_char};
my $sep = $self->{sep_char};
+ my $re = qr/(?:\Q$quot\E)/;
+
+ local $/ = "\r" if $self->{_AUTO_DETECT_CR};
+
+ my $line = $io->getline();
my $eol = $self->{eol};
- my $re = qr/(?:\Q$quot\E)/;
-
- if ( defined $line and $line =~ /${re}0/ ) {
+ # AUTO DETECTION EOL CR
+ if ( defined $line and defined $eol and $eol eq '' and $line =~ /[^\r]\r[^\r\n]/ and eof ) {
+ $self->{_AUTO_DETECT_CR} = 1;
+ $self->{eol} = "\r";
+ seek( $io, 0, 0 ); # restart
+ 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
@@ -610,42 +618,53 @@
}
$self->auto_diag( $auto_diag ) if ( $auto_diag ); # restore
- }
- else {
- $line .= $io->getline() while ( defined $line and scalar(my @list = $line =~ /$re/g) % 2 and !eof($io) );
-
- if (defined $eol and defined $line) {
- $line =~ s/\Q$eol\E$//;
- }
-
- $self->_parse($line) or return;
- }
-
- if ( $self->{_BOUND_COLUMNS} ) {
- my @vals = $self->_fields();
- my ( $max, $count ) = ( scalar @vals, 0 );
-
- if ( @{ $self->{_BOUND_COLUMNS} } < $max ) {
- $self->_set_error_diag(3006);
- return;
- }
-
- for ( my $i = 0; $i < $max; $i++ ) {
- my $bind = $self->{_BOUND_COLUMNS}->[ $i ];
- if ( Scalar::Util::readonly( $$bind ) ) {
- $self->_set_error_diag(3008);
- return;
- }
- $$bind = $vals[ $i ];
- }
-
- return [];
- }
- else {
- [ $self->_fields() ];
- }
-
-}
+
+ 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$//;
+ }
+
+ $self->_parse($line);
+
+ return $self->_return_getline_result();
+}
+
+
+sub _return_getline_result {
+
+ if ( eof ) {
+ $_[0]->{_AUTO_DETECT_CR} = 0;
+ }
+
+ return unless $_[0]->{_STATUS};
+
+ return [ $_[0]->_fields() ] unless $_[0]->{_BOUND_COLUMNS};
+
+ my @vals = $_[0]->_fields();
+ my ( $max, $count ) = ( scalar @vals, 0 );
+
+ if ( @{ $_[0]->{_BOUND_COLUMNS} } < $max ) {
+ $_[0]->_set_error_diag(3006);
+ return;
+ }
+
+ for ( my $i = 0; $i < $max; $i++ ) {
+ my $bind = $_[0]->{_BOUND_COLUMNS}->[ $i ];
+ if ( Scalar::Util::readonly( $$bind ) ) {
+ $_[0]->_set_error_diag(3008);
+ return;
+ }
+ $$bind = $vals[ $i ];
+ }
+
+ return [];
+}
+
+
################################################################################
# getline_hr
################################################################################
Modified: branches/upstream/libtext-csv-perl/current/t/45_eol.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-perl/current/t/45_eol.t?rev=45918&op=diff
==============================================================================
--- branches/upstream/libtext-csv-perl/current/t/45_eol.t (original)
+++ branches/upstream/libtext-csv-perl/current/t/45_eol.t Sat Oct 17 14:09:32 2009
@@ -3,7 +3,7 @@
use strict;
$^W = 1;
-use Test::More tests => 262;
+use Test::More tests => 278;
BEGIN {
$ENV{PERL_TEXT_CSV} = 0;
@@ -15,6 +15,8 @@
$| = 1;
# Embedded newline tests
+
+my $def_rs = $/;
foreach my $rs ("\n", "\r\n", "\r") {
for $\ (undef, $rs) {
@@ -56,7 +58,7 @@
}
else {
ok (my $row = $csv->getline (*FH), "getline |$s_eol|");
- is (ref $row, "ARRAY", "row |$s_eol|");
+ is (ref $row, "ARRAY", "row |$s_eol|");
@p = @$row;
}
@@ -70,6 +72,7 @@
unlink "_eol.csv";
}
}
+$/ = $def_rs;
{ my $csv = Text::CSV->new ({ escape_char => undef });
@@ -85,28 +88,50 @@
SKIP: {
$] < 5.008 and skip "\$\\ tests don't work in perl 5.6.x and older", 2;
{ local $\ = "#\r\n";
- my $csv = Text::CSV->new ();
- open FH, ">_eol.csv";
- $csv->print (*FH, [ "a", 1 ]);
- close FH;
- open FH, "<_eol.csv";
- local $/;
- is (<FH>, "a,1#\r\n", "Strange \$\\");
- close FH;
- unlink "_eol.csv";
+ my $csv = Text::CSV->new ();
+ open FH, ">_eol.csv";
+ $csv->print (*FH, [ "a", 1 ]);
+ close FH;
+ open FH, "<_eol.csv";
+ local $/;
+ is (<FH>, "a,1#\r\n", "Strange \$\\");
+ close FH;
+ unlink "_eol.csv";
+ }
+ { local $\ = "#\r\n";
+ my $csv = Text::CSV->new ({ eol => $\ });
+ open FH, ">_eol.csv";
+ $csv->print (*FH, [ "a", 1 ]);
+ close FH;
+ open FH, "<_eol.csv";
+ local $/;
+ is (<FH>, "a,1#\r\n", "Strange \$\\ + eol");
+ close FH;
+ unlink "_eol.csv";
+ }
}
-{ local $\ = "#\r\n";
- my $csv = Text::CSV->new ({ eol => $\ });
- open FH, ">_eol.csv";
- $csv->print (*FH, [ "a", 1 ]);
- close FH;
- open FH, "<_eol.csv";
- local $/;
- is (<FH>, "a,1#\r\n", "Strange \$\\ + eol");
- close FH;
- unlink "_eol.csv";
+$/ = $def_rs;
+
+
+ok (1, "Auto-detecting \\r");
+{ my @row = qw( a b c ); local $" = ",";
+ for (["\n", "\\n"], ["\r\n", "\\r\\n"], ["\r", "\\r"]) {
+ my ($eol, $s_eol) = @$_;
+ open FH, ">_eol.csv";
+ print FH qq{@row$eol at row$eol at row$eol\x91};
+ close FH;
+ open FH, "<_eol.csv";
+
+ my $c = Text::CSV->new ({ binary => 1, auto_diag => 1 });
+ is ($c->eol (), "", "default EOL");
+ is_deeply ($c->getline (*FH), [ @row ], "EOL 1 $s_eol");
+ is ($c->eol (), $eol eq "\r" ? "\r" : "", "EOL");
+ is_deeply ($c->getline (*FH), [ @row ], "EOL 2 $s_eol");
+ is_deeply ($c->getline (*FH), [ @row ], "EOL 3 $s_eol");
+ close FH;
+ unlink "_eol.csv";
+ }
}
-}
ok (1, "Specific \\r test from tfrayner");
{ $/ = "\r";
@@ -127,7 +152,7 @@
close FH;
unlink "_eol.csv";
}
-
+$/ = $def_rs;
ok (1, "EOL undef");
{ $/ = "\r";
@@ -144,6 +169,6 @@
close FH;
unlink "_eol.csv";
}
-
+$/ = $def_rs;
1;
Modified: branches/upstream/libtext-csv-perl/current/t/65_allow.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-perl/current/t/65_allow.t?rev=45918&op=diff
==============================================================================
--- branches/upstream/libtext-csv-perl/current/t/65_allow.t (original)
+++ branches/upstream/libtext-csv-perl/current/t/65_allow.t Sat Oct 17 14:09:32 2009
@@ -14,7 +14,7 @@
}
my $csv;
-
+#=pod
ok (1, "Allow unescaped quotes");
# Allow unescaped quotes inside an unquoted field
{ my @bad = (
@@ -293,7 +293,7 @@
}
}
}
-
+#=cut
{ ok (1, "verbatim");
my $csv = Text::CSV->new ({
sep_char => "^",
@@ -341,12 +341,16 @@
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], "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], "Abe\nTimmerman#\r\n", "#\\r\\n $gc fld 2");
+ is ($fld[2], $gc ? "Abe\nTimmerman#\r\n"
+ : "Abe", "#\\r\\n $gc fld 2");
}
ok (1, "verbatim on getline (*FH)");
@@ -363,11 +367,15 @@
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], "Timmerman", "#\\r\\n $gc fld 3");
+ is ($row->[3], $gc ? "Timmerman"
+ : "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], "Abe\nTimmerman", "#\\r\\n $gc fld 2");
+ is ($row->[2], $gc ? "Abe\nTimmerman"
+ : "Abe", "#\\r\\n $gc fld 2");
}
$gc = $csv->verbatim ();
More information about the Pkg-perl-cvs-commits
mailing list