diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-08-29 09:54:20 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-08-29 12:33:53 -0700 |
commit | 92f2ac5f91d4e93cd51cdb5d8e967e1a73c9d7dc (patch) | |
tree | 0efa22aaad4a7ea379b709c14e39d5bb71f45a21 | |
parent | 88d6953212e6c8eb2ac9df08c4903ff86b7ef650 (diff) | |
download | perl-92f2ac5f91d4e93cd51cdb5d8e967e1a73c9d7dc.tar.gz |
&CORE::setpgrp()
This commit allows &CORE::setpgrp to be called through references and
via ampersand syntax. pp_setpgrp 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 setpgrp how many arguments it’s
actually getting. See commit 0163043a for details.
-rw-r--r-- | gv.c | 2 | ||||
-rw-r--r-- | pp_sys.c | 10 | ||||
-rw-r--r-- | t/op/coreamp.t | 13 |
3 files changed, 16 insertions, 9 deletions
@@ -1358,7 +1358,7 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags, case KEY_lstat: case KEY_pop: case KEY_push: - case KEY_setpgrp: case KEY_shift: + case KEY_shift: case KEY_splice: case KEY_stat: case KEY_system: @@ -4342,16 +4342,12 @@ PP(pp_setpgrp) dVAR; dSP; dTARGET; Pid_t pgrp; Pid_t pid; - if (MAXARG == 1) pgrp = 0, pid = TOPi; - else if (MAXARG < 2) { - pgrp = 0; + pgrp = MAXARG == 2 && (TOPs||POPs) ? POPi : 0; + if (MAXARG > 0) pid = TOPs && TOPi; + else { pid = 0; XPUSHi(-1); } - else { - pgrp = POPi; - pid = TOPi; - } TAINT_PROPER("setpgrp"); #ifdef BSD_SETPGRP diff --git a/t/op/coreamp.t b/t/op/coreamp.t index 50897a0109..5ef3a2bd39 100644 --- a/t/op/coreamp.t +++ b/t/op/coreamp.t @@ -657,7 +657,18 @@ test_proto "sem$_" for qw "ctl get op"; test_proto 'send'; test_proto "set$_" for qw ' - grent hostent netent priority protoent pwent servent sockopt + grent hostent netent +'; + +test_proto 'setpgrp'; +$tests +=2; +eval { &mysetpgrp( 0) }; +pass "&setpgrp with one argument"; +eval { &mysetpgrp }; +pass "&setpgrp with no arguments"; + +test_proto "set$_" for qw ' + priority protoent pwent servent sockopt '; test_proto "shm$_" for qw "ctl get read write"; |