From: Mark-Jason Dominus Date: Wed, 30 Oct 2002 17:27:53 +0000 (+0000) Subject: [perl #18165] "0" fails as right-hand argument to .. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=545956b788eca1693eabb4527163db9c8186832c;p=p5sagit%2Fp5-mst-13.2.git [perl #18165] "0" fails as right-hand argument to .. From: Mark-Jason Dominus (via RT) Message-Id: (Fixed by making an exception for .."0" in pp_flop.) p4raw-id: //depot/perl@18073 --- diff --git a/pp_ctl.c b/pp_ctl.c index 07069ca..a482489 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -943,10 +943,15 @@ PP(pp_flop) if (SvGMAGICAL(right)) mg_get(right); + /* This code tries to decide if "$left .. $right" should use the + magical string increment, or if the range is numeric (we make + an exception for .."0" [#18165]). AMS 20021031. */ + if (SvNIOKp(left) || !SvPOKp(left) || SvNIOKp(right) || !SvPOKp(right) || (looks_like_number(left) && *SvPVX(left) != '0' && - looks_like_number(right) && *SvPVX(right) != '0')) + looks_like_number(right) && (*SvPVX(right) != '0' || + SvCUR(right) == 1))) { if (SvNV(left) < IV_MIN || SvNV(right) > IV_MAX) DIE(aTHX_ "Range iterator outside integer range"); diff --git a/t/op/range.t b/t/op/range.t index e8aecf5..862e64d 100755 --- a/t/op/range.t +++ b/t/op/range.t @@ -1,6 +1,6 @@ #!./perl -print "1..15\n"; +print "1..16\n"; print join(':',1..5) eq '1:2:3:4:5' ? "ok 1\n" : "not ok 1\n"; @@ -73,3 +73,7 @@ for my $x ("0"..-1) { print "not "; } print "ok 15\n"; + +# [#18165] Should allow "-4".."0", broken by #4730. (AMS 20021031) +print "not " unless 5 == (() = "-4".."0"); +print "ok 16\n";