diff options
author | Mike Guy <mjtg@cam.ac.uk> | 2000-08-10 16:50:54 +0100 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2000-08-11 00:07:53 +0000 |
commit | 0a3ece5567993cdf5de26e22ebce420ba267a0f6 (patch) | |
tree | a6bc7487d1b9a9184d7721017583b8b7f17b857c | |
parent | 91e6cb7768546a70d950faf2589360c55fa9771a (diff) | |
download | perl-0a3ece5567993cdf5de26e22ebce420ba267a0f6.tar.gz |
Fixes to looking-like-number to keep behaviour as it was in 5.005_03.
Subject: Re: [ID 20000810.002] $a["1foo"] same as $a[0]
Message-Id: <E13Mtfa-0005Ge-00@libra.cus.cam.ac.uk>
p4raw-id: //depot/perl@6583
-rw-r--r-- | sv.c | 17 | ||||
-rwxr-xr-x | t/op/int.t | 8 |
2 files changed, 11 insertions, 14 deletions
@@ -1569,22 +1569,13 @@ Perl_sv_2iv(pTHX_ register SV *sv) goto ret_iv_max; } } - else if (numtype) { - /* The NV may be reconstructed from IV - safe to cache IV, - which may be calculated by atol(). */ - if (SvTYPE(sv) == SVt_PV) - sv_upgrade(sv, SVt_PVIV); - (void)SvIOK_on(sv); - SvIVX(sv) = Atol(SvPVX(sv)); - } - else { /* Not a number. Cache 0. */ - dTHR; - + else { /* The NV may be reconstructed from IV - safe to cache IV, + which may be calculated by atol(). */ if (SvTYPE(sv) < SVt_PVIV) sv_upgrade(sv, SVt_PVIV); (void)SvIOK_on(sv); - SvIVX(sv) = 0; - if (ckWARN(WARN_NUMERIC)) + SvIVX(sv) = Atol(SvPVX(sv)); + if (! numtype && ckWARN(WARN_NUMERIC)) not_a_number(sv); } } diff --git a/t/op/int.t b/t/op/int.t index 6ac0866a2b..bf2100264d 100755 --- a/t/op/int.t +++ b/t/op/int.t @@ -5,7 +5,7 @@ BEGIN { unshift @INC, '../lib'; } -print "1..6\n"; +print "1..7\n"; # compile time evaluation @@ -28,3 +28,9 @@ print $x == -7 ? "ok 5\n" : "# expected -7, got $x\nnot ok 5\n"; $y = (3/-10)*-10; print $x+$y == 3 && abs($x) < 10 ? "ok 6\n" : "not ok 6\n"; } + +# check bad strings still get converted + +@x = ( 6, 8, 10); +print "not " if $x["1foo"] != 8; +print "ok 7\n"; |