From: Rafael Garcia-Suarez Date: Mon, 18 Jan 2010 06:29:50 +0000 (+0100) Subject: Revert "[perl #62646] Maximum string length with substr" X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=54fcd2cd405902c42b2f46e5110b540f83c77028;p=p5sagit%2Fp5-mst-13.2.git Revert "[perl #62646] Maximum string length with substr" This reverts commit b6d1426f94a845fb8fece8b6ad0b7d9f35f2d62e. Conflicts: pp.c --- diff --git a/pp.c b/pp.c index 089401b..2f4703b 100644 --- a/pp.c +++ b/pp.c @@ -3079,12 +3079,12 @@ PP(pp_substr) { dVAR; dSP; dTARGET; SV *sv; - IV len = 0; + I32 len = 0; STRLEN curlen; STRLEN utf8_curlen; - IV pos; - IV rem; - IV fail; + I32 pos; + I32 rem; + I32 fail; const I32 lvalue = PL_op->op_flags & OPf_MOD || LVRET; const char *tmps; const I32 arybase = CopARYBASE_get(PL_curcop); @@ -3147,7 +3147,7 @@ PP(pp_substr) rem = curlen; else if (len >= 0) { rem = pos+len; - if (rem > (IV)curlen) + if (rem > (I32)curlen) rem = curlen; } else { @@ -3167,11 +3167,8 @@ PP(pp_substr) RETPUSHUNDEF; } else { - const IV upos = pos; - const IV urem = rem; - /* FIXME -- if an IV is longer than an I32, we're truncating here, - * but a 64-bit version of sv_pos_u2b is not (yet) available. - */ + const I32 upos = pos; + const I32 urem = rem; if (utf8_curlen) sv_pos_u2b(sv, (I32 *)&pos, (I32 *)&rem); tmps += pos; diff --git a/t/re/substr.t b/t/re/substr.t index 49fd97b..c3fa6e1 100644 --- a/t/re/substr.t +++ b/t/re/substr.t @@ -24,7 +24,7 @@ $SIG{__WARN__} = sub { require './test.pl'; -plan(338); +plan(334); run_tests() unless caller; @@ -682,19 +682,4 @@ is($x, "\x{100}\x{200}\xFFb"); is(substr($a,1,1), 'b'); } -# [perl #62646] offsets exceeding 32 bits on 64-bit system -SKIP: { - skip("32-bit system", 4) unless ~0 > 0xffffffff; - my $a = "abc"; - my $r; - $w = 0; - $r = substr($a, 0xffffffff, 1); - is($r, undef); - is($w, 1); - $w = 0; - $r = substr($a, 0xffffffff+1, 1); - is($r, undef); - is($w, 1); -} - }