This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
&CORE::substr()
authorFather Chrysostomos <sprout@cpan.org>
Sun, 28 Aug 2011 06:29:13 +0000 (23:29 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 28 Aug 2011 06:37:48 +0000 (23:37 -0700)
commit7bc95ae1a56bd0ccfe9db1092344cd2d1566beca
tree98d78f818036eec595f3ceb97a6d10cad0d11eb9
parentd22667bf3cdadad95b9d176de3bf87d0b0e1286e
&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.)
gv.c
op.c
pp.c
t/op/coreamp.t