Date: Tue, 17 Dec 2002 03:56:39 -0500 (EST) From: parv <parv_fm@emailgroups.net> To: FreeBSD-gnats-submit@FreeBSD.org Cc: tobez@FreeBSD.org Subject: ports/46322: lang/perl5 - string '0' (zero) is not converted to number as range operand Message-ID: <20021217085639.0E1E1B930@moo.holy.cow>
next in thread | raw e-mail | index | archive | help
>Number: 46322 >Category: ports >Synopsis: lang/perl5 - string '0' (zero) is not converted to number as range operand >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Dec 17 01:00:20 PST 2002 >Closed-Date: >Last-Modified: >Originator: parv >Release: FreeBSD 4.7-RELEASE-p2 i386 >Organization: bitter almonds >Environment: System: FreeBSD moo.holy.cow 4.7-RELEASE-p2 perl 5.6.1 compiled on oct 29 2002 >Description: following code should print a list of numbers from -2 to 0 but doesn't... perl -e 'print "$_ " for "-2" .. "0"' see also... http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2002-10/msg01179.html http://groups.google.com/groups?th=5ca62e9cb8bd3366 >How-To-Repeat: install perl 5.6.1, run above code. >Fix: lifted from... http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2002-10/msg01179.html ...following patch is claimed to fix the problem... ==== //depot/perl/pp_ctl.c#325 (text) ==== Index: perl/pp_ctl.c --- perl/pp_ctl.c#324~18048~ Tue Oct 22 22:34:26 2002 +++ perl/pp_ctl.c Thu Oct 31 01:17:12 2002 @@ -943,10 +943,15 @@ 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"); ==== //depot/perl/t/op/range.t#9 (xtext) ==== Index: perl/t/op/range.t --- perl/t/op/range.t#8~4730~ Wed Dec 29 01:25:56 1999 +++ perl/t/op/range.t Thu Oct 31 01:17:12 2002 @@ -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 @@ 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"; >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021217085639.0E1E1B930>