Hello community, here is the log from the commit of package perl-Text-CSV_XS for openSUSE:Factory checked in at 2013-07-30 18:44:02 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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" Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Text-CSV_XS/perl-Text-CSV_XS.changes 2013-06-05 13:07:33.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.perl-Text-CSV_XS.new/perl-Text-CSV_XS.changes 2013-07-30 18:44:02.000000000 +0200 @@ -1,0 +2,11 @@ +Sat Jul 27 11:58:34 UTC 2013 - [email protected] + +- updated to 1.01 + * Cache not re-read on getline_all (RT#86155) + * Fix automatic UTF-8 in getline/parse for SV's with \0 + * Documents return value of bind_columns without arguments + * Fix automatic UTF-8 in getline/parse + * Clarify eol documentation + * Move error_input to XS + +------------------------------------------------------------------- Old: ---- Text-CSV_XS-0.97.tgz New: ---- Text-CSV_XS-1.01.tgz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Text-CSV_XS.spec ++++++ --- /var/tmp/diff_new_pack.sEL7ew/_old 2013-07-30 18:44:05.000000000 +0200 +++ /var/tmp/diff_new_pack.sEL7ew/_new 2013-07-30 18:44:05.000000000 +0200 @@ -17,7 +17,7 @@ Name: perl-Text-CSV_XS -Version: 0.97 +Version: 1.01 Release: 0 %define cpan_name Text-CSV_XS Summary: comma-separated values manipulation routines @@ -29,7 +29,7 @@ BuildRequires: perl BuildRequires: perl-macros #BuildRequires: perl(Text::CSV_XS) -Recommends: perl(Encode) >= 2.49 +Recommends: perl(Encode) >= 2.51 %{perl_requires} %description ++++++ Text-CSV_XS-0.97.tgz -> Text-CSV_XS-1.01.tgz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-0.97/CSV_XS.pm new/Text-CSV_XS-1.01/CSV_XS.pm --- old/Text-CSV_XS-0.97/CSV_XS.pm 2013-03-30 15:58:47.000000000 +0100 +++ new/Text-CSV_XS-1.01/CSV_XS.pm 2013-06-13 20:08:19.000000000 +0200 @@ -27,7 +27,7 @@ use Carp; use vars qw( $VERSION @ISA ); -$VERSION = "0.97"; +$VERSION = "1.01"; @ISA = qw( DynaLoader ); bootstrap Text::CSV_XS $VERSION; @@ -368,17 +368,6 @@ return $self->{_EOF}; } # status -# error_input -# -# object method returning the first invalid argument to the most recent -# combine () or parse (). there are no side-effects. - -sub error_input -{ - my $self = shift; - return $self->{_ERROR_INPUT}; - } # error_input - # erro_diag # # If (and only if) an error occurred, this function returns a code that @@ -659,14 +648,12 @@ use Text::CSV_XS; my @rows; - my $csv = Text::CSV_XS->new ({ binary => 1 }) or - die "Cannot use CSV: ".Text::CSV_XS->error_diag (); + my $csv = Text::CSV_XS->new ({ binary => 1, auto_diag => 1 }); open my $fh, "<:encoding(utf8)", "test.csv" or die "test.csv: $!"; while (my $row = $csv->getline ($fh)) { $row->[2] =~ m/pattern/ or next; # 3rd field should match push @rows, $row; } - $csv->eof or $csv->error_diag (); close $fh; $csv->eol ("\r\n"); @@ -685,12 +672,12 @@ =head2 Embedded newlines -B<Important Note>: The default behavior is to accept only ASCII characters. -This means that fields can not contain newlines. If your data contains -newlines embedded in fields, or characters above 0x7e (tilde), or binary -data, you B<I<must>> set C<< binary => 1 >> in the call to L</new>. To -cover the widest range of parsing options, you will always want to set -binary. +B<Important Note>: The default behavior is to accept only ASCII characters +in the range from C<0x20> (space) to C<0x7E> (tilde). This means that +fields can not contain newlines. If your data contains newlines embedded +in fields, or characters above 0x7e (tilde), or binary data, you +B<I<must>> set C<< binary => 1 >> in the call to L</new>. To cover the +widest range of parsing options, you will always want to set binary. But you still have the problem that you have to pass a correct line to the L</parse> method, which is more complicated from the usual point of usage: @@ -702,21 +689,22 @@ will break, as the while might read broken lines, as that does not care about the quoting. If you need to support embedded newlines, the way to go -is either - - my $csv = Text::CSV_XS->new ({ binary => 1, eol => $/ }); - while (my $row = $csv->getline (*ARGV)) { - my @fields = @$row; - -or, more safely in perl 5.6 and up +is to B<not> pass C<eol> in the parser (it accepts C<\n>, C<\r>, B<and> +C<\r\n> by default) and then - my $csv = Text::CSV_XS->new ({ binary => 1, eol => $/ }); + my $csv = Text::CSV_XS->new ({ binary => 1 }); open my $io, "<", $file or die "$file: $!"; while (my $row = $csv->getline ($io)) { my @fields = @$row; +The old(er) way of using global file handles is still supported + + while (my $row = $csv->getline (*ARGV)) { + =head2 Unicode +Unicode is only tested to work with perl-5.8.2 and up. + On parsing (both for L</getline> and L</parse>), if the source is marked being UTF8, then all fields that are marked binary will also be marked UTF8. @@ -856,15 +844,18 @@ =item eol X<eol> -An end-of-line string to add to rows. C<undef> is replaced with an empty -string. The default is C<$\>. Common values for C<eol> are C<"\012"> (Line -Feed) or C<"\015\012"> (Carriage Return, Line Feed). Cannot exceed 7 (ASCII) -characters. +An end-of-line string to add to rows. + +When not passed in a B<parser> instance, the default behavior is to accept +C<\n>, C<\r>, and C<\r\n>, so it is probably safer to not specify C<eol> at +all. Passing C<undef> or the empty string behave the same. + +Common values for C<eol> are C<"\012"> (C<\n> or Line Feed), C<"\015\012"> +(C<\r\n> or Carriage Return, Line Feed), and C<"\015"> (C<\r> or Carriage +Return). The C<eol> attribute cannot exceed 7 (ASCII) characters. If both C<$/> and C<eol> equal C<"\015">, parsing lines that end on only a -Carriage Return without Line Feed, will be L</parse>d correct. Line endings, -whether in C<$/> or C<eol>, other than C<undef>, C<"\n">, C<"\r\n">, or -C<"\r"> are not (yet) supported for parsing. +Carriage Return without Line Feed, will be L</parse>d correct. =item sep_char X<sep_char> @@ -1396,6 +1387,9 @@ $csv->bind_columns (undef); +If no arguments are passed at all, L</bind_columns> will return the list +current bindings or C<undef> if no binds are active. + =head2 eof X<eof> @@ -1546,7 +1540,8 @@ $bad_argument = $csv->error_input (); This object function returns the erroneous argument (if it exists) of -L</combine> or L</parse>, whichever was called more recently. +L</combine> or L</parse>, whichever was called more recently. If the last +call was successful, C<error_input> will return C<undef>. =head2 error_diag X<error_diag> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-0.97/CSV_XS.xs new/Text-CSV_XS-1.01/CSV_XS.xs --- old/Text-CSV_XS-0.97/CSV_XS.xs 2013-03-30 15:58:16.000000000 +0100 +++ new/Text-CSV_XS-1.01/CSV_XS.xs 2013-06-16 20:36:10.000000000 +0200 @@ -7,23 +7,18 @@ #include <EXTERN.h> #include <perl.h> #include <XSUB.h> -#define NEED_PL_parser #define DPPP_PL_parser_NO_DUMMY -#define NEED_load_module #define NEED_my_snprintf -#define NEED_newRV_noinc #define NEED_pv_escape #define NEED_pv_pretty -#define NEED_sv_2pv_flags -#define NEED_vload_module -#include "ppport.h" -#define is_utf8_sv(s) is_utf8_string ((U8 *)SvPV_nolen (s), 0) #ifndef PERLIO_F_UTF8 # define PERLIO_F_UTF8 0x00008000 # endif #ifndef MAXINT # define MAXINT ((int)(~(unsigned)0 >> 1)) # endif +#include "ppport.h" +#define is_utf8_sv(s) is_utf8_string ((U8 *)SvPV_nolen (s), SvCUR (s)) #define MAINT_DEBUG 0 @@ -335,11 +330,11 @@ } /* _pretty_str */ #define _cache_show_byte(trim,idx) \ - c = cp[idx]; warn (" %-20s %02x:%3d\n", trim, c, c) + c = cp[idx]; warn (" %-21s %02x:%3d\n", trim, c, c) #define _cache_show_char(trim,idx) \ - c = cp[idx]; warn (" %-20s %02x:%s\n", trim, c, _pretty_str (&c, 1)) + c = cp[idx]; warn (" %-21s %02x:%s\n", trim, c, _pretty_str (&c, 1)) #define _cache_show_str(trim,l,str) \ - warn (" %-20s %02d:%s\n", trim, l, _pretty_str (str, l)) + warn (" %-21s %02d:%s\n", trim, l, _pretty_str (str, l)) #define _cache_show_cstr(trim,l,idx) _cache_show_str (trim, l, cp + idx) #define xs_cache_diag(hv) cx_xs_cache_diag (aTHX_ hv) @@ -641,7 +636,7 @@ sv_catpvn (SvRV (dst), csv->buffer, csv->used); result = TRUE; } - if (csv->utf8 && SvROK (dst) && is_utf8_sv (SvRV (dst))) + if (csv->utf8 && !csv->useIO && SvROK (dst) && is_utf8_sv (SvRV (dst))) SvUTF8_on (SvRV (dst)); csv->used = keep; return result; @@ -938,23 +933,25 @@ #endif #define AV_PUSH { \ - *SvEND (sv) = (char)0; \ - SvUTF8_off (sv); \ - if (SvCUR (sv) == 0 && (csv->empty_is_undef || (!(f & CSV_FLAGS_QUO) && csv->blank_is_undef)))\ - sv_setpvn (sv, NULL, 0); \ - else { \ - if (csv->allow_whitespace && ! (f & CSV_FLAGS_QUO)) \ - strip_trail_whitespace (sv); \ - if (f & CSV_FLAGS_BIN && csv->utf8) \ - SvUTF8_on (sv); \ - } \ - SvSETMAGIC (sv); \ - unless (csv->is_bound) av_push (fields, sv); \ - PUSH_RPT; \ - sv = NULL; \ - if (csv->keep_meta_info && fflags) \ - av_push (fflags, newSViv (f)); \ - waitingForField = 1; \ + *SvEND (sv) = (char)0; \ + SvUTF8_off (sv); \ + if (SvCUR (sv) == 0 && ( \ + csv->empty_is_undef || \ + (!(f & CSV_FLAGS_QUO) && csv->blank_is_undef))) \ + sv_setpvn (sv, NULL, 0); \ + else { \ + if (csv->allow_whitespace && ! (f & CSV_FLAGS_QUO)) \ + strip_trail_whitespace (sv); \ + if (f & CSV_FLAGS_BIN && (csv->utf8 || is_utf8_sv (sv))) \ + SvUTF8_on (sv); \ + } \ + SvSETMAGIC (sv); \ + unless (csv->is_bound) av_push (fields, sv); \ + PUSH_RPT; \ + sv = NULL; \ + if (csv->keep_meta_info && fflags) \ + av_push (fflags, newSViv (f)); \ + waitingForField = 1; \ } #define strip_trail_whitespace(sv) cx_strip_trail_whitespace (aTHX_ sv) @@ -1552,6 +1549,9 @@ length = SvIV (len); while (c_xsParse (csv, hv, row, NULL, io, 1)) { + + SetupCsv (&csv, hv, self); + if (skip > 0) { skip--; av_empty (row); /* re-use */ @@ -1637,6 +1637,27 @@ /* XS SetDiag */ void +error_input (self) + SV *self + + PPCODE: + HV *hv; + + if (self && SvOK (self) && SvROK (self) && SvTYPE (SvRV (self)) == SVt_PVHV) { + HV *hv = (HV *)SvRV (self); + SV **sv = hv_fetchs (hv, "_ERROR_INPUT", FALSE); + if (sv && *sv && SvOK (*sv)) + ST (0) = *sv; + else + ST (0) = newSV (0); + } + else + ST (0) = newSV (0); + + XSRETURN (1); + /* XS error_input */ + +void Combine (self, dst, fields, useIO) SV *self SV *dst diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-0.97/ChangeLog new/Text-CSV_XS-1.01/ChangeLog --- old/Text-CSV_XS-0.97/ChangeLog 2013-03-30 15:58:16.000000000 +0100 +++ new/Text-CSV_XS-1.01/ChangeLog 2013-06-16 20:40:11.000000000 +0200 @@ -1,3 +1,17 @@ +1.01 - 2013-06-16, H.Merijn Brand + - Cache not re-read on getline_all (RT#86155) + +1.00 - 2013-06-13, H.Merijn Brand + * Fix automatic UTF-8 in getline/parse for SV's with \0 + +0.99 - 2013-06-05, H.Merijn Brand + * Documents return value of bind_columns without arguments + * Fix automatic UTF-8 in getline/parse + +0.98 - 2013-06-03, H.Merijn Brand + * Clarify eol documentation + * Move error_input to XS + 0.97 - 2013-03-30, H.Merijn Brand * Regain the speed from 0.91 (buffer back to 1k) * Minor cleanup in XS code diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-0.97/META.json new/Text-CSV_XS-1.01/META.json --- old/Text-CSV_XS-0.97/META.json 2013-03-30 16:32:26.000000000 +0100 +++ new/Text-CSV_XS-1.01/META.json 2013-06-17 09:23:10.000000000 +0200 @@ -1,47 +1,45 @@ { + "license" : [ + "perl_5" + ], + "abstract" : "Comma-Separated Values manipulation routines", + "meta-spec" : { + "version" : "2", + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec" + }, + "release_status" : "stable", "resources" : { + "license" : [ + "http://dev.perl.org/licenses/" + ], "repository" : { - "web" : "http://repo.or.cz/w/Text-CSV_XS.git", "url" : "http://repo.or.cz/r/Text-CSV_XS.git", + "web" : "http://repo.or.cz/w/Text-CSV_XS.git", "type" : "git" - }, - "license" : [ - "http://dev.perl.org/licenses/" - ] - }, - "meta-spec" : { - "version" : "2", - "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec" + } }, - "generated_by" : "Author", - "version" : "0.97", "name" : "Text-CSV_XS", + "version" : "1.01", + "provides" : { + "Text::CSV_XS" : { + "version" : "1.01", + "file" : "CSV_XS.pm" + } + }, "author" : [ "H.Merijn Brand <[email protected]>" ], "dynamic_config" : 1, - "license" : [ - "perl_5" - ], "prereqs" : { - "test" : { - "requires" : { - "Test::More" : "0", - "Tie::Scalar" : "0" - }, - "recommends" : { - "Encode" : "2.47" - } - }, "runtime" : { "requires" : { - "perl" : "5.006001", "IO::Handle" : "0", + "perl" : "5.006001", "DynaLoader" : "0" }, "recommends" : { - "perl" : "5.016003", - "Encode" : "2.49" + "Encode" : "2.51", + "perl" : "5.016003" } }, "configure" : { @@ -53,14 +51,13 @@ "requires" : { "Config" : "0" } + }, + "test" : { + "requires" : { + "Test::More" : "0", + "Tie::Scalar" : "0" + } } }, - "provides" : { - "Text::CSV_XS" : { - "version" : "0.97", - "file" : "CSV_XS.pm" - } - }, - "abstract" : "Comma-Separated Values manipulation routines", - "release_status" : "stable" + "generated_by" : "Author" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-0.97/META.yml new/Text-CSV_XS-1.01/META.yml --- old/Text-CSV_XS-0.97/META.yml 2013-03-30 16:32:26.000000000 +0100 +++ new/Text-CSV_XS-1.01/META.yml 2013-06-17 09:23:10.000000000 +0200 @@ -7,7 +7,7 @@ configure_requires: ExtUtils::MakeMaker: 0 dynamic_config: 1 -generated_by: Author, CPAN::Meta::Converter version 2.120921 +generated_by: Author, CPAN::Meta::Converter version 2.131560 license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -16,21 +16,17 @@ provides: Text::CSV_XS: file: CSV_XS.pm - version: '0.97' + version: '1.01' recommends: - Encode: '2.49' + Encode: '2.51' perl: '5.016003' requires: DynaLoader: 0 IO::Handle: 0 + Test::More: 0 + Tie::Scalar: 0 perl: '5.006001' resources: license: http://dev.perl.org/licenses/ repository: http://repo.or.cz/r/Text-CSV_XS.git -runtime: - recommends: - Encode: '2.47' - requires: - Test::More: 0 - Tie::Scalar: 0 -version: '0.97' +version: '1.01' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-0.97/README new/Text-CSV_XS-1.01/README --- old/Text-CSV_XS-0.97/README 2013-01-13 18:23:08.000000000 +0100 +++ new/Text-CSV_XS-1.01/README 2013-06-13 13:00:16.000000000 +0200 @@ -29,7 +29,8 @@ perl 5.6.1 or up. examples/csv-check requires perl with defined-or and PerlIO, and making that work on other versions is left as an exercise to the - reader. Other examples are checked against 5.8.4. + reader. Other examples are checked against 5.8.4. For Unicode to + work more or less reliable, you'd need perl 5.8.2 or newer. Build/Installation: Standard build/installation: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-0.97/ppport.h new/Text-CSV_XS-1.01/ppport.h --- old/Text-CSV_XS-0.97/ppport.h 2013-03-18 18:05:02.000000000 +0100 +++ new/Text-CSV_XS-1.01/ppport.h 2013-05-19 17:46:00.000000000 +0200 @@ -6,7 +6,7 @@ ppport.h -- Perl/Pollution/Portability Version 3.20 - Automatically created by Devel::PPPort running under perl 5.016003. + Automatically created by Devel::PPPort running under perl 5.018000. Do NOT edit this file directly! -- Edit PPPort_pm.PL and the includes in parts/inc/ instead. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-0.97/t/50_utf8.t new/Text-CSV_XS-1.01/t/50_utf8.t --- old/Text-CSV_XS-0.97/t/50_utf8.t 2012-06-16 20:09:44.000000000 +0200 +++ new/Text-CSV_XS-1.01/t/50_utf8.t 2013-06-13 13:28:18.000000000 +0200 @@ -6,7 +6,7 @@ use Test::More; BEGIN { - if ($] < 5.008) { + if ($] < 5.008001) { plan skip_all => "UTF8 tests useless in this ancient perl version"; } else { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-0.97/t/51_utf8.t new/Text-CSV_XS-1.01/t/51_utf8.t --- old/Text-CSV_XS-0.97/t/51_utf8.t 2012-06-07 15:07:59.000000000 +0200 +++ new/Text-CSV_XS-1.01/t/51_utf8.t 2013-06-13 16:39:45.000000000 +0200 @@ -6,7 +6,7 @@ use Test::More; BEGIN { - $] < 5.008 and + $] < 5.008001 and plan skip_all => "UTF8 tests useless in this ancient perl version"; } @@ -43,7 +43,7 @@ [ "bytes up :encoding(UTF-8)", ":encoding(UTF-8)", $bytes_up, "utf8", "no warn", ], ); - plan tests => 1 + 6 * @tests; + plan tests => 11 + 6 * @tests; } BEGIN { @@ -93,3 +93,44 @@ is (warned ($c_warn), warned ($p_warn), "$test against Perl warning"); is (warned ($c_warn), $expect_w, "$test against expected warning"); } + +# Test automatic upgrades for valid UTF-8 +{ my $blob = pack "C*", 0..255; $blob =~ tr/",//d; + # perl-5.10.x has buggy SvCUR () on blob + $] >= 5.010000 && $] <= 5.012001 and $blob =~ tr/\0//d; + my @data = ( + qq[1,aap,3], # No diac + qq[1,a\x{e1}p,3], # a_ACUTE in ISO-8859-1 + qq[1,a\x{c4}\x{83}p,3], # a_BREVE in UTF-8 + qq[1,"$blob",3], # Binary shit + ) x 2; + my $data = join "\n" => @data; + my @expect = ("aap", "a\341p", "a\x{0103}p", $blob) x 2; + + my $csv = Text::CSV_XS->new ({ binary => 1, auto_diag => 1 }); + + foreach my $bc (undef, 3) { + my @read; + + # Using getline () + open my $fh, "<", \$data; + $bc and $csv->bind_columns (\my ($f1, $f2, $f3)); + is (scalar $csv->bind_columns, $bc, "Columns_bound?"); + while (my $row = $csv->getline ($fh)) { + push @read, $bc ? $f2 : $row->[1]; + } + close $fh; + is_deeply (\@read, \@expect, "Set and reset UTF-8 ".($bc?"no bind":"bind_columns")); + is_deeply ([ map { utf8::is_utf8 ($_) } @read ], + [ "", "", 1, "", "", "", 1, "" ], "UTF8 flags"); + + # Using parse () + @read = map { + $csv->parse ($_); + $bc ? $f2 : ($csv->fields)[1]; + } @data; + is_deeply (\@read, \@expect, "Set and reset UTF-8 ".($bc?"no bind":"bind_columns")); + is_deeply ([ map { utf8::is_utf8 ($_) } @read ], + [ "", "", 1, "", "", "", 1, "" ], "UTF8 flags"); + } + } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-0.97/t/77_getall.t new/Text-CSV_XS-1.01/t/77_getall.t --- old/Text-CSV_XS-0.97/t/77_getall.t 2012-11-19 16:03:07.000000000 +0100 +++ new/Text-CSV_XS-1.01/t/77_getall.t 2013-06-16 20:35:09.000000000 +0200 @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 31; +use Test::More tests => 61; BEGIN { require_ok "Text::CSV_XS"; @@ -13,19 +13,14 @@ $| = 1; -my @list = ( +my @testlist = ( [ 1, "a", "\x01", "A" ], [ 2, "b", "\x02", "B" ], [ 3, "c", "\x03", "C" ], [ 4, "d", "\x04", "D" ], ); -{ ok (my $csv = Text::CSV_XS->new ({ binary => 1, eol => "\n" }), "csv out"); - open my $fh, ">", "_77test.csv" or die "_77test.csv: $!"; - ok ($csv->print ($fh, $_), "write $_->[0]") for @list; - close $fh; - } - +my @list; sub do_tests { my $sub = shift; @@ -42,34 +37,45 @@ $sub->([@list[1..3]], -3, 3); } # do_tests -{ ok (my $csv = Text::CSV_XS->new ({ binary => 1 }), "csv in"); +foreach my $eol ("\n", "\r") { - do_tests (sub { - my ($expect, @args) = @_; - open my $fh, "<", "_77test.csv" or die "_77test.csv: $!"; - my $s_args = join ", " => @args; - is_deeply ($csv->getline_all ($fh, @args), $expect, "getline_all ($s_args)"); + @list = @testlist; + + { ok (my $csv = Text::CSV_XS->new ({ binary => 1, eol => $eol }), "csv out EOL "._readable ($eol)); + open my $fh, ">", "_77test.csv" or die "_77test.csv: $!"; + ok ($csv->print ($fh, $_), "write $_->[0]") for @list; close $fh; - }); - } + } -{ ok (my $csv = Text::CSV_XS->new ({ binary => 1 }), "csv in"); - ok ($csv->column_names (my @cn = qw( foo bar bin baz )), "Set column names"); - @list = map { my %h; @h{@cn} = @$_; \%h } @list; + { ok (my $csv = Text::CSV_XS->new ({ binary => 1 }), "csv in"); - do_tests (sub { - my ($expect, @args) = @_; + do_tests (sub { + my ($expect, @args) = @_; + open my $fh, "<", "_77test.csv" or die "_77test.csv: $!"; + my $s_args = join ", " => @args; + is_deeply ($csv->getline_all ($fh, @args), $expect, "getline_all ($s_args)"); + close $fh; + }); + } + + { ok (my $csv = Text::CSV_XS->new ({ binary => 1 }), "csv in"); + ok ($csv->column_names (my @cn = qw( foo bar bin baz )), "Set column names"); + @list = map { my %h; @h{@cn} = @$_; \%h } @list; + + do_tests (sub { + my ($expect, @args) = @_; + open my $fh, "<", "_77test.csv" or die "_77test.csv: $!"; + my $s_args = join ", " => @args; + is_deeply ($csv->getline_hr_all ($fh, @args), $expect, "getline_hr_all ($s_args)"); + close $fh; + }); + } + + { ok (my $csv = Text::CSV_XS->new ({ binary => 1 }), "csv in"); open my $fh, "<", "_77test.csv" or die "_77test.csv: $!"; - my $s_args = join ", " => @args; - is_deeply ($csv->getline_hr_all ($fh, @args), $expect, "getline_hr_all ($s_args)"); - close $fh; - }); - } + eval { my $row = $csv->getline_hr_all ($fh); }; + is ($csv->error_diag () + 0, 3002, "Use _hr before colnames ()"); + } -{ ok (my $csv = Text::CSV_XS->new ({ binary => 1 }), "csv in"); - open my $fh, "<", "_77test.csv" or die "_77test.csv: $!"; - eval { my $row = $csv->getline_hr_all ($fh); }; - is ($csv->error_diag () + 0, 3002, "Use _hr before colnames ()"); + unlink "_77test.csv"; } - -unlink "_77test.csv"; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV_XS-0.97/t/80_diag.t new/Text-CSV_XS-1.01/t/80_diag.t --- old/Text-CSV_XS-0.97/t/80_diag.t 2013-03-30 15:58:16.000000000 +0100 +++ new/Text-CSV_XS-1.01/t/80_diag.t 2013-06-03 13:22:44.000000000 +0200 @@ -3,7 +3,7 @@ use strict; use warnings; - use Test::More tests => 138; + use Test::More tests => 141; #use Test::More "no_plan"; my %err; @@ -140,6 +140,12 @@ is ($warn[0], "CACHE: invalid\n", "Uninitialized cache"); } +{ my $csv = Text::CSV_XS->new (); + ok ($csv->parse (q{1,"abc"}), "Valid parse"); + is ($csv->error_input (), undef, "Undefined error_input"); + is ($csv->{_ERROR_INPUT}, undef, "Undefined error_input"); + } + my $diag_file = "_$$.out"; open EH, ">&STDERR"; open STDERR, ">", $diag_file; -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
