Closed afresh1 closed 4 years ago
It might help to tell which version of perl on what OS and which version of Text::CSV_XS you are using. I now see what you mean.
#!/pro/bin/perl
use 5.16.2;
use warnings;
use Text::CSV_XS;
binmode STDOUT, ":encoding(utf-8)";
binmode STDERR, ":encoding(utf-8)";
my $h = shift // 0;
sub show {
say join ", " => map { "\x{231e}$_\x{231d}" } @_;
} # show
my $csv = Text::CSV_XS->new ({ auto_diag => 2 });
if ($h) {
say "Calling header";
show ($csv->header (*DATA)); # comment out this line to hide the bug
}
while (my $row = $csv->getline (*DATA)) {
show (@$row);
}
say "EOF: ", $csv->eof ? "Yes" : "No";
$csv->error_diag;
__DATA__
Foo,Bar,Baz
a,xxx,1
b,"xx"xx", 2
c, foo , 3
$ perl issue#19.pl 0
⌞Foo⌝, ⌞Bar⌝, ⌞Baz⌝
⌞a⌝, ⌞xxx⌝, ⌞1⌝
# CSV_XS ERROR: 2023 - EIQ - QUO character not allowed @ rec 2 pos 6 field 2
Exit 2
$ perl issue#19.pl 1
Calling header
⌞foo⌝, ⌞bar⌝, ⌞baz⌝
⌞a⌝, ⌞xxx⌝, ⌞1⌝
EOF: No
# CSV_XS ERROR: 2023 - EIQ - QUO character not allowed @ rec 3 pos 6 field 2
Exit 2
I apologize, I should have included OS and perl version information, although it doesn't seem to make a difference. I did say 1.40 in the description, but wasn't clear that was Text::CSV_XS 1.40. I ran the script with the latest release of each even version of perl from 5.10 through 5.30 and on perl 5.31 all with the same results. This was both on linux and OpenBSD.
I can reproduce, and I will look into it. $work interferes though. And again, thanks for reporting!
@afresh1 can you pull and try? I think I fixed it. (tests now also included)
That does seem to work the way I expect, thank you!
@afresh1 any feedback?
Feedback beyond the fix seems to be good? I am not sure what feedback you are asking for.
/me missed that you closed it. sorry.
In this short test script, I expect a "CSV_XS ERROR: 2023 - EIQ - QUO character not allowed @ rec 2 pos 6 field 2" exception in the loop, and that happens if the line calling
$csv->header
is commented out. However, after calling->header
it seemsText::CSV_XS::error_diag
is getting called with no arguments and so$self
is falsy and so thecroak
is never triggered. Instead we fall through to the "why no auto_diag" exception.