From 9d3c658e5c246089e541ed0d652aaccf018f16e9 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Thu, 25 Aug 2011 18:10:53 -0700 Subject: [PATCH] &CORE::exit() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This commit allows &CORE::exit to be called through references and via ampersand syntax. pp_exit is modified to take into account the nulls pushed on to the stack in pp_coreargs, since pp_coreargs has no other way to tell exit how many arguments it’s actually getting. --- gv.c | 2 +- pp_ctl.c | 3 +++ t/op/coresubs.t | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gv.c b/gv.c index 0ecbf96..6f1756c 100644 --- a/gv.c +++ b/gv.c @@ -1353,7 +1353,7 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags, return gv; case KEY_chdir: case KEY_chomp: case KEY_chop: - case KEY_each: case KEY_eof: case KEY_exec: case KEY_exit: + case KEY_each: case KEY_eof: case KEY_exec: case KEY_getpgrp: case KEY_gmtime: case KEY_index: case KEY_keys: case KEY_localtime: case KEY_lock: case KEY_lstat: diff --git a/pp_ctl.c b/pp_ctl.c index 997f492..76786c0 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -3139,6 +3139,9 @@ PP(pp_exit) if (MAXARG < 1) anum = 0; + else if (!TOPs) { + anum = 0; (void)POPs; + } else { anum = SvIVx(POPs); #ifdef VMS diff --git a/t/op/coresubs.t b/t/op/coresubs.t index 9ed64cc..c0f5966 100644 --- a/t/op/coresubs.t +++ b/t/op/coresubs.t @@ -320,6 +320,11 @@ test_proto $_ for qw( endgrent endhostent endnetent endprotoent endpwent endservent ); +test_proto 'exit'; +$tests ++; +is runperl(prog => '&CORE::exit; END { print q-ok- }'), 'ok', + '&exit with no args'; + test_proto 'fork'; test_proto 'formline'; -- 2.7.4