diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-08-26 23:50:06 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-08-26 23:58:03 -0700 |
commit | f650fa729f03aabdf12058228971129d911b4aa1 (patch) | |
tree | c3f5c89c23a685ae9e36d2b15dfdc41782ec80ce | |
parent | 014333460b4235140c1e4ad346b2581af7ff6592 (diff) | |
download | perl-f650fa729f03aabdf12058228971129d911b4aa1.tar.gz |
&CORE::reset()
This commit allows &CORE::reset to be called through references and
via ampersand syntax. pp_reset 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 reset how many arguments it’s
actually getting. See commit 0163043a for details.
-rw-r--r-- | gv.c | 2 | ||||
-rw-r--r-- | pp_ctl.c | 3 | ||||
-rw-r--r-- | t/op/coreamp.t | 14 |
3 files changed, 17 insertions, 2 deletions
@@ -1357,7 +1357,7 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags, case KEY_keys: case KEY_lstat: case KEY_pop: - case KEY_push: case KEY_reset: + case KEY_push: case KEY_select: case KEY_send: case KEY_setpgrp: case KEY_shift: case KEY_sleep: case KEY_splice: @@ -2007,7 +2007,8 @@ PP(pp_reset) { dVAR; dSP; - const char * const tmps = (MAXARG < 1) ? (const char *)"" : POPpconstx; + const char * const tmps = + (MAXARG < 1 || (!TOPs && !POPs)) ? (const char *)"" : POPpconstx; sv_reset(tmps, CopSTASH(PL_curcop)); PUSHs(&PL_sv_yes); RETURN; diff --git a/t/op/coreamp.t b/t/op/coreamp.t index b77d56a939..ef6db6314c 100644 --- a/t/op/coreamp.t +++ b/t/op/coreamp.t @@ -33,6 +33,7 @@ my %op_desc = ( join => 'join or string', readline => '<HANDLE>', readpipe => 'quoted execution (``, qx)', + reset => 'symbol reset', ref => 'reference-type operator', ); sub op_desc($) { @@ -577,6 +578,19 @@ test_proto 'rename'; test_proto 'ref', [], 'ARRAY'; +test_proto 'reset'; +$tests += 2; +my $oncer = sub { "a" =~ m?a? }; +&$oncer; +&myreset; +ok &$oncer, '&reset with one arg'; +package resettest { + $b = "c"; + $banana = "cream"; + &::myreset('b'); + ::lis [$b,$banana],[(undef)x2], '2-arg &reset'; +} + test_proto 'reverse'; $tests += 2; is &myreverse('reward'), 'drawer', '&reverse'; |