Skip to content

Commit

Permalink
Import of HMBRAND/Text-CSV_XS-0.61 from CPAN.
Browse files Browse the repository at this point in the history
gitpan-cpan-distribution: Text-CSV_XS
gitpan-cpan-version:      0.61
gitpan-cpan-path:         HMBRAND/Text-CSV_XS-0.61.tgz
gitpan-cpan-author:       HMBRAND
gitpan-cpan-maturity:     released
  • Loading branch information
H.Merijn Brand authored and Gitpan committed Oct 22, 2014
1 parent 441b62d commit 11808ba
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 12 deletions.
14 changes: 8 additions & 6 deletions CSV_XS.pm
Expand Up @@ -30,7 +30,7 @@ use DynaLoader ();
use Carp;

use vars qw( $VERSION @ISA );
$VERSION = "0.60";
$VERSION = "0.61";
@ISA = qw( DynaLoader );
bootstrap Text::CSV_XS $VERSION;

Expand Down Expand Up @@ -141,6 +141,7 @@ sub _set_attr_N
{
my ($self, $name, $val) = @_;
$self->{$name} = $val;
$self->{_CACHE} or return;
my @cache = unpack "C*", $self->{_CACHE};
my $i = $_cache_id{$name};
$cache[$i++] = $_ for unpack "C*", pack "N", $val;
Expand Down Expand Up @@ -944,15 +945,16 @@ invalid argument.
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:
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);
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(3)> and L<IO::Wrap(3)>
for details.
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(3)> and
L<IO::Wrap(3)> 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 ()>,
Expand Down
8 changes: 6 additions & 2 deletions CSV_XS.xs
Expand Up @@ -249,7 +249,6 @@ static void cx_SetupCsv (pTHX_ csv_t *csv, HV *self)
if ((svp = hv_fetchs (self, "eol", FALSE)) && *svp && SvOK (*svp)) {
csv->eol = SvPV (*svp, len);
csv->eol_len = len;
csv->eol_is_cr = 0;
}
}
csv->is_bound =
Expand Down Expand Up @@ -308,6 +307,11 @@ static void cx_SetupCsv (pTHX_ csv_t *csv, HV *self)
csv->types_len = len;
}

csv->is_bound = 0;
if ((svp = hv_fetchs (self, "_is_bound", FALSE)) && *svp && SvOK(*svp)) {
csv->is_bound = SvIV(*svp);
}

csv->binary = bool_opt ("binary");
csv->keep_meta_info = bool_opt ("keep_meta_info");
csv->always_quote = bool_opt ("always_quote");
Expand Down Expand Up @@ -1161,7 +1165,7 @@ static int cx_xsCombine (pTHX_ HV *hv, AV *av, SV *io, bool useIO)
SetupCsv (&csv, hv);
csv.useIO = useIO;
#if (PERL_BCDVERSION >= 0x5008000)
if (*csv.eol)
if (csv.eol && *csv.eol)
PL_ors_sv = &PL_sv_undef;
#endif
result = Combine (&csv, io, av);
Expand Down
6 changes: 6 additions & 0 deletions ChangeLog
@@ -1,3 +1,9 @@
2009-03-08 0.61 - H.Merijn Brand <h.m.brand@xs4all.nl>

* valgrind found a possible uninitialized value
* Restriction in print () was only for really old perls
* Fix for bind_columns () initialisation (vincent, RT#43927)

2009-01-27 0.60 - H.Merijn Brand <h.m.brand@xs4all.nl>

* Optimize for threaded perls. (Goro Fuji, RT#42517)
Expand Down
4 changes: 2 additions & 2 deletions META.yml
@@ -1,6 +1,6 @@
--- #YAML:1.1
name: Text-CSV_XS
version: 0.60
version: 0.61
abstract: Comma-Separated Values manipulation routines
license: perl
author:
Expand All @@ -10,7 +10,7 @@ distribution_type: module
provides:
Text::CSV_XS:
file: CSV_XS.pm
version: 0.60
version: 0.61
requires:
perl: 5.005
DynaLoader: 0
Expand Down
2 changes: 1 addition & 1 deletion ppport.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 23 additions & 1 deletion t/70_rt.t
Expand Up @@ -4,7 +4,7 @@ use strict;
$^W = 1;

#use Test::More "no_plan";
use Test::More tests => 86;
use Test::More tests => 91;

BEGIN {
use_ok "Text::CSV_XS", ();
Expand Down Expand Up @@ -183,6 +183,26 @@ while (<DATA>) {
}
}

{ # http://rt.cpan.org/Ticket/Display.html?id=43927
# 43927: Is bind_columns broken or am I using it wrong?
$rt = 43927;
SKIP: {
open FH, ">$csv_file";
print FH @{$input{$rt}};
close FH;
my ($c1, $c2);
ok (my $csv = Text::CSV_XS->new ({ binary => 1 }), "RT-$rt: $desc{$rt}");
ok ($csv->bind_columns (\$c1, \$c2), "bind columns");
open FH, "<$csv_file";
ok (my $row = $csv->getline (*FH), "getline () with bound columns");
$csv->error_diag ();
close FH;
unlink $csv_file;
is_deeply ($row, [], "should return empty ref");
is_deeply ([ $c1, $c2], [ 1, 2 ], "fields ()");
}
}

__END__
«24386» - \t doesn't work in _XS, works in _PP
VIN StockNumber Year Make Model MD Engine EngineSize Transmission DriveTrain Trim BodyStyle CityFuel HWYFuel Mileage Color InteriorColor InternetPrice RetailPrice Notes ShortReview Certified NewUsed Image_URLs Equipment
Expand Down Expand Up @@ -215,3 +235,5 @@ code,name,price,description
«42642» - failure on unusual quote/sep values
þDOGþþCATþþWOMBATþþBANDERSNATCHþ
þ0þþ1þþ2þþ3þ
«43927» - Is bind_columns broken or am I using it wrong?
1,2

0 comments on commit 11808ba

Please sign in to comment.