From: Nicholas Clark Date: Thu, 24 Nov 2011 20:28:27 +0000 (+0100) Subject: Refactor S_usage() to take 0 parameters and exit directly(). X-Git-Tag: accepted/trunk/20130322.191538~1870 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b6f82619da63473c236f7d338cafcc1bfd4bafe3;p=platform%2Fupstream%2Fperl.git Refactor S_usage() to take 0 parameters and exit directly(). This simplifies the code, as it's only called from one spot, in Perl_moreswitches(). --- diff --git a/embed.fnc b/embed.fnc index 0c3c3f8..4c8a364 100644 --- a/embed.fnc +++ b/embed.fnc @@ -1756,7 +1756,7 @@ rs |void |my_exit_jump s |void |nuke_stacks s |int |open_script |NN const char *scriptname|bool dosearch \ |NN bool *suidscript|NN PerlIO **rsfpp -s |void |usage |NN const char *name +sr |void |usage #ifndef SETUID_SCRIPTS_ARE_SECURE_NOW so |void |validate_suid |NN PerlIO *rsfp #endif diff --git a/embed.h b/embed.h index d29c18a..7b0118e 100644 --- a/embed.h +++ b/embed.h @@ -1421,7 +1421,7 @@ #define open_script(a,b,c,d) S_open_script(aTHX_ a,b,c,d) #define parse_body(a,b) S_parse_body(aTHX_ a,b) #define run_body(a) S_run_body(aTHX_ a) -#define usage(a) S_usage(aTHX_ a) +#define usage() S_usage(aTHX) # endif # if defined(PERL_IN_PP_C) #define do_chomp(a,b,c) S_do_chomp(aTHX_ a,b,c) diff --git a/perl.c b/perl.c index fe69e8c..b4a2544 100644 --- a/perl.c +++ b/perl.c @@ -2912,7 +2912,7 @@ Perl_require_pv(pTHX_ const char *pv) } STATIC void -S_usage(pTHX_ const char *name) /* XXX move this out into a module ? */ +S_usage(pTHX) /* XXX move this out into a module ? */ { /* This message really ought to be max 23 lines. * Removed -h because the user already knows that option. Others? */ @@ -2955,13 +2955,12 @@ NULL const char * const *p = usage_msg; PerlIO *out = PerlIO_stdout(); - PERL_ARGS_ASSERT_USAGE; - PerlIO_printf(out, "\nUsage: %s [switches] [--] [programfile] [arguments]\n", - name); + PL_origargv[0]); while (*p) PerlIO_puts(out, *p++); + my_exit(0); } /* convert a string of -D options (or digits) into an int. @@ -3168,8 +3167,7 @@ Perl_moreswitches(pTHX_ const char *s) return s; } case 'h': - usage(PL_origargv[0]); - my_exit(0); + usage(); case 'i': Safefree(PL_inplace); #if defined(__CYGWIN__) /* do backup extension automagically */ diff --git a/proto.h b/proto.h index 7cc4c08..56ca49a 100644 --- a/proto.h +++ b/proto.h @@ -5880,10 +5880,8 @@ STATIC void* S_parse_body(pTHX_ char **env, XSINIT_t xsinit); STATIC void S_run_body(pTHX_ I32 oldscope) __attribute__noreturn__; -STATIC void S_usage(pTHX_ const char *name) - __attribute__nonnull__(pTHX_1); -#define PERL_ARGS_ASSERT_USAGE \ - assert(name) +STATIC void S_usage(pTHX) + __attribute__noreturn__; #endif #if defined(PERL_IN_PP_C)