r52958 - in /branches/upstream/libtext-csv-xs-perl/current: CSV_XS.pm CSV_XS.xs ChangeLog MANIFEST META.yml Makefile.PL README examples/csv-check examples/csv2xls examples/parser-xs.pl examples/speed.pl t/50_utf8.t t/51_utf8.t t/80_diag.t

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Wed Feb 17 19:08:34 UTC 2010


Author: jawnsy-guest
Date: Wed Feb 17 19:08:22 2010
New Revision: 52958

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=52958
Log:
[svn-upgrade] Integrating new upstream version, libtext-csv-xs-perl (0.71)

Added:
    branches/upstream/libtext-csv-xs-perl/current/t/51_utf8.t
Modified:
    branches/upstream/libtext-csv-xs-perl/current/CSV_XS.pm
    branches/upstream/libtext-csv-xs-perl/current/CSV_XS.xs
    branches/upstream/libtext-csv-xs-perl/current/ChangeLog
    branches/upstream/libtext-csv-xs-perl/current/MANIFEST
    branches/upstream/libtext-csv-xs-perl/current/META.yml
    branches/upstream/libtext-csv-xs-perl/current/Makefile.PL
    branches/upstream/libtext-csv-xs-perl/current/README
    branches/upstream/libtext-csv-xs-perl/current/examples/csv-check
    branches/upstream/libtext-csv-xs-perl/current/examples/csv2xls
    branches/upstream/libtext-csv-xs-perl/current/examples/parser-xs.pl
    branches/upstream/libtext-csv-xs-perl/current/examples/speed.pl
    branches/upstream/libtext-csv-xs-perl/current/t/50_utf8.t
    branches/upstream/libtext-csv-xs-perl/current/t/80_diag.t

Modified: branches/upstream/libtext-csv-xs-perl/current/CSV_XS.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-xs-perl/current/CSV_XS.pm?rev=52958&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/CSV_XS.pm (original)
+++ branches/upstream/libtext-csv-xs-perl/current/CSV_XS.pm Wed Feb 17 19:08:22 2010
@@ -1,6 +1,6 @@
 package Text::CSV_XS;
 
-# Copyright (c) 2007-2009 H.Merijn Brand.  All rights reserved.
+# Copyright (c) 2007-2010 H.Merijn Brand.  All rights reserved.
 # Copyright (c) 1998-2001 Jochen Wiedmann. All rights reserved.
 # Portions Copyright (c) 1997 Alan Citterman. All rights reserved.
 #
@@ -30,7 +30,7 @@
 use Carp;
 
 use vars   qw( $VERSION @ISA );
-$VERSION = "0.70";
+$VERSION = "0.71";
 @ISA     = qw( DynaLoader );
 bootstrap Text::CSV_XS $VERSION;
 
@@ -114,12 +114,14 @@
 	    }
 #	croak?
 	$last_new_err = SetDiag (undef, 1000, "INI - Unknown attribute '$_'");
+	$attr->{auto_diag} and error_diag ();
 	return;
 	}
 
     my $self  = {%def_attr, %{$attr}};
     if (my $ec = _check_sanity ($self)) {
 	$last_new_err = SetDiag (undef, $ec);
+	$attr->{auto_diag} and error_diag ();
 	return;
 	}
 
