From c9c1a41c581101f53cc36efae53cd8ebb568962f Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 12 Jul 2006 19:17:55 +0000 Subject: A couple things that got tangled up in my tree, easier to check in both than untangle them: Rewrite u_signal_names() into get_signum() and get_signame(), plus trim the signal list to that required by posix (they can specify the numbers for the rest if they really need them). (This is preparatory cleanup for adding a timeout applet like Roberto Foglietta wants.) Export the itoa (added due to Denis Vlasenko, although it's not quite his preferred implementation) from xfuncs.c so it's actually used, and remove several other redundant implementations of itoa and utoa() in the tree. --- shell/ash.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) (limited to 'shell/ash.c') diff --git a/shell/ash.c b/shell/ash.c index ba99381a2..de8d06e90 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -2035,7 +2035,6 @@ static void onsig(int); static int dotrap(void); static void setinteractive(int); static void exitshell(void) ATTRIBUTE_NORETURN; -static int decode_signal(const char *, int); /* * This routine is called when an error or an interrupt occurs in an @@ -6548,7 +6547,7 @@ usage: } if (**++argv == '-') { - signo = decode_signal(*argv + 1, 1); + signo = get_signum(*argv + 1); if (signo < 0) { int c; @@ -6562,7 +6561,7 @@ usage: list = 1; break; case 's': - signo = decode_signal(optionarg, 1); + signo = get_signum(optionarg); if (signo < 0) { sh_error( "invalid signal number or name: %s", @@ -6588,14 +6587,14 @@ usage: if (!*argv) { for (i = 1; i < NSIG; i++) { - name = u_signal_names(0, &i, 1); - if (name) + name = get_signame(i); + if (isdigit(*name)) out1fmt(snlfmt, name); } return 0; } - name = u_signal_names(*argptr, &signo, -1); - if (name) + name = get_signame(signo); + if (isdigit(*name)) out1fmt(snlfmt, name); else sh_error("invalid signal number or exit status: %s", *argptr); @@ -11617,9 +11616,7 @@ trapcmd(int argc, char **argv) if (trap[signo] != NULL) { const char *sn; - sn = u_signal_names(0, &signo, 0); - if (sn == NULL) - sn = "???"; + sn = get_signame(signo); out1fmt("trap -- %s %s\n", single_quote(trap[signo]), sn); } @@ -11631,7 +11628,7 @@ trapcmd(int argc, char **argv) else action = *ap++; while (*ap) { - if ((signo = decode_signal(*ap, 0)) < 0) + if ((signo = get_signum(*ap)) < 0) sh_error("%s: bad trap", *ap); INTOFF; if (action) { @@ -11934,14 +11931,6 @@ out: /* NOTREACHED */ } -static int decode_signal(const char *string, int minsig) -{ - int signo; - const char *name = u_signal_names(string, &signo, minsig); - - return name ? signo : -1; -} - /* var.c */ static struct var *vartab[VTABSIZE]; -- cgit v1.2.3