From: M.J.T. Guy Date: Mon, 7 Jul 1997 12:37:51 +0000 (+1200) Subject: Fwd: substr("foo", -1000) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d9fdd1afe4b88705294e21dc4e070c42d3d9a4d8;p=p5sagit%2Fp5-mst-13.2.git Fwd: substr("foo", -1000) Subject: hmmm. Isn't it weird that substr("foo", -1000) is silently converted to substr("foo", 0, 3) while substr("foo", 1000) always causes RETPUSHUNDEF and possibly a warning? I'd say there's too much code in pp.c:pp_substr. Credited: Jarkko Hietaniemi Credited: Tim Bunce p5p-msgid: 9707072304.AA01069@toad.ig.co.uk private-msgid: 199707100655.JAA14924@alpha.hut.fi --- diff --git a/pp.c b/pp.c index fa36c50..d791c4b 100644 --- a/pp.c +++ b/pp.c @@ -1628,11 +1628,8 @@ PP(pp_substr) pos = POPi - arybase; sv = POPs; tmps = SvPV(sv, curlen); - if (pos < 0) { + if (pos < 0) pos += curlen + arybase; - if (pos < 0 && MAXARG < 3) - pos = 0; - } if (pos < 0 || pos > curlen) { if (dowarn || lvalue) warn("substr outside of string");