r6411 - in /branches/upstream/libtext-csv-perl/current: CSV_XS.pm CSV_XS.xs ChangeLog META.yml examples/csv2xls t/30_types.t

dmn at users.alioth.debian.org dmn at users.alioth.debian.org
Fri Aug 10 10:12:05 UTC 2007


Author: dmn
Date: Fri Aug 10 10:12:05 2007
New Revision: 6411

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

Modified:
    branches/upstream/libtext-csv-perl/current/CSV_XS.pm
    branches/upstream/libtext-csv-perl/current/CSV_XS.xs
    branches/upstream/libtext-csv-perl/current/ChangeLog
    branches/upstream/libtext-csv-perl/current/META.yml
    branches/upstream/libtext-csv-perl/current/examples/csv2xls
    branches/upstream/libtext-csv-perl/current/t/30_types.t

Modified: branches/upstream/libtext-csv-perl/current/CSV_XS.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libtext-csv-perl/current/CSV_XS.pm?rev=6411&op=diff
==============================================================================
--- branches/upstream/libtext-csv-perl/current/CSV_XS.pm (original)
+++ branches/upstream/libtext-csv-perl/current/CSV_XS.pm Fri Aug 10 10:12:05 2007
@@ -28,7 +28,7 @@
 use DynaLoader ();
 
 use vars   qw( $VERSION @ISA );
-$VERSION = "0.30";
+$VERSION = "0.31";
 @ISA     = qw( DynaLoader );
 
 sub PV { 0 }

Modified: branches/upstream/libtext-csv-perl/current/CSV_XS.xs
URL: http://svn.debian.org/wsvn/branches/upstream/libtext-csv-perl/current/CSV_XS.xs?rev=6411&op=diff
==============================================================================
--- branches/upstream/libtext-csv-perl/current/CSV_XS.xs (original)
+++ branches/upstream/libtext-csv-perl/current/CSV_XS.xs Fri Aug 10 10:12:05 2007
@@ -956,7 +956,7 @@
 			break;
 
 		    case CSV_XS_TYPE_NV:
-			sv_setnv (*svp, SvIV (*svp));
+			sv_setnv (*svp, SvNV (*svp));
 			break;
 
 		    default:

Modified: branches/upstream/libtext-csv-perl/current/ChangeLog
URL: http://svn.debian.org/wsvn/branches/upstream/libtext-csv-perl/current/ChangeLog?rev=6411&op=diff
==============================================================================
--- branches/upstream/libtext-csv-perl/current/ChangeLog (original)
+++ branches/upstream/libtext-csv-perl/current/ChangeLog Fri Aug 10 10:12:05 2007
@@ -1,3 +1,11 @@
+2007-07-23  0.31 - H.Merijn Brand   <h.m.brand at xs4all.nl>
+
+	* Removed prototypes in examples/csv2xls
+	* Improved usage for examples/csv2xls (GetOpt::Long now does --help/-?)
+	* Extended examples/csv2xls to deal with Unicode (-u)
+	* Serious bug in Text::CSV_XS::NV () type setting, causing the
+	  resulting field to be truncated to IV
+
 2007-06-21  0.30 - H.Merijn Brand   <h.m.brand at xs4all.nl>
 
 	* ,\rx, is definitely an error without binary (used to HANG!)

Modified: branches/upstream/libtext-csv-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libtext-csv-perl/current/META.yml?rev=6411&op=diff
==============================================================================
--- branches/upstream/libtext-csv-perl/current/META.yml (original)
+++ branches/upstream/libtext-csv-perl/current/META.yml Fri Aug 10 10:12:05 2007
@@ -1,15 +1,15 @@
 --- #YAML:1.0
 name:                Text-CSV_XS
-version:             0.30
+version:             0.31
 abstract:            Comma-Separated Values manipulation routines
 license:             perl
-generated_by:        ExtUtils::MakeMaker version 6.32
+generated_by:        ExtUtils::MakeMaker version 6.36
 distribution_type:   module
 requires:     
     Test::Harness:                 0
     Test::More:                    0
 meta-spec:
-    url:     http://module-build.sourceforge.net/META-spec-v1.2.html
-    version: 1.2
+    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
+    version: 1.3
 author:
     - H.Merijn Brand <h.merijn at xs4all.nl>

Modified: branches/upstream/libtext-csv-perl/current/examples/csv2xls
URL: http://svn.debian.org/wsvn/branches/upstream/libtext-csv-perl/current/examples/csv2xls?rev=6411&op=diff
==============================================================================
--- branches/upstream/libtext-csv-perl/current/examples/csv2xls (original)
+++ branches/upstream/libtext-csv-perl/current/examples/csv2xls Fri Aug 10 10:12:05 2007
@@ -1,16 +1,17 @@
 #!/usr/bin/perl
 
 # csv2xls: Convert csv to xls
-#	   (m)'07 [06-May-2007]
-
-our $VERSION = "1.0";
+#	   (m)'07 [03 Jul 2007]
 
 use strict;
 use warnings;
 
