summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorRob Landley2006-07-12 19:17:55 +0000
committerRob Landley2006-07-12 19:17:55 +0000
commitc9c1a41c581101f53cc36efae53cd8ebb568962f (patch)
tree0aa4024f33e22567444f78d83d7d4b7986abe795 /shell
parent801ab140132a111e9524371c9b8d425579692389 (diff)
downloadbusybox-c9c1a41c581101f53cc36efae53cd8ebb568962f.zip
busybox-c9c1a41c581101f53cc36efae53cd8ebb568962f.tar.gz
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')
-rw-r--r--shell/ash.c27
-rw-r--r--shell/lash.c31
-rw-r--r--shell/msh.c41
3 files changed, 9 insertions, 90 deletions
diff --git a/shell/ash.c b/shell/ash.c
index ba99381..de8d06e 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];
diff --git a/shell/lash.c b/shell/lash.c
index c5aaf1d..92c24d1 100644
--- a/shell/lash.c
+++ b/shell/lash.c
@@ -22,18 +22,7 @@
#include "busybox.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <string.h>
-#include <sys/ioctl.h>
-#include <sys/wait.h>
-#include <unistd.h>
#include <getopt.h>
-#include <termios.h>
#include "cmdedit.h"
#ifdef CONFIG_LOCALE_SUPPORT
@@ -697,26 +686,6 @@ static int get_command(FILE * source, char *command)
return 0;
}
-static char* itoa(int i)
-{
- static char a[7]; /* Max 7 ints */
- char *b = a + sizeof(a) - 1;
- int sign = (i < 0);
-
- if (sign)
- i = -i;
- *b = 0;
- do
- {
- *--b = '0' + (i % 10);
- i /= 10;
- }
- while (i);
- if (sign)
- *--b = '-';
- return b;
-}
-
static char * strsep_space( char *string, int * ix)
{
char *token;
diff --git a/shell/msh.c b/shell/msh.c
index 6330701..b491a08 100644
--- a/shell/msh.c
+++ b/shell/msh.c
@@ -10,41 +10,12 @@
* Robert Schwebel <r.schwebel@pengutronix.de>
* Erik Andersen <andersen@codepoet.org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Original copyright notice is retained at the end of this file.
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "busybox.h"
-#include <ctype.h>
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <limits.h>
#include <setjmp.h>
-#include <signal.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-#include <sys/stat.h>
#include <sys/times.h>
-#include <sys/types.h>
-#include <sys/wait.h>
#include "cmdedit.h"
@@ -293,7 +264,6 @@ static char *space(int n);
static char *strsave(char *s, int a);
static char *evalstr(char *cp, int f);
static char *putn(int n);
-static char *itoa(int n);
static char *unquote(char *as);
static struct var *lookup(char *n);
static int rlookup(char *n);
@@ -1252,15 +1222,6 @@ static char *putn(int n)
return (itoa(n));
}
-static char *itoa(int n)
-{
- static char s[20];
-
- snprintf(s, sizeof(s), "%u", n);
- return (s);
-}
-
-
static void next(int f)
{
PUSHIO(afile, f, filechar);