r45381 - in /trunk/libtext-csv-xs-perl: CSV_XS.pm CSV_XS.xs ChangeLog MANIFEST META.yml debian/changelog debian/control debian/rules examples/csv-check examples/csv2xls examples/csvdiff

ansgar-guest at users.alioth.debian.org ansgar-guest at users.alioth.debian.org
Mon Oct 5 15:27:21 UTC 2009


Author: ansgar-guest
Date: Mon Oct  5 15:26:59 2009
New Revision: 45381

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=45381
Log:
* New upstream release
* debian/control: Make build-dep on perl unversioned.
* debian/control: Bump Standards-Version to 3.8.3.
* debian/rules: Fix path to perl interpreter in examples.
  + Bump build-dep on debhelper to 7.0.50 for override_*

Added:
    trunk/libtext-csv-xs-perl/examples/csvdiff
      - copied unchanged from r45380, branches/upstream/libtext-csv-xs-perl/current/examples/csvdiff
Modified:
    trunk/libtext-csv-xs-perl/CSV_XS.pm
    trunk/libtext-csv-xs-perl/CSV_XS.xs
    trunk/libtext-csv-xs-perl/ChangeLog
    trunk/libtext-csv-xs-perl/MANIFEST
    trunk/libtext-csv-xs-perl/META.yml
    trunk/libtext-csv-xs-perl/debian/changelog
    trunk/libtext-csv-xs-perl/debian/control
    trunk/libtext-csv-xs-perl/debian/rules
    trunk/libtext-csv-xs-perl/examples/csv-check
    trunk/libtext-csv-xs-perl/examples/csv2xls

Modified: trunk/libtext-csv-xs-perl/CSV_XS.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/CSV_XS.pm?rev=45381&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/CSV_XS.pm (original)
+++ trunk/libtext-csv-xs-perl/CSV_XS.pm Mon Oct  5 15:26:59 2009
@@ -30,7 +30,7 @@
 use Carp;
 
 use vars   qw( $VERSION @ISA );
-$VERSION = "0.67";
+$VERSION = "0.68";
 @ISA     = qw( DynaLoader );
 bootstrap Text::CSV_XS $VERSION;
 
@@ -355,10 +355,25 @@
 	}
 
     my $context = wantarray;
