summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-08-27 23:29:13 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-08-27 23:37:48 -0700
commit7bc95ae1a56bd0ccfe9db1092344cd2d1566beca (patch)
tree98d78f818036eec595f3ceb97a6d10cad0d11eb9 /gv.c
parentd22667bf3cdadad95b9d176de3bf87d0b0e1286e (diff)
downloadperl-7bc95ae1a56bd0ccfe9db1092344cd2d1566beca.tar.gz
&CORE::substr()
This commit makes &CORE::substr callable through references and via &ampersand syntax. It’s a bit awkward, as we need a substr op that is flagged as hav- ing 4 arguments *and* possibly returning an lvalue. The code in op_lvalue_flags wasn’t really set up for that, so I needed to flag the op with OPpMAYBE_LVSUB in coresub_op before it gets passed to op_lvalue_flags. It turned out that only that was necessary, as op_lvalue_flags does an op_private == 4 check (rather than (op_private & 7) == 4 or some such) when checking for the 4-arg case and croak- ing. When the op arrives in op_lvalue_flags, it’s already flagged OPpMAYBE_LVSUB|4 which != 4. pp_substr is also modified to check for nulls and, if necessary, adjust its count of how many arguments were actually passed.)
Diffstat (limited to 'gv.c')
-rw-r--r--gv.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/gv.c b/gv.c
index 50ebea8e60..25548ebca3 100644
--- a/gv.c
+++ b/gv.c
@@ -1360,7 +1360,7 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags,
case KEY_push:
case KEY_setpgrp: case KEY_shift:
case KEY_splice:
- case KEY_stat: case KEY_substr:
+ case KEY_stat:
case KEY_sysopen:
case KEY_system:
case KEY_tell: case KEY_tie: case KEY_tied:
@@ -1400,7 +1400,9 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags,
new ATTRSUB. */
(void)core_prototype((SV *)cv, name, code, &opnum);
if (ampable) {
- if (opnum == OP_VEC || opnum == OP_LOCK) CvLVALUE_on(cv);
+ if (opnum == OP_VEC || opnum == OP_LOCK
+ || opnum == OP_SUBSTR)
+ CvLVALUE_on(cv);
newATTRSUB(oldsavestack_ix,
newSVOP(
OP_CONST, 0,