This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [perl #18165] "0" fails as right-hand argument to ..
authorSlaven Rezic <slaven@rezic.de>
Sat, 30 Nov 2002 00:07:05 +0000 (01:07 +0100)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Sun, 8 Dec 2002 22:04:39 +0000 (22:04 +0000)
Message-ID: <8765ugnffq.fsf@vran.herceg.de>

p4raw-id: //depot/perl@18264

pp_ctl.c
t/cmd/for.t

index 76a2466..2bebcbc 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1690,11 +1690,11 @@ PP(pp_enteriter)
        cx->blk_loop.iterary = (AV*)SvREFCNT_inc(POPs);
        if (SvTYPE(cx->blk_loop.iterary) != SVt_PVAV) {
            dPOPss;
+           /* See comment in pp_flop() */
            if (SvNIOKp(sv) || !SvPOKp(sv) ||
                SvNIOKp(cx->blk_loop.iterary) || !SvPOKp(cx->blk_loop.iterary) ||
                (looks_like_number(sv) && *SvPVX(sv) != '0' &&
-                looks_like_number((SV*)cx->blk_loop.iterary) &&
-                *SvPVX(cx->blk_loop.iterary) != '0'))
+                looks_like_number((SV*)cx->blk_loop.iterary)))
            {
                 if (SvNV(sv) < IV_MIN ||
                     SvNV((SV*)cx->blk_loop.iterary) >= IV_MAX)
index 90b5ff0..3275c71 100755 (executable)
@@ -1,6 +1,6 @@
 #!./perl
 
-print "1..11\n";
+print "1..12\n";
 
 for ($i = 0; $i <= 10; $i++) {
     $x[$i] = $i;
@@ -66,3 +66,8 @@ foreach $b (bar()) {
 }
 print $a == 7 ? "ok" : "not ok", " 11\n";
 
+$loop_count = 0;
+for ("-3" .. "0") {
+    $loop_count++;
+}
+print $loop_count == 4 ? "ok" : "not ok", " 12\n";