-    unless (defined $context) {	# Void context
-	if ($diag[0]) {
+    unless (defined $context) {	# Void context, auto-diag
+	if ($diag[0] && $diag[0] != 2012 && $self && ref $self) {
 	    my $msg = "# CSV_XS ERROR: $diag[0] - $diag[1]\n";
-	    $self && ref $self && $self->{auto_diag} > 1 ? die $msg : warn $msg;
+
+	    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;
 	    }
 	return;
 	}
@@ -556,31 +571,21 @@
 
  use Text::CSV_XS;
 
- $csv = Text::CSV_XS->new ();          # create a new object
- $csv = Text::CSV_XS->new (\%attr);    # create a new object
-
- $status  = $csv->combine (@columns);  # combine columns into a string
- $line    = $csv->string ();           # get the combined string
-
- $status  = $csv->parse ($line);       # parse a CSV string into fields
- @columns = $csv->fields ();           # get the parsed fields
-
- $status       = $csv->status ();      # get the most recent status
- $bad_argument = $csv->error_input (); # get the most recent bad argument
- $diag         = $csv->error_diag ();  # if an error occured, explains WHY
-
- $status = $csv->print ($io, $colref); # Write an array of fields
-                                       # immediately to a file $io
- $colref = $csv->getline ($io);        # Read a line from file $io,
-                                       # parse it and return an array
-                                       # ref of fields
- $csv->bind_columns (@refs);           # Set return fields for getline ()
- $csv->column_names (@names);          # Set column names for getline_hr ()
- $ref = $csv->getline_hr ($io);        # getline (), but returns a hashref
- $eof = $csv->eof ();                  # Indicate if last parse or
-                                       # getline () hit End Of File
-
- $csv->types (\@t_array);              # Set column types
+ my @rows;
+ my $csv = Text::CSV_XS->new ({ binary => 1 }) or
+     die "Cannot use CSV: ".Text::CSV->error_diag ();
+ 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");
+ open $fh, ">:encoding(utf8)", "new.csv" or die "new.csv: $!";
+ $csv->print ($fh, $_) for @rows;
+ close $fh or die "new.csv: $!";
 
 =head1 DESCRIPTION
 
@@ -786,7 +791,7 @@
 are now correctly parsed, even though it violates the CSV specs.
 
 Note that B<all> whitespace is stripped from start and end of each
-field. That would make is more a I<feature> than a way to be able
+field. That would make it more a I<feature> than a way to be able
 to parse bad CSV lines, as
 
  1,   2.0,  3,   ape  , monkey
@@ -968,12 +973,14 @@
 Set to true will cause C<error_diag ()> to be automatically be called
 in void context upon errors.
 
+In case of error C<2012 - EOF>), this call will be void.
+
 If set to a value greater than 1, it will die on errors instead of
 warn.
 
-Future extensions to this feature will include auto-detection of the
-C<autodie> module being enabled, which will raise the value of C<auto_diag>
-with C<1> on the moment the error is detected.
+Future extensions to this feature will include more reliable auto-detection
+of the C<autodie> module being enabled, which will raise the value of
+C<auto_diag> with C<1> on the moment the error is detected.
 
 =back
 
@@ -1021,6 +1028,29 @@
 
  "INI - Unknown attribute 'ecs_char'"
 
+=head2 print
+
+ $status = $csv->print ($io, $colref);
+
+Similar to C<combine () + string () + print>, but more efficient. It
+expects an array ref as input (not an array!) and the resulting string is
+not really created, but immediately written to the I<$io> object, typically
+an IO handle or any other object that offers a I<print> method. Note, this
+implies that the following is wrong in perl 5.005_xx and older:
+
+ open FILE, ">", "whatever";
+ $status = $csv->print (\*FILE, $colref);
+
+as in perl 5.005 and older, the glob C<\*FILE> is not an object, thus it
+doesn't have a print method. The solution is to use an IO::File object or
+to hide the glob behind an IO::Wrap object. See L<IO::File> and L<IO::Wrap>
+for details.
+
+For performance reasons the print method doesn't create a result string.
+In particular the I<$csv-E<gt>string ()>, I<$csv-E<gt>status ()>,
+I<$csv->fields ()> and I<$csv-E<gt>error_input ()> methods are meaningless
+after executing this method.
+
 =head2 combine
 
  $status = $csv->combine (@columns);
@@ -1032,35 +1062,27 @@
 C<string ()> is undefined and C<error_input ()> can be called to retrieve an
 invalid argument.
 
-=head2 print
-
- $status = $csv->print ($io, $colref);
-
-Similar to combine, but it expects an array ref as input (not an array!)
-and the resulting string is not really created, but immediately written
-to the I<$io> object, typically an IO handle or any other object that
-offers a I<print> method. Note, this implies that the following is wrong
-in perl 5.005_xx and older:
-
- open FILE, ">", "whatever";
- $status = $csv->print (\*FILE, $colref);
-
-as in perl 5.005 and older, the glob C<\*FILE> is not an object, thus it
-doesn't have a print method. The solution is to use an IO::File object or
-to hide the glob behind an IO::Wrap object. See L<IO::File> and L<IO::Wrap>
-for details.
-
-For performance reasons the print method doesn't create a result string.
-In particular the I<$csv-E<gt>string ()>, I<$csv-E<gt>status ()>,
-I<$csv->fields ()> and I<$csv-E<gt>error_input ()> methods are meaningless
-after executing this method.
-
 =head2 string
 
  $line = $csv->string ();
 
 This object function returns the input to C<parse ()> or the resultant CSV
 string of C<combine ()>, whichever was called more recently.
+
+=head2 getline
+
+ $colref = $csv->getline ($io);
+
+This is the counterpart to print, like parse is the counterpart to
+combine: It reads a row from the IO object $io using $io->getline ()
+and parses this row into an array ref. This array ref is returned
+by the function or undef for failure.
+
+When fields are bound with C<bind_columns ()>, the return value is a
+reference to an empty list.
+
+The I<$csv-E<gt>string ()>, I<$csv-E<gt>fields ()> and I<$csv-E<gt>status ()>
+methods are meaningless, again.
 
 =head2 parse
 
@@ -1075,21 +1097,6 @@
 
 You may use the I<types ()> method for setting column types. See the
 description below.
-
-=head2 getline
-
- $colref = $csv->getline ($io);
-
-This is the counterpart to print, like parse is the counterpart to
-combine: It reads a row from the IO object $io using $io->getline ()
-and parses this row into an array ref. This array ref is returned
-by the function or undef for failure.
-
-When fields are bound with C<bind_columns ()>, the return value is a
-reference to an empty list.
-
-The I<$csv-E<gt>string ()>, I<$csv-E<gt>fields ()> and I<$csv-E<gt>status ()>
-methods are meaningless, again.
 
 =head2 getline_hr
 
@@ -1370,7 +1377,9 @@
   close $csv_fh or die "hello.csv: $!";
 
 For more extended examples, see the C<examples/> subdirectory in the
-original distribution. The following files can be found there:
+original distribution or the git repository at
+http://repo.or.cz/w/Text-CSV_XS.git?a=tree;f=examples. The following files
+can be found there:
 
 =over 2
 
@@ -1395,6 +1404,14 @@
 A script to convert CSV to Microsoft Excel. This requires L<Date::Calc>
 and L<Spreadsheet::WriteExcel>. The converter accepts various options and
 can produce UTF-8 Excel files.
+
+=item csvdiff
+
+A script that provides colorized diff on sorted CSV files, assuming first
+line is header and first field is the key. Output options include colorized
+ANSI escape codes or HTML.
+
+  $ csvdiff --html --output=diff.html file1.csv file2.csv
 
 =back
 
@@ -1505,9 +1522,9 @@
 class method, like C<Text::CSV_XS->error_diag ()>.
 
 C<$csv->error_diag ()> is automatically called upon error when the contractor
-was called with C<auto_diag> set to 1 or 2, or when C<autodie> is in effect
-(NYI).  When set to 1, this will cause a C<warn ()> with the error message,
-when set to 2, it will C<die ()>.
+was called with C<auto_diag> set to 1 or 2, or when C<autodie> is in effect.
+When set to 1, this will cause a C<warn ()> with the error message, when set
+to 2, it will C<die ()>. C<2012 - EOF> is excluded from C<auto_diag> reports.
 
 Currently errors as described below are available. I've tried to make the error
 itself explanatory enough, but more descriptions will be added. For most of

Modified: trunk/libtext-csv-xs-perl/CSV_XS.xs
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/CSV_XS.xs?rev=45381&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/CSV_XS.xs (original)
+++ trunk/libtext-csv-xs-perl/CSV_XS.xs Mon Oct  5 15:26:59 2009
@@ -211,7 +211,7 @@
 static SV *cx_SetDiag (pTHX_ csv_t *csv, int xse)
 {
     dSP;
-    SV   *err = SvDiag (xse);
+    SV *err = SvDiag (xse);
 
     if (err)
 	(void)hv_store (csv->self, "_ERROR_DIAG",  11, err,           0);

Modified: trunk/libtext-csv-xs-perl/ChangeLog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/ChangeLog?rev=45381&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/ChangeLog (original)
+++ trunk/libtext-csv-xs-perl/ChangeLog Mon Oct  5 15:26:59 2009
@@ -1,3 +1,11 @@
+2009-09-25 0.68 - H.Merijn Brand   <h.m.brand at xs4all.nl>
+
+    * Attribute auto_diag now localizes to +1 if autodie is active
+    * Output name generation in csv2xls (RT#48954)
+    * Added csvdiff to examples/
+    * Reordered docs. Rewrote SYNOPSIS to be more like a real-world
+      code example
+
 2009-08-08 0.67 - H.Merijn Brand   <h.m.brand at xs4all.nl>
 
     * Fix empty_diag typo for attribute handler

Modified: trunk/libtext-csv-xs-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/MANIFEST?rev=45381&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/MANIFEST (original)
+++ trunk/libtext-csv-xs-perl/MANIFEST Mon Oct  5 15:26:59 2009
@@ -1,11 +1,12 @@
 ChangeLog		Change history
 README			Docs
 MANIFEST		This file
+META.yml		Module meta-data
 CSV_XS.PL		Modify CSV_XS.pm for older perl versions
 CSV_XS.pm		Perl part of the module
 CSV_XS.xs		C part of the module
 Makefile.PL		Makefile generator
-ppport.h
+ppport.h		Perl/Pollution/Portability script/include file
 t/00_pod.t		Check if pod is valid
 t/01_pod.t		Check if pod covers all
 t/10_base.t		Base tests (combine and parse only)
@@ -30,7 +31,7 @@
 t/util.pl		Extra test utilities
 examples/csv2xls	Script to onvert CSV files to M$Excel
 examples/csv-check	Script to check a CSV file/stream
+examples/csvdiff	Script to shoff diff between sorted CSV files
 examples/parser-xs.pl	Parse CSV stream, be forgiving on bad lines
 examples/speed.pl	Small benchmark script
 files/utf8.csv		A UTF-8 encode test file
-META.yml                                 Module meta-data (added by MakeMaker)

Modified: trunk/libtext-csv-xs-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/META.yml?rev=45381&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/META.yml (original)
+++ trunk/libtext-csv-xs-perl/META.yml Mon Oct  5 15:26:59 2009
@@ -1,6 +1,6 @@
 --- #YAML:1.1
 name:                    Text-CSV_XS
-version:                 0.67
+version:                 0.68
 abstract:                Comma-Separated Values manipulation routines
 license:                 perl
 author:              
@@ -10,11 +10,13 @@
 provides:
     Text::CSV_XS:
         file:            CSV_XS.pm
-        version:         0.67
+        version:         0.68
 requires:     
     perl:                5.005
     DynaLoader:          0
     IO::Handle:          0
+recommends:     
+    perl:                5.010001
 configure_requires:
     ExtUtils::MakeMaker: 0
 build_requires:

Modified: trunk/libtext-csv-xs-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/debian/changelog?rev=45381&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/debian/changelog (original)
+++ trunk/libtext-csv-xs-perl/debian/changelog Mon Oct  5 15:26:59 2009
@@ -1,8 +1,16 @@
-libtext-csv-xs-perl (0.67-2) UNRELEASED; urgency=low
-
+libtext-csv-xs-perl (0.68-1) unstable; urgency=low
+
+  [ Ryan Niebur ]
   * Update ryan52's email address
 
- -- Ryan Niebur <ryan at debian.org>  Fri, 25 Sep 2009 00:26:45 -0700
+  [ Ansgar Burchardt ]
+  * New upstream release
+  * debian/control: Make build-dep on perl unversioned.
+  * debian/control: Bump Standards-Version to 3.8.3.
+  * debian/rules: Fix path to perl interpreter in examples.
+    + Bump build-dep on debhelper to 7.0.50 for override_*
+
+ -- Ansgar Burchardt <ansgar at 43-1.org>  Tue, 06 Oct 2009 00:24:11 +0900
 
 libtext-csv-xs-perl (0.67-1) unstable; urgency=low
 

Modified: trunk/libtext-csv-xs-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/debian/control?rev=45381&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/debian/control (original)
+++ trunk/libtext-csv-xs-perl/debian/control Mon Oct  5 15:26:59 2009
@@ -8,11 +8,11 @@
  Ryan Niebur <ryan at debian.org>
 Section: perl
 Priority: optional
-Standards-Version: 3.8.2
+Standards-Version: 3.8.3
 Homepage: http://search.cpan.org/dist/Text-CSV_XS/
 Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libtext-csv-xs-perl/
 Vcs-Browser: http://svn.debian.org/viewsvn/pkg-perl/trunk/libtext-csv-xs-perl/
-Build-Depends: debhelper (>= 7), perl (>> 5.8.1), libtest-pod-perl,
+Build-Depends: debhelper (>= 7.0.50), perl, libtest-pod-perl,
  libtest-pod-coverage-perl
 
 Package: libtext-csv-xs-perl

Modified: trunk/libtext-csv-xs-perl/debian/rules
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/debian/rules?rev=45381&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/debian/rules (original)
+++ trunk/libtext-csv-xs-perl/debian/rules Mon Oct  5 15:26:59 2009
@@ -1,3 +1,10 @@
 #!/usr/bin/make -f
+
+TMP = $(CURDIR)/debian/libtext-csv-xs-perl
+
 %:
 	dh $@
+
+override_dh_installexamples:
+	dh_installexamples
+	sed -i s,/pro/bin/perl,/usr/bin/perl, $(TMP)/usr/share/doc/libtext-csv-xs-perl/examples/*

Modified: trunk/libtext-csv-xs-perl/examples/csv-check
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/examples/csv-check?rev=45381&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/examples/csv-check (original)
+++ trunk/libtext-csv-xs-perl/examples/csv-check Mon Oct  5 15:26:59 2009
@@ -65,6 +65,7 @@
     quote_char     => $quo,
     binary         => 1,
     keep_meta_info => 1,
+    auto_diag      => 1,
     });
 
 sub done

Modified: trunk/libtext-csv-xs-perl/examples/csv2xls
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtext-csv-xs-perl/examples/csv2xls?rev=45381&op=diff
==============================================================================
--- trunk/libtext-csv-xs-perl/examples/csv2xls (original)
+++ trunk/libtext-csv-xs-perl/examples/csv2xls Mon Oct  5 15:26:59 2009
@@ -6,7 +6,7 @@
 use strict;
 use warnings;
 
-our $VERSION = "1.6";
+our $VERSION = "1.61";
 
 sub usage
 {
@@ -53,7 +53,7 @@
     ) or usage (1);
 
 my $title = @ARGV && -f $ARGV[0] ? $ARGV[0] : "csv2xls";
-($xls ||= $title) =~ s/\.csv$/.xls/;
+($xls ||= $title) =~ s/(?:\.csv)?$/.xls/i;
 
 -s $xls && $frc and unlink $xls;
 if (-s $xls) {




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