&CORE::sleep()
authorFather Chrysostomos <sprout@cpan.org>
Sun, 28 Aug 2011 01:40:05 +0000 (18:40 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 28 Aug 2011 06:37:48 +0000 (23:37 -0700)
This commit allows &CORE::sleep to be called through references and
via ampersand syntax.  pp_sleep 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 sleep how many arguments it’s
actually getting.  See commit 0163043a for details.

Unfortunately, sleep with no args is nearly impossible to test porta-
bly.  But I have checked that it works.

gv.c
pp_sys.c
t/op/coreamp.t

diff --git a/gv.c b/gv.c
index d5b497f..d903004 100644 (file)
--- 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_sleep:
+           case KEY_setpgrp: case KEY_shift:
            case KEY_splice:
            case KEY_srand: case KEY_stat: case KEY_substr:
            case KEY_sysopen:
index 6737845..747fd78 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -4579,7 +4579,7 @@ PP(pp_sleep)
     Time_t when;
 
     (void)time(&lasttime);
-    if (MAXARG < 1)
+    if (MAXARG < 1 || (!TOPs && !POPs))
        PerlProc_pause();
     else {
        duration = POPi;
index 06464f1..03fc14f 100644 (file)
@@ -655,6 +655,7 @@ test_proto "set$_" for qw '
 test_proto "shm$_" for qw "ctl get read write";
 test_proto 'shutdown';
 test_proto 'sin';
+test_proto 'sleep';
 test_proto "socket$_" for "", "pair";
 
 test_proto 'sprintf';