summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-08-26 12:40:13 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-08-26 12:40:13 -0700
commitd3e26383b699ba248aece0da481bcd07d3e4aa60 (patch)
treea3c55f0365e90c6d9ff8f0e929ac1b68c514ab12 /pp.c
parente937c40d399bae93789feb66422b1547265ce0e0 (diff)
downloadperl-d3e26383b699ba248aece0da481bcd07d3e4aa60.tar.gz
&CORE::index() and &CORE::rindex()
This commit allows &CORE::index and &CORE::rindex to be called through references and via ampersand syntax. pp_index is modified to take into account the nulls pushed on to the stack in pp_coreargs, which happens because pp_coreargs has no other way to tell pp_index how many arguments it’s actually getting. See commit 0163043a for details.
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/pp.c b/pp.c
index 156c4d36fd..de2b35c2c5 100644
--- a/pp.c
+++ b/pp.c
@@ -3260,8 +3260,9 @@ PP(pp_index)
bool big_utf8;
bool little_utf8;
const bool is_index = PL_op->op_type == OP_INDEX;
+ const bool threeargs = MAXARG >= 3 && (TOPs || ((void)POPs,0));
- if (MAXARG >= 3) {
+ if (threeargs) {
/* arybase is in characters, like offset, so combine prior to the
UTF-8 to bytes calculation. */
offset = POPi - arybase;
@@ -3335,7 +3336,7 @@ PP(pp_index)
little_p = SvPVX(little);
}
- if (MAXARG < 3)
+ if (!threeargs)
offset = is_index ? 0 : biglen;
else {
if (big_utf8 && offset > 0)