aboutsummaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-07-12 19:17:55 +0000
committerRob Landley <rob@landley.net>2006-07-12 19:17:55 +0000
commitc9c1a41c581101f53cc36efae53cd8ebb568962f (patch)
tree0aa4024f33e22567444f78d83d7d4b7986abe795 /shell/ash.c
parent801ab140132a111e9524371c9b8d425579692389 (diff)
downloadbusybox-w32-c9c1a41c581101f53cc36efae53cd8ebb568962f.tar.gz
busybox-w32-c9c1a41c581101f53cc36efae53cd8ebb568962f.tar.bz2
busybox-w32-c9c1a41c581101f53cc36efae53cd8ebb568962f.zip
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.
Diffstat (limited to 'shell/ash.c')
-rw-r--r--shell/ash.c27
1 files changed, 8 insertions, 19 deletions
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);
2035static int dotrap(void); 2035static int dotrap(void);
2036static void setinteractive(int); 2036static void setinteractive(int);
2037static void exitshell(void) ATTRIBUTE_NORETURN; 2037static void exitshell(void) ATTRIBUTE_NORETURN;
2038static int decode_signal(const char *, int);
2039 2038
2040/* 2039/*
2041 * This routine is called when an error or an interrupt occurs in an 2040 * This routine is called when an error or an interrupt occurs in an
@@ -6548,7 +6547,7 @@ usage:
6548 } 6547 }
6549 6548
6550 if (**++argv == '-') { 6549 if (**++argv == '-') {
6551 signo = decode_signal(*argv + 1, 1); 6550 signo = get_signum(*argv + 1);
6552 if (signo < 0) { 6551 if (signo < 0) {
6553 int c; 6552 int c;
6554 6553
@@ -6562,7 +6561,7 @@ usage:
6562 list = 1; 6561 list = 1;
6563 break; 6562 break;
6564 case 's': 6563 case 's':
6565 signo = decode_signal(optionarg, 1); 6564 signo = get_signum(optionarg);
6566 if (signo < 0) { 6565 if (signo < 0) {
6567 sh_error( 6566 sh_error(
6568 "invalid signal number or name: %s", 6567 "invalid signal number or name: %s",
@@ -6588,14 +6587,14 @@ usage:
6588 6587
6589 if (!*argv) { 6588 if (!*argv) {
6590 for (i = 1; i < NSIG; i++) { 6589 for (i = 1; i < NSIG; i++) {
6591 name = u_signal_names(0, &i, 1); 6590 name = get_signame(i);
6592 if (name) 6591 if (isdigit(*name))
6593 out1fmt(snlfmt, name); 6592 out1fmt(snlfmt, name);
6594 } 6593 }
6595 return 0; 6594 return 0;
6596 } 6595 }
6597 name = u_signal_names(*argptr, &signo, -1); 6596 name = get_signame(signo);
6598 if (name) 6597 if (isdigit(*name))
6599 out1fmt(snlfmt, name); 6598 out1fmt(snlfmt, name);
6600 else 6599 else
6601 sh_error("invalid signal number or exit status: %s", *argptr); 6600 sh_error("invalid signal number or exit status: %s", *argptr);
@@ -11617,9 +11616,7 @@ trapcmd(int argc, char **argv)
11617 if (trap[signo] != NULL) { 11616 if (trap[signo] != NULL) {
11618 const char *sn; 11617 const char *sn;
11619 11618
11620 sn = u_signal_names(0, &signo, 0); 11619 sn = get_signame(signo);
11621 if (sn == NULL)
11622 sn = "???";
11623 out1fmt("trap -- %s %s\n", 11620 out1fmt("trap -- %s %s\n",
11624 single_quote(trap[signo]), sn); 11621 single_quote(trap[signo]), sn);
11625 } 11622 }
@@ -11631,7 +11628,7 @@ trapcmd(int argc, char **argv)
11631 else 11628 else
11632 action = *ap++; 11629 action = *ap++;
11633 while (*ap) { 11630 while (*ap) {
11634 if ((signo = decode_signal(*ap, 0)) < 0) 11631 if ((signo = get_signum(*ap)) < 0)
11635 sh_error("%s: bad trap", *ap); 11632 sh_error("%s: bad trap", *ap);
11636 INTOFF; 11633 INTOFF;
11637 if (action) { 11634 if (action) {
@@ -11934,14 +11931,6 @@ out:
11934 /* NOTREACHED */ 11931 /* NOTREACHED */
11935} 11932}
11936 11933
11937static int decode_signal(const char *string, int minsig)
11938{
11939 int signo;
11940 const char *name = u_signal_names(string, &signo, minsig);
11941
11942 return name ? signo : -1;
11943}
11944
11945/* var.c */ 11934/* var.c */
11946 11935
11947static struct var *vartab[VTABSIZE]; 11936static struct var *vartab[VTABSIZE];