if (GIMME == G_ARRAY) {
dPOPPOPssrl;
- register I32 i, j;
+ register IV i, j;
register SV *sv;
- I32 max;
+ IV max;
if (SvGMAGICAL(left))
mg_get(left);
mg_get(right);
if (RANGE_IS_NUMERIC(left,right)) {
- if (SvNV(left) < IV_MIN || SvNV(right) > IV_MAX)
+ if ((SvOK(left) && SvNV(left) < IV_MIN) ||
+ (SvOK(right) && SvNV(right) > IV_MAX))
DIE(aTHX_ "Range iterator outside integer range");
i = SvIV(left);
max = SvIV(right);
cx->blk_loop.iterary = (AV*)SvREFCNT_inc(POPs);
if (SvTYPE(cx->blk_loop.iterary) != SVt_PVAV) {
dPOPss;
- if (RANGE_IS_NUMERIC(sv,(SV*)cx->blk_loop.iterary)) {
- if (SvNV(sv) < IV_MIN ||
- SvNV((SV*)cx->blk_loop.iterary) >= IV_MAX)
+ SV *right = (SV*)cx->blk_loop.iterary;
+ if (RANGE_IS_NUMERIC(sv,right)) {
+ if ((SvOK(sv) && SvNV(sv) < IV_MIN) ||
+ (SvOK(right) && SvNV(right) >= IV_MAX))
DIE(aTHX_ "Range iterator outside integer range");
cx->blk_loop.iterix = SvIV(sv);
- cx->blk_loop.itermax = SvIV((SV*)cx->blk_loop.iterary);
+ cx->blk_loop.itermax = SvIV(right);
}
else {
STRLEN n_a;
cx->blk_loop.iterlval = newSVsv(sv);
- SvPV_force(cx->blk_loop.iterlval,n_a);
+ (void) SvPV_force(cx->blk_loop.iterlval,n_a);
+ (void) SvPV(right,n_a);
}
}
}
if (cx->blk_loop.iterlval) {
/* string increment */
register SV* cur = cx->blk_loop.iterlval;
- STRLEN maxlen;
- char *max = SvPV((SV*)av, maxlen);
+ STRLEN maxlen = 0;
+ char *max = SvOK((SV*)av) ? SvPV((SV*)av, maxlen) : "";
if (!SvNIOK(cur) && SvCUR(cur) <= maxlen) {
if (SvREFCNT(*itersvp) == 1 && !SvMAGICAL(*itersvp)) {
/* safe to reuse old SV */
#!./perl
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+use Config;
+
print "1..37\n";
print join(':',1..5) eq '1:2:3:4:5' ? "ok 1\n" : "not ok 1\n";
print "ok 10\n";
# check bounds
-@a = 0x7ffffffe..0x7fffffff;
-print "not " unless "@a" eq "2147483646 2147483647";
+if ($Config{ivsize} == 8) {
+ @a = eval "0x7ffffffffffffffe..0x7fffffffffffffff";
+ $a = "9223372036854775806 9223372036854775807";
+ @b = eval "-0x7fffffffffffffff..-0x7ffffffffffffffe";
+ $b = "-9223372036854775807 -9223372036854775806";
+}
+else {
+ @a = eval "0x7ffffffe..0x7fffffff";
+ $a = "2147483646 2147483647";
+ @b = eval "-0x7fffffff..-0x7ffffffe";
+ $b = "-2147483647 -2147483646";
+}
+
+print "not " unless "@a" eq $a;
print "ok 11\n";
-@a = -0x7fffffff..-0x7ffffffe;
-print "not " unless "@a" eq "-2147483647 -2147483646";
+print "not " unless "@b" eq $b;
print "ok 12\n";
# check magic