Skip to content

Commit

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

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

Expand Down Expand Up @@ -134,7 +134,7 @@ my %_cache_id = ( # Keep in sync with XS!
eol_is_cr => 20,
has_types => 21,
verbatim => 22,
blank_is_undef => 23,
empty_is_undef => 23,
auto_diag => 24,

_is_bound => 25, # 25 .. 28
Expand Down
22 changes: 11 additions & 11 deletions CSV_XS.xs
Expand Up @@ -8,6 +8,7 @@
#include <perl.h>
#include <XSUB.h>
#define NEED_PL_parser
#define DPPP_PL_parser_NO_DUMMY
#define NEED_sv_2pv_flags
#define NEED_load_module
#define NEED_newRV_noinc
Expand Down Expand Up @@ -213,10 +214,10 @@ static SV *cx_SetDiag (pTHX_ csv_t *csv, int xse)
SV *err = SvDiag (xse);

if (err)
hv_store (csv->self, "_ERROR_DIAG", 11, err, 0);
(void)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);
(void)hv_store (csv->self, "_ERROR_POS", 10, newSViv (0), 0);
(void)hv_store (csv->self, "_ERROR_INPUT", 12, newSVpvs (""), 0);
}
if (err && csv->pself && csv->auto_diag) {
ENTER;
Expand Down Expand Up @@ -375,7 +376,7 @@ static void cx_SetupCsv (pTHX_ csv_t *csv, HV *self, SV *pself)
csv->cache[CACHE_ID__is_bound + 3] = (csv->is_bound & 0x000000FF);

if ((csv->tmp = newSVpvn ((char *)csv->cache, CACHE_SIZE)))
hv_store (self, "_CACHE", 6, csv->tmp, 0);
(void)hv_store (self, "_CACHE", 6, csv->tmp, 0);
}

