an exception for .."0" [#18165]). AMS 20021031. */
#define RANGE_IS_NUMERIC(left,right) ( \
+ (!SvOK(left) && !SvOK(right)) || \
SvNIOKp(left) || (SvOK(left) && !SvPOKp(left)) || \
SvNIOKp(right) || (SvOK(right) && !SvPOKp(right)) || \
(looks_like_number(left) && SvPOKp(left) && *SvPVX(left) != '0' && \
cx->blk_loop.iterix = SvIV(sv);
cx->blk_loop.itermax = SvIV((SV*)cx->blk_loop.iterary);
}
- else
+ else {
+ STRLEN n_a;
cx->blk_loop.iterlval = newSVsv(sv);
+ SvPV_force(cx->blk_loop.iterlval,n_a);
+ }
}
}
else {
#!./perl
-print "1..25\n";
+print "1..30\n";
print join(':',1..5) eq '1:2:3:4:5' ? "ok 1\n" : "not ok 1\n";
print join(":",undef.."B") eq '' ? "ok 23\n" : "not ok 23\n";
print join(":","B".."") eq '' ? "ok 24\n" : "not ok 24\n";
print join(":","B"..undef) eq '' ? "ok 25\n" : "not ok 25\n";
+
+# undef..undef used to segfault and should be 0..0
+print join(":",undef..undef) eq '0' ? "ok 26\n" : "not ok 26\n";
+
+# also test undef in foreach loops
+@foo=(); push @foo, $_ for undef..2;
+print join(":",@foo) eq '0:1:2' ? "ok 27\n" : "not ok 27\n";
+
+@foo=(); push @foo, $_ for -2..undef;
+print join(":",@foo) eq '-2:-1:0' ? "ok 28\n" : "not ok 28\n";
+
+@foo=(); push @foo, $_ for undef.."B";
+print join(":",@foo) eq '' ? "ok 29\n" : "not ok 29\n";
+
+@foo=(); push @foo, $_ for "B"..undef;
+print join(":",@foo) eq '' ? "ok 30\n" : "not ok 30\n";