Skip to content

Commit 61bacb9

Browse files
bookmauke
authored andcommitted
[Data-Dumper] fix string comparisons with $] to use numeric comparison instead
The fix follows Zefram's suggestion from https://www.nntp.perl.org/group/perl.perl5.porters/2012/05/msg186846.html > On older perls, however, $] had a numeric value that was built up using > floating-point arithmetic, such as 5+0.006+0.000002. This would not > necessarily match the conversion of the complete value from string form > [perl #72210]. You can work around that by explicitly stringifying > $] (which produces a correct string) and having *that* numify (to a > correctly-converted floating point value) for comparison. I cultivate > the habit of always stringifying $] to work around this, regardless of > the threshold where the bug was fixed. So I'd write > > use if "$]" >= 5.014, warnings => "non_unicode";
1 parent 992f768 commit 61bacb9

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

dist/Data-Dumper/Dumper.pm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use warnings;
1717
use 5.008_001;
1818
require Exporter;
1919

20-
use constant IS_PRE_516_PERL => $] < 5.016;
20+
use constant IS_PRE_516_PERL => "$]" < 5.016;
2121
use constant SUPPORTS_CORE_BOOLS => defined &builtin::is_bool;
2222

2323
use Carp ();
@@ -30,7 +30,7 @@ our ( $Indent, $Trailingcomma, $Purity, $Pad, $Varname, $Useqq, $Terse, $Freezer
3030
our ( @ISA, @EXPORT, @EXPORT_OK, $VERSION );
3131

3232
BEGIN {
33-
$VERSION = '2.190'; # Don't forget to set version and release
33+
$VERSION = '2.191'; # Don't forget to set version and release
3434
# date in POD below!
3535

3636
@ISA = qw(Exporter);
@@ -210,7 +210,7 @@ sub Dump {
210210
return &Dumpxs
211211
unless $Data::Dumper::Useperl || (ref($_[0]) && $_[0]->{useperl})
212212
# Use pure perl version on earlier releases on EBCDIC platforms
213-
|| (! $IS_ASCII && $] lt 5.021_010);
213+
|| (! $IS_ASCII && "$]" < 5.021_010);
214214
return &Dumpperl;
215215
}
216216

@@ -1456,7 +1456,7 @@ modify it under the same terms as Perl itself.
14561456
14571457
=head1 VERSION
14581458
1459-
Version 2.190
1459+
Version 2.191
14601460
14611461
=head1 SEE ALSO
14621462

dist/Data-Dumper/t/dumper.t

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,7 +1670,7 @@ EOW
16701670
{
16711671
# [github #18614 - handling of Unicode characters in regexes]
16721672
# [github #18764 - ... without breaking subsequent Latin-1]
1673-
if ($] lt '5.010') {
1673+
if ("$]" < 5.010) {
16741674
SKIP_BOTH("Incomplete support for UTF-8 in old perls");
16751675
last;
16761676
}
@@ -1683,11 +1683,11 @@ EOW
16831683
# '\xb6'
16841684
#];
16851685
EOW
1686-
if ($] lt '5.010001') {
1686+
if ("$]" < 5.010001) {
16871687
$want =~ s!qr/!qr/(?-xism:!g;
16881688
$want =~ s!/,!)/,!g;
16891689
}
1690-
elsif ($] gt '5.014') {
1690+
elsif ("$]" > 5.014) {
16911691
$want =~ s{/(,?)$}{/u$1}mg;
16921692
}
16931693
my $want_xs = $want;
@@ -1713,7 +1713,7 @@ EOW
17131713
# qr/ $bs$bs$bs\\/ /
17141714
#];
17151715
EOW
1716-
if ($] lt '5.010001') {
1716+
if ("$]" < 5.010001) {
17171717
$want =~ s!qr/!qr/(?-xism:!g;
17181718
$want =~ s! /! )/!g;
17191719
}
@@ -1724,7 +1724,7 @@ EOW
17241724
#############
17251725
{
17261726
# [github #18614, github #18764, perl #58608 corner cases]
1727-
if ($] lt '5.010') {
1727+
if ("$]" < 5.010) {
17281728
SKIP_BOTH("Incomplete support for UTF-8 in old perls");
17291729
last;
17301730
}
@@ -1738,11 +1738,11 @@ EOW
17381738
# '\xB6'
17391739
#];
17401740
EOW
1741-
if ($] lt '5.010001') {
1741+
if ("$]" < 5.010001) {
17421742
$want =~ s!qr/!qr/(?-xism:!g;
17431743
$want =~ s!/,!)/,!g;
17441744
}
1745-
elsif ($] gt '5.014') {
1745+
elsif ("$]" > 5.014) {
17461746
$want =~ s{/(,?)$}{/u$1}mg;
17471747
}
17481748
my $want_xs = $want;
@@ -1772,10 +1772,10 @@ EOW
17721772
# '\xB6'
17731773
#];
17741774
EOW
1775-
if ($] lt '5.014') {
1775+
if ("$]" < 5.014) {
17761776
$want =~ s{/u,$}{/,}mg;
17771777
}
1778-
if ($] lt '5.010001') {
1778+
if ("$]" < 5.010001) {
17791779
$want =~ s!qr/!qr/(?-xism:!g;
17801780
$want =~ s!/,!)/,!g;
17811781
}

0 commit comments

Comments
 (0)