@@ -351,24 +353,29 @@
 
     my $context = wantarray;
     unless (defined $context) {	# Void context, auto-diag
-	if ($diag[0] && $diag[0] != 2012 && $self && ref $self) {
+	if ($diag[0] && $diag[0] != 2012) {
 	    my $msg = "# CSV_XS ERROR: $diag[0] - $diag[1]\n";
-
-	    my $lvl = $self->{auto_diag};
-	    if ($lvl < 2) {
-		my @c = caller (2);
-		if (@c >= 11 && $c[10] && ref $c[10] eq "HASH") {
-		    my $hints = $c[10];
-		    (exists $hints->{autodie} && $hints->{autodie} or
-		     exists $hints->{"guard Fatal"} &&
-		    !exists $hints->{"no Fatal"}) and
-			$lvl++;
-		    # Future releases of autodie will probably set $^H{autodie}
-		    #  to "autodie @args", like "autodie :all" or "autodie open"
-		    #  so we can/should check for "open" or "new"
+	    if ($self && ref $self) {	# auto_diag
+
+		my $lvl = $self->{auto_diag};
+		if ($lvl < 2) {
+		    my @c = caller (2);
+		    if (@c >= 11 && $c[10] && ref $c[10] eq "HASH") {
+			my $hints = $c[10];
+			(exists $hints->{autodie} && $hints->{autodie} or
+			 exists $hints->{"guard Fatal"} &&
+			!exists $hints->{"no Fatal"}) and
+			    $lvl++;
+			# Future releases of autodie will probably set $^H{autodie}
+			#  to "autodie @args", like "autodie :all" or "autodie open"
+			#  so we can/should check for "open" or "new"
+			}
 		    }
+		$lvl > 1 ? die $msg : warn $msg;
 		}
-	    $lvl > 1 ? die $msg : warn $msg;
+	    else {	# called without args in void context
+		warn $msg;
+		}
 	    }
 	return;
 	}
@@ -1699,7 +1706,7 @@
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright (C) 2007-2009 H.Merijn Brand for PROCURA B.V.
+Copyright (C) 2007-2010 H.Merijn Brand for PROCURA B.V.
 Copyright (C) 1998-2001 Jochen Wiedmann. All rights reserved.
 Portions Copyright (C) 1997 Alan Citterman. All rights reserved.
 

Modified: branches/upstream/libtext-csv-xs-perl/current/CSV_XS.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-xs-perl/current/CSV_XS.xs?rev=52958&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/CSV_XS.xs (original)
+++ branches/upstream/libtext-csv-xs-perl/current/CSV_XS.xs Wed Feb 17 19:08:22 2010
@@ -1,4 +1,4 @@
-/*  Copyright (c) 2007-2009 H.Merijn Brand.  All rights reserved.
+/*  Copyright (c) 2007-2010 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.
@@ -21,6 +21,9 @@
 #  define SvUTF8_on(sv)	/* no-op */
 #  define SvUTF8(sv)	0
 #  endif
+#ifndef PERLIO_F_UTF8
+#  define PERLIO_F_UTF8	0x00008000
+#  endif
 
 #define MAINT_DEBUG	0
 
@@ -358,7 +361,7 @@
     else if ((svp = hv_fetchs (hv, "eol", FALSE)) && *svp && SvOK (*svp)) {
 	STRLEN len;
 	byte *eol = (byte *)SvPV (*svp, len);
-	_cache_show_str  ("eol", len,		eol);
+	_cache_show_str  ("eol", (int)len,	eol);
 	}
     else
 	_cache_show_str  ("eol", 8,		(byte *)"<broken>");
@@ -567,6 +570,8 @@
 	PUSHs ((dst));
 	PUSHs (tmp);
 	PUTBACK;
+	if (csv->utf8)
+	    SvUTF8_on (tmp);
 	result = call_sv (m_print, G_SCALAR | G_METHOD);
 	SPAGAIN;
 	if (result) {

Modified: branches/upstream/libtext-csv-xs-perl/current/ChangeLog
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-xs-perl/current/ChangeLog?rev=52958&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/ChangeLog (original)
+++ branches/upstream/libtext-csv-xs-perl/current/ChangeLog Wed Feb 17 19:08:22 2010
@@ -1,3 +1,12 @@
+2010-02-15 0.71 - H.Merijn Brand   <h.m.brand at xs4all.nl>
+
+    * Upped copyright to 2010
+    * Prevent double encoding: make Text::CSV_XS streams behave just
+      like perl would (thanks ikegami for the test cases)
+    * Text::CSV_XS->error_diag () in void context now warns instead of
+      doing nothing
+    * auto_diag also used for new () itself
+
 2009-12-02 0.70 - H.Merijn Brand   <h.m.brand at xs4all.nl>
 
     * Add quote_space attribute

Modified: branches/upstream/libtext-csv-xs-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-xs-perl/current/MANIFEST?rev=52958&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/MANIFEST (original)
+++ branches/upstream/libtext-csv-xs-perl/current/MANIFEST Wed Feb 17 19:08:22 2010
@@ -20,6 +20,7 @@
 t/41_null.t		NULL test in combination with line endings
 t/45_eol.t		Embedded EOL
 t/50_utf8.t		Unicode stress tests
+t/51_utf8.t		Unicode IO encoding tests
 t/55_combi.t		Different CSV character combinations
 t/60_samples.t		Miscellaneous problems from the modules history.
 t/65_allow.t		Allow bad formats

Modified: branches/upstream/libtext-csv-xs-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-xs-perl/current/META.yml?rev=52958&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/META.yml (original)
+++ branches/upstream/libtext-csv-xs-perl/current/META.yml Wed Feb 17 19:08:22 2010
@@ -1,6 +1,6 @@
 --- #YAML:1.1
 name:                    Text-CSV_XS
-version:                 0.70
+version:                 0.71
 abstract:                Comma-Separated Values manipulation routines
 license:                 perl
 author:              
@@ -10,7 +10,7 @@
 provides:
     Text::CSV_XS:
         file:            CSV_XS.pm
-        version:         0.70
+        version:         0.71
 requires:     
     perl:                5.005
     DynaLoader:          0

Modified: branches/upstream/libtext-csv-xs-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-xs-perl/current/Makefile.PL?rev=52958&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/Makefile.PL (original)
+++ branches/upstream/libtext-csv-xs-perl/current/Makefile.PL Wed Feb 17 19:08:22 2010
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# Copyright PROCURA B.V. (c) 2006-2009 H.Merijn Brand
+# Copyright PROCURA B.V. (c) 2006-2010 H.Merijn Brand
 
 require 5.005; # <- also see postamble at the bottom for META.yml
 use strict;

Modified: branches/upstream/libtext-csv-xs-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-xs-perl/current/README?rev=52958&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/README (original)
+++ branches/upstream/libtext-csv-xs-perl/current/README Wed Feb 17 19:08:22 2010
@@ -7,7 +7,7 @@
     fields into a CSV string and parse a CSV string into fields.
 
 Copying:
-    Copyright (c) 2007-2009 H.Merijn Brand.  All rights reserved.
+    Copyright (c) 2007-2010 H.Merijn Brand.  All rights reserved.
     Copyright (c) 1998-2001 Jochen Wiedmann. All rights reserved.
     Portions Copyright (c) 1997 Alan Citterman. All rights reserved.
 

Modified: branches/upstream/libtext-csv-xs-perl/current/examples/csv-check
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-xs-perl/current/examples/csv-check?rev=52958&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/examples/csv-check (original)
+++ branches/upstream/libtext-csv-xs-perl/current/examples/csv-check Wed Feb 17 19:08:22 2010
@@ -1,7 +1,7 @@
 #!/pro/bin/perl
 
 # csv-check: Check validity of CSV file and report
-#	   (m)'09 [12 Oct 2009] Copyright H.M.Brand 2007-2009
+#	   (m)'09 [12 Oct 2009] Copyright H.M.Brand 2007-2010
 
 # This code requires the defined-or feature and PerlIO
 

Modified: branches/upstream/libtext-csv-xs-perl/current/examples/csv2xls
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-xs-perl/current/examples/csv2xls?rev=52958&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/examples/csv2xls (original)
+++ branches/upstream/libtext-csv-xs-perl/current/examples/csv2xls Wed Feb 17 19:08:22 2010
@@ -1,7 +1,7 @@
 #!/pro/bin/perl
 
 # csv2xls: Convert csv to xls
-#	   (m)'08 [22 May 2008] Copyright H.M.Brand 2007-2009
+#	   (m)'08 [22 May 2008] Copyright H.M.Brand 2007-2010
 
 use strict;
 use warnings;

Modified: branches/upstream/libtext-csv-xs-perl/current/examples/parser-xs.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-xs-perl/current/examples/parser-xs.pl?rev=52958&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/examples/parser-xs.pl (original)
+++ branches/upstream/libtext-csv-xs-perl/current/examples/parser-xs.pl Wed Feb 17 19:08:22 2010
@@ -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-2009
+#	   (m)'08 [23 Apr 2008] Copyright H.M.Brand 2008-2010
 
 use strict;
 use warnings;

Modified: branches/upstream/libtext-csv-xs-perl/current/examples/speed.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-xs-perl/current/examples/speed.pl?rev=52958&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/examples/speed.pl (original)
+++ branches/upstream/libtext-csv-xs-perl/current/examples/speed.pl Wed Feb 17 19:08:22 2010
@@ -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-2009
+#	   (m)'08 [07 Apr 2008] Copyright H.M.Brand 2007-2010
 
 require 5.005;
 use strict;

Modified: branches/upstream/libtext-csv-xs-perl/current/t/50_utf8.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-xs-perl/current/t/50_utf8.t?rev=52958&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/t/50_utf8.t (original)
+++ branches/upstream/libtext-csv-xs-perl/current/t/50_utf8.t Wed Feb 17 19:08:22 2010
@@ -31,7 +31,7 @@
 # 0D = \r  3B = ;
 foreach my $test (
   # Space-like characters
-  [ "\x{0000A0}", "U+0000A0 NO-BRAK SPACE"				],
+  [ "\x{0000A0}", "U+0000A0 NO-BREAK SPACE"				],
   [ "\x{00200B}", "U+00200B ZERO WIDTH SPACE"				],
   # Some characters with possible problems in the code point
   [ "\x{000122}", "U+000122 LATIN CAPITAL LETTER G WITH CEDILLA"	],

Added: branches/upstream/libtext-csv-xs-perl/current/t/51_utf8.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-xs-perl/current/t/51_utf8.t?rev=52958&op=file
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/t/51_utf8.t (added)
+++ branches/upstream/libtext-csv-xs-perl/current/t/51_utf8.t Wed Feb 17 19:08:22 2010
@@ -1,0 +1,95 @@
+#!/usr/bin/perl
+
+use strict;
+$^W = 1;
+
+use Test::More;
+
+BEGIN {
+    $] < 5.008 and
+	plan skip_all => "UTF8 tests useless in this ancient perl version";
+    }
+
+my @tests;
+
+BEGIN {
+    delete $ENV{PERLIO};
+
+    my $euro_ch = "\x{20ac}";
+
+    utf8::encode    (my $bytes = $euro_ch);
+    utf8::downgrade (my $bytes_dn = $bytes);
+    utf8::upgrade   (my $bytes_up = $bytes);
+
+    @tests = (
+	# $test                        $perlio             $data,      $encoding $expect_w
+	# ---------------------------- ------------------- ----------- --------- ----------
+	[ "Unicode  default",          "",                 $euro_ch,   "utf8",   "warn",    ],
+	[ "Unicode  binmode",          "[binmode]",        $euro_ch,   "utf8",   "warn",    ],
+	[ "Unicode  :utf8",            ":utf8",            $euro_ch,   "utf8",   "no warn", ],
+	[ "Unicode  :encoding(utf8)",  ":encoding(utf8)",  $euro_ch,   "utf8",   "no warn", ],
+	[ "Unicode  :encoding(UTF-8)", ":encoding(UTF-8)", $euro_ch,   "utf8",   "no warn", ],
+
+	[ "bytes dn default",          "",                 $bytes_dn,  "[none]", "no warn", ],
+	[ "bytes dn binmode",          "[binmode]",        $bytes_dn,  "[none]", "no warn", ],
+	[ "bytes dn :utf8",            ":utf8",            $bytes_dn,  "utf8",   "no warn", ],
+	[ "bytes dn :encoding(utf8)",  ":encoding(utf8)",  $bytes_dn,  "utf8",   "no warn", ],
+	[ "bytes dn :encoding(UTF-8)", ":encoding(UTF-8)", $bytes_dn,  "utf8",   "no warn", ],
+
+	[ "bytes up default",          "",                 $bytes_up,  "[none]", "no warn", ],
+	[ "bytes up binmode",          "[binmode]",        $bytes_up,  "[none]", "no warn", ],
+	[ "bytes up :utf8",            ":utf8",            $bytes_up,  "utf8",   "no warn", ],
+	[ "bytes up :encoding(utf8)",  ":encoding(utf8)",  $bytes_up,  "utf8",   "no warn", ],
+	[ "bytes up :encoding(UTF-8)", ":encoding(UTF-8)", $bytes_up,  "utf8",   "no warn", ],
+	);
+
+    plan tests => 1 + 6 * @tests;
+    }
+
+BEGIN {
+    require_ok "Text::CSV_XS";
+    plan skip_all => "Cannot load Text::CSV_XS" if $@;
+    require "t/util.pl";
+    }
+
+sub hexify { join " ", map { sprintf "%02x", $_ } unpack "C*", @_ }
+sub warned { length ($_[0]) ? "warn" : "no warn" }
+
+my $csv = Text::CSV_XS->new ({ auto_diag => 1, binary => 1 });
+
+for (@tests) {
+    my ($test, $perlio, $data, $enc, $expect_w) = @$_;
+
+    my $expect = qq{"$data"};
+    $enc eq "utf8" and utf8::encode ($expect);
+
+    my ($p_out, $p_fh) = ("");
+    my ($c_out, $c_fh) = ("");
+
+    if ($perlio eq "[binmode]") {
+	open $p_fh, ">", \$p_out;  binmode $p_fh;
+	open $c_fh, ">", \$c_out;  binmode $c_fh;
+	}
+    else {
+	open $p_fh, ">$perlio", \$p_out;
+	open $c_fh, ">$perlio", \$c_out;
+	}
+
+    my $p_warn = "";
+    {	local $SIG{__WARN__} = sub { $p_warn .= join "", @_ };
+	ok ((print $p_fh qq{"$data"}),        "$test perl print");
+	close $p_fh;
+	}
+
+    my $c_warn = "";
+    {	local $SIG{__WARN__} = sub { $c_warn .= join "", @_ };
+	ok ($csv->print ($c_fh, [ $data ]),   "$test csv print");
+	close $c_fh;
+	}
+
+    is (hexify ($c_out), hexify ($p_out),   "$test against Perl");
+    is (hexify ($c_out), hexify ($expect),  "$test against expected");
+
+    is (warned ($c_warn), warned ($p_warn), "$test against Perl warning");
+    is (warned ($c_warn), $expect_w,        "$test against expected warning");
+    }

Modified: branches/upstream/libtext-csv-xs-perl/current/t/80_diag.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-xs-perl/current/t/80_diag.t?rev=52958&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/t/80_diag.t (original)
+++ branches/upstream/libtext-csv-xs-perl/current/t/80_diag.t Wed Feb 17 19:08:22 2010
@@ -3,7 +3,7 @@
 use strict;
 $^W = 1;
 
- use Test::More tests => 90;
+ use Test::More tests => 99;
 #use Test::More "no_plan";
 
 my %err;
@@ -66,6 +66,33 @@
 
 is (Text::CSV_XS->new ({ ecs_char => ":" }), undef, "Unsupported option");
 
+{   my @warn;
+    local $SIG{__WARN__} = sub { push @warn, @_ };
+    Text::CSV_XS::error_diag ();
+    ok (@warn == 1, "Error_diag in void context ::");
+    like ($warn[0], qr{^# CSV_XS ERROR: 1000 - INI}, "error content");
+    }
+{   my @warn;
+    local $SIG{__WARN__} = sub { push @warn, @_ };
+    Text::CSV_XS->error_diag ();
+    ok (@warn == 1, "Error_diag in void context ->");
+    like ($warn[0], qr{^# CSV_XS ERROR: 1000 - INI}, "error content");
+    }
+
+{   my @warn;
+    local $SIG{__WARN__} = sub { push @warn, @_ };
+    is (Text::CSV_XS->new ({ auto_diag => 0, ecs_char => ":" }), undef,
+	"Unsupported option");
+    ok (@warn == 0, "Error_diag in from new ({ auto_diag => 0})");
+    }
+{   my @warn;
+    local $SIG{__WARN__} = sub { push @warn, @_ };
+    is (Text::CSV_XS->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_XS ERROR: 1000 - INI}, "error content");
+    }
+
 is (Text::CSV_XS::error_diag (), "INI - Unknown attribute 'ecs_char'",
 					"Last failure for new () - FAIL");
 is (Text::CSV_XS->error_diag (), "INI - Unknown attribute 'ecs_char'",




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