Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package perl-Text-CSV for openSUSE:Factory checked in at 2022-08-17 18:16:39 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Text-CSV (Old) and /work/SRC/openSUSE:Factory/.perl-Text-CSV.new.1521 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Text-CSV" Wed Aug 17 18:16:39 2022 rev:26 rq:997352 version:2.02 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Text-CSV/perl-Text-CSV.changes 2021-07-02 13:27:18.468834736 +0200 +++ /work/SRC/openSUSE:Factory/.perl-Text-CSV.new.1521/perl-Text-CSV.changes 2022-08-17 18:22:54.451148287 +0200 @@ -1,0 +2,10 @@ +Mon Aug 8 03:11:38 UTC 2022 - Tina M??ller <[email protected]> + +- updated to 2.02 + see /usr/share/doc/packages/perl-Text-CSV/Changes + + 2.02 2022-08-08 + - Imported tests/fixes from Text::CSV_XS 1.48 + - Fixed a case where csv function is called as a method (GH#46) + +------------------------------------------------------------------- Old: ---- Text-CSV-2.01.tar.gz New: ---- Text-CSV-2.02.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Text-CSV.spec ++++++ --- /var/tmp/diff_new_pack.4resDA/_old 2022-08-17 18:22:54.895149207 +0200 +++ /var/tmp/diff_new_pack.4resDA/_new 2022-08-17 18:22:54.903149224 +0200 @@ -1,7 +1,7 @@ # # spec file for package perl-Text-CSV # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,10 +18,10 @@ %define cpan_name Text-CSV Name: perl-Text-CSV -Version: 2.01 +Version: 2.02 Release: 0 -Summary: Comma-separated values manipulator (using XS or PurePerl) License: Artistic-1.0 OR GPL-1.0-or-later +Summary: Comma-separated values manipulator (using XS or PurePerl) URL: https://metacpan.org/release/%{cpan_name} Source0: https://cpan.metacpan.org/authors/id/I/IS/ISHIGAKI/%{cpan_name}-%{version}.tar.gz Source1: cpanspec.yml @@ -30,7 +30,7 @@ BuildRequires: perl-macros BuildRequires: perl(Test::More) >= 0.71 Requires: perl(Test::More) >= 0.71 -Recommends: perl(Text::CSV_XS) >= 1.46 +Recommends: perl(Text::CSV_XS) >= 1.48 %{perl_requires} %description ++++++ Text-CSV-2.01.tar.gz -> Text-CSV-2.02.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV-2.01/Changes new/Text-CSV-2.02/Changes --- old/Text-CSV-2.01/Changes 2021-06-19 06:14:49.000000000 +0200 +++ new/Text-CSV-2.02/Changes 2022-08-07 22:20:39.000000000 +0200 @@ -1,5 +1,9 @@ Revision history for Perl extension Text::CSV. +2.02 2022-08-08 + - Imported tests/fixes from Text::CSV_XS 1.48 + - Fixed a case where csv function is called as a method (GH#46) + 2.01 2021-06-19 - Imported tests/fixes from Text::CSV_XS 1.46 - Updated XS_Version to 1.46, and if an older version diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV-2.01/MANIFEST new/Text-CSV-2.02/MANIFEST --- old/Text-CSV-2.01/MANIFEST 2021-06-19 06:15:32.000000000 +0200 +++ new/Text-CSV-2.02/MANIFEST 2022-08-07 22:22:06.000000000 +0200 @@ -19,6 +19,7 @@ t/41_null.t t/45_eol.t t/46_eol_si.t +t/47_comment.t t/50_utf8.t t/51_utf8.t t/55_combi.t @@ -37,6 +38,7 @@ t/85_util.t t/90_csv.t t/91_csv_cb.t +t/csv_method.t t/fields_containing_0.t t/rt99774.t t/util.pl diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV-2.01/META.json new/Text-CSV-2.02/META.json --- old/Text-CSV-2.01/META.json 2021-06-19 06:15:32.000000000 +0200 +++ new/Text-CSV-2.02/META.json 2022-08-07 22:22:06.000000000 +0200 @@ -32,7 +32,7 @@ }, "runtime" : { "recommends" : { - "Text::CSV_XS" : "1.46" + "Text::CSV_XS" : "1.48" }, "requires" : { "IO::Handle" : "0", @@ -54,6 +54,6 @@ "url" : "https://github.com/makamaka/Text-CSV" } }, - "version" : "2.01", + "version" : "2.02", "x_serialization_backend" : "JSON::PP version 4.05" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV-2.01/META.yml new/Text-CSV-2.02/META.yml --- old/Text-CSV-2.01/META.yml 2021-06-19 06:15:32.000000000 +0200 +++ new/Text-CSV-2.02/META.yml 2022-08-07 22:22:06.000000000 +0200 @@ -18,7 +18,7 @@ - t - inc recommends: - Text::CSV_XS: '1.46' + Text::CSV_XS: '1.48' requires: IO::Handle: '0' Test::Harness: '0' @@ -28,5 +28,5 @@ bugtracker: https://github.com/makamaka/Text-CSV/issues license: http://dev.perl.org/licenses/ repository: https://github.com/makamaka/Text-CSV -version: '2.01' +version: '2.02' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV-2.01/lib/Text/CSV.pm new/Text-CSV-2.02/lib/Text/CSV.pm --- old/Text-CSV-2.01/lib/Text/CSV.pm 2021-06-19 06:10:05.000000000 +0200 +++ new/Text-CSV-2.02/lib/Text/CSV.pm 2022-08-07 22:20:44.000000000 +0200 @@ -4,27 +4,41 @@ use strict; use Exporter; use Carp (); -use vars qw( $VERSION $DEBUG @ISA @EXPORT_OK ); +use vars qw( $VERSION $DEBUG @ISA @EXPORT_OK %EXPORT_TAGS ); @ISA = qw( Exporter ); -@EXPORT_OK = qw( csv ); BEGIN { - $VERSION = '2.01'; + $VERSION = '2.02'; $DEBUG = 0; } # if use CSV_XS, requires version my $Module_XS = 'Text::CSV_XS'; my $Module_PP = 'Text::CSV_PP'; -my $XS_Version = '1.46'; +my $XS_Version = '1.48'; my $Is_Dynamic = 0; my @PublicMethods = qw/ version error_diag error_input - known_attributes csv - PV IV NV + known_attributes + PV IV NV CSV_TYPE_PV CSV_TYPE_IV CSV_TYPE_NV + CSV_FLAGS_IS_QUOTED CSV_FLAGS_IS_BINARY CSV_FLAGS_ERROR_IN_FIELD CSV_FLAGS_IS_MISSING /; + +%EXPORT_TAGS = ( + CONSTANTS => [qw( + CSV_FLAGS_IS_QUOTED + CSV_FLAGS_IS_BINARY + CSV_FLAGS_ERROR_IN_FIELD + CSV_FLAGS_IS_MISSING + CSV_TYPE_PV + CSV_TYPE_IV + CSV_TYPE_NV + )], +); +@EXPORT_OK = (qw(csv PV IV NV), @{$EXPORT_TAGS{CONSTANTS}}); + # # Check the environment variable to decide worker module. @@ -76,6 +90,14 @@ } +sub csv { + if (@_ && ref $_[0] eq __PACKAGE__ or ref $_[0] eq __PACKAGE__->backend) { + splice @_, 0, 0, "csv"; + } + my $backend = __PACKAGE__->backend; + no strict 'refs'; + &{"$backend\::csv"}(@_); +} sub require_xs_version { $XS_Version; } @@ -428,7 +450,7 @@ it you will need to also change the C<escape_char> to be the same as what you have changed the L<C<quote_char>|/quote_char> to. -Setting C<escape_char> to <undef> or C<""> will disable escaping completely +Setting C<escape_char> to C<undef> or C<""> will completely disable escapes and is greatly discouraged. This will also disable C<escape_null>. The escape character can not be equal to the separation character. @@ -471,6 +493,8 @@ =head3 formula_handling +Alias for L</formula> + =head3 formula my $csv = Text::CSV->new ({ formula => "none" }); @@ -784,7 +808,7 @@ By default, all "unsafe" bytes inside a string cause the combined field to be quoted. By setting this attribute to C<0>, you can disable that trigger -for bytes >= C<0x7F>. +for bytes C<< >= 0x7F >>. =head3 escape_null @@ -1165,7 +1189,7 @@ =head2 fragment This function tries to implement RFC7111 (URI Fragment Identifiers for the -text/csv Media Type) - http://tools.ietf.org/html/rfc7111 +text/csv Media Type) - https://datatracker.ietf.org/doc/html/rfc7111 my $AoA = $csv->fragment ($fh, $spec); @@ -1248,7 +1272,7 @@ =back -L<RFC7111|http://tools.ietf.org/html/rfc7111> does B<not> allow different +L<RFC7111|https://datatracker.ietf.org/doc/html/rfc7111> does B<not> allow different types of specs to be combined (either C<row> I<or> C<col> I<or> C<cell>). Passing an invalid fragment specification will croak and set error 2013. @@ -1568,14 +1592,20 @@ =item IV +=item CSV_TYPE_IV + Set field type to integer. =item NV +=item CSV_TYPE_NV + Set field type to numeric/float. =item PV +=item CSV_TYPE_PV + Set field type to string. =back @@ -1604,14 +1634,32 @@ =over 2 -=item C< >0x0001 +=item C<0x0001> + +=item C<CSV_FLAGS_IS_QUOTED> The field was quoted. -=item C< >0x0002 +=item C<0x0002> + +=item C<CSV_FLAGS_IS_BINARY> The field was binary. +=item C<0x0004> + +=item C<CSV_FLAGS_ERROR_IN_FIELD> + +The field was invalid. + +Currently only used when C<allow_loose_quotes> is active. + +=item C<0x0010> + +=item C<CSV_FLAGS_IS_MISSING> + +The field was missing. + =back See the C<is_***> methods below. @@ -2195,6 +2243,19 @@ This attribute implies a default of C<auto> for the C<headers> attribute. +The headers can also be kept internally to keep stable header order: + + csv (in => csv (in => "file.csv", kh => "internal"), + out => "new.csv", + kh => "internal"); + +where C<internal> can also be C<1>, C<yes>, or C<true>. This is similar to + + my @h; + csv (in => csv (in => "file.csv", kh => \@h), + out => "new.csv", + headers => \@h); + =head3 fragment Only output the fragment as defined in the L</fragment> method. This option diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV-2.01/lib/Text/CSV_PP.pm new/Text-CSV-2.02/lib/Text/CSV_PP.pm --- old/Text-CSV-2.01/lib/Text/CSV_PP.pm 2021-06-19 06:08:36.000000000 +0200 +++ new/Text-CSV-2.02/lib/Text/CSV_PP.pm 2022-08-07 22:20:44.000000000 +0200 @@ -9,28 +9,50 @@ use strict; use Exporter (); -use vars qw($VERSION @ISA @EXPORT_OK); +use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS); use Carp; -$VERSION = '2.01'; +$VERSION = '2.02'; @ISA = qw(Exporter); -@EXPORT_OK = qw(csv); sub PV { 0 } sub IV { 1 } sub NV { 2 } +sub CSV_TYPE_PV { PV } +sub CSV_TYPE_IV { IV } +sub CSV_TYPE_NV { NV } + sub IS_QUOTED () { 0x0001; } sub IS_BINARY () { 0x0002; } sub IS_ERROR () { 0x0004; } sub IS_MISSING () { 0x0010; } +sub CSV_FLAGS_IS_QUOTED { IS_QUOTED } +sub CSV_FLAGS_IS_BINARY { IS_BINARY } +sub CSV_FLAGS_ERROR_IN_FIELD { IS_ERROR } +sub CSV_FLAGS_IS_MISSING { IS_MISSING } + sub HOOK_ERROR () { 0x0001; } sub HOOK_AFTER_PARSE () { 0x0002; } sub HOOK_BEFORE_PRINT () { 0x0004; } sub useIO_EOF () { 0x0010; } +%EXPORT_TAGS = ( + CONSTANTS => [qw( + CSV_FLAGS_IS_QUOTED + CSV_FLAGS_IS_BINARY + CSV_FLAGS_ERROR_IN_FIELD + CSV_FLAGS_IS_MISSING + + CSV_TYPE_PV + CSV_TYPE_IV + CSV_TYPE_NV + )], +); +@EXPORT_OK = (qw(csv PV IV NV), @{$EXPORT_TAGS{CONSTANTS}}); + my $ERRORS = { # Generic errors 1000 => "INI - constructor failed", @@ -231,6 +253,7 @@ my $last_new_error = Text::CSV_PP->SetDiag(0); my $ebcdic = ord("A") == 0xC1; # Faster than $Config{'ebcdic'} +my @internal_kh; my $last_error; # NOT a method: is also used before bless @@ -1393,6 +1416,9 @@ or croak $last_new_error; defined $form and $csv->formula ($form); + $kh && !ref $kh && $kh =~ m/^(?:1|yes|true|internal|auto)$/i and + $kh = \@internal_kh; + return { csv => $csv, attr => { %attr }, @@ -1432,6 +1458,9 @@ } if ($c->{out} && !$c->{sink}) { + !$hdrs && ref $c->{'kh'} && $c->{'kh'} == \@internal_kh and + $hdrs = $c->{'kh'}; + if (ref $in eq "CODE") { my $hdr = 1; while (my $row = $in->($csv)) { @@ -1449,7 +1478,7 @@ } } } - elsif (ref $in->[0] eq "ARRAY") { # aoa + elsif (@{$in} == 0 or ref $in->[0] eq "ARRAY") { # aoa ref $hdrs and $csv->print ($fh, $hdrs); for (@{$in}) { $c->{cboi} and $c->{cboi}->($csv, $_); @@ -1460,7 +1489,7 @@ else { # aoh my @hdrs = ref $hdrs ? @{$hdrs} : keys %{$in->[0]}; defined $hdrs or $hdrs = "auto"; - ref $hdrs || $hdrs eq "auto" and + ref $hdrs || $hdrs eq "auto" and @hdrs and $csv->print ($fh, [ map { $hdr{$_} || $_ } @hdrs ]); for (@{$in}) { local %_; @@ -1478,7 +1507,7 @@ my @row1; if (defined $c->{hd_s} || defined $c->{hd_b} || defined $c->{hd_m} || defined $c->{hd_c}) { my %harg; - defined $c->{hd_s} and $harg{set_set} = $c->{hd_s}; + defined $c->{hd_s} and $harg{sep_set} = $c->{hd_s}; defined $c->{hd_d} and $harg{detect_bom} = $c->{hd_b}; defined $c->{hd_m} and $harg{munge_column_names} = $hdrs ? "none" : $c->{hd_m}; defined $c->{hd_c} and $harg{set_column_names} = $hdrs ? 0 : $c->{hd_c}; @@ -1488,6 +1517,7 @@ } if ($c->{kh}) { + @internal_kh = (); ref $c->{kh} eq "ARRAY" or croak ($csv->SetDiag (1501)); $hdrs ||= "auto"; } @@ -2155,7 +2185,9 @@ unless ($ctx->{useIO} & useIO_EOF) { $self->__parse_error($ctx, 2014, $ctx->{used}); } - $result = undef; + if ($last_error) { + $result = undef; + } } } @@ -3058,6 +3090,7 @@ $res = $self->_set_diag($ctx, $error); } else { + $last_error = $error; $res = $self->_sv_diag($error); } if (defined $errstr) { @@ -3363,7 +3396,7 @@ it you will need to also change the C<escape_char> to be the same as what you have changed the L<C<quote_char>|/quote_char> to. -Setting C<escape_char> to <undef> or C<""> will disable escaping completely +Setting C<escape_char> to C<undef> or C<""> will completely disable escapes and is greatly discouraged. This will also disable C<escape_null>. The escape character can not be equal to the separation character. @@ -3406,6 +3439,8 @@ =head3 formula_handling +Alias for L</formula> + =head3 formula my $csv = Text::CSV_PP->new ({ formula => "none" }); @@ -3719,7 +3754,7 @@ By default, all "unsafe" bytes inside a string cause the combined field to be quoted. By setting this attribute to C<0>, you can disable that trigger -for bytes >= C<0x7F>. +for bytes C<< >= 0x7F >>. =head3 escape_null @@ -4100,7 +4135,7 @@ =head2 fragment This function tries to implement RFC7111 (URI Fragment Identifiers for the -text/csv Media Type) - http://tools.ietf.org/html/rfc7111 +text/csv Media Type) - https://datatracker.ietf.org/doc/html/rfc7111 my $AoA = $csv->fragment ($fh, $spec); @@ -4183,7 +4218,7 @@ =back -L<RFC7111|http://tools.ietf.org/html/rfc7111> does B<not> allow different +L<RFC7111|https://datatracker.ietf.org/doc/html/rfc7111> does B<not> allow different types of specs to be combined (either C<row> I<or> C<col> I<or> C<cell>). Passing an invalid fragment specification will croak and set error 2013. @@ -4503,14 +4538,20 @@ =item IV +=item CSV_TYPE_IV + Set field type to integer. =item NV +=item CSV_TYPE_NV + Set field type to numeric/float. =item PV +=item CSV_TYPE_PV + Set field type to string. =back @@ -4539,14 +4580,32 @@ =over 2 -=item C< >0x0001 +=item C<0x0001> + +=item C<CSV_FLAGS_IS_QUOTED> The field was quoted. -=item C< >0x0002 +=item C<0x0002> + +=item C<CSV_FLAGS_IS_BINARY> The field was binary. +=item C<0x0004> + +=item C<CSV_FLAGS_ERROR_IN_FIELD> + +The field was invalid. + +Currently only used when C<allow_loose_quotes> is active. + +=item C<0x0010> + +=item C<CSV_FLAGS_IS_MISSING> + +The field was missing. + =back See the C<is_***> methods below. @@ -5111,6 +5170,19 @@ This attribute implies a default of C<auto> for the C<headers> attribute. +The headers can also be kept internally to keep stable header order: + + csv (in => csv (in => "file.csv", kh => "internal"), + out => "new.csv", + kh => "internal"); + +where C<internal> can also be C<1>, C<yes>, or C<true>. This is similar to + + my @h; + csv (in => csv (in => "file.csv", kh => \@h), + out => "new.csv", + headers => \@h); + =head3 fragment Only output the fragment as defined in the L</fragment> method. This option diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV-2.01/t/01_is_pp.t new/Text-CSV-2.02/t/01_is_pp.t --- old/Text-CSV-2.01/t/01_is_pp.t 2021-01-17 19:30:33.000000000 +0100 +++ new/Text-CSV-2.02/t/01_is_pp.t 2022-08-07 11:32:35.000000000 +0200 @@ -6,13 +6,17 @@ use Test::More tests => 4; BEGIN { - $ENV{PERL_TEXT_CSV} = 0; + $ENV{PERL_TEXT_CSV} = $ENV{TEST_PERL_TEXT_CSV} || 0; use_ok "Text::CSV"; plan skip_all => "Cannot load Text::CSV" if $@; } -{ +if (!$ENV{PERL_TEXT_CSV} or !eval { require Text::CSV_XS; 1 }) { ok my $csv = Text::CSV->new; ok $csv->is_pp; is $csv->module => 'Text::CSV_PP'; +} else { + ok my $csv = Text::CSV->new; + ok $csv->is_xs; + is $csv->module => 'Text::CSV_XS'; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV-2.01/t/12_acc.t new/Text-CSV-2.02/t/12_acc.t --- old/Text-CSV-2.01/t/12_acc.t 2021-06-19 05:35:18.000000000 +0200 +++ new/Text-CSV-2.02/t/12_acc.t 2022-08-07 21:51:04.000000000 +0200 @@ -11,6 +11,8 @@ plan skip_all => "Cannot load Text::CSV" if $@; } +my $Backend = Text::CSV->backend; + my $csv; ok ($csv = Text::CSV->new, "new ()"); @@ -238,7 +240,7 @@ # And test erroneous calls is (Text::CSV::new (0), undef, "new () as function"); -is (Text::CSV::error_diag (), "usage: my \$csv = Text::CSV_PP->new ([{ option => value, ... }]);", +is (Text::CSV::error_diag (), "usage: my \$csv = $Backend->new ([{ option => value, ... }]);", "Generic usage () message"); is (Text::CSV->new ({ oel => "" }), undef, "typo in attr"); is (Text::CSV::error_diag (), "INI - Unknown attribute 'oel'", "Unsupported attr"); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV-2.01/t/47_comment.t new/Text-CSV-2.02/t/47_comment.t --- old/Text-CSV-2.01/t/47_comment.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Text-CSV-2.02/t/47_comment.t 2022-08-07 21:51:04.000000000 +0200 @@ -0,0 +1,60 @@ +#!/usr/bin/perl + +use strict; +$^W = 1; + +use Test::More; +BEGIN { $ENV{PERL_TEXT_CSV} = $ENV{TEST_PERL_TEXT_CSV} || 0; } +use Text::CSV; + +BEGIN { + if ($] < 5.008002) { + plan skip_all => "These tests require Encode and Unicode support"; + } + else { + require Encode; + plan tests => 60; + } + require "./t/util.pl"; + } + +$| = 1; + +my $tfn = "_47cmnt.csv"; END { -f $tfn and unlink $tfn; } + +foreach my $cstr ("#", "//", "Comment", "\xe2\x98\x83") { + foreach my $rest ("", " 1,2", "a,b") { + + my $csv = Text::CSV->new ({ binary => 1 }); + $csv->comment_str ($cstr); + + my $fh; + open $fh, ">", $tfn or die "$tfn: $!\n"; + print $fh qq{$cstr$rest\n}; + print $fh qq{c,$cstr\n}; + print $fh qq{ $cstr\n}; + print $fh qq{e,$cstr,$rest\n}; + print $fh qq{$cstr\n}; + print $fh qq{g,i$cstr\n}; + print $fh qq{j,"k\n${cstr}k"\n}; + print $fh qq{$cstr\n}; + close $fh; + + open $fh, "<", $tfn or die "$tfn: $!\n"; + + my $cuni = Encode::decode ("utf-8", $cstr); + my @rest = split m/,/ => $rest, -1; @rest or push @rest => ""; + + is_deeply ($csv->getline ($fh), [ "c", $cuni ], "$cstr , $rest"); + is_deeply ($csv->getline ($fh), [ " $cuni" ], "leading space"); + is_deeply ($csv->getline ($fh), [ "e", $cuni, @rest ], "not start of line"); + is_deeply ($csv->getline ($fh), [ "g", "i$cuni" ], "not start of field"); + is_deeply ($csv->getline ($fh), [ "j", "k\n${cuni}k" ], "in quoted field after NL"); + + close $fh; + + unlink $tfn; + } + } + +1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV-2.01/t/51_utf8.t new/Text-CSV-2.02/t/51_utf8.t --- old/Text-CSV-2.01/t/51_utf8.t 2021-06-19 05:35:18.000000000 +0200 +++ new/Text-CSV-2.02/t/51_utf8.t 2022-08-07 22:18:09.000000000 +0200 @@ -222,7 +222,7 @@ is ($str, "I${H}${h}L\"${h}ve${h}${H}Perl", "Correct quotation"); } -# Tests pulled from tests in perl6 +# Tests pulled from tests in Raku { my $csv = Text::CSV->new ({ binary => 1, auto_diag => 1 }); my $h = pack "C*", 224, 34, 204, 182; ok ($csv->combine (1, $h, 3)); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV-2.01/t/71_pp.t new/Text-CSV-2.02/t/71_pp.t --- old/Text-CSV-2.01/t/71_pp.t 2021-01-17 19:30:33.000000000 +0100 +++ new/Text-CSV-2.02/t/71_pp.t 2022-08-07 11:32:35.000000000 +0200 @@ -8,7 +8,7 @@ use Test::More tests => 104; -BEGIN { $ENV{PERL_TEXT_CSV} = $ARGV[0] || 0; } +BEGIN { $ENV{PERL_TEXT_CSV} = $ENV{TEST_PERL_TEXT_CSV} || 0; } BEGIN { require_ok "Text::CSV"; @@ -303,7 +303,8 @@ } -{ # https://rt.cpan.org/Ticket/Display.html?id=83705 +SKIP: { # https://rt.cpan.org/Ticket/Display.html?id=83705 +skip "pp only for now", 3 unless Text::CSV->is_pp; my $csv = Text::CSV->new( { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV-2.01/t/79_callbacks.t new/Text-CSV-2.02/t/79_callbacks.t --- old/Text-CSV-2.01/t/79_callbacks.t 2021-06-19 05:35:18.000000000 +0200 +++ new/Text-CSV-2.02/t/79_callbacks.t 2022-08-07 22:18:09.000000000 +0200 @@ -3,7 +3,7 @@ use strict; $^W = 1; - use Test::More tests => 111; + use Test::More tests => 113; #use Test::More "no_plan"; BEGIN { @@ -160,7 +160,47 @@ open $fh, "<", $tfn or die "$tfn: $!\n"; $csv->callbacks (after_parse => sub { $_[1][0] eq 3 and return \"skip" }); -is_deeply ($csv->getline_all ($fh), [[1,"foo"],[2,"bar"],[4,"zoo"]]); +is_deeply ($csv->getline_all ($fh), [[1,"foo"],[2,"bar"],[4,"zoo"]], "skip"); +close $fh; + +open $fh, ">", $tfn or die "$tfn: $!\n"; +print $fh <<"EOC"; +1,foo +2,bar,fail +3,baz +4 +5,eox +EOC +close $fh; + +open $fh, "<", $tfn or die "$tfn: $!\n"; +my @rpt; +$csv = Text::CSV->new ({ strict => 1, auto_diag => 1 }); +$csv->callbacks (error => sub { + my ($err, $msg, $pos, $recno, $fldno) = @_; + if ($err == 2014) { + push @rpt => [ $recno, $fldno, $pos ]; + $csv->SetDiag (0); + } + }); +is_deeply ([ $csv->getline_all ($fh), @rpt ], + [[[ 1, "foo" ], [ 2, "bar", "fail" ], [ 3, "baz" ], [ 4 ], [ 5, "eox" ]], + [ 2, 3, 12 ], [ 4, 1, 3 ]], "Can catch strict 2014 with \$csv"); +close $fh; + +open $fh, "<", $tfn or die "$tfn: $!\n"; +@rpt = (); +$csv = Text::CSV->new ({ strict => 1, auto_diag => 1, callbacks => { + error => sub { + my ($err, $msg, $pos, $recno, $fldno) = @_; + if ($err == 2014) { + push @rpt => [ $recno, $fldno, $pos ]; + Text::CSV->SetDiag (0); + } + }}}); +is_deeply ([ $csv->getline_all ($fh), @rpt ], + [[[ 1, "foo" ], [ 2, "bar", "fail" ], [ 3, "baz" ], [ 4 ], [ 5, "eox" ]], + [ 2, 3, 12 ], [ 4, 1, 3 ]], "Can catch strict 2014 with class"); close $fh; __END__ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV-2.01/t/80_diag.t new/Text-CSV-2.02/t/80_diag.t --- old/Text-CSV-2.01/t/80_diag.t 2021-06-19 05:35:18.000000000 +0200 +++ new/Text-CSV-2.02/t/80_diag.t 2022-08-07 21:51:04.000000000 +0200 @@ -65,7 +65,7 @@ local $SIG{__WARN__} = sub { push @warn, @_ }; $csv->error_diag (); ok (@warn == 1, "Got error message"); - like ($warn[0], qr{^# CSV_PP ERROR: 2037 - EIF}, "error content"); + like ($warn[0], qr{^# CSV_(?:PP|XS) ERROR: 2037 - EIF}, "error content"); } is ($csv->eof, "", "No EOF"); @@ -78,13 +78,13 @@ local $SIG{__WARN__} = sub { push @warn, @_ }; Text::CSV::error_diag (); ok (@warn == 1, "Error_diag in void context ::"); - like ($warn[0], qr{^# CSV_PP ERROR: 1000 - INI}, "error content"); + like ($warn[0], qr{^# CSV_(?:PP|XS) ERROR: 1000 - INI}, "error content"); } { my @warn; local $SIG{__WARN__} = sub { push @warn, @_ }; Text::CSV->error_diag (); ok (@warn == 1, "Error_diag in void context ->"); - like ($warn[0], qr{^# CSV_PP ERROR: 1000 - INI}, "error content"); + like ($warn[0], qr{^# CSV_(?:PP|XS) ERROR: 1000 - INI}, "error content"); } { my @warn; @@ -98,7 +98,7 @@ is (Text::CSV->new ({ auto_diag => 1, ecs_char => ":" }), undef, "Unsupported option"); ok (@warn == 1, "Error_diag in from new ({ auto_diag => 1})"); - like ($warn[0], qr{^# CSV_PP ERROR: 1000 - INI}, "error content"); + like ($warn[0], qr{^# CSV_(?:PP|XS) ERROR: 1000 - INI}, "error content"); } is (Text::CSV::error_diag (), "INI - Unknown attribute 'ecs_char'", @@ -121,7 +121,7 @@ is ($csv->{_RECNO}, 0, "No records read yet"); is ($csv->parse ('"","'), 0, "1 - bad parse"); ok (@warn == 1, "1 - One error"); - like ($warn[0], qr '^# CSV_PP ERROR: 2027 -', "1 - error message"); + like ($warn[0], qr '^# CSV_(?:PP|XS) ERROR: 2027 -', "1 - error message"); is ($csv->{_RECNO}, 1, "One record read"); } { my @warn; @@ -131,14 +131,14 @@ ok (@warn == 1, "1 - One error"); @warn = split m/\n/ => $warn[0]; ok (@warn == 3, "1 - error plus two lines"); - like ($warn[0], qr '^# CSV_PP ERROR: 2027 -', "1 - error message"); + like ($warn[0], qr '^# CSV_(?:PP|XS) ERROR: 2027 -', "1 - error message"); like ($warn[1], qr '^"","', "1 - input line"); like ($warn[2], qr '^ \^', "1 - position indicator"); is ($csv->{_RECNO}, 2, "Another record read"); } { ok ($csv->{auto_diag} = 2, "auto_diag = 2 to die"); eval { $csv->parse ('"","') }; - like ($@, qr '^# CSV_PP ERROR: 2027 -', "2 - error message"); + like ($@, qr '^# CSV_(?:PP|XS) ERROR: 2027 -', "2 - error message"); } { my @warn; @@ -385,7 +385,7 @@ 1; }; is_deeply (\@row, [[qw(foo bar baz)],[qw(a xxx 1)]], "2 valid rows"); - like ($@, qr '^# CSV_PP ERROR: 2023 -', "3rd row dies error 2023"); + like ($@, qr '^# CSV_(?:PP|XS) ERROR: 2023 -', "3rd row dies error 2023"); } } else { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV-2.01/t/81_subclass.t new/Text-CSV-2.02/t/81_subclass.t --- old/Text-CSV-2.01/t/81_subclass.t 2021-06-19 05:23:28.000000000 +0200 +++ new/Text-CSV-2.02/t/81_subclass.t 2022-08-07 21:51:04.000000000 +0200 @@ -3,7 +3,7 @@ package Text::CSV::Subclass; BEGIN { - $ENV{PERL_TEXT_CSV} = 0; + $ENV{PERL_TEXT_CSV} = $ENV{TEST_PERL_TEXT_CSV} || 0; } BEGIN { require Text::CSV; } # needed for perl5.005 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV-2.01/t/90_csv.t new/Text-CSV-2.02/t/90_csv.t --- old/Text-CSV-2.01/t/90_csv.t 2021-06-19 05:35:18.000000000 +0200 +++ new/Text-CSV-2.02/t/90_csv.t 2022-08-07 22:18:09.000000000 +0200 @@ -5,7 +5,7 @@ use Config; #use Test::More "no_plan"; - use Test::More tests => 115; + use Test::More tests => 128; BEGIN { $ENV{PERL_TEXT_CSV} = $ENV{TEST_PERL_TEXT_CSV} || 0; @@ -71,9 +71,14 @@ ok (my $ref = csv (in => $tfn, $alias => \@hdr), "csv ($alias => ... -- implied headers)"); is_deeply (\@hdr, [qw( foo bar baz )], "Headers kept for $alias"); } + foreach my $alias (qw( internal true yes 1 )) { + ok (my $ref = csv (in => $tfn, kh => $alias), "csv (kh => $alias)"); + ok (csv (in => $ref, out => \my $buf, kh => $alias, quote_space => 0, eol => "\n"), "get it back"); + is ($buf, $data, "Headers kept for $alias"); + } } else { - ok (1, q{This perl cannot do scalar IO}) for 1..14; + ok (1, q{This perl cannot do scalar IO}) for 1..26; } if ($] >= 5.008001) { @@ -239,7 +244,7 @@ local $SIG{__DIE__} = sub { $err = shift; }; local $SIG{__WARN__} = sub { $err = shift; }; - foreach my $hr (1, "foo", \my %hr, sub { 42; }, *STDOUT) { + foreach my $hr (42, "foo", \my %hr, sub { 42; }, *STDOUT) { $r = eval { csv (in => $tfn, kh => $hr, auto_diag => 0); }; $err =~ s{\s+at\s+\S+\s+line\s+\d+\.\r?\n?\Z}{}; is ($r, undef, "Fail call with bad keep_header type"); @@ -362,6 +367,12 @@ is ($dta, qq{1,2\n}, "out to \\*STDOUT"); unlink $ofn; + open STDOUT, ">", $ofn; + csv (in => []); + close STDOUT; + is (-s $ofn, 0, "No data results in an empty file"); + unlink $ofn; + SKIP: { $] <= 5.008 and skip qq{$] does not support ScalarIO}, 6; my $aoa = [[ 1, 2 ]]; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV-2.01/t/csv_method.t new/Text-CSV-2.02/t/csv_method.t --- old/Text-CSV-2.01/t/csv_method.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Text-CSV-2.02/t/csv_method.t 2022-08-07 22:15:22.000000000 +0200 @@ -0,0 +1,35 @@ +use strict; +use warnings; +use File::Spec; +use Test::More tests => 5; + +BEGIN { + $ENV{PERL_TEXT_CSV} = $ENV{TEST_PERL_TEXT_CSV} || 0; + require_ok "Text::CSV"; + plan skip_all => "Cannot load Text::CSV" if $@; + } + +{ + my $file = prepare('1,2,3'); + my $csv = Text::CSV->new (); + ok my $aoa = eval { $csv->csv (in => $file) }; + is_deeply($aoa, [[1,2,3]]) or note explain $aoa; + unlink $file; +} + +{ + my $file = prepare('col1;col2;col3','1;2;3'); + my $csv = Text::CSV->new ({ sep_char => ";" }); + ok my $aoh = eval { $csv->csv (in => $file, bom => 1) }; + is_deeply($aoh, [{col1 => 1, col2 => 2, col3 => 3}]) or note explain $aoh; + unlink $file; +} + +sub prepare { + my @lines = @_; + my $file = File::Spec->catfile(File::Spec->tmpdir, "file.csv"); + open my $fh, '>', $file; + print $fh "$_\n" for @lines; + close $fh; + $file; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV-2.01/t/rt99774.t new/Text-CSV-2.02/t/rt99774.t --- old/Text-CSV-2.01/t/rt99774.t 2021-01-17 19:30:33.000000000 +0100 +++ new/Text-CSV-2.02/t/rt99774.t 2022-08-07 11:32:35.000000000 +0200 @@ -6,7 +6,7 @@ BEGIN { - $ENV{PERL_TEXT_CSV} = 0; + $ENV{PERL_TEXT_CSV} = $ENV{TEST_PERL_TEXT_CSV} || 0; require_ok "Text::CSV"; plan skip_all => "Cannot load Text::CSV" if $@; require "./t/util.pl"; @@ -28,7 +28,7 @@ # https://rt.cpan.org/Public/Bug/Display.html?id=92509 for my $allow_whitespace ( 0, 1 ) { - $csv = Text::CSV_PP->new ( { allow_whitespace => $allow_whitespace } ); + $csv = Text::CSV->new ( { allow_whitespace => $allow_whitespace } ); $csv->parse(q{"value1","0","value3"}); is_deeply( [$csv->fields], ["value1","0","value3"], 'allow_whitespace:' . $allow_whitespace ); }