-sub usage ()
+our $VERSION = "1.2";
+
+sub usage
 {
-    print STDERR <<EOU;
+    my $err = shift and select STDERR;
+    print <<EOU;
 usage: csv2xls [-s <sep>] [-q <quot>] [-w <width>] [-d <dtfmt>]
                [-o <xls>] [file.csv]
        -s <sep>   use <sep>   as seperator char. Auto-detect, default = ';'
@@ -21,11 +22,10 @@
 		  if from standard input, defaults to csv2xls.xls
        -f         force usage of <xls> if already exists (unlink before use)
        -d <dtfmt> use <dtfmt> as date formats.   Default = 'dd-mm-yyyy'
+       -u         CSV is UTF8
 EOU
-    exit;
+    exit $err;
     } # usage
-
- at ARGV == 1 and $ARGV[0] eq "-?" || $ARGV[0] =~ m/^-+help$/ and usage ();
 
 use Getopt::Long qw(:config bundling nopermute passthrough);
 my $sep;	# Set after reading first line in a flurry attempt to auto-detect
@@ -33,16 +33,20 @@
 my $wdt = 4;	# Default minimal column width
 my $xls;	# Excel out file name
 my $frc = 0;	# Force use of file
+my $utf = 0;	# Data is encoded in Unicode
 my $dtf = "dd-mm-yyyy";	# Date format
 
 GetOptions (
+    "help|?"	=> sub { usage (0); },
+
     "c|s=s"	=> \$sep,
     "q=s"	=> \$quo,
     "w=i"	=> \$wdt,
     "o|x=s"	=> \$xls,
     "d=s"	=> \$dtf,
     "f"		=> \$frc,
-    ) or usage;
+    "u"		=> \$utf,
+    ) or usage (1);
 
 my $title = @ARGV && -f $ARGV[0] ? $ARGV[0] : "csv2xls";
 ($xls //= $title) =~ s/\.csv$/.xls/;
@@ -60,6 +64,7 @@
 use Date::Calc qw( Delta_Days Days_in_Month );
 use Spreadsheet::WriteExcel;
 use Spreadsheet::WriteExcel::Big;
+use Encode qw( from_to );
 
 my $csv;
 
@@ -94,7 +99,12 @@
 	    # Yeah I know it should be a ',' (hence Csv), but the majority
 	    # of the csv files to be shown comes from fucking Micky$hit,
 	    # that uses semiColon ';' instead.
-	$csv = Text::CSV_XS-> new ({ sep_char => $sep, quote_char => $quo, binary => 1 });
+	$csv = Text::CSV_XS-> new ({
+	    sep_char       => $sep,
+	    quote_char     => $quo,
+	    binary         => 1,
+	    keep_meta_info => 1,
+	    });
 	}
     $csv->parse ($_);
     my @row = $csv->fields () or next;
@@ -104,8 +114,20 @@
 	my $l = length $val;
 	$l > $w[$c] and $w[$c] = $l;
 
+	if ($utf and $csv->is_binary ($c)) {
+	    from_to ($val, "utf-8", "ucs2");
+	    $wks->write_unicode ($h, $c, $val);
+	    next;
+	    }
+
 	if ($csv->is_quoted ($c)) {
-	    $wks->write_string ($h, $c, $val);
+	    if ($utf) {
+		from_to ($val, "utf-8", "ucs2");
+		$wks->write_unicode ($h, $c, $val);
+		}
+	    else {
+		$wks->write_string  ($h, $c, $val);
+		}
 	    next;
 	    }
 

Modified: branches/upstream/libtext-csv-perl/current/t/30_types.t
URL: http://svn.debian.org/wsvn/branches/upstream/libtext-csv-perl/current/t/30_types.t?rev=6411&op=diff
==============================================================================
--- branches/upstream/libtext-csv-perl/current/t/30_types.t (original)
+++ branches/upstream/libtext-csv-perl/current/t/30_types.t Fri Aug 10 10:12:05 2007
@@ -3,7 +3,7 @@
 use strict;
 $^W = 1;
 
-use Test::More tests => 21;
+use Test::More tests => 25;
 
 BEGIN {
     use_ok "Text::CSV_XS", ();
@@ -38,6 +38,12 @@
 # should be "\001\000\002"
 is ($csv->{_types}, $inp,			"IV PV NV");
 
+ok ($csv->parse ("2.55,CSFDATVM01,3.77"),	"parse ()");
+my @fields = $csv->fields ();
+is ($fields[0], "2",				"Field 1");
+is ($fields[1], "CSFDATVM01",			"Field 2");
+is ($fields[2], "3.77",				"Field 3");
+
 ok ($csv->combine ("", "", "1.00"),		"combine ()");
 is ($csv->string, ',,1.00',			"string");
 
@@ -47,7 +53,7 @@
 ok ($csv->parse ($csv->string ()),		"parse (combine ())");
 like ($warning, qr/numeric/,			"numeric warning");
 
-my @fields = $csv->fields ();
+ at fields = $csv->fields ();
 is ($fields[0], "0",				"Field 1");
 is ($fields[1], "",				"Field 2");
 is ($fields[2], "1",				"Field 3");




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