Hello community, here is the log from the commit of package perl-Text-CSV_XS for openSUSE:Factory checked in at 2018-03-24 16:09:37 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Text-CSV_XS (Old) and /work/SRC/openSUSE:Factory/.perl-Text-CSV_XS.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Text-CSV_XS" Sat Mar 24 16:09:37 2018 rev:36 rq:590307 version:1.35 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Text-CSV_XS/perl-Text-CSV_XS.changes 2017-12-15 14:01:15.816554964 +0100 +++ /work/SRC/openSUSE:Factory/.perl-Text-CSV_XS.new/perl-Text-CSV_XS.changes 2018-03-24 16:09:39.363878028 +0100 @@ -1,0 +2,17 @@ +Thu Mar 22 10:32:57 UTC 2018 - [email protected] + +- updated to 1.35 + see /usr/share/doc/packages/perl-Text-CSV_XS/ChangeLog + + 1.35 - 2018-03-21, H.Merijn Brand + * Remove META.yml from MANIFEST.skip + * Use UNIVERSAL::isa to protect against unblessed references + * -Wformat warning (RT#123729) + * Make detect_bom result available + * It's 2018 + * Add csv (out => \"skip") - suppress output deliberately + * Allow sub as top-level filter + * Tested against Test2::Harness-0.001062 (yath test) + * Tested against perl-5.27.10 + +------------------------------------------------------------------- Old: ---- Text-CSV_XS-1.34.tgz New: ---- Text-CSV_XS-1.35.tgz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Text-CSV_XS.spec ++++++ --- /var/tmp/diff_new_pack.hsPcP9/_old 2018-03-24 16:09:40.555835059 +0100 +++ /var/tmp/diff_new_pack.hsPcP9/_new 2018-03-24 16:09:40.559834915 +0100 @@ -1,7 +1,7 @@ # # spec file for package perl-Text-CSV_XS # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: perl-Text-CSV_XS -Version: 1.34 +Version: 1.35 Release: 0 %define cpan_name Text-CSV_XS Summary: Comma-Separated Values Manipulation Routines ++++++ Text-CSV_XS-1.34.tgz -> Text-CSV_XS-1.35.tgz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-1.34/CSV_XS.pm new/Text-CSV_XS-1.35/CSV_XS.pm --- old/Text-CSV_XS-1.34/CSV_XS.pm 2017-11-05 19:47:38.000000000 +0100 +++ new/Text-CSV_XS-1.35/CSV_XS.pm 2018-02-28 10:26:41.000000000 +0100 @@ -1,6 +1,6 @@ package Text::CSV_XS; -# Copyright (c) 2007-2017 H.Merijn Brand. All rights reserved. +# Copyright (c) 2007-2018 H.Merijn Brand. All rights reserved. # Copyright (c) 1998-2001 Jochen Wiedmann. All rights reserved. # Copyright (c) 1997 Alan Citterman. All rights reserved. # @@ -26,7 +26,7 @@ use Carp; use vars qw( $VERSION @ISA @EXPORT_OK ); -$VERSION = "1.34"; +$VERSION = "1.35"; @ISA = qw( DynaLoader Exporter ); @EXPORT_OK = qw( csv ); bootstrap Text::CSV_XS $VERSION; @@ -91,6 +91,8 @@ _COLUMN_NAMES => undef, _BOUND_COLUMNS => undef, _AHEAD => undef, + + ENCODING => undef, ); my %attr_alias = ( quote_always => "always_quote", @@ -609,8 +611,10 @@ my $self = shift; my @diag = (0 + $last_new_err, $last_new_err, 0, 0, 0); + # Docs state to NEVER use UNIVERSAL::isa, because it will *never* call an + # overridden isa method in any class. Well, that is exacly what I want here if ($self && ref $self && # Not a class method or direct call - $self->isa (__PACKAGE__) && exists $self->{_ERROR_DIAG}) { + UNIVERSAL::isa ($self, __PACKAGE__) && exists $self->{_ERROR_DIAG}) { $diag[0] = 0 + $self->{_ERROR_DIAG}; $diag[1] = $self->{_ERROR_DIAG}; $diag[2] = 1 + $self->{_ERROR_POS} if exists $self->{_ERROR_POS}; @@ -857,6 +861,8 @@ elsif ($hdr =~ s/^\x84\x31\x95\x33//) { $enc = "gb-18030" } elsif ($hdr =~ s/^\x{feff}//) { $enc = "" } + $self->{ENCODING} = uc $enc; + $hdr eq "" and croak ($self->SetDiag (1010)); if ($enc) { @@ -1079,9 +1085,11 @@ $enc =~ m/^[-\w.]+$/ and $enc = ":encoding($enc)"; my $fh; - my $cls = 0; # If I open a file, I have to close it - my $in = delete $attr{in} || delete $attr{file} or croak $csv_usage; - my $out = delete $attr{out} || delete $attr{file}; + my $sink = 0; + my $cls = 0; # If I open a file, I have to close it + my $in = delete $attr{in} || delete $attr{file} or croak $csv_usage; + my $out = exists $attr{out} && !$attr{out} ? \"skip" + : delete $attr{out} || delete $attr{file}; ref $in eq "CODE" || ref $in eq "ARRAY" and $out ||= \*STDOUT; @@ -1090,17 +1098,23 @@ qq{ csv (in => csv (in => "$in"), out => "$out");\n}; if ($out) { - if ((ref $out and ref $out ne "SCALAR") or "GLOB" eq ref \$out) { + if ((ref $out and "SCALAR" ne ref $out) or "GLOB" eq ref \$out) { $fh = $out; } + elsif (ref $out and "SCALAR" eq ref $out and defined $$out and $$out eq "skip") { + delete $attr{out}; + $sink = 1; + } else { open $fh, ">", $out or croak "$out: $!"; $cls = 1; } - $enc and binmode $fh, $enc; - unless (defined $attr{eol}) { - my @layers = eval { PerlIO::get_layers ($fh) }; - $attr{eol} = (grep m/crlf/ => @layers) ? "\n" : "\r\n"; + if ($fh) { + $enc and binmode $fh, $enc; + unless (defined $attr{eol}) { + my @layers = eval { PerlIO::get_layers ($fh) }; + $attr{eol} = (grep m/crlf/ => @layers) ? "\n" : "\r\n"; + } } } @@ -1125,7 +1139,7 @@ open $fh, "<$enc", $in or croak "$in: $!"; $cls = 1; } - $fh or croak qq{No valid source passed. "in" is required}; + $fh || $sink or croak qq{No valid source passed. "in" is required}; my $hdrs = delete $attr{headers}; my $frag = delete $attr{fragment}; @@ -1167,7 +1181,8 @@ ); defined $fltr && !ref $fltr && exists $fltr{$fltr} and $fltr = { 0 => $fltr{$fltr} }; - ref $fltr eq "HASH" or $fltr = undef; + ref $fltr eq "CODE" and $fltr = { 0 => $fltr }; + ref $fltr eq "HASH" or $fltr = undef; exists $attr{formula} and $attr{formula} = _supported_formula (undef, $attr{formula}); @@ -1183,6 +1198,7 @@ fh => $fh, cls => $cls, in => $in, + sink => $sink, out => $out, enc => $enc, hdrs => $hdrs, @@ -1213,7 +1229,7 @@ $hdrs = "auto"; } - if ($c->{out}) { + if ($c->{out} && !$c->{sink}) { if (ref $in eq "CODE") { my $hdr = 1; while (my $row = $in->($csv)) { @@ -1358,6 +1374,8 @@ } } + $c->{sink} and return; + defined wantarray or return csv (%{$c->{attr}}, in => $ref, headers => $hdrs, %{$c->{attr}}); @@ -2633,10 +2651,17 @@ UTF-32LE. BOM's also support UTF-1, UTF-EBCDIC, SCSU, BOCU-1, and GB-18030 but L<Encode> does not (yet). UTF-7 is not supported. -The encoding is set using C<binmode> on C<$fh>. +If a supported BOM was detected as start of the stream, it is stored in the +abject attribute C<ENCODING>. + + my $enc = $csv->{ENCODING}; + +The encoding is used with C<binmode> on C<$fh>. If the handle was opened in a (correct) encoding, this method will B<not> -alter the encoding, as it checks the leading B<bytes> of the first line. +alter the encoding, as it checks the leading B<bytes> of the first line. In +case the stream starts with a decode BOM (C<U+FEFF>), C<{ENCODING}> will be +C<""> (empty) instead of the default C<undef>. =item munge_column_names X<munge_column_names> @@ -3072,6 +3097,8 @@ csv (in => $aoa, out => *STDOUT); csv (in => $aoa, out => \*STDOUT); csv (in => $aoa, out => \my $data); + csv (in => $aoa, out => undef); + csv (in => $aoa, out => \"skip"); In output mode, the default CSV options when producing CSV are @@ -3093,6 +3120,18 @@ on the number of records. The C<csv> function ends when the coderef returns a false value. +If C<out> is set to a reference of the literal string C<"skip">, the output +will be suppressed completely, which might be useful in combination with a +filter for side effects only. + + my %cache; + csv (in => "dump.csv", + out => \"skip", + on_in => sub { $cache{$_[1][1]}++ }); + +Currently, setting C<out> to any false value (C<undef>, C<"">, 0) will be +equivalent to C<\"skip">. + =head3 encoding X<encoding> @@ -3495,26 +3534,27 @@ X<filter> This callback can be used to filter records. It is called just after a new -record has been scanned. The callback accepts a hashref where the keys are -the index to the row (the field number, 1-based) and the values are subs to -return a true or false value. +record has been scanned. The callback accepts a: + +=over 2 + +=item hashref + +The keys are the index to the row (the field name or field number, 1-based) +and the values are subs to return a true or false value. csv (in => "file.csv", filter => { 3 => sub { m/a/ }, # third field should contain an "a" 5 => sub { length > 4 }, # length of the 5th field minimal 5 }); - csv (in => "file.csv", filter => "not_blank"); - csv (in => "file.csv", filter => "not_empty"); - csv (in => "file.csv", filter => "filled"); + csv (in => "file.csv", filter => { foo => sub { $_ > 4 }}); If the keys to the filter hash contain any character that is not a digit it will also implicitly set L</headers> to C<"auto"> unless L</headers> was already passed as argument. When headers are active, returning an array of hashes, the filter is not applicable to the header itself. - csv (in => "file.csv", filter => { foo => sub { $_ > 4 }}); - All sub results should match, as in AND. The context of the callback sets C<$_> localized to the field indicated by @@ -3538,7 +3578,26 @@ filter => { 2 => sub { $_ = uc; 1 }} -B<Predefined filters> +=item coderef + + csv (in => "file.csv", filter => sub { $n++; 0; }); + +If the argument to C<filter> is a coderef, it is an alias or shortcut to a +filter on column 0: + + csv (filter => sub { $n++; 0 }); + +is equal to + + csv (filter => { 0 => sub { $n++; 0 }); + +=item filter-name + + csv (in => "file.csv", filter => "not_blank"); + csv (in => "file.csv", filter => "not_empty"); + csv (in => "file.csv", filter => "filled"); + +These are predefined filters Given a file like (line numbers prefixed for doc purpose only): @@ -3595,6 +3654,8 @@ =back +=back + =item after_in X<after_in> @@ -4423,7 +4484,7 @@ =head1 COPYRIGHT AND LICENSE - Copyright (C) 2007-2017 H.Merijn Brand. All rights reserved. + Copyright (C) 2007-2018 H.Merijn Brand. All rights reserved. Copyright (C) 1998-2001 Jochen Wiedmann. All rights reserved. Copyright (C) 1997 Alan Citterman. All rights reserved. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-1.34/CSV_XS.xs new/Text-CSV_XS-1.35/CSV_XS.xs --- old/Text-CSV_XS-1.34/CSV_XS.xs 2017-10-19 19:38:46.000000000 +0200 +++ new/Text-CSV_XS-1.35/CSV_XS.xs 2018-01-14 12:38:59.000000000 +0100 @@ -1,4 +1,4 @@ -/* Copyright (c) 2007-2017 H.Merijn Brand. All rights reserved. +/* Copyright (c) 2007-2018 H.Merijn Brand. All rights reserved. * Copyright (c) 1998-2001 Jochen Wiedmann. All rights reserved. * This program is free software; you can redistribute it and/or * modify it under the same terms as Perl itself. @@ -367,6 +367,7 @@ csv_t *csv = &csvs; IV iv; + byte bv; char *cp = "\0"; STRLEN len = 0; @@ -384,6 +385,7 @@ iv = (IV)SvNV (val); /* uncoverable statement ancient perl required */ else iv = *cp; + bv = (unsigned)iv & 0xff; switch (idx) { @@ -401,28 +403,28 @@ case CACHE_ID_escape_char: csv->escape_char = *cp; break; /* boolean/numeric */ - case CACHE_ID_binary: csv->binary = iv; break; - case CACHE_ID_keep_meta_info: csv->keep_meta_info = iv; break; - case CACHE_ID_always_quote: csv->always_quote = iv; break; - case CACHE_ID_quote_empty: csv->quote_empty = iv; break; - case CACHE_ID_quote_space: csv->quote_space = iv; break; - case CACHE_ID_escape_null: csv->escape_null = iv; break; - case CACHE_ID_quote_binary: csv->quote_binary = iv; break; - case CACHE_ID_decode_utf8: csv->decode_utf8 = iv; break; - case CACHE_ID_allow_loose_escapes: csv->allow_loose_escapes = iv; break; - case CACHE_ID_allow_loose_quotes: csv->allow_loose_quotes = iv; break; - case CACHE_ID_allow_unquoted_escape: csv->allow_unquoted_escape = iv; break; - case CACHE_ID_allow_whitespace: csv->allow_whitespace = iv; break; - case CACHE_ID_blank_is_undef: csv->blank_is_undef = iv; break; - case CACHE_ID_empty_is_undef: csv->empty_is_undef = iv; break; - case CACHE_ID_formula: csv->formula = iv; break; - case CACHE_ID_strict: csv->strict = iv; break; - case CACHE_ID_verbatim: csv->verbatim = iv; break; - case CACHE_ID_auto_diag: csv->auto_diag = iv; break; - case CACHE_ID_diag_verbose: csv->diag_verbose = iv; break; - case CACHE_ID__has_ahead: csv->has_ahead = iv; break; - case CACHE_ID__has_hooks: csv->has_hooks = iv; break; - case CACHE_ID_has_error_input: csv->has_error_input = iv; break; + case CACHE_ID_binary: csv->binary = bv; break; + case CACHE_ID_keep_meta_info: csv->keep_meta_info = bv; break; + case CACHE_ID_always_quote: csv->always_quote = bv; break; + case CACHE_ID_quote_empty: csv->quote_empty = bv; break; + case CACHE_ID_quote_space: csv->quote_space = bv; break; + case CACHE_ID_escape_null: csv->escape_null = bv; break; + case CACHE_ID_quote_binary: csv->quote_binary = bv; break; + case CACHE_ID_decode_utf8: csv->decode_utf8 = bv; break; + case CACHE_ID_allow_loose_escapes: csv->allow_loose_escapes = bv; break; + case CACHE_ID_allow_loose_quotes: csv->allow_loose_quotes = bv; break; + case CACHE_ID_allow_unquoted_escape: csv->allow_unquoted_escape = bv; break; + case CACHE_ID_allow_whitespace: csv->allow_whitespace = bv; break; + case CACHE_ID_blank_is_undef: csv->blank_is_undef = bv; break; + case CACHE_ID_empty_is_undef: csv->empty_is_undef = bv; break; + case CACHE_ID_formula: csv->formula = bv; break; + case CACHE_ID_strict: csv->strict = bv; break; + case CACHE_ID_verbatim: csv->verbatim = bv; break; + case CACHE_ID_auto_diag: csv->auto_diag = bv; break; + case CACHE_ID_diag_verbose: csv->diag_verbose = bv; break; + case CACHE_ID__has_ahead: csv->has_ahead = bv; break; + case CACHE_ID__has_hooks: csv->has_hooks = bv; break; + case CACHE_ID_has_error_input: csv->has_error_input = bv; break; /* a 4-byte IV */ case CACHE_ID__is_bound: csv->is_bound = iv; break; @@ -724,7 +726,7 @@ } #define bound_field(csv,i,keep) cx_bound_field (aTHX_ csv, i, keep) -static SV *cx_bound_field (pTHX_ csv_t *csv, int i, int keep) { +static SV *cx_bound_field (pTHX_ csv_t *csv, SSize_t i, int keep) { SV *sv = csv->bound; AV *av; @@ -776,7 +778,7 @@ char field[128]; SV **svp; - if (csv->recno) sprintf (rec, " in record %d", csv->recno + 1); + if (csv->recno) sprintf (rec, " in record %lu", csv->recno + 1); else *rec = (char)0; *field = (char)0; @@ -961,7 +963,7 @@ } /* Combine */ #define ParseError(csv,xse,pos) cx_ParseError (aTHX_ csv, xse, pos) -static void cx_ParseError (pTHX_ csv_t *csv, int xse, int pos) { +static void cx_ParseError (pTHX_ csv_t *csv, int xse, STRLEN pos) { (void)hv_store (csv->self, "_ERROR_POS", 10, newSViv (pos), 0); (void)hv_store (csv->self, "_ERROR_FLD", 10, newSViv (csv->fld_idx), 0); if (csv->tmp) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-1.34/ChangeLog new/Text-CSV_XS-1.35/ChangeLog --- old/Text-CSV_XS-1.34/ChangeLog 2017-11-05 19:48:03.000000000 +0100 +++ new/Text-CSV_XS-1.35/ChangeLog 2018-03-21 12:24:13.000000000 +0100 @@ -1,3 +1,14 @@ +1.35 - 2018-03-21, H.Merijn Brand + * Remove META.yml from MANIFEST.skip + * Use UNIVERSAL::isa to protect against unblessed references + * -Wformat warning (RT#123729) + * Make detect_bom result available + * It's 2018 + * Add csv (out => \"skip") - suppress output deliberately + * Allow sub as top-level filter + * Tested against Test2::Harness-0.001062 (yath test) + * Tested against perl-5.27.10 + 1.34 - 2017-11-05, H.Merijn Brand * Bad arg for formula (like "craok") will now die with error 1500 * Row report in formula reporting was off by 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-1.34/META.json new/Text-CSV_XS-1.35/META.json --- old/Text-CSV_XS-1.34/META.json 2017-11-05 19:49:34.000000000 +0100 +++ new/Text-CSV_XS-1.35/META.json 2018-03-21 15:00:16.000000000 +0100 @@ -1,42 +1,24 @@ { - "provides" : { - "Text::CSV_XS" : { - "file" : "CSV_XS.pm", - "version" : "1.34" - } - }, - "resources" : { - "x_IRC" : "irc://irc.perl.org/#csv", - "license" : [ - "http://dev.perl.org/licenses/" - ], - "repository" : { - "type" : "git", - "url" : "https://github.com/Tux/Text-CSV_XS", - "web" : "https://github.com/Tux/Text-CSV_XS" - }, - "homepage" : "https://metacpan.org/pod/Text::CSV_XS" - }, "prereqs" : { "test" : { "requires" : { - "Tie::Scalar" : "0", - "Test::More" : "0" + "Test::More" : "0", + "Tie::Scalar" : "0" } }, - "runtime" : { - "recommends" : { - "Encode" : "2.93" - }, + "configure" : { "requires" : { - "IO::Handle" : "0", - "DynaLoader" : "0", - "perl" : "5.006001" + "ExtUtils::MakeMaker" : "0" } }, - "configure" : { + "runtime" : { "requires" : { - "ExtUtils::MakeMaker" : "0" + "perl" : "5.006001", + "IO::Handle" : "0", + "DynaLoader" : "0" + }, + "recommends" : { + "Encode" : "2.97" } }, "build" : { @@ -45,20 +27,38 @@ } } }, - "version" : "1.34", - "abstract" : "Comma-Separated Values manipulation routines", + "provides" : { + "Text::CSV_XS" : { + "version" : "1.35", + "file" : "CSV_XS.pm" + } + }, "name" : "Text-CSV_XS", "generated_by" : "Author", - "meta-spec" : { - "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", - "version" : 2 - }, + "version" : "1.35", + "abstract" : "Comma-Separated Values manipulation routines", + "license" : [ + "perl_5" + ], "release_status" : "stable", + "resources" : { + "repository" : { + "url" : "https://github.com/Tux/Text-CSV_XS", + "web" : "https://github.com/Tux/Text-CSV_XS", + "type" : "git" + }, + "license" : [ + "http://dev.perl.org/licenses/" + ], + "homepage" : "https://metacpan.org/pod/Text::CSV_XS", + "x_IRC" : "irc://irc.perl.org/#csv" + }, + "dynamic_config" : 1, "author" : [ "H.Merijn Brand <[email protected]>" ], - "license" : [ - "perl_5" - ], - "dynamic_config" : 1 + "meta-spec" : { + "version" : 2, + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec" + } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-1.34/META.yml new/Text-CSV_XS-1.35/META.yml --- old/Text-CSV_XS-1.34/META.yml 2017-11-05 19:49:34.000000000 +0100 +++ new/Text-CSV_XS-1.35/META.yml 2018-03-21 15:00:16.000000000 +0100 @@ -16,9 +16,9 @@ provides: Text::CSV_XS: file: CSV_XS.pm - version: '1.34' + version: '1.35' recommends: - Encode: '2.93' + Encode: '2.97' requires: DynaLoader: 0 IO::Handle: 0 @@ -30,4 +30,4 @@ homepage: https://metacpan.org/pod/Text::CSV_XS license: http://dev.perl.org/licenses/ repository: https://github.com/Tux/Text-CSV_XS -version: '1.34' +version: '1.35' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-1.34/Makefile.PL new/Text-CSV_XS-1.35/Makefile.PL --- old/Text-CSV_XS-1.34/Makefile.PL 2017-10-19 16:22:21.000000000 +0200 +++ new/Text-CSV_XS-1.35/Makefile.PL 2018-01-01 14:58:27.000000000 +0100 @@ -1,6 +1,6 @@ #!/usr/bin/perl -# Copyright PROCURA B.V. (c) 2006-2017 H.Merijn Brand +# Copyright PROCURA B.V. (c) 2006-2018 H.Merijn Brand require 5.006001; # <- also see postamble at the bottom for META.yml use strict; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-1.34/README new/Text-CSV_XS-1.35/README --- old/Text-CSV_XS-1.34/README 2017-10-19 16:22:21.000000000 +0200 +++ new/Text-CSV_XS-1.35/README 2018-01-01 14:58:30.000000000 +0100 @@ -7,7 +7,7 @@ combine fields into a CSV string and parse a CSV string into fields. Copying: - Copyright (c) 2007-2017 H.Merijn Brand. All rights reserved. + Copyright (c) 2007-2018 H.Merijn Brand. All rights reserved. Copyright (c) 1998-2001 Jochen Wiedmann. All rights reserved. Portions Copyright (c) 1997 Alan Citterman. All rights reserved. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-1.34/examples/csv-check new/Text-CSV_XS-1.35/examples/csv-check --- old/Text-CSV_XS-1.34/examples/csv-check 2017-10-18 09:40:00.000000000 +0200 +++ new/Text-CSV_XS-1.35/examples/csv-check 2018-01-01 14:57:36.000000000 +0100 @@ -1,7 +1,7 @@ #!/pro/bin/perl # csv-check: Check validity of CSV file and report -# (m)'17 [18 Oct 2017] Copyright H.M.Brand 2007-2017 +# (m)'17 [24 Nov 2017] Copyright H.M.Brand 2007-2018 # This code requires the defined-or feature and PerlIO @@ -11,7 +11,7 @@ use Data::Peek; use Encode qw( decode ); -our $VERSION = "2.0"; # 2017-10-18 +our $VERSION = "2.01"; # 2017-11-24 my $cmd = $0; $cmd =~ s{.*/}{}; sub usage { @@ -100,7 +100,7 @@ }); sub done { - (my $file = $ARGV // "") =~ s{(\S)$}{$1 }; + my $file = $ARGV // "STDIN"; (my $pv = "$]0000000") =~ s{^([0-9]+)\.([0-9]{3})([0-9]{3})[0-9]*} {sprintf "%d.%d.%d",$1,$2,$3}e; my $uv = eval { @@ -118,6 +118,7 @@ $eol //= $csv->eol || "--unknown--"; print "OK: rows: $rows, columns: $cols\n"; print " sep = <$sep>, quo = <$quo>, bin = <$bin>, eol = <$eol>\n"; + print " encoding = $csv->{ENCODING}\n" if $csv->{ENCODING}; if (@coll > 1) { print "multiple column lengths:\n"; printf " %6d line%s with %4d field%s\n", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-1.34/examples/csv2xls new/Text-CSV_XS-1.35/examples/csv2xls --- old/Text-CSV_XS-1.34/examples/csv2xls 2017-10-18 08:57:22.000000000 +0200 +++ new/Text-CSV_XS-1.35/examples/csv2xls 2018-01-01 14:57:46.000000000 +0100 @@ -1,7 +1,7 @@ #!/pro/bin/perl # csv2xls: Convert csv to xls -# (m)'17 [18 Oct 2017] Copyright H.M.Brand 2007-2017 +# (m)'17 [18 Oct 2017] Copyright H.M.Brand 2007-2018 use 5.12.0; use warnings; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-1.34/examples/csv2xlsx new/Text-CSV_XS-1.35/examples/csv2xlsx --- old/Text-CSV_XS-1.34/examples/csv2xlsx 2017-10-20 14:26:23.000000000 +0200 +++ new/Text-CSV_XS-1.35/examples/csv2xlsx 2018-01-01 14:57:50.000000000 +0100 @@ -1,7 +1,7 @@ #!/pro/bin/perl # csv2xlsx: Convert csv to xlsx -# (m)'17 [20 Oct 2017] Copyright H.M.Brand 2007-2017 +# (m)'17 [20 Oct 2017] Copyright H.M.Brand 2007-2018 use 5.14.0; use warnings; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-1.34/examples/parser-xs.pl new/Text-CSV_XS-1.35/examples/parser-xs.pl --- old/Text-CSV_XS-1.34/examples/parser-xs.pl 2017-01-29 16:16:23.000000000 +0100 +++ new/Text-CSV_XS-1.35/examples/parser-xs.pl 2018-01-01 14:57:04.000000000 +0100 @@ -3,7 +3,7 @@ # This script can be used as a base to parse unreliable CSV streams # Modify to your own needs # -# (m)'08 [23 Apr 2008] Copyright H.M.Brand 2008-2017 +# (m)'08 [23 Apr 2008] Copyright H.M.Brand 2008-2018 use strict; use warnings; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-1.34/examples/speed.pl new/Text-CSV_XS-1.35/examples/speed.pl --- old/Text-CSV_XS-1.34/examples/speed.pl 2017-01-29 16:16:23.000000000 +0100 +++ new/Text-CSV_XS-1.35/examples/speed.pl 2018-01-01 14:57:07.000000000 +0100 @@ -1,7 +1,7 @@ #!/usr/bin/perl -w # speed.pl: compare different versions of Text-CSV* modules -# (m)'08 [07 Apr 2008] Copyright H.M.Brand 2007-2017 +# (m)'08 [07 Apr 2008] Copyright H.M.Brand 2007-2018 require 5.006001; use strict; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-1.34/t/12_acc.t new/Text-CSV_XS-1.35/t/12_acc.t --- old/Text-CSV_XS-1.34/t/12_acc.t 2017-10-19 16:22:21.000000000 +0200 +++ new/Text-CSV_XS-1.35/t/12_acc.t 2017-11-24 16:14:15.000000000 +0100 @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 228; +use Test::More tests => 231; BEGIN { use_ok "Text::CSV_XS"; @@ -48,11 +48,13 @@ qq{"txt =, ""Hi!""",Yes,,2,,1.09,"\r",}, "string"); is ($csv->sep_char (";"), ";", "sep_char (;)"); +is ($csv->sep ("**"), "**", "sep (**)"); is ($csv->sep (";"), ";", "sep (;)"); is ($csv->sep_char (), ";", "sep_char ()"); is ($csv->quote_char ("="), "=", "quote_char (=)"); is ($csv->quote (undef), "", "quote (undef)"); is ($csv->quote (""), "", "quote (undef)"); +is ($csv->quote ("**"), "**", "quote (**)"); is ($csv->quote ("="), "=", "quote (=)"); is ($csv->eol (undef), "", "eol (undef)"); is ($csv->eol (""), "", "eol ('')"); @@ -86,6 +88,7 @@ is ($csv->diag_verbose (undef), 0, "diag_verbose (undef)"); is ($csv->diag_verbose (""), 0, "diag_verbose (\"\")"); is ($csv->verbatim (1), 1, "verbatim (1)"); +is ($csv->formula ("diag"), "diag", "formula (\"diag\")"); is ($csv->strict (1), 1, "strict (1)"); is ($csv->quote_space (1), 1, "quote_space (1)"); is ($csv->quote_empty (1), 1, "quote_empty (1)"); @@ -247,6 +250,7 @@ verbatim strict formula types callbacks + ENCODING )]; is_deeply ([ Text::CSV_XS::known_attributes () ], $attr, "Known attributes (function)"); is_deeply ([ Text::CSV_XS->known_attributes () ], $attr, "Known attributes (class method)"); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-1.34/t/66_formula.t new/Text-CSV_XS-1.35/t/66_formula.t --- old/Text-CSV_XS-1.34/t/66_formula.t 2017-10-19 19:55:39.000000000 +0200 +++ new/Text-CSV_XS-1.35/t/66_formula.t 2018-03-21 14:14:05.000000000 +0100 @@ -141,7 +141,8 @@ sub writer { my $f = shift; - ok (my $csv = Text::CSV_XS->new ({ formula => $f, quote_empty => 1 }), "new $f"); + ok (my $csv = Text::CSV_XS->new ({ + formula_handling => $f, quote_empty => 1 }), "new $f"); ok ($csv->combine ("1", "=2+3", "4"), "combine $f"); $csv->string; } # writer diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-1.34/t/85_util.t new/Text-CSV_XS-1.35/t/85_util.t --- old/Text-CSV_XS-1.34/t/85_util.t 2017-11-03 16:14:51.000000000 +0100 +++ new/Text-CSV_XS-1.35/t/85_util.t 2017-11-24 16:15:00.000000000 +0100 @@ -14,7 +14,7 @@ plan skip_all => "This test unit requires perl-5.8.2 or higher"; } else { - my $n = 1340; + my $n = 1370; $pu and $n -= 120; plan tests => $n; } @@ -283,6 +283,7 @@ binmode $fh; ok (1, "$fnm opened for enc $enc"); ok ($csv->header ($fh), "headers with BOM for $enc"); + $enc =~ m/^utf/ and is ($csv->{ENCODING}, uc $enc, "Encoding inquirable"); is (($csv->column_names)[1], "b\x{00e5}r", "column name was decoded"); ok (my $row = $csv->getline_hr ($fh), "getline_hr"); is ($row->{"b\x{00e5}r"}, "1 \x{20ac} each", "Returned in Unicode"); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-1.34/t/91_csv_cb.t new/Text-CSV_XS-1.35/t/91_csv_cb.t --- old/Text-CSV_XS-1.34/t/91_csv_cb.t 2017-11-05 14:19:04.000000000 +0100 +++ new/Text-CSV_XS-1.35/t/91_csv_cb.t 2018-02-28 10:35:30.000000000 +0100 @@ -4,7 +4,7 @@ use warnings; #use Test::More "no_plan"; - use Test::More tests => 52; + use Test::More tests => 58; BEGIN { use_ok "Text::CSV_XS", ("csv"); @@ -208,3 +208,43 @@ is_deeply (csv (in => $tfn, filter => "filled"), [[3,3,3],[5,7,9],[8,13,18]], "filter => filled"); + +is_deeply (csv (in => $tfn, filter => sub { + grep { defined && m/\S/ } @{$_[1]} }), + [[3,3,3],[5,7,9],[8,13,18]], + "filter => filled"); + +# Count rows in different ways +open FH, ">", $tfn or die "$tfn: $!"; +print FH <<"EOD"; +foo,bar,baz +1,,3 +0,"d +€",4 +999,999, +EOD +close FH; + +{ my $n = 0; + open my $fh, "<", $tfn; + my $csv = Text::CSV_XS->new ({ binary => 1 }); + while (my $row = $csv->getline ($fh)) { $n++; } + close $fh; + is ($n, 4, "Count rows with getline"); + } +{ my $n = 0; + my $aoa = csv (in => $tfn, on_in => sub { $n++ }); + is ($n, 4, "Count rows with on_in"); + } +{ my $n = 0; + my $aoa = csv (in => $tfn, filter => { 0 => sub { $n++; 0; }}); + is ($n, 4, "Count rows with filter hash"); + } +{ my $n = 0; + my $aoa = csv (in => $tfn, filter => sub { $n++; 0; }); + is ($n, 4, "Count rows with filter sub"); + } +{ my $n = 0; + csv (in => $tfn, on_in => sub { $n++; 0; }, out => \"skip"); + is ($n, 4, "Count rows with on_in and skipped out"); + }
