summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-08-29 09:54:20 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-08-29 12:33:53 -0700
commit92f2ac5f91d4e93cd51cdb5d8e967e1a73c9d7dc (patch)
tree0efa22aaad4a7ea379b709c14e39d5bb71f45a21
parent88d6953212e6c8eb2ac9df08c4903ff86b7ef650 (diff)
downloadperl-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.c2
-rw-r--r--pp_sys.c10
-rw-r--r--t/op/coreamp.t13
3 files changed, 16 insertions, 9 deletions
diff --git a/gv.c b/gv.c
index 1c337ef1f6..086e398a3f 100644
--- a/gv.c
+++ b/gv.c
@@ -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:
diff --git a/pp_sys.c b/pp_sys.c
index 7ae1644728..5cd9ef6613 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -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";