diff options
author | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-07-12 19:17:55 +0000 |
---|---|---|
committer | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-07-12 19:17:55 +0000 |
commit | 4c90819a28a6ff368dc8ec867714cf856e6b58f3 (patch) | |
tree | 0aa4024f33e22567444f78d83d7d4b7986abe795 /shell | |
parent | f09cc3b1b53e74ebe0f5733f73d55846d25194ec (diff) | |
download | busybox-w32-4c90819a28a6ff368dc8ec867714cf856e6b58f3.tar.gz busybox-w32-4c90819a28a6ff368dc8ec867714cf856e6b58f3.tar.bz2 busybox-w32-4c90819a28a6ff368dc8ec867714cf856e6b58f3.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.
git-svn-id: svn://busybox.net/trunk/busybox@15687 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 27 | ||||
-rw-r--r-- | shell/lash.c | 31 | ||||
-rw-r--r-- | shell/msh.c | 41 |
3 files changed, 9 insertions, 90 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); | |||
2035 | static int dotrap(void); | 2035 | static int dotrap(void); |
2036 | static void setinteractive(int); | 2036 | static void setinteractive(int); |
2037 | static void exitshell(void) ATTRIBUTE_NORETURN; | 2037 | static void exitshell(void) ATTRIBUTE_NORETURN; |
2038 | static 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 | ||
11937 | static 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 | ||
11947 | static struct var *vartab[VTABSIZE]; | 11936 | static struct var *vartab[VTABSIZE]; |
diff --git a/shell/lash.c b/shell/lash.c index c5aaf1d1f..92c24d1c2 100644 --- a/shell/lash.c +++ b/shell/lash.c | |||
@@ -22,18 +22,7 @@ | |||
22 | 22 | ||
23 | 23 | ||
24 | #include "busybox.h" | 24 | #include "busybox.h" |
25 | #include <stdio.h> | ||
26 | #include <stdlib.h> | ||
27 | #include <ctype.h> | ||
28 | #include <errno.h> | ||
29 | #include <fcntl.h> | ||
30 | #include <signal.h> | ||
31 | #include <string.h> | ||
32 | #include <sys/ioctl.h> | ||
33 | #include <sys/wait.h> | ||
34 | #include <unistd.h> | ||
35 | #include <getopt.h> | 25 | #include <getopt.h> |
36 | #include <termios.h> | ||
37 | #include "cmdedit.h" | 26 | #include "cmdedit.h" |
38 | 27 | ||
39 | #ifdef CONFIG_LOCALE_SUPPORT | 28 | #ifdef CONFIG_LOCALE_SUPPORT |
@@ -697,26 +686,6 @@ static int get_command(FILE * source, char *command) | |||
697 | return 0; | 686 | return 0; |
698 | } | 687 | } |
699 | 688 | ||
700 | static char* itoa(int i) | ||
701 | { | ||
702 | static char a[7]; /* Max 7 ints */ | ||
703 | char *b = a + sizeof(a) - 1; | ||
704 | int sign = (i < 0); | ||
705 | |||
706 | if (sign) | ||
707 | i = -i; | ||
708 | *b = 0; | ||
709 | do | ||
710 | { | ||
711 | *--b = '0' + (i % 10); | ||
712 | i /= 10; | ||
713 | } | ||
714 | while (i); | ||
715 | if (sign) | ||
716 | *--b = '-'; | ||
717 | return b; | ||
718 | } | ||
719 | |||
720 | static char * strsep_space( char *string, int * ix) | 689 | static char * strsep_space( char *string, int * ix) |
721 | { | 690 | { |
722 | char *token; | 691 | char *token; |
diff --git a/shell/msh.c b/shell/msh.c index 633070112..b491a08a4 100644 --- a/shell/msh.c +++ b/shell/msh.c | |||
@@ -10,41 +10,12 @@ | |||
10 | * Robert Schwebel <r.schwebel@pengutronix.de> | 10 | * Robert Schwebel <r.schwebel@pengutronix.de> |
11 | * Erik Andersen <andersen@codepoet.org> | 11 | * Erik Andersen <andersen@codepoet.org> |
12 | * | 12 | * |
13 | * This program is free software; you can redistribute it and/or modify | 13 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
14 | * it under the terms of the GNU General Public License as published by | ||
15 | * the Free Software Foundation; either version 2 of the License, or | ||
16 | * (at your option) any later version. | ||
17 | * | ||
18 | * This program is distributed in the hope that it will be useful, | ||
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
21 | * General Public License for more details. | ||
22 | * | ||
23 | * You should have received a copy of the GNU General Public License | ||
24 | * along with this program; if not, write to the Free Software | ||
25 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
26 | * | ||
27 | * Original copyright notice is retained at the end of this file. | ||
28 | */ | 14 | */ |
29 | 15 | ||
30 | #include "busybox.h" | 16 | #include "busybox.h" |
31 | #include <ctype.h> | ||
32 | #include <dirent.h> | ||
33 | #include <errno.h> | ||
34 | #include <fcntl.h> | ||
35 | #include <limits.h> | ||
36 | #include <setjmp.h> | 17 | #include <setjmp.h> |
37 | #include <signal.h> | ||
38 | #include <stddef.h> | ||
39 | #include <stdio.h> | ||
40 | #include <stdlib.h> | ||
41 | #include <string.h> | ||
42 | #include <time.h> | ||
43 | #include <unistd.h> | ||
44 | #include <sys/stat.h> | ||
45 | #include <sys/times.h> | 18 | #include <sys/times.h> |
46 | #include <sys/types.h> | ||
47 | #include <sys/wait.h> | ||
48 | 19 | ||
49 | #include "cmdedit.h" | 20 | #include "cmdedit.h" |
50 | 21 | ||
@@ -293,7 +264,6 @@ static char *space(int n); | |||
293 | static char *strsave(char *s, int a); | 264 | static char *strsave(char *s, int a); |
294 | static char *evalstr(char *cp, int f); | 265 | static char *evalstr(char *cp, int f); |
295 | static char *putn(int n); | 266 | static char *putn(int n); |
296 | static char *itoa(int n); | ||
297 | static char *unquote(char *as); | 267 | static char *unquote(char *as); |
298 | static struct var *lookup(char *n); | 268 | static struct var *lookup(char *n); |
299 | static int rlookup(char *n); | 269 | static int rlookup(char *n); |
@@ -1252,15 +1222,6 @@ static char *putn(int n) | |||
1252 | return (itoa(n)); | 1222 | return (itoa(n)); |
1253 | } | 1223 | } |
1254 | 1224 | ||
1255 | static char *itoa(int n) | ||
1256 | { | ||
1257 | static char s[20]; | ||
1258 | |||
1259 | snprintf(s, sizeof(s), "%u", n); | ||
1260 | return (s); | ||
1261 | } | ||
1262 | |||
1263 | |||
1264 | static void next(int f) | 1225 | static void next(int f) |
1265 | { | 1226 | { |
1266 | PUSHIO(afile, f, filechar); | 1227 | PUSHIO(afile, f, filechar); |