r35452 - in /branches/upstream/libtext-csv-xs-perl/current: CSV_XS.pm CSV_XS.xs ChangeLog META.yml Makefile.PL examples/csv-check t/12_acc.t t/65_allow.t t/80_diag.t

ansgar-guest at users.alioth.debian.org ansgar-guest at users.alioth.debian.org
Fri May 15 17:47:50 UTC 2009


Author: ansgar-guest
Date: Fri May 15 17:47:36 2009
New Revision: 35452

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

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/META.yml
    branches/upstream/libtext-csv-xs-perl/current/Makefile.PL
    branches/upstream/libtext-csv-xs-perl/current/examples/csv-check
    branches/upstream/libtext-csv-xs-perl/current/t/12_acc.t
    branches/upstream/libtext-csv-xs-perl/current/t/65_allow.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=35452&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/CSV_XS.pm (original)
+++ branches/upstream/libtext-csv-xs-perl/current/CSV_XS.pm Fri May 15 17:47:36 2009
@@ -30,7 +30,7 @@
 use Carp;
 
 use vars   qw( $VERSION @ISA );
-$VERSION = "0.64";
+$VERSION = "0.65";
 @ISA     = qw( DynaLoader );
 bootstrap Text::CSV_XS $VERSION;
 
@@ -81,8 +81,9 @@
 
 sub new
 {
-    $last_new_err =
-	"usage: my \$csv = Text::CSV_XS->new ([{ option => value, ... }]);";
+    $last_new_err = SetDiag (undef, 1000,
+	"usage: my \$csv = Text::CSV_XS->new ([{ option => value, ... }]);");
+
     my $proto = shift;
     my $attr  = shift || {};
     my $class = ref ($proto) || $proto	or return;
@@ -92,7 +93,7 @@
 	    next;
 	    }
 #	croak?
-	$last_new_err = "Unknown attribute '$_'";
+	$last_new_err = SetDiag (undef, 1000, "INI - Unknown attribute '$_'");
 	return;
 	}
 
@@ -311,15 +312,14 @@
 sub error_diag
 {
     my $self = shift;
-    my @diag = (0, $last_new_err, 0);
-
-    unless ($self && ref $self) {	# Class method or direct call
-	$last_new_err and $diag[0] = 1000;
-	}
-    elsif ($self->isa (__PACKAGE__) && exists $self->{_ERROR_DIAG}) {
+    my @diag = (0 + $last_new_err, $last_new_err, 0);
+
+    if ($self && ref $self && # Not a class method or direct call
+	 $self->isa (__PACKAGE__) && exists $self->{_ERROR_DIAG}) {
 	@diag = (0 + $self->{_ERROR_DIAG}, $self->{_ERROR_DIAG});
 	exists $self->{_ERROR_POS} and $diag[2] = 1 + $self->{_ERROR_POS};
 	}
+
     my $context = wantarray;
     unless (defined $context) {	# Void context
 	$diag[0] and print STDERR "# CSV_XS ERROR: $diag[0] - $diag[1]\n";
@@ -950,11 +950,11 @@
 the fail reason available through the C<error_diag ()> method.
 
  $csv = Text::CSV_XS->new ({ ecs_char => 1 }) or
-     die Text::CSV_XS->error_diag ();
+     die "".Text::CSV_XS->error_diag ();
 
 C<error_diag ()> will return a string like
 
- "Unknown attribute 'ecs_char'"
+ "INI - Unknown attribute 'ecs_char'"
 
 =head2 combine
 

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=35452&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/CSV_XS.xs (original)
+++ branches/upstream/libtext-csv-xs-perl/current/CSV_XS.xs Fri May 15 17:47:36 2009
@@ -210,9 +210,8 @@
 {
     SV   *err = SvDiag (xse);
 
-    if (err) {
+    if (err)
 	hv_store (csv->self, "_ERROR_DIAG",  11, err,           0);
-	}
     if (xse == 0) {
 	hv_store (csv->self, "_ERROR_POS",   10, newSViv  (0),  0);
 	hv_store (csv->self, "_ERROR_INPUT", 12, newSVpvs (""), 0);
@@ -1196,7 +1195,7 @@
     m_print   = newSVpvs ("print");
 
 void
-SetDiag (self, xse)
+SetDiag (self, xse, ...)
     SV		*self
     int		 xse
 
@@ -1211,6 +1210,13 @@
 	}
     else
 	ST (0) = SvDiag (xse);
+
+    if (xse && items > 1 && SvPOK (ST (2))) {
+	STRLEN len;
+	sv_setpvn (ST (0),  SvPVX (ST (2)), SvCUR (ST (2)));
+	SvIOK_on  (ST (0));
+	}
+
     XSRETURN (1);
     /* XS SetDiag */
 

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=35452&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/ChangeLog (original)
+++ branches/upstream/libtext-csv-xs-perl/current/ChangeLog Fri May 15 17:47:36 2009
@@ -1,3 +1,13 @@
+2009-05-14 0.65 - H.Merijn Brand   <h.m.brand at xs4all.nl>
+
+	* Initial known errors can now be checked on number (1002)
+	* More tests for illegal combinations
+	* Added -u option to examples/csv-check to validate utf-8 encoding
+	* Correct documentation for error_diag () return value in case of
+	  contructor failure (Slaven, RT#46076)
+	* All error_diag () returns should now be dual-var (both numeric
+	  and string context valid)
+
 2009-04-03 0.64 - H.Merijn Brand   <h.m.brand at xs4all.nl>
 
 	* Skip perlio tests for perl older than 5.8, as perlio

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=35452&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/META.yml (original)
+++ branches/upstream/libtext-csv-xs-perl/current/META.yml Fri May 15 17:47:36 2009
@@ -1,6 +1,6 @@
 --- #YAML:1.1
 name:                    Text-CSV_XS
-version:                 0.64
+version:                 0.65
 abstract:                Comma-Separated Values manipulation routines
 license:                 perl
 author:              
@@ -10,7 +10,7 @@
 provides:
     Text::CSV_XS:
         file:            CSV_XS.pm
-        version:         0.64
+        version:         0.65
 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=35452&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/Makefile.PL (original)
+++ branches/upstream/libtext-csv-xs-perl/current/Makefile.PL Fri May 15 17:47:36 2009
@@ -82,7 +82,10 @@
 	'	- at tail -5 valgrind.log',
 	'',
 	'leaktest:',
-	q{	sandbox/leaktest $(FULLPERLRUN) "test_harness($(TEST_VERBOSE), '$(INST_LIB)', '$(INST_ARCHLIB)')" $(TEST_FILES)},
+	q{	sandbox/leaktest  $(FULLPERLRUN) "test_harness($(TEST_VERBOSE), '$(INST_LIB)', '$(INST_ARCHLIB)')" $(TEST_FILES)},
+	'',
+	'leaktrace:',
+	q{	sandbox/leaktrace $(FULLPERLRUN) "test_harness($(TEST_VERBOSE), '$(INST_LIB)', '$(INST_ARCHLIB)')" $(TEST_FILES)},
 	'',
 	'checkmeta:',
 	'	perl sandbox/genPPPort_h.pl',

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=35452&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/examples/csv-check (original)
+++ branches/upstream/libtext-csv-xs-perl/current/examples/csv-check Fri May 15 17:47:36 2009
@@ -6,15 +6,19 @@
 use strict;
 use warnings;
 
-our $VERSION = "1.2";
+use Data::Peek;
+use Encode qw( decode );
+
+our $VERSION = "1.3";	# 2009-04-09
 
 sub usage
 {
     my $err = shift and select STDERR;
     print <<EOU;
-usage: csv-check [-s <sep>] [-q <quot>] [file.csv]
+usage: csv-check [-s <sep>] [-q <quot>] [-u] [file.csv]
        -s <sep>   use <sep>   as seperator char. Auto-detect, default = ','
        -q <quot>  use <quot>  as quotation char. Default = '"'
+       -u         check if all fields are valid unicode
 EOU
     exit $err;
     } # usage
@@ -22,12 +26,13 @@
 use Getopt::Long qw(:config bundling nopermute passthrough);
 my $sep;	# Set after reading first line in a flurry attempt to auto-detect
 my $quo = '"';
-
+my $opt_u = 0;
 GetOptions (
     "help|?"	=> sub { usage (0); },
 
     "c|s=s"	=> \$sep,
     "q=s"	=> \$quo,
+    "u"		=> \$opt_u,
     ) or usage (1);
 
 use Text::CSV_XS;
@@ -64,7 +69,9 @@
 
 sub done
 {
-    print "Checked with $0 $VERSION using Text::CSV_XS $Text::CSV_XS::VERSION\n";
+    (my $file = $ARGV // "") =~ s{(\S)$}{$1 };
+    (my $prog = $0) =~ s{.*/}{};
+    print "Checked $file with $prog $VERSION using Text::CSV_XS $Text::CSV_XS::VERSION\n";
     my @diag = $csv->error_diag;
     if ($diag[0] == 2012 && $csv->eof) {
 	my @coll = sort { $a <=> $b } keys %cols;
@@ -95,6 +102,17 @@
     my $r = shift;
     $cols{scalar @$r}++;
     grep { $_ & 0x0002 } $csv->meta_info and $bin = 1;
+    if ($opt_u) {
+	my @r = @$r;
+	foreach my $x (0 .. $#r) {
+	    local $SIG{__WARN__} = sub {
+		(my $msg = shift) =~ s{ at /\S+Encode.pm.*}{};
+		printf STDERR "Field %3d:%3d - '%s'\t- %s",
+		    $rows, $x, DPeek ($r[$x]), $msg;
+		};
+	    my $oct = decode ("utf-8", $r[$x], Encode::FB_WARN);
+	    }
+	}
     } # stats
 
 if ($firstline) {

Modified: branches/upstream/libtext-csv-xs-perl/current/t/12_acc.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-xs-perl/current/t/12_acc.t?rev=35452&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/t/12_acc.t (original)
+++ branches/upstream/libtext-csv-xs-perl/current/t/12_acc.t Fri May 15 17:47:36 2009
@@ -3,7 +3,7 @@
 use strict;
 $^W = 1;	# use warnings core since 5.6
 
-use Test::More tests => 47;
+use Test::More tests => 66;
 
 BEGIN {
     use_ok "Text::CSV_XS";
@@ -51,11 +51,11 @@
     qq{=txt \\=, "Hi!"=;=Yes=;==;=2=;;=1.09=;=\r=;\r},	"string");
 
 # Funny settings, all three translate to \0 internally
-$csv = Text::CSV_XS->new ({
+ok ($csv = Text::CSV_XS->new ({
     sep_char	=> undef,
     quote_char	=> undef,
     escape_char	=> undef,
-    });
+    }),						"new (undef ...)");
 is ($csv->sep_char,		undef,		"sep_char undef");
 is ($csv->quote_char,		undef,		"quote_char undef");
 is ($csv->escape_char,		undef,		"escape_char undef");
@@ -68,14 +68,37 @@
 $csv->binary (1);
 ok ( $csv->parse ("foo,foo\0bar"),		"parse (foo)");
 
+# Some forbidden combinations
+foreach my $ws (" ", "\t") {
+    ok ($csv = Text::CSV_XS->new ({ escape_char => $ws }), "New blank escape");
+    eval { ok ($csv->allow_whitespace (1), "Allow ws") };
+    is (($csv->error_diag)[0], 1002, "Wrong combo");
+    ok ($csv = Text::CSV_XS->new ({ quote_char  => $ws }), "New blank quote");
+    eval { ok ($csv->allow_whitespace (1), "Allow ws") };
+    is (($csv->error_diag)[0], 1002, "Wrong combo");
+    ok ($csv = Text::CSV_XS->new ({ allow_whitespace => 1 }), "New ws 1");
+    eval { ok ($csv->escape_char ($ws),     "esc") };
+    is (($csv->error_diag)[0], 1002, "Wrong combo");
+    ok ($csv = Text::CSV_XS->new ({ allow_whitespace => 1 }), "New ws 1");
+    eval { ok ($csv->quote_char  ($ws),     "esc") };
+    is (($csv->error_diag)[0], 1002, "Wrong combo");
+    }
+eval { $csv = Text::CSV_XS->new ({
+    escape_char      => "\t",
+    quote_char       => " ",
+    allow_whitespace => 1,
+    }) };
+like ((Text::CSV_XS::error_diag)[1], qr{^INI - allow_whitespace}, "Wrong combo - error message");
+is   ((Text::CSV_XS::error_diag)[0], 1002, "Wrong combo - numeric error");
+
 # And test erroneous calls
 
 is (Text::CSV_XS::new (0),		   undef,	"new () as function");
 is (Text::CSV_XS::error_diag (), "usage: my \$csv = Text::CSV_XS->new ([{ option => value, ... }]);",
 							"Generic usage () message");
 is (Text::CSV_XS->new ({ oel     => "" }), undef,	"typo in attr");
-is (Text::CSV_XS::error_diag (), "Unknown attribute 'oel'",	"Unsupported attr");
+is (Text::CSV_XS::error_diag (), "INI - Unknown attribute 'oel'",	"Unsupported attr");
 is (Text::CSV_XS->new ({ _STATUS => "" }), undef,	"private attr");
-is (Text::CSV_XS::error_diag (), "Unknown attribute '_STATUS'",	"Unsupported private attr");
+is (Text::CSV_XS::error_diag (), "INI - Unknown attribute '_STATUS'",	"Unsupported private attr");
 
 1;

Modified: branches/upstream/libtext-csv-xs-perl/current/t/65_allow.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-csv-xs-perl/current/t/65_allow.t?rev=35452&op=diff
==============================================================================
--- branches/upstream/libtext-csv-xs-perl/current/t/65_allow.t (original)
+++ branches/upstream/libtext-csv-xs-perl/current/t/65_allow.t Fri May 15 17:47:36 2009
@@ -30,7 +30,7 @@
 	$csv = Text::CSV_XS->new ();
 	ok ($csv,			"$tst - new (alq => 0)");
 	is ($csv->parse ($bad), $valid,	"$tst - parse () fail");
-	is (0 + $csv->error_diag, $err,		"$tst - error $err");
+	is (0 + $csv->error_diag, $err,	"$tst - error $err");
 
 	$csv->allow_loose_quotes (1);
 	ok ($csv->parse ($bad),		"$tst - parse () pass");

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=35452&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 Fri May 15 17:47:36 2009
@@ -64,11 +64,11 @@
 
 is (Text::CSV_XS->new ({ ecs_char => ":" }), undef, "Unsupported option");
 
-is (Text::CSV_XS::error_diag (), "Unknown attribute 'ecs_char'",
+is (Text::CSV_XS::error_diag (), "INI - Unknown attribute 'ecs_char'",
 					"Last failure for new () - FAIL");
-is (Text::CSV_XS->error_diag (), "Unknown attribute 'ecs_char'",
+is (Text::CSV_XS->error_diag (), "INI - Unknown attribute 'ecs_char'",
 					"Last failure for new () - FAIL");
-is (Text::CSV_XS::error_diag (bless {}, "Foo"), "Unknown attribute 'ecs_char'",
+is (Text::CSV_XS::error_diag (bless {}, "Foo"), "INI - Unknown attribute 'ecs_char'",
 					"Last failure for new () - FAIL");
 $csv->SetDiag (0);
 is (0 + $csv->error_diag (), 0,  "Reset error NUM");
@@ -88,6 +88,6 @@
 is (Text::CSV_XS::Subclass->new ({ ecs_char => ":" }), undef, "Unsupported option");
 
 is (Text::CSV_XS::Subclass->error_diag (),
-    "Unknown attribute 'ecs_char'",	"Last failure for new () - FAIL");
+    "INI - Unknown attribute 'ecs_char'",	"Last failure for new () - FAIL");
 
 1;




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