if (csv->is_bound) {
Expand Down Expand Up @@ -530,7 +531,7 @@ static int cx_Combine (pTHX_ csv_t *csv, SV *dst, AV *fields)
#define ParseError(csv,xse,pos) cx_ParseError (aTHX_ csv, xse, pos)
static void cx_ParseError (pTHX_ csv_t *csv, int xse, int pos)
{
hv_store (csv->self, "_ERROR_POS", 10, newSViv (pos), 0);
(void)hv_store (csv->self, "_ERROR_POS", 10, newSViv (pos), 0);
if (csv->tmp) {
if (hv_store (csv->self, "_ERROR_INPUT", 12, csv->tmp, 0))
SvREFCNT_inc (csv->tmp);
Expand Down Expand Up @@ -1087,16 +1088,16 @@ static int cx_xsParse (pTHX_ SV *self, HV *hv, AV *av, AV *avf, SV *src, bool us
csv.utf8 = SvUTF8 (src);
csv.bptr = SvPV (src, csv.size);
}
hv_delete (hv, "_ERROR_INPUT", 12, G_DISCARD);
(void)hv_delete (hv, "_ERROR_INPUT", 12, G_DISCARD);
result = Parse (&csv, src, av, avf);
if (csv.useIO & useIO_EOF)
hv_store (hv, "_EOF", 4, &PL_sv_yes, 0);
(void)hv_store (hv, "_EOF", 4, &PL_sv_yes, 0);
else
hv_store (hv, "_EOF", 4, &PL_sv_no, 0);
(void)hv_store (hv, "_EOF", 4, &PL_sv_no, 0);
if (csv.useIO) {
if (csv.keep_meta_info) {
hv_delete (hv, "_FFLAGS", 7, G_DISCARD);
hv_store (hv, "_FFLAGS", 7, newRV_noinc ((SV *)avf), 0);
(void)hv_delete (hv, "_FFLAGS", 7, G_DISCARD);
(void)hv_store (hv, "_FFLAGS", 7, newRV_noinc ((SV *)avf), 0);
}
else {
av_undef (avf);
Expand Down Expand Up @@ -1176,7 +1177,6 @@ SetDiag (self, xse, ...)
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));
}
Expand Down
5 changes: 5 additions & 0 deletions ChangeLog
@@ -1,3 +1,8 @@
2009-08-08 0.67 - H.Merijn Brand <h.m.brand@xs4all.nl>

* Fix empty_diag typo for attribute handler
* Fix AUTOMATED_TESTING erroneous skip

2009-08-07 0.66 - H.Merijn Brand <h.m.brand@xs4all.nl>

* Reordered examples in doc to show best method first
Expand Down
1 change: 1 addition & 0 deletions MANIFEST
Expand Up @@ -26,6 +26,7 @@ t/70_rt.t Tests based on RT reports
t/75_hashref.t getline_hr related tests
t/76_magic.t array_ref from magig
t/80_diag.t Error diagnostics
t/81_subclass.t Subclassed
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
Expand Down
4 changes: 2 additions & 2 deletions META.yml
@@ -1,6 +1,6 @@
--- #YAML:1.1
name: Text-CSV_XS
version: 0.66
version: 0.67
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.66
version: 0.67
requires:
perl: 5.005
DynaLoader: 0
Expand Down
7 changes: 5 additions & 2 deletions t/12_acc.t
Expand Up @@ -3,7 +3,7 @@
use strict;
$^W = 1; # use warnings core since 5.6

use Test::More tests => 83;
use Test::More tests => 86;

BEGIN {
use_ok "Text::CSV_XS";
Expand All @@ -24,8 +24,9 @@ is ($csv->allow_loose_quotes, 0, "allow_loose_quotes");
is ($csv->allow_loose_escapes, 0, "allow_loose_escapes");
is ($csv->allow_whitespace, 0, "allow_whitespace");
is ($csv->blank_is_undef, 0, "blank_is_undef");
is ($csv->verbatim, 0, "verbatim");
is ($csv->empty_is_undef, 0, "empty_is_undef");
is ($csv->auto_diag, 0, "auto_diag");
is ($csv->verbatim, 0, "verbatim");

is ($csv->binary (1), 1, "binary (1)");
my @fld = ( 'txt =, "Hi!"', "Yes", "", 2, undef, "1.09", "\r", undef );
Expand All @@ -45,6 +46,8 @@ is ($csv->allow_loose_quotes (1), 1, "allow_loose_quotes (1)");
is ($csv->allow_loose_escapes (1), 1, "allow_loose_escapes (1)");
is ($csv->allow_whitespace (1), 1, "allow_whitespace (1)");
is ($csv->blank_is_undef (1), 1, "blank_is_undef (1)");
is ($csv->empty_is_undef (1), 1, "empty_is_undef (1)");
is ($csv->auto_diag (1), 1, "auto_diag (1)");
is ($csv->verbatim (1), 1, "verbatim (1)");
is ($csv->escape_char ("\\"), "\\", "escape_char (\\)");
ok ($csv->combine (@fld), "combine");
Expand Down
24 changes: 3 additions & 21 deletions t/80_diag.t
Expand Up @@ -3,7 +3,7 @@
use strict;
$^W = 1;

use Test::More tests => 94;
use Test::More tests => 90;
#use Test::More "no_plan";

my %err;
Expand Down Expand Up @@ -57,8 +57,7 @@ parse_err 2032, 2, qq{ \r};
parse_err 2034, 4, qq{1, "bar",2};
parse_err 2037, 1, qq{\0 };

unless (($ENV{AUTOMATED_TESTING} || 0) == "1") {
my @warn;
{ my @warn;
local $SIG{__WARN__} = sub { push @warn, @_ };
$csv->error_diag ();
ok (@warn == 1, "Got error message");
Expand All @@ -85,26 +84,9 @@ $csv = Text::CSV_XS->new ({ auto_diag => 1 });
ok (@warn == 1, "1 - One error");
like ($warn[0], qr '^# CSV_XS ERROR: 2027 -', "1 - error message");
}
{ my @warn;
ok ($csv->{auto_diag} = 2, "auto_diag = 2 to die");
{ ok ($csv->{auto_diag} = 2, "auto_diag = 2 to die");
eval { $csv->parse ('"","') };
like ($@, qr '^# CSV_XS ERROR: 2027 -', "2 - error message");
}

package Text::CSV_XS::Subclass;

use base "Text::CSV_XS";

use Test::More;

ok (1, "Subclassed");

my $csvs = Text::CSV_XS::Subclass->new ();
is ($csvs->error_diag (), "", "Last failure for new () - OK");

is (Text::CSV_XS::Subclass->new ({ ecs_char => ":" }), undef, "Unsupported option");

is (Text::CSV_XS::Subclass->error_diag (),
"INI - Unknown attribute 'ecs_char'", "Last failure for new () - FAIL");

1;
28 changes: 28 additions & 0 deletions t/81_subclass.t
@@ -0,0 +1,28 @@
#!/usr/bin/perl

package Text::CSV_XS::Subclass;

BEGIN { require Text::CSV_XS; } # needed for perl5.005

use strict;
$^W = 1;
$| = 1;

use base "Text::CSV_XS";

use Test::More tests => 5;

ok (1, "Subclassed");

my $csvs = Text::CSV_XS::Subclass->new ();
is ($csvs->error_diag (), "", "Last failure for new () - OK");

my $sc_csv;
eval { $sc_csv = Text::CSV_XS::Subclass->new ({ ecs_char => ":" }); };
is ($sc_csv, undef, "Unsupported option");
is ($@, "", "error");

is (Text::CSV_XS::Subclass->error_diag (),
"INI - Unknown attribute 'ecs_char'", "Last failure for new () - FAIL");

1;

0 comments on commit c436091

Please sign in to comment.