diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | ash.c | 171 | ||||
-rw-r--r-- | cmdedit.c | 24 | ||||
-rw-r--r-- | coreutils/cut.c | 6 | ||||
-rw-r--r-- | coreutils/uudecode.c | 10 | ||||
-rw-r--r-- | cut.c | 6 | ||||
-rw-r--r-- | include/libbb.h | 4 | ||||
-rw-r--r-- | kill.c | 142 | ||||
-rw-r--r-- | libbb/arith.c | 33 | ||||
-rw-r--r-- | libbb/concat_path_file.c | 2 | ||||
-rw-r--r-- | libbb/libbb.h | 4 | ||||
-rw-r--r-- | miscutils/update.c | 3 | ||||
-rw-r--r-- | procps/kill.c | 142 | ||||
-rw-r--r-- | shell/ash.c | 171 | ||||
-rw-r--r-- | shell/cmdedit.c | 24 | ||||
-rw-r--r-- | update.c | 3 | ||||
-rw-r--r-- | uudecode.c | 10 |
17 files changed, 187 insertions, 570 deletions
@@ -247,7 +247,7 @@ safe_read.c safe_strncpy.c syscalls.c syslog_msg_with_name.c time_string.c \ | |||
247 | trim.c unzip.c vdprintf.c verror_msg.c vperror_msg.c wfopen.c xfuncs.c \ | 247 | trim.c unzip.c vdprintf.c verror_msg.c vperror_msg.c wfopen.c xfuncs.c \ |
248 | xgetcwd.c xreadlink.c xregcomp.c interface.c remove_file.c last_char_is.c \ | 248 | xgetcwd.c xreadlink.c xregcomp.c interface.c remove_file.c last_char_is.c \ |
249 | copyfd.c vherror_msg.c herror_msg.c herror_msg_and_die.c xgethostbyname.c \ | 249 | copyfd.c vherror_msg.c herror_msg.c herror_msg_and_die.c xgethostbyname.c \ |
250 | dirname.c make_directory.c create_icmp_socket.c arith.c | 250 | dirname.c make_directory.c create_icmp_socket.c u_signal_names.c arith.c |
251 | LIBBB_OBJS=$(patsubst %.c,$(LIBBB)/%.o, $(LIBBB_CSRC)) | 251 | LIBBB_OBJS=$(patsubst %.c,$(LIBBB)/%.o, $(LIBBB_CSRC)) |
252 | LIBBB_CFLAGS = -I$(LIBBB) | 252 | LIBBB_CFLAGS = -I$(LIBBB) |
253 | ifneq ($(strip $(BB_SRC_DIR)),) | 253 | ifneq ($(strip $(BB_SRC_DIR)),) |
@@ -52,6 +52,7 @@ | |||
52 | 52 | ||
53 | /* If you need ash to act as a full Posix shell, with full math | 53 | /* If you need ash to act as a full Posix shell, with full math |
54 | * support, enable this. This adds a bit over 2k an x86 system. */ | 54 | * support, enable this. This adds a bit over 2k an x86 system. */ |
55 | //#undef ASH_MATH_SUPPORT | ||
55 | #define ASH_MATH_SUPPORT | 56 | #define ASH_MATH_SUPPORT |
56 | 57 | ||
57 | /* Getopts is used by shell procedures to parse positional parameters. | 58 | /* Getopts is used by shell procedures to parse positional parameters. |
@@ -78,8 +79,6 @@ | |||
78 | /* These are here to work with glibc -- Don't change these... */ | 79 | /* These are here to work with glibc -- Don't change these... */ |
79 | #undef FNMATCH_BROKEN | 80 | #undef FNMATCH_BROKEN |
80 | #undef GLOB_BROKEN | 81 | #undef GLOB_BROKEN |
81 | #undef _GNU_SOURCE | ||
82 | #undef __USE_GNU | ||
83 | 82 | ||
84 | #include <assert.h> | 83 | #include <assert.h> |
85 | #include <ctype.h> | 84 | #include <ctype.h> |
@@ -4839,6 +4838,7 @@ static void | |||
4839 | expari(int flag) | 4838 | expari(int flag) |
4840 | { | 4839 | { |
4841 | char *p, *start; | 4840 | char *p, *start; |
4841 | int errcode; | ||
4842 | int result; | 4842 | int result; |
4843 | int begoff; | 4843 | int begoff; |
4844 | int quotes = flag & (EXP_FULL | EXP_CASE); | 4844 | int quotes = flag & (EXP_FULL | EXP_CASE); |
@@ -4877,9 +4877,13 @@ expari(int flag) | |||
4877 | removerecordregions(begoff); | 4877 | removerecordregions(begoff); |
4878 | if (quotes) | 4878 | if (quotes) |
4879 | rmescapes(p+2); | 4879 | rmescapes(p+2); |
4880 | result = arith(p+2); | 4880 | result = arith(p+2, &errcode); |
4881 | if (result < 0) | 4881 | if (errcode < 0) { |
4882 | error("arith: syntax error: \"%s\"\n", p+2); | 4882 | if(errcode == -2) |
4883 | error("divide by zero"); | ||
4884 | else | ||
4885 | error("syntax error: \"%s\"\n", p+2); | ||
4886 | } | ||
4883 | snprintf(p, 12, "%d", result); | 4887 | snprintf(p, 12, "%d", result); |
4884 | 4888 | ||
4885 | while (*p++) | 4889 | while (*p++) |
@@ -5429,9 +5433,9 @@ expandmeta(str, flag) | |||
5429 | goto nometa; | 5433 | goto nometa; |
5430 | p = preglob(str->text); | 5434 | p = preglob(str->text); |
5431 | INTOFF; | 5435 | INTOFF; |
5432 | switch (glob(p, GLOB_NOMAGIC, 0, &pglob)) { | 5436 | switch (glob(p, 0, 0, &pglob)) { |
5433 | case 0: | 5437 | case 0: |
5434 | if (!(pglob.gl_flags & GLOB_MAGCHAR)) | 5438 | if(pglob.gl_pathv[1]==0 && !strcmp(p, pglob.gl_pathv[0])) |
5435 | goto nometa2; | 5439 | goto nometa2; |
5436 | addglob(&pglob); | 5440 | addglob(&pglob); |
5437 | globfree(&pglob); | 5441 | globfree(&pglob); |
@@ -6006,7 +6010,7 @@ static int histcmd(argc, argv) | |||
6006 | struct redirtab { | 6010 | struct redirtab { |
6007 | struct redirtab *next; | 6011 | struct redirtab *next; |
6008 | short renamed[10]; /* Current ash support only 0-9 descriptors */ | 6012 | short renamed[10]; /* Current ash support only 0-9 descriptors */ |
6009 | /* char renamed[10]; */ /* char on arm (and others) can't be negative */ | 6013 | /* char on arm (and others) can't be negative */ |
6010 | }; | 6014 | }; |
6011 | 6015 | ||
6012 | static struct redirtab *redirlist; | 6016 | static struct redirtab *redirlist; |
@@ -6166,7 +6170,7 @@ preadfd(void) | |||
6166 | retry: | 6170 | retry: |
6167 | #ifdef BB_FEATURE_COMMAND_EDITING | 6171 | #ifdef BB_FEATURE_COMMAND_EDITING |
6168 | { | 6172 | { |
6169 | if (parsefile->fd) | 6173 | if (!iflag || parsefile->fd) |
6170 | nr = safe_read(parsefile->fd, buf, BUFSIZ - 1); | 6174 | nr = safe_read(parsefile->fd, buf, BUFSIZ - 1); |
6171 | else { | 6175 | else { |
6172 | nr = cmdedit_read_input((char*)cmdedit_prompt, buf); | 6176 | nr = cmdedit_read_input((char*)cmdedit_prompt, buf); |
@@ -6468,80 +6472,6 @@ static void setjobctl(int enable) | |||
6468 | #endif | 6472 | #endif |
6469 | 6473 | ||
6470 | 6474 | ||
6471 | /* A translation list so we can be polite to our users. */ | ||
6472 | static char *signal_names[NSIG + 2] = { | ||
6473 | "EXIT", | ||
6474 | "SIGHUP", | ||
6475 | "SIGINT", | ||
6476 | "SIGQUIT", | ||
6477 | "SIGILL", | ||
6478 | "SIGTRAP", | ||
6479 | "SIGABRT", | ||
6480 | "SIGBUS", | ||
6481 | "SIGFPE", | ||
6482 | "SIGKILL", | ||
6483 | "SIGUSR1", | ||
6484 | "SIGSEGV", | ||
6485 | "SIGUSR2", | ||
6486 | "SIGPIPE", | ||
6487 | "SIGALRM", | ||
6488 | "SIGTERM", | ||
6489 | "SIGJUNK(16)", | ||
6490 | "SIGCHLD", | ||
6491 | "SIGCONT", | ||
6492 | "SIGSTOP", | ||
6493 | "SIGTSTP", | ||
6494 | "SIGTTIN", | ||
6495 | "SIGTTOU", | ||
6496 | "SIGURG", | ||
6497 | "SIGXCPU", | ||
6498 | "SIGXFSZ", | ||
6499 | "SIGVTALRM", | ||
6500 | "SIGPROF", | ||
6501 | "SIGWINCH", | ||
6502 | "SIGIO", | ||
6503 | "SIGPWR", | ||
6504 | "SIGSYS", | ||
6505 | #ifdef SIGRTMIN | ||
6506 | "SIGRTMIN", | ||
6507 | "SIGRTMIN+1", | ||
6508 | "SIGRTMIN+2", | ||
6509 | "SIGRTMIN+3", | ||
6510 | "SIGRTMIN+4", | ||
6511 | "SIGRTMIN+5", | ||
6512 | "SIGRTMIN+6", | ||
6513 | "SIGRTMIN+7", | ||
6514 | "SIGRTMIN+8", | ||
6515 | "SIGRTMIN+9", | ||
6516 | "SIGRTMIN+10", | ||
6517 | "SIGRTMIN+11", | ||
6518 | "SIGRTMIN+12", | ||
6519 | "SIGRTMIN+13", | ||
6520 | "SIGRTMIN+14", | ||
6521 | "SIGRTMIN+15", | ||
6522 | "SIGRTMAX-15", | ||
6523 | "SIGRTMAX-14", | ||
6524 | "SIGRTMAX-13", | ||
6525 | "SIGRTMAX-12", | ||
6526 | "SIGRTMAX-11", | ||
6527 | "SIGRTMAX-10", | ||
6528 | "SIGRTMAX-9", | ||
6529 | "SIGRTMAX-8", | ||
6530 | "SIGRTMAX-7", | ||
6531 | "SIGRTMAX-6", | ||
6532 | "SIGRTMAX-5", | ||
6533 | "SIGRTMAX-4", | ||
6534 | "SIGRTMAX-3", | ||
6535 | "SIGRTMAX-2", | ||
6536 | "SIGRTMAX-1", | ||
6537 | "SIGRTMAX", | ||
6538 | #endif | ||
6539 | "DEBUG", | ||
6540 | (char *)0x0, | ||
6541 | }; | ||
6542 | |||
6543 | |||
6544 | |||
6545 | #ifdef JOBS | 6475 | #ifdef JOBS |
6546 | static int | 6476 | static int |
6547 | killcmd(argc, argv) | 6477 | killcmd(argc, argv) |
@@ -6599,18 +6529,20 @@ usage: | |||
6599 | } | 6529 | } |
6600 | 6530 | ||
6601 | if (list) { | 6531 | if (list) { |
6532 | const char *name; | ||
6533 | |||
6602 | if (!*argptr) { | 6534 | if (!*argptr) { |
6603 | out1str("0\n"); | 6535 | out1str("0\n"); |
6604 | for (i = 1; i < NSIG; i++) { | 6536 | for (i = 1; i < NSIG; i++) { |
6605 | printf(snlfmt, signal_names[i] + 3); | 6537 | name = u_signal_names(0, &i, 1); |
6538 | if(name) | ||
6539 | printf(snlfmt, name); | ||
6606 | } | 6540 | } |
6607 | return 0; | 6541 | return 0; |
6608 | } | 6542 | } |
6609 | signo = atoi(*argptr); | 6543 | name = u_signal_names(*argptr, &signo, -1); |
6610 | if (signo > 128) | 6544 | if (name) |
6611 | signo -= 128; | 6545 | printf(snlfmt, name); |
6612 | if (0 < signo && signo < NSIG) | ||
6613 | printf(snlfmt, signal_names[signo] + 3); | ||
6614 | else | 6546 | else |
6615 | error("invalid signal number or exit status: %s", | 6547 | error("invalid signal number or exit status: %s", |
6616 | *argptr); | 6548 | *argptr); |
@@ -8834,12 +8766,6 @@ copynodelist(const struct nodelist *lp) | |||
8834 | static char * | 8766 | static char * |
8835 | nodesavestr(const char *s) | 8767 | nodesavestr(const char *s) |
8836 | { | 8768 | { |
8837 | #ifdef _GNU_SOURCE | ||
8838 | char *rtn = funcstring; | ||
8839 | |||
8840 | funcstring = stpcpy(funcstring, s) + 1; | ||
8841 | return rtn; | ||
8842 | #else | ||
8843 | const char *p = s; | 8769 | const char *p = s; |
8844 | char *q = funcstring; | 8770 | char *q = funcstring; |
8845 | char *rtn = funcstring; | 8771 | char *rtn = funcstring; |
@@ -8848,7 +8774,6 @@ nodesavestr(const char *s) | |||
8848 | continue; | 8774 | continue; |
8849 | funcstring = q; | 8775 | funcstring = q; |
8850 | return rtn; | 8776 | return rtn; |
8851 | #endif | ||
8852 | } | 8777 | } |
8853 | 8778 | ||
8854 | #ifdef ASH_GETOPTS | 8779 | #ifdef ASH_GETOPTS |
@@ -12052,11 +11977,15 @@ trapcmd(argc, argv) | |||
12052 | for (signo = 0 ; signo < NSIG ; signo++) { | 11977 | for (signo = 0 ; signo < NSIG ; signo++) { |
12053 | if (trap[signo] != NULL) { | 11978 | if (trap[signo] != NULL) { |
12054 | char *p; | 11979 | char *p; |
11980 | const char *sn; | ||
12055 | 11981 | ||
12056 | p = single_quote(trap[signo]); | 11982 | p = single_quote(trap[signo]); |
12057 | printf("trap -- %s %s\n", p, | 11983 | sn = sys_siglist[signo]; |
12058 | signal_names[signo] + (signo ? 3 : 0) | 11984 | if(sn==NULL) |
12059 | ); | 11985 | sn = u_signal_names(0, &signo, 0); |
11986 | if(sn==NULL) | ||
11987 | sn = "???"; | ||
11988 | printf("trap -- %s %s\n", p, sn); | ||
12060 | stunalloc(p); | 11989 | stunalloc(p); |
12061 | } | 11990 | } |
12062 | } | 11991 | } |
@@ -12273,30 +12202,11 @@ l2: _exit(status); | |||
12273 | static int decode_signal(const char *string, int minsig) | 12202 | static int decode_signal(const char *string, int minsig) |
12274 | { | 12203 | { |
12275 | int signo; | 12204 | int signo; |
12205 | const char *name = u_signal_names(string, &signo, minsig); | ||
12276 | 12206 | ||
12277 | if (is_number(string, &signo)) { | 12207 | return name ? signo : -1; |
12278 | if (signo >= NSIG) { | ||
12279 | return -1; | ||
12280 | } | ||
12281 | return signo; | ||
12282 | } | ||
12283 | |||
12284 | signo = minsig; | ||
12285 | if (!signo) { | ||
12286 | goto zero; | ||
12287 | } | ||
12288 | for (; signo < NSIG; signo++) { | ||
12289 | if (!strcasecmp(string, &(signal_names[signo])[3])) { | ||
12290 | return signo; | ||
12291 | } | ||
12292 | zero: | ||
12293 | if (!strcasecmp(string, signal_names[signo])) { | ||
12294 | return signo; | ||
12295 | } | ||
12296 | } | ||
12297 | |||
12298 | return -1; | ||
12299 | } | 12208 | } |
12209 | |||
12300 | static struct var **hashvar (const char *); | 12210 | static struct var **hashvar (const char *); |
12301 | static void showvars (const char *, int, int); | 12211 | static void showvars (const char *, int, int); |
12302 | static struct var **findvar (struct var **, const char *); | 12212 | static struct var **findvar (struct var **, const char *); |
@@ -12616,6 +12526,7 @@ found:; | |||
12616 | return 0; | 12526 | return 0; |
12617 | } | 12527 | } |
12618 | 12528 | ||
12529 | |||
12619 | /* | 12530 | /* |
12620 | * The "local" command. | 12531 | * The "local" command. |
12621 | */ | 12532 | */ |
@@ -12874,7 +12785,7 @@ findvar(struct var **vpp, const char *name) | |||
12874 | /* | 12785 | /* |
12875 | * Copyright (c) 1999 Herbert Xu <herbert@debian.org> | 12786 | * Copyright (c) 1999 Herbert Xu <herbert@debian.org> |
12876 | * This file contains code for the times builtin. | 12787 | * This file contains code for the times builtin. |
12877 | * $Id: ash.c,v 1.16 2001/08/01 17:21:33 kraai Exp $ | 12788 | * $Id: ash.c,v 1.17 2001/08/02 05:02:45 andersen Exp $ |
12878 | */ | 12789 | */ |
12879 | static int timescmd (int argc, char **argv) | 12790 | static int timescmd (int argc, char **argv) |
12880 | { | 12791 | { |
@@ -12894,24 +12805,32 @@ static int timescmd (int argc, char **argv) | |||
12894 | return 0; | 12805 | return 0; |
12895 | } | 12806 | } |
12896 | 12807 | ||
12897 | |||
12898 | #ifdef ASH_MATH_SUPPORT | 12808 | #ifdef ASH_MATH_SUPPORT |
12899 | /* The let builtin. */ | 12809 | /* The let builtin. */ |
12900 | int letcmd(int argc, char **argv) | 12810 | int letcmd(int argc, char **argv) |
12901 | { | 12811 | { |
12812 | int errcode; | ||
12902 | long result=0; | 12813 | long result=0; |
12903 | if (argc == 2) { | 12814 | if (argc == 2) { |
12904 | char *tmp, *expression, p[13]; | 12815 | char *tmp, *expression, p[13]; |
12905 | expression = strchr(argv[1], '='); | 12816 | expression = strchr(argv[1], '='); |
12906 | if (!expression) { | 12817 | if (!expression) { |
12818 | /* Cannot use 'error()' here, or the return code | ||
12819 | * will be incorrect */ | ||
12907 | out2fmt("sh: let: syntax error: \"%s\"\n", argv[1]); | 12820 | out2fmt("sh: let: syntax error: \"%s\"\n", argv[1]); |
12908 | return 0; | 12821 | return 0; |
12909 | } | 12822 | } |
12910 | *expression = '\0'; | 12823 | *expression = '\0'; |
12911 | tmp = ++expression; | 12824 | tmp = ++expression; |
12912 | result = arith(tmp); | 12825 | result = arith(tmp, &errcode); |
12913 | if (result < 0) { | 12826 | if (errcode < 0) { |
12914 | out2fmt("sh: let: syntax error: \"%s=%s\"\n", argv[1], expression); | 12827 | /* Cannot use 'error()' here, or the return code |
12828 | * will be incorrect */ | ||
12829 | out2fmt("sh: let: "); | ||
12830 | if(errcode == -2) | ||
12831 | out2fmt("divide by zero"); | ||
12832 | else | ||
12833 | out2fmt("syntax error: \"%s=%s\"\n", argv[1], expression); | ||
12915 | return 0; | 12834 | return 0; |
12916 | } | 12835 | } |
12917 | snprintf(p, 12, "%ld", result); | 12836 | snprintf(p, 12, "%ld", result); |
@@ -1167,25 +1167,21 @@ int cmdedit_read_input(char *prompt, char command[BUFSIZ]) | |||
1167 | len = 0; | 1167 | len = 0; |
1168 | command_ps = command; | 1168 | command_ps = command; |
1169 | 1169 | ||
1170 | if (new_settings.c_cc[VERASE] == 0) { /* first call */ | 1170 | getTermSettings(0, (void *) &initial_settings); |
1171 | 1171 | memcpy(&new_settings, &initial_settings, sizeof(struct termios)); | |
1172 | getTermSettings(0, (void *) &initial_settings); | 1172 | new_settings.c_lflag &= ~ICANON; /* unbuffered input */ |
1173 | memcpy(&new_settings, &initial_settings, sizeof(struct termios)); | 1173 | /* Turn off echoing and CTRL-C, so we can trap it */ |
1174 | new_settings.c_lflag &= ~ICANON; /* unbuffered input */ | 1174 | new_settings.c_lflag &= ~(ECHO | ECHONL | ISIG); |
1175 | /* Turn off echoing and CTRL-C, so we can trap it */ | ||
1176 | new_settings.c_lflag &= ~(ECHO | ECHONL | ISIG); | ||
1177 | #ifndef linux | 1175 | #ifndef linux |
1178 | /* Hmm, in linux c_cc[] not parsed if set ~ICANON */ | 1176 | /* Hmm, in linux c_cc[] not parsed if set ~ICANON */ |
1179 | new_settings.c_cc[VMIN] = 1; | 1177 | new_settings.c_cc[VMIN] = 1; |
1180 | new_settings.c_cc[VTIME] = 0; | 1178 | new_settings.c_cc[VTIME] = 0; |
1181 | /* Turn off CTRL-C, so we can trap it */ | 1179 | /* Turn off CTRL-C, so we can trap it */ |
1182 | # ifndef _POSIX_VDISABLE | 1180 | # ifndef _POSIX_VDISABLE |
1183 | # define _POSIX_VDISABLE '\0' | 1181 | # define _POSIX_VDISABLE '\0' |
1184 | # endif | 1182 | # endif |
1185 | new_settings.c_cc[VINTR] = _POSIX_VDISABLE; | 1183 | new_settings.c_cc[VINTR] = _POSIX_VDISABLE; |
1186 | #endif | 1184 | #endif |
1187 | } | ||
1188 | |||
1189 | command[0] = 0; | 1185 | command[0] = 0; |
1190 | 1186 | ||
1191 | setTermSettings(0, (void *) &new_settings); | 1187 | setTermSettings(0, (void *) &new_settings); |
diff --git a/coreutils/cut.c b/coreutils/cut.c index abe05726b..3ed264870 100644 --- a/coreutils/cut.c +++ b/coreutils/cut.c | |||
@@ -344,10 +344,8 @@ extern int cut_main(int argc, char **argv) | |||
344 | int i; | 344 | int i; |
345 | FILE *file; | 345 | FILE *file; |
346 | for (i = optind; i < argc; i++) { | 346 | for (i = optind; i < argc; i++) { |
347 | file = fopen(argv[i], "r"); | 347 | file = wfopen(argv[i], "r"); |
348 | if (file == NULL) { | 348 | if(file) { |
349 | perror_msg("%s", argv[i]); | ||
350 | } else { | ||
351 | cut_file(file); | 349 | cut_file(file); |
352 | fclose(file); | 350 | fclose(file); |
353 | } | 351 | } |
diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c index 6ac9f1bf3..a4059ddfe 100644 --- a/coreutils/uudecode.c +++ b/coreutils/uudecode.c | |||
@@ -201,9 +201,8 @@ static int decode (const char *inname, | |||
201 | const char *forced_outname) | 201 | const char *forced_outname) |
202 | { | 202 | { |
203 | struct passwd *pw; | 203 | struct passwd *pw; |
204 | register int n; | ||
205 | register char *p; | 204 | register char *p; |
206 | int mode, n1; | 205 | int mode; |
207 | char buf[2 * BUFSIZ]; | 206 | char buf[2 * BUFSIZ]; |
208 | char *outname; | 207 | char *outname; |
209 | int do_base64 = 0; | 208 | int do_base64 = 0; |
@@ -249,12 +248,7 @@ static int decode (const char *inname, | |||
249 | error_msg("%s: No user `%s'", inname, buf + 1); | 248 | error_msg("%s: No user `%s'", inname, buf + 1); |
250 | return FALSE; | 249 | return FALSE; |
251 | } | 250 | } |
252 | n = strlen (pw->pw_dir); | 251 | outname = concat_path_file(pw->pw_dir, p); |
253 | n1 = strlen (p); | ||
254 | outname = (char *) xmalloc ((size_t) (n + n1 + 2)); | ||
255 | memcpy (outname + n + 1, p, (size_t) (n1 + 1)); | ||
256 | memcpy (outname, pw->pw_dir, (size_t) n); | ||
257 | outname[n] = '/'; | ||
258 | dofre = TRUE; | 252 | dofre = TRUE; |
259 | } | 253 | } |
260 | } | 254 | } |
@@ -344,10 +344,8 @@ extern int cut_main(int argc, char **argv) | |||
344 | int i; | 344 | int i; |
345 | FILE *file; | 345 | FILE *file; |
346 | for (i = optind; i < argc; i++) { | 346 | for (i = optind; i < argc; i++) { |
347 | file = fopen(argv[i], "r"); | 347 | file = wfopen(argv[i], "r"); |
348 | if (file == NULL) { | 348 | if(file) { |
349 | perror_msg("%s", argv[i]); | ||
350 | } else { | ||
351 | cut_file(file); | 349 | cut_file(file); |
352 | fclose(file); | 350 | fclose(file); |
353 | } | 351 | } |
diff --git a/include/libbb.h b/include/libbb.h index 66acc2278..df52027ce 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -212,7 +212,7 @@ char *xreadlink(const char *path); | |||
212 | char *concat_path_file(const char *path, const char *filename); | 212 | char *concat_path_file(const char *path, const char *filename); |
213 | char *last_char_is(const char *s, int c); | 213 | char *last_char_is(const char *s, int c); |
214 | 214 | ||
215 | extern long arith (const char *startbuf); | 215 | extern long arith (const char *startbuf, int *errcode); |
216 | 216 | ||
217 | typedef struct file_headers_s { | 217 | typedef struct file_headers_s { |
218 | char *name; | 218 | char *name; |
@@ -261,6 +261,8 @@ char *dirname (const char *path); | |||
261 | 261 | ||
262 | int make_directory (char *path, mode_t mode, int flags); | 262 | int make_directory (char *path, mode_t mode, int flags); |
263 | 263 | ||
264 | const char *u_signal_names(const char *str_sig, int *signo, int startnum); | ||
265 | |||
264 | #define CT_AUTO 0 | 266 | #define CT_AUTO 0 |
265 | #define CT_UNIX2DOS 1 | 267 | #define CT_UNIX2DOS 1 |
266 | #define CT_DOS2UNIX 2 | 268 | #define CT_DOS2UNIX 2 |
@@ -34,96 +34,11 @@ | |||
34 | static const int KILL = 0; | 34 | static const int KILL = 0; |
35 | static const int KILLALL = 1; | 35 | static const int KILLALL = 1; |
36 | 36 | ||
37 | struct signal_name { | ||
38 | const char *name; | ||
39 | int number; | ||
40 | }; | ||
41 | |||
42 | static const struct signal_name signames[] = { | ||
43 | /* POSIX signals */ | ||
44 | { "HUP", SIGHUP }, /* 1 */ | ||
45 | { "INT", SIGINT }, /* 2 */ | ||
46 | { "QUIT", SIGQUIT }, /* 3 */ | ||
47 | { "ILL", SIGILL }, /* 4 */ | ||
48 | { "ABRT", SIGABRT }, /* 6 */ | ||
49 | { "FPE", SIGFPE }, /* 8 */ | ||
50 | { "KILL", SIGKILL }, /* 9 */ | ||
51 | { "SEGV", SIGSEGV }, /* 11 */ | ||
52 | { "PIPE", SIGPIPE }, /* 13 */ | ||
53 | { "ALRM", SIGALRM }, /* 14 */ | ||
54 | { "TERM", SIGTERM }, /* 15 */ | ||
55 | { "USR1", SIGUSR1 }, /* 10 (arm,i386,m68k,ppc), 30 (alpha,sparc*), 16 (mips) */ | ||
56 | { "USR2", SIGUSR2 }, /* 12 (arm,i386,m68k,ppc), 31 (alpha,sparc*), 17 (mips) */ | ||
57 | { "CHLD", SIGCHLD }, /* 17 (arm,i386,m68k,ppc), 20 (alpha,sparc*), 18 (mips) */ | ||
58 | { "CONT", SIGCONT }, /* 18 (arm,i386,m68k,ppc), 19 (alpha,sparc*), 25 (mips) */ | ||
59 | { "STOP", SIGSTOP }, /* 19 (arm,i386,m68k,ppc), 17 (alpha,sparc*), 23 (mips) */ | ||
60 | { "TSTP", SIGTSTP }, /* 20 (arm,i386,m68k,ppc), 18 (alpha,sparc*), 24 (mips) */ | ||
61 | { "TTIN", SIGTTIN }, /* 21 (arm,i386,m68k,ppc,alpha,sparc*), 26 (mips) */ | ||
62 | { "TTOU", SIGTTOU }, /* 22 (arm,i386,m68k,ppc,alpha,sparc*), 27 (mips) */ | ||
63 | /* Miscellaneous other signals */ | ||
64 | #ifdef SIGTRAP | ||
65 | { "TRAP", SIGTRAP }, /* 5 */ | ||
66 | #endif | ||
67 | #ifdef SIGIOT | ||
68 | { "IOT", SIGIOT }, /* 6, same as SIGABRT */ | ||
69 | #endif | ||
70 | #ifdef SIGEMT | ||
71 | { "EMT", SIGEMT }, /* 7 (mips,alpha,sparc*) */ | ||
72 | #endif | ||
73 | #ifdef SIGBUS | ||
74 | { "BUS", SIGBUS }, /* 7 (arm,i386,m68k,ppc), 10 (mips,alpha,sparc*) */ | ||
75 | #endif | ||
76 | #ifdef SIGSYS | ||
77 | { "SYS", SIGSYS }, /* 12 (mips,alpha,sparc*) */ | ||
78 | #endif | ||
79 | #ifdef SIGSTKFLT | ||
80 | { "STKFLT", SIGSTKFLT }, /* 16 (arm,i386,m68k,ppc) */ | ||
81 | #endif | ||
82 | #ifdef SIGURG | ||
83 | { "URG", SIGURG }, /* 23 (arm,i386,m68k,ppc), 16 (alpha,sparc*), 21 (mips) */ | ||
84 | #endif | ||
85 | #ifdef SIGIO | ||
86 | { "IO", SIGIO }, /* 29 (arm,i386,m68k,ppc), 23 (alpha,sparc*), 22 (mips) */ | ||
87 | #endif | ||
88 | #ifdef SIGPOLL | ||
89 | { "POLL", SIGPOLL }, /* same as SIGIO */ | ||
90 | #endif | ||
91 | #ifdef SIGCLD | ||
92 | { "CLD", SIGCLD }, /* same as SIGCHLD (mips) */ | ||
93 | #endif | ||
94 | #ifdef SIGXCPU | ||
95 | { "XCPU", SIGXCPU }, /* 24 (arm,i386,m68k,ppc,alpha,sparc*), 30 (mips) */ | ||
96 | #endif | ||
97 | #ifdef SIGXFSZ | ||
98 | { "XFSZ", SIGXFSZ }, /* 25 (arm,i386,m68k,ppc,alpha,sparc*), 31 (mips) */ | ||
99 | #endif | ||
100 | #ifdef SIGVTALRM | ||
101 | { "VTALRM", SIGVTALRM }, /* 26 (arm,i386,m68k,ppc,alpha,sparc*), 28 (mips) */ | ||
102 | #endif | ||
103 | #ifdef SIGPROF | ||
104 | { "PROF", SIGPROF }, /* 27 (arm,i386,m68k,ppc,alpha,sparc*), 29 (mips) */ | ||
105 | #endif | ||
106 | #ifdef SIGPWR | ||
107 | { "PWR", SIGPWR }, /* 30 (arm,i386,m68k,ppc), 29 (alpha,sparc*), 19 (mips) */ | ||
108 | #endif | ||
109 | #ifdef SIGINFO | ||
110 | { "INFO", SIGINFO }, /* 29 (alpha) */ | ||
111 | #endif | ||
112 | #ifdef SIGLOST | ||
113 | { "LOST", SIGLOST }, /* 29 (arm,i386,m68k,ppc,sparc*) */ | ||
114 | #endif | ||
115 | #ifdef SIGWINCH | ||
116 | { "WINCH", SIGWINCH }, /* 28 (arm,i386,m68k,ppc,alpha,sparc*), 20 (mips) */ | ||
117 | #endif | ||
118 | #ifdef SIGUNUSED | ||
119 | { "UNUSED", SIGUNUSED }, /* 31 (arm,i386,m68k,ppc) */ | ||
120 | #endif | ||
121 | {0, 0} | ||
122 | }; | ||
123 | 37 | ||
124 | extern int kill_main(int argc, char **argv) | 38 | extern int kill_main(int argc, char **argv) |
125 | { | 39 | { |
126 | int whichApp, sig = SIGTERM; | 40 | int whichApp, sig = SIGTERM; |
41 | const char *name; | ||
127 | 42 | ||
128 | #ifdef BB_KILLALL | 43 | #ifdef BB_KILLALL |
129 | /* Figure out what we are trying to do here */ | 44 | /* Figure out what we are trying to do here */ |
@@ -142,52 +57,37 @@ extern int kill_main(int argc, char **argv) | |||
142 | while (*++(*argv)) { | 57 | while (*++(*argv)) { |
143 | switch (**argv) { | 58 | switch (**argv) { |
144 | case 'l': | 59 | case 'l': |
145 | { | 60 | if(argc>1) { |
61 | for(argv++; *argv; argv++) { | ||
62 | name = u_signal_names(*argv, &sig, -1); | ||
63 | if(name!=NULL) | ||
64 | printf("%s\n", name); | ||
65 | } | ||
66 | } else { | ||
146 | int col = 0; | 67 | int col = 0; |
147 | const struct signal_name *s = signames; | 68 | for(sig=1; sig < NSIG; sig++) { |
148 | 69 | name = u_signal_names(0, &sig, 1); | |
149 | while (s->name != 0) { | 70 | if(name==NULL) /* unnamed */ |
150 | col += fprintf(stderr, "%2d) %-8s", s->number, s->name); | 71 | continue; |
151 | s++; | 72 | col += printf("%2d) %-16s", sig, name); |
152 | if (col > 60) { | 73 | if (col > 60) { |
153 | fprintf(stderr, "\n"); | 74 | printf("\n"); |
154 | col = 0; | 75 | col = 0; |
155 | } | 76 | } |
156 | } | 77 | } |
157 | fprintf(stderr, "\n\n"); | 78 | printf("\n"); |
158 | return EXIT_SUCCESS; | ||
159 | } | 79 | } |
160 | break; | 80 | return EXIT_SUCCESS; |
161 | case '-': | 81 | case '-': |
162 | show_usage(); | 82 | show_usage(); |
163 | default: | 83 | default: |
164 | { | 84 | name = u_signal_names(*argv, &sig, 0); |
165 | if (isdigit(**argv)) { | 85 | if(name==NULL) |
166 | sig = atoi(*argv); | 86 | error_msg_and_die( "bad signal name: %s", *argv); |
167 | if (sig < 0 || sig >= NSIG) | ||
168 | goto end; | ||
169 | else { | ||
170 | argc--; | ||
171 | argv++; | ||
172 | goto do_it_now; | ||
173 | } | ||
174 | } else { | ||
175 | const struct signal_name *s = signames; | ||
176 | |||
177 | while (s->name != 0) { | ||
178 | if (strcasecmp(s->name, *argv) == 0) { | ||
179 | sig = s->number; | ||
180 | argc--; | 87 | argc--; |
181 | argv++; | 88 | argv++; |
182 | goto do_it_now; | 89 | goto do_it_now; |
183 | } | 90 | } |
184 | s++; | ||
185 | } | ||
186 | if (s->name == 0) | ||
187 | goto end; | ||
188 | } | ||
189 | } | ||
190 | } | ||
191 | argc--; | 91 | argc--; |
192 | argv++; | 92 | argv++; |
193 | } | 93 | } |
@@ -239,8 +139,4 @@ extern int kill_main(int argc, char **argv) | |||
239 | #endif | 139 | #endif |
240 | 140 | ||
241 | return EXIT_SUCCESS; | 141 | return EXIT_SUCCESS; |
242 | |||
243 | |||
244 | end: | ||
245 | error_msg_and_die( "bad signal name: %s", *argv); | ||
246 | } | 142 | } |
diff --git a/libbb/arith.c b/libbb/arith.c index c7a3cf98b..04c45ec3d 100644 --- a/libbb/arith.c +++ b/libbb/arith.c | |||
@@ -119,20 +119,26 @@ static short arith_apply(operator op, long *numstack, long **numstackptr) | |||
119 | NUMPTR[-1] = (NUMPTR[-1] <= *NUMPTR); | 119 | NUMPTR[-1] = (NUMPTR[-1] <= *NUMPTR); |
120 | else if (op == TOK_MUL) | 120 | else if (op == TOK_MUL) |
121 | NUMPTR[-1] *= *NUMPTR; | 121 | NUMPTR[-1] *= *NUMPTR; |
122 | else if (op == TOK_DIV) | 122 | else if (op == TOK_DIV) { |
123 | if(*NUMPTR==0) | ||
124 | return -2; | ||
123 | NUMPTR[-1] /= *NUMPTR; | 125 | NUMPTR[-1] /= *NUMPTR; |
124 | else if (op == TOK_REM) | 126 | } |
127 | else if (op == TOK_REM) { | ||
128 | if(*NUMPTR==0) | ||
129 | return -2; | ||
125 | NUMPTR[-1] %= *NUMPTR; | 130 | NUMPTR[-1] %= *NUMPTR; |
131 | } | ||
126 | else if (op == TOK_ADD) | 132 | else if (op == TOK_ADD) |
127 | NUMPTR[-1] += *NUMPTR; | 133 | NUMPTR[-1] += *NUMPTR; |
128 | else if (op == TOK_SUB) | 134 | else if (op == TOK_SUB) |
129 | NUMPTR[-1] -= *NUMPTR; | 135 | NUMPTR[-1] -= *NUMPTR; |
130 | } | 136 | } |
131 | return 0; | 137 | return 0; |
132 | err: return(1); | 138 | err: return(-1); |
133 | } | 139 | } |
134 | 140 | ||
135 | extern long arith (const char *startbuf) | 141 | extern long arith (const char *startbuf, int *errcode) |
136 | { | 142 | { |
137 | register char arithval; | 143 | register char arithval; |
138 | const char *expr = startbuf; | 144 | const char *expr = startbuf; |
@@ -142,8 +148,9 @@ extern long arith (const char *startbuf) | |||
142 | unsigned char prec; | 148 | unsigned char prec; |
143 | 149 | ||
144 | long *numstack, *numstackptr; | 150 | long *numstack, *numstackptr; |
145 | |||
146 | operator *stack = alloca(datasizes * sizeof(operator)), *stackptr = stack; | 151 | operator *stack = alloca(datasizes * sizeof(operator)), *stackptr = stack; |
152 | |||
153 | *errcode = 0; | ||
147 | numstack = alloca((datasizes/2+1)*sizeof(long)), numstackptr = numstack; | 154 | numstack = alloca((datasizes/2+1)*sizeof(long)), numstackptr = numstack; |
148 | 155 | ||
149 | while ((arithval = *expr)) { | 156 | while ((arithval = *expr)) { |
@@ -163,7 +170,8 @@ extern long arith (const char *startbuf) | |||
163 | op = *--stackptr; | 170 | op = *--stackptr; |
164 | if (op == TOK_LPAREN) | 171 | if (op == TOK_LPAREN) |
165 | goto prologue; | 172 | goto prologue; |
166 | if(ARITH_APPLY(op)) goto err; | 173 | *errcode = ARITH_APPLY(op); |
174 | if(*errcode) return *errcode; | ||
167 | } | 175 | } |
168 | goto err; /* Mismatched parens */ | 176 | goto err; /* Mismatched parens */ |
169 | } if (arithval == '|') { | 177 | } if (arithval == '|') { |
@@ -231,17 +239,22 @@ extern long arith (const char *startbuf) | |||
231 | 239 | ||
232 | prec = PREC(op); | 240 | prec = PREC(op); |
233 | if (prec != UNARYPREC) | 241 | if (prec != UNARYPREC) |
234 | while (stackptr != stack && PREC(stackptr[-1]) >= prec) | 242 | while (stackptr != stack && PREC(stackptr[-1]) >= prec) { |
235 | if(ARITH_APPLY(*--stackptr)) goto err; | 243 | *errcode = ARITH_APPLY(*--stackptr); |
244 | if(*errcode) return *errcode; | ||
245 | } | ||
236 | *stackptr++ = op; | 246 | *stackptr++ = op; |
237 | lasttok = op; | 247 | lasttok = op; |
238 | prologue: ++expr; | 248 | prologue: ++expr; |
239 | } /* yay */ | 249 | } /* yay */ |
240 | 250 | ||
241 | while (stackptr != stack) | 251 | while (stackptr != stack) { |
242 | if(ARITH_APPLY(*--stackptr)) goto err; | 252 | *errcode = ARITH_APPLY(*--stackptr); |
253 | if(*errcode) return *errcode; | ||
254 | } | ||
243 | if (numstackptr != numstack+1) { | 255 | if (numstackptr != numstack+1) { |
244 | err: | 256 | err: |
257 | *errcode = -1; | ||
245 | return -1; | 258 | return -1; |
246 | /* NOTREACHED */ | 259 | /* NOTREACHED */ |
247 | } | 260 | } |
diff --git a/libbb/concat_path_file.c b/libbb/concat_path_file.c index c699a84f7..86dd2fbbf 100644 --- a/libbb/concat_path_file.c +++ b/libbb/concat_path_file.c | |||
@@ -17,7 +17,7 @@ extern char *concat_path_file(const char *path, const char *filename) | |||
17 | if (!path) | 17 | if (!path) |
18 | path=""; | 18 | path=""; |
19 | lc = last_char_is(path, '/'); | 19 | lc = last_char_is(path, '/'); |
20 | if (filename[0] == '/') | 20 | while (*filename == '/') |
21 | filename++; | 21 | filename++; |
22 | outbuf = xmalloc(strlen(path)+strlen(filename)+1+(lc==NULL)); | 22 | outbuf = xmalloc(strlen(path)+strlen(filename)+1+(lc==NULL)); |
23 | sprintf(outbuf, "%s%s%s", path, (lc==NULL)? "/" : "", filename); | 23 | sprintf(outbuf, "%s%s%s", path, (lc==NULL)? "/" : "", filename); |
diff --git a/libbb/libbb.h b/libbb/libbb.h index 66acc2278..df52027ce 100644 --- a/libbb/libbb.h +++ b/libbb/libbb.h | |||
@@ -212,7 +212,7 @@ char *xreadlink(const char *path); | |||
212 | char *concat_path_file(const char *path, const char *filename); | 212 | char *concat_path_file(const char *path, const char *filename); |
213 | char *last_char_is(const char *s, int c); | 213 | char *last_char_is(const char *s, int c); |
214 | 214 | ||
215 | extern long arith (const char *startbuf); | 215 | extern long arith (const char *startbuf, int *errcode); |
216 | 216 | ||
217 | typedef struct file_headers_s { | 217 | typedef struct file_headers_s { |
218 | char *name; | 218 | char *name; |
@@ -261,6 +261,8 @@ char *dirname (const char *path); | |||
261 | 261 | ||
262 | int make_directory (char *path, mode_t mode, int flags); | 262 | int make_directory (char *path, mode_t mode, int flags); |
263 | 263 | ||
264 | const char *u_signal_names(const char *str_sig, int *signo, int startnum); | ||
265 | |||
264 | #define CT_AUTO 0 | 266 | #define CT_AUTO 0 |
265 | #define CT_UNIX2DOS 1 | 267 | #define CT_UNIX2DOS 1 |
266 | #define CT_DOS2UNIX 2 | 268 | #define CT_DOS2UNIX 2 |
diff --git a/miscutils/update.c b/miscutils/update.c index 603740e38..27a04ddee 100644 --- a/miscutils/update.c +++ b/miscutils/update.c | |||
@@ -69,9 +69,6 @@ extern int update_main(int argc, char **argv) | |||
69 | if (daemon(0, 1) < 0) | 69 | if (daemon(0, 1) < 0) |
70 | perror_msg_and_die("daemon"); | 70 | perror_msg_and_die("daemon"); |
71 | 71 | ||
72 | /* Become a proper daemon */ | ||
73 | setsid(); | ||
74 | chdir("/"); | ||
75 | #ifdef OPEN_MAX | 72 | #ifdef OPEN_MAX |
76 | for (pid = 0; pid < OPEN_MAX; pid++) close(pid); | 73 | for (pid = 0; pid < OPEN_MAX; pid++) close(pid); |
77 | #else | 74 | #else |
diff --git a/procps/kill.c b/procps/kill.c index 34cbc4d6a..3884ebdf4 100644 --- a/procps/kill.c +++ b/procps/kill.c | |||
@@ -34,96 +34,11 @@ | |||
34 | static const int KILL = 0; | 34 | static const int KILL = 0; |
35 | static const int KILLALL = 1; | 35 | static const int KILLALL = 1; |
36 | 36 | ||
37 | struct signal_name { | ||
38 | const char *name; | ||
39 | int number; | ||
40 | }; | ||
41 | |||
42 | static const struct signal_name signames[] = { | ||
43 | /* POSIX signals */ | ||
44 | { "HUP", SIGHUP }, /* 1 */ | ||
45 | { "INT", SIGINT }, /* 2 */ | ||
46 | { "QUIT", SIGQUIT }, /* 3 */ | ||
47 | { "ILL", SIGILL }, /* 4 */ | ||
48 | { "ABRT", SIGABRT }, /* 6 */ | ||
49 | { "FPE", SIGFPE }, /* 8 */ | ||
50 | { "KILL", SIGKILL }, /* 9 */ | ||
51 | { "SEGV", SIGSEGV }, /* 11 */ | ||
52 | { "PIPE", SIGPIPE }, /* 13 */ | ||
53 | { "ALRM", SIGALRM }, /* 14 */ | ||
54 | { "TERM", SIGTERM }, /* 15 */ | ||
55 | { "USR1", SIGUSR1 }, /* 10 (arm,i386,m68k,ppc), 30 (alpha,sparc*), 16 (mips) */ | ||
56 | { "USR2", SIGUSR2 }, /* 12 (arm,i386,m68k,ppc), 31 (alpha,sparc*), 17 (mips) */ | ||
57 | { "CHLD", SIGCHLD }, /* 17 (arm,i386,m68k,ppc), 20 (alpha,sparc*), 18 (mips) */ | ||
58 | { "CONT", SIGCONT }, /* 18 (arm,i386,m68k,ppc), 19 (alpha,sparc*), 25 (mips) */ | ||
59 | { "STOP", SIGSTOP }, /* 19 (arm,i386,m68k,ppc), 17 (alpha,sparc*), 23 (mips) */ | ||
60 | { "TSTP", SIGTSTP }, /* 20 (arm,i386,m68k,ppc), 18 (alpha,sparc*), 24 (mips) */ | ||
61 | { "TTIN", SIGTTIN }, /* 21 (arm,i386,m68k,ppc,alpha,sparc*), 26 (mips) */ | ||
62 | { "TTOU", SIGTTOU }, /* 22 (arm,i386,m68k,ppc,alpha,sparc*), 27 (mips) */ | ||
63 | /* Miscellaneous other signals */ | ||
64 | #ifdef SIGTRAP | ||
65 | { "TRAP", SIGTRAP }, /* 5 */ | ||
66 | #endif | ||
67 | #ifdef SIGIOT | ||
68 | { "IOT", SIGIOT }, /* 6, same as SIGABRT */ | ||
69 | #endif | ||
70 | #ifdef SIGEMT | ||
71 | { "EMT", SIGEMT }, /* 7 (mips,alpha,sparc*) */ | ||
72 | #endif | ||
73 | #ifdef SIGBUS | ||
74 | { "BUS", SIGBUS }, /* 7 (arm,i386,m68k,ppc), 10 (mips,alpha,sparc*) */ | ||
75 | #endif | ||
76 | #ifdef SIGSYS | ||
77 | { "SYS", SIGSYS }, /* 12 (mips,alpha,sparc*) */ | ||
78 | #endif | ||
79 | #ifdef SIGSTKFLT | ||
80 | { "STKFLT", SIGSTKFLT }, /* 16 (arm,i386,m68k,ppc) */ | ||
81 | #endif | ||
82 | #ifdef SIGURG | ||
83 | { "URG", SIGURG }, /* 23 (arm,i386,m68k,ppc), 16 (alpha,sparc*), 21 (mips) */ | ||
84 | #endif | ||
85 | #ifdef SIGIO | ||
86 | { "IO", SIGIO }, /* 29 (arm,i386,m68k,ppc), 23 (alpha,sparc*), 22 (mips) */ | ||
87 | #endif | ||
88 | #ifdef SIGPOLL | ||
89 | { "POLL", SIGPOLL }, /* same as SIGIO */ | ||
90 | #endif | ||
91 | #ifdef SIGCLD | ||
92 | { "CLD", SIGCLD }, /* same as SIGCHLD (mips) */ | ||
93 | #endif | ||
94 | #ifdef SIGXCPU | ||
95 | { "XCPU", SIGXCPU }, /* 24 (arm,i386,m68k,ppc,alpha,sparc*), 30 (mips) */ | ||
96 | #endif | ||
97 | #ifdef SIGXFSZ | ||
98 | { "XFSZ", SIGXFSZ }, /* 25 (arm,i386,m68k,ppc,alpha,sparc*), 31 (mips) */ | ||
99 | #endif | ||
100 | #ifdef SIGVTALRM | ||
101 | { "VTALRM", SIGVTALRM }, /* 26 (arm,i386,m68k,ppc,alpha,sparc*), 28 (mips) */ | ||
102 | #endif | ||
103 | #ifdef SIGPROF | ||
104 | { "PROF", SIGPROF }, /* 27 (arm,i386,m68k,ppc,alpha,sparc*), 29 (mips) */ | ||
105 | #endif | ||
106 | #ifdef SIGPWR | ||
107 | { "PWR", SIGPWR }, /* 30 (arm,i386,m68k,ppc), 29 (alpha,sparc*), 19 (mips) */ | ||
108 | #endif | ||
109 | #ifdef SIGINFO | ||
110 | { "INFO", SIGINFO }, /* 29 (alpha) */ | ||
111 | #endif | ||
112 | #ifdef SIGLOST | ||
113 | { "LOST", SIGLOST }, /* 29 (arm,i386,m68k,ppc,sparc*) */ | ||
114 | #endif | ||
115 | #ifdef SIGWINCH | ||
116 | { "WINCH", SIGWINCH }, /* 28 (arm,i386,m68k,ppc,alpha,sparc*), 20 (mips) */ | ||
117 | #endif | ||
118 | #ifdef SIGUNUSED | ||
119 | { "UNUSED", SIGUNUSED }, /* 31 (arm,i386,m68k,ppc) */ | ||
120 | #endif | ||
121 | {0, 0} | ||
122 | }; | ||
123 | 37 | ||
124 | extern int kill_main(int argc, char **argv) | 38 | extern int kill_main(int argc, char **argv) |
125 | { | 39 | { |
126 | int whichApp, sig = SIGTERM; | 40 | int whichApp, sig = SIGTERM; |
41 | const char *name; | ||
127 | 42 | ||
128 | #ifdef BB_KILLALL | 43 | #ifdef BB_KILLALL |
129 | /* Figure out what we are trying to do here */ | 44 | /* Figure out what we are trying to do here */ |
@@ -142,52 +57,37 @@ extern int kill_main(int argc, char **argv) | |||
142 | while (*++(*argv)) { | 57 | while (*++(*argv)) { |
143 | switch (**argv) { | 58 | switch (**argv) { |
144 | case 'l': | 59 | case 'l': |
145 | { | 60 | if(argc>1) { |
61 | for(argv++; *argv; argv++) { | ||
62 | name = u_signal_names(*argv, &sig, -1); | ||
63 | if(name!=NULL) | ||
64 | printf("%s\n", name); | ||
65 | } | ||
66 | } else { | ||
146 | int col = 0; | 67 | int col = 0; |
147 | const struct signal_name *s = signames; | 68 | for(sig=1; sig < NSIG; sig++) { |
148 | 69 | name = u_signal_names(0, &sig, 1); | |
149 | while (s->name != 0) { | 70 | if(name==NULL) /* unnamed */ |
150 | col += fprintf(stderr, "%2d) %-8s", s->number, s->name); | 71 | continue; |
151 | s++; | 72 | col += printf("%2d) %-16s", sig, name); |
152 | if (col > 60) { | 73 | if (col > 60) { |
153 | fprintf(stderr, "\n"); | 74 | printf("\n"); |
154 | col = 0; | 75 | col = 0; |
155 | } | 76 | } |
156 | } | 77 | } |
157 | fprintf(stderr, "\n\n"); | 78 | printf("\n"); |
158 | return EXIT_SUCCESS; | ||
159 | } | 79 | } |
160 | break; | 80 | return EXIT_SUCCESS; |
161 | case '-': | 81 | case '-': |
162 | show_usage(); | 82 | show_usage(); |
163 | default: | 83 | default: |
164 | { | 84 | name = u_signal_names(*argv, &sig, 0); |
165 | if (isdigit(**argv)) { | 85 | if(name==NULL) |
166 | sig = atoi(*argv); | 86 | error_msg_and_die( "bad signal name: %s", *argv); |
167 | if (sig < 0 || sig >= NSIG) | ||
168 | goto end; | ||
169 | else { | ||
170 | argc--; | ||
171 | argv++; | ||
172 | goto do_it_now; | ||
173 | } | ||
174 | } else { | ||
175 | const struct signal_name *s = signames; | ||
176 | |||
177 | while (s->name != 0) { | ||
178 | if (strcasecmp(s->name, *argv) == 0) { | ||
179 | sig = s->number; | ||
180 | argc--; | 87 | argc--; |
181 | argv++; | 88 | argv++; |
182 | goto do_it_now; | 89 | goto do_it_now; |
183 | } | 90 | } |
184 | s++; | ||
185 | } | ||
186 | if (s->name == 0) | ||
187 | goto end; | ||
188 | } | ||
189 | } | ||
190 | } | ||
191 | argc--; | 91 | argc--; |
192 | argv++; | 92 | argv++; |
193 | } | 93 | } |
@@ -239,8 +139,4 @@ extern int kill_main(int argc, char **argv) | |||
239 | #endif | 139 | #endif |
240 | 140 | ||
241 | return EXIT_SUCCESS; | 141 | return EXIT_SUCCESS; |
242 | |||
243 | |||
244 | end: | ||
245 | error_msg_and_die( "bad signal name: %s", *argv); | ||
246 | } | 142 | } |
diff --git a/shell/ash.c b/shell/ash.c index b1aec6278..bcd12f106 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -52,6 +52,7 @@ | |||
52 | 52 | ||
53 | /* If you need ash to act as a full Posix shell, with full math | 53 | /* If you need ash to act as a full Posix shell, with full math |
54 | * support, enable this. This adds a bit over 2k an x86 system. */ | 54 | * support, enable this. This adds a bit over 2k an x86 system. */ |
55 | //#undef ASH_MATH_SUPPORT | ||
55 | #define ASH_MATH_SUPPORT | 56 | #define ASH_MATH_SUPPORT |
56 | 57 | ||
57 | /* Getopts is used by shell procedures to parse positional parameters. | 58 | /* Getopts is used by shell procedures to parse positional parameters. |
@@ -78,8 +79,6 @@ | |||
78 | /* These are here to work with glibc -- Don't change these... */ | 79 | /* These are here to work with glibc -- Don't change these... */ |
79 | #undef FNMATCH_BROKEN | 80 | #undef FNMATCH_BROKEN |
80 | #undef GLOB_BROKEN | 81 | #undef GLOB_BROKEN |
81 | #undef _GNU_SOURCE | ||
82 | #undef __USE_GNU | ||
83 | 82 | ||
84 | #include <assert.h> | 83 | #include <assert.h> |
85 | #include <ctype.h> | 84 | #include <ctype.h> |
@@ -4839,6 +4838,7 @@ static void | |||
4839 | expari(int flag) | 4838 | expari(int flag) |
4840 | { | 4839 | { |
4841 | char *p, *start; | 4840 | char *p, *start; |
4841 | int errcode; | ||
4842 | int result; | 4842 | int result; |
4843 | int begoff; | 4843 | int begoff; |
4844 | int quotes = flag & (EXP_FULL | EXP_CASE); | 4844 | int quotes = flag & (EXP_FULL | EXP_CASE); |
@@ -4877,9 +4877,13 @@ expari(int flag) | |||
4877 | removerecordregions(begoff); | 4877 | removerecordregions(begoff); |
4878 | if (quotes) | 4878 | if (quotes) |
4879 | rmescapes(p+2); | 4879 | rmescapes(p+2); |
4880 | result = arith(p+2); | 4880 | result = arith(p+2, &errcode); |
4881 | if (result < 0) | 4881 | if (errcode < 0) { |
4882 | error("arith: syntax error: \"%s\"\n", p+2); | 4882 | if(errcode == -2) |
4883 | error("divide by zero"); | ||
4884 | else | ||
4885 | error("syntax error: \"%s\"\n", p+2); | ||
4886 | } | ||
4883 | snprintf(p, 12, "%d", result); | 4887 | snprintf(p, 12, "%d", result); |
4884 | 4888 | ||
4885 | while (*p++) | 4889 | while (*p++) |
@@ -5429,9 +5433,9 @@ expandmeta(str, flag) | |||
5429 | goto nometa; | 5433 | goto nometa; |
5430 | p = preglob(str->text); | 5434 | p = preglob(str->text); |
5431 | INTOFF; | 5435 | INTOFF; |
5432 | switch (glob(p, GLOB_NOMAGIC, 0, &pglob)) { | 5436 | switch (glob(p, 0, 0, &pglob)) { |
5433 | case 0: | 5437 | case 0: |
5434 | if (!(pglob.gl_flags & GLOB_MAGCHAR)) | 5438 | if(pglob.gl_pathv[1]==0 && !strcmp(p, pglob.gl_pathv[0])) |
5435 | goto nometa2; | 5439 | goto nometa2; |
5436 | addglob(&pglob); | 5440 | addglob(&pglob); |
5437 | globfree(&pglob); | 5441 | globfree(&pglob); |
@@ -6006,7 +6010,7 @@ static int histcmd(argc, argv) | |||
6006 | struct redirtab { | 6010 | struct redirtab { |
6007 | struct redirtab *next; | 6011 | struct redirtab *next; |
6008 | short renamed[10]; /* Current ash support only 0-9 descriptors */ | 6012 | short renamed[10]; /* Current ash support only 0-9 descriptors */ |
6009 | /* char renamed[10]; */ /* char on arm (and others) can't be negative */ | 6013 | /* char on arm (and others) can't be negative */ |
6010 | }; | 6014 | }; |
6011 | 6015 | ||
6012 | static struct redirtab *redirlist; | 6016 | static struct redirtab *redirlist; |
@@ -6166,7 +6170,7 @@ preadfd(void) | |||
6166 | retry: | 6170 | retry: |
6167 | #ifdef BB_FEATURE_COMMAND_EDITING | 6171 | #ifdef BB_FEATURE_COMMAND_EDITING |
6168 | { | 6172 | { |
6169 | if (parsefile->fd) | 6173 | if (!iflag || parsefile->fd) |
6170 | nr = safe_read(parsefile->fd, buf, BUFSIZ - 1); | 6174 | nr = safe_read(parsefile->fd, buf, BUFSIZ - 1); |
6171 | else { | 6175 | else { |
6172 | nr = cmdedit_read_input((char*)cmdedit_prompt, buf); | 6176 | nr = cmdedit_read_input((char*)cmdedit_prompt, buf); |
@@ -6468,80 +6472,6 @@ static void setjobctl(int enable) | |||
6468 | #endif | 6472 | #endif |
6469 | 6473 | ||
6470 | 6474 | ||
6471 | /* A translation list so we can be polite to our users. */ | ||
6472 | static char *signal_names[NSIG + 2] = { | ||
6473 | "EXIT", | ||
6474 | "SIGHUP", | ||
6475 | "SIGINT", | ||
6476 | "SIGQUIT", | ||
6477 | "SIGILL", | ||
6478 | "SIGTRAP", | ||
6479 | "SIGABRT", | ||
6480 | "SIGBUS", | ||
6481 | "SIGFPE", | ||
6482 | "SIGKILL", | ||
6483 | "SIGUSR1", | ||
6484 | "SIGSEGV", | ||
6485 | "SIGUSR2", | ||
6486 | "SIGPIPE", | ||
6487 | "SIGALRM", | ||
6488 | "SIGTERM", | ||
6489 | "SIGJUNK(16)", | ||
6490 | "SIGCHLD", | ||
6491 | "SIGCONT", | ||
6492 | "SIGSTOP", | ||
6493 | "SIGTSTP", | ||
6494 | "SIGTTIN", | ||
6495 | "SIGTTOU", | ||
6496 | "SIGURG", | ||
6497 | "SIGXCPU", | ||
6498 | "SIGXFSZ", | ||
6499 | "SIGVTALRM", | ||
6500 | "SIGPROF", | ||
6501 | "SIGWINCH", | ||
6502 | "SIGIO", | ||
6503 | "SIGPWR", | ||
6504 | "SIGSYS", | ||
6505 | #ifdef SIGRTMIN | ||
6506 | "SIGRTMIN", | ||
6507 | "SIGRTMIN+1", | ||
6508 | "SIGRTMIN+2", | ||
6509 | "SIGRTMIN+3", | ||
6510 | "SIGRTMIN+4", | ||
6511 | "SIGRTMIN+5", | ||
6512 | "SIGRTMIN+6", | ||
6513 | "SIGRTMIN+7", | ||
6514 | "SIGRTMIN+8", | ||
6515 | "SIGRTMIN+9", | ||
6516 | "SIGRTMIN+10", | ||
6517 | "SIGRTMIN+11", | ||
6518 | "SIGRTMIN+12", | ||
6519 | "SIGRTMIN+13", | ||
6520 | "SIGRTMIN+14", | ||
6521 | "SIGRTMIN+15", | ||
6522 | "SIGRTMAX-15", | ||
6523 | "SIGRTMAX-14", | ||
6524 | "SIGRTMAX-13", | ||
6525 | "SIGRTMAX-12", | ||
6526 | "SIGRTMAX-11", | ||
6527 | "SIGRTMAX-10", | ||
6528 | "SIGRTMAX-9", | ||
6529 | "SIGRTMAX-8", | ||
6530 | "SIGRTMAX-7", | ||
6531 | "SIGRTMAX-6", | ||
6532 | "SIGRTMAX-5", | ||
6533 | "SIGRTMAX-4", | ||
6534 | "SIGRTMAX-3", | ||
6535 | "SIGRTMAX-2", | ||
6536 | "SIGRTMAX-1", | ||
6537 | "SIGRTMAX", | ||
6538 | #endif | ||
6539 | "DEBUG", | ||
6540 | (char *)0x0, | ||
6541 | }; | ||
6542 | |||
6543 | |||
6544 | |||
6545 | #ifdef JOBS | 6475 | #ifdef JOBS |
6546 | static int | 6476 | static int |
6547 | killcmd(argc, argv) | 6477 | killcmd(argc, argv) |
@@ -6599,18 +6529,20 @@ usage: | |||
6599 | } | 6529 | } |
6600 | 6530 | ||
6601 | if (list) { | 6531 | if (list) { |
6532 | const char *name; | ||
6533 | |||
6602 | if (!*argptr) { | 6534 | if (!*argptr) { |
6603 | out1str("0\n"); | 6535 | out1str("0\n"); |
6604 | for (i = 1; i < NSIG; i++) { | 6536 | for (i = 1; i < NSIG; i++) { |
6605 | printf(snlfmt, signal_names[i] + 3); | 6537 | name = u_signal_names(0, &i, 1); |
6538 | if(name) | ||
6539 | printf(snlfmt, name); | ||
6606 | } | 6540 | } |
6607 | return 0; | 6541 | return 0; |
6608 | } | 6542 | } |
6609 | signo = atoi(*argptr); | 6543 | name = u_signal_names(*argptr, &signo, -1); |
6610 | if (signo > 128) | 6544 | if (name) |
6611 | signo -= 128; | 6545 | printf(snlfmt, name); |
6612 | if (0 < signo && signo < NSIG) | ||
6613 | printf(snlfmt, signal_names[signo] + 3); | ||
6614 | else | 6546 | else |
6615 | error("invalid signal number or exit status: %s", | 6547 | error("invalid signal number or exit status: %s", |
6616 | *argptr); | 6548 | *argptr); |
@@ -8834,12 +8766,6 @@ copynodelist(const struct nodelist *lp) | |||
8834 | static char * | 8766 | static char * |
8835 | nodesavestr(const char *s) | 8767 | nodesavestr(const char *s) |
8836 | { | 8768 | { |
8837 | #ifdef _GNU_SOURCE | ||
8838 | char *rtn = funcstring; | ||
8839 | |||
8840 | funcstring = stpcpy(funcstring, s) + 1; | ||
8841 | return rtn; | ||
8842 | #else | ||
8843 | const char *p = s; | 8769 | const char *p = s; |
8844 | char *q = funcstring; | 8770 | char *q = funcstring; |
8845 | char *rtn = funcstring; | 8771 | char *rtn = funcstring; |
@@ -8848,7 +8774,6 @@ nodesavestr(const char *s) | |||
8848 | continue; | 8774 | continue; |
8849 | funcstring = q; | 8775 | funcstring = q; |
8850 | return rtn; | 8776 | return rtn; |
8851 | #endif | ||
8852 | } | 8777 | } |
8853 | 8778 | ||
8854 | #ifdef ASH_GETOPTS | 8779 | #ifdef ASH_GETOPTS |
@@ -12052,11 +11977,15 @@ trapcmd(argc, argv) | |||
12052 | for (signo = 0 ; signo < NSIG ; signo++) { | 11977 | for (signo = 0 ; signo < NSIG ; signo++) { |
12053 | if (trap[signo] != NULL) { | 11978 | if (trap[signo] != NULL) { |
12054 | char *p; | 11979 | char *p; |
11980 | const char *sn; | ||
12055 | 11981 | ||
12056 | p = single_quote(trap[signo]); | 11982 | p = single_quote(trap[signo]); |
12057 | printf("trap -- %s %s\n", p, | 11983 | sn = sys_siglist[signo]; |
12058 | signal_names[signo] + (signo ? 3 : 0) | 11984 | if(sn==NULL) |
12059 | ); | 11985 | sn = u_signal_names(0, &signo, 0); |
11986 | if(sn==NULL) | ||
11987 | sn = "???"; | ||
11988 | printf("trap -- %s %s\n", p, sn); | ||
12060 | stunalloc(p); | 11989 | stunalloc(p); |
12061 | } | 11990 | } |
12062 | } | 11991 | } |
@@ -12273,30 +12202,11 @@ l2: _exit(status); | |||
12273 | static int decode_signal(const char *string, int minsig) | 12202 | static int decode_signal(const char *string, int minsig) |
12274 | { | 12203 | { |
12275 | int signo; | 12204 | int signo; |
12205 | const char *name = u_signal_names(string, &signo, minsig); | ||
12276 | 12206 | ||
12277 | if (is_number(string, &signo)) { | 12207 | return name ? signo : -1; |
12278 | if (signo >= NSIG) { | ||
12279 | return -1; | ||
12280 | } | ||
12281 | return signo; | ||
12282 | } | ||
12283 | |||
12284 | signo = minsig; | ||
12285 | if (!signo) { | ||
12286 | goto zero; | ||
12287 | } | ||
12288 | for (; signo < NSIG; signo++) { | ||
12289 | if (!strcasecmp(string, &(signal_names[signo])[3])) { | ||
12290 | return signo; | ||
12291 | } | ||
12292 | zero: | ||
12293 | if (!strcasecmp(string, signal_names[signo])) { | ||
12294 | return signo; | ||
12295 | } | ||
12296 | } | ||
12297 | |||
12298 | return -1; | ||
12299 | } | 12208 | } |
12209 | |||
12300 | static struct var **hashvar (const char *); | 12210 | static struct var **hashvar (const char *); |
12301 | static void showvars (const char *, int, int); | 12211 | static void showvars (const char *, int, int); |
12302 | static struct var **findvar (struct var **, const char *); | 12212 | static struct var **findvar (struct var **, const char *); |
@@ -12616,6 +12526,7 @@ found:; | |||
12616 | return 0; | 12526 | return 0; |
12617 | } | 12527 | } |
12618 | 12528 | ||
12529 | |||
12619 | /* | 12530 | /* |
12620 | * The "local" command. | 12531 | * The "local" command. |
12621 | */ | 12532 | */ |
@@ -12874,7 +12785,7 @@ findvar(struct var **vpp, const char *name) | |||
12874 | /* | 12785 | /* |
12875 | * Copyright (c) 1999 Herbert Xu <herbert@debian.org> | 12786 | * Copyright (c) 1999 Herbert Xu <herbert@debian.org> |
12876 | * This file contains code for the times builtin. | 12787 | * This file contains code for the times builtin. |
12877 | * $Id: ash.c,v 1.16 2001/08/01 17:21:33 kraai Exp $ | 12788 | * $Id: ash.c,v 1.17 2001/08/02 05:02:45 andersen Exp $ |
12878 | */ | 12789 | */ |
12879 | static int timescmd (int argc, char **argv) | 12790 | static int timescmd (int argc, char **argv) |
12880 | { | 12791 | { |
@@ -12894,24 +12805,32 @@ static int timescmd (int argc, char **argv) | |||
12894 | return 0; | 12805 | return 0; |
12895 | } | 12806 | } |
12896 | 12807 | ||
12897 | |||
12898 | #ifdef ASH_MATH_SUPPORT | 12808 | #ifdef ASH_MATH_SUPPORT |
12899 | /* The let builtin. */ | 12809 | /* The let builtin. */ |
12900 | int letcmd(int argc, char **argv) | 12810 | int letcmd(int argc, char **argv) |
12901 | { | 12811 | { |
12812 | int errcode; | ||
12902 | long result=0; | 12813 | long result=0; |
12903 | if (argc == 2) { | 12814 | if (argc == 2) { |
12904 | char *tmp, *expression, p[13]; | 12815 | char *tmp, *expression, p[13]; |
12905 | expression = strchr(argv[1], '='); | 12816 | expression = strchr(argv[1], '='); |
12906 | if (!expression) { | 12817 | if (!expression) { |
12818 | /* Cannot use 'error()' here, or the return code | ||
12819 | * will be incorrect */ | ||
12907 | out2fmt("sh: let: syntax error: \"%s\"\n", argv[1]); | 12820 | out2fmt("sh: let: syntax error: \"%s\"\n", argv[1]); |
12908 | return 0; | 12821 | return 0; |
12909 | } | 12822 | } |
12910 | *expression = '\0'; | 12823 | *expression = '\0'; |
12911 | tmp = ++expression; | 12824 | tmp = ++expression; |
12912 | result = arith(tmp); | 12825 | result = arith(tmp, &errcode); |
12913 | if (result < 0) { | 12826 | if (errcode < 0) { |
12914 | out2fmt("sh: let: syntax error: \"%s=%s\"\n", argv[1], expression); | 12827 | /* Cannot use 'error()' here, or the return code |
12828 | * will be incorrect */ | ||
12829 | out2fmt("sh: let: "); | ||
12830 | if(errcode == -2) | ||
12831 | out2fmt("divide by zero"); | ||
12832 | else | ||
12833 | out2fmt("syntax error: \"%s=%s\"\n", argv[1], expression); | ||
12915 | return 0; | 12834 | return 0; |
12916 | } | 12835 | } |
12917 | snprintf(p, 12, "%ld", result); | 12836 | snprintf(p, 12, "%ld", result); |
diff --git a/shell/cmdedit.c b/shell/cmdedit.c index 3b4750455..2ec81548d 100644 --- a/shell/cmdedit.c +++ b/shell/cmdedit.c | |||
@@ -1167,25 +1167,21 @@ int cmdedit_read_input(char *prompt, char command[BUFSIZ]) | |||
1167 | len = 0; | 1167 | len = 0; |
1168 | command_ps = command; | 1168 | command_ps = command; |
1169 | 1169 | ||
1170 | if (new_settings.c_cc[VERASE] == 0) { /* first call */ | 1170 | getTermSettings(0, (void *) &initial_settings); |
1171 | 1171 | memcpy(&new_settings, &initial_settings, sizeof(struct termios)); | |
1172 | getTermSettings(0, (void *) &initial_settings); | 1172 | new_settings.c_lflag &= ~ICANON; /* unbuffered input */ |
1173 | memcpy(&new_settings, &initial_settings, sizeof(struct termios)); | 1173 | /* Turn off echoing and CTRL-C, so we can trap it */ |
1174 | new_settings.c_lflag &= ~ICANON; /* unbuffered input */ | 1174 | new_settings.c_lflag &= ~(ECHO | ECHONL | ISIG); |
1175 | /* Turn off echoing and CTRL-C, so we can trap it */ | ||
1176 | new_settings.c_lflag &= ~(ECHO | ECHONL | ISIG); | ||
1177 | #ifndef linux | 1175 | #ifndef linux |
1178 | /* Hmm, in linux c_cc[] not parsed if set ~ICANON */ | 1176 | /* Hmm, in linux c_cc[] not parsed if set ~ICANON */ |
1179 | new_settings.c_cc[VMIN] = 1; | 1177 | new_settings.c_cc[VMIN] = 1; |
1180 | new_settings.c_cc[VTIME] = 0; | 1178 | new_settings.c_cc[VTIME] = 0; |
1181 | /* Turn off CTRL-C, so we can trap it */ | 1179 | /* Turn off CTRL-C, so we can trap it */ |
1182 | # ifndef _POSIX_VDISABLE | 1180 | # ifndef _POSIX_VDISABLE |
1183 | # define _POSIX_VDISABLE '\0' | 1181 | # define _POSIX_VDISABLE '\0' |
1184 | # endif | 1182 | # endif |
1185 | new_settings.c_cc[VINTR] = _POSIX_VDISABLE; | 1183 | new_settings.c_cc[VINTR] = _POSIX_VDISABLE; |
1186 | #endif | 1184 | #endif |
1187 | } | ||
1188 | |||
1189 | command[0] = 0; | 1185 | command[0] = 0; |
1190 | 1186 | ||
1191 | setTermSettings(0, (void *) &new_settings); | 1187 | setTermSettings(0, (void *) &new_settings); |
@@ -69,9 +69,6 @@ extern int update_main(int argc, char **argv) | |||
69 | if (daemon(0, 1) < 0) | 69 | if (daemon(0, 1) < 0) |
70 | perror_msg_and_die("daemon"); | 70 | perror_msg_and_die("daemon"); |
71 | 71 | ||
72 | /* Become a proper daemon */ | ||
73 | setsid(); | ||
74 | chdir("/"); | ||
75 | #ifdef OPEN_MAX | 72 | #ifdef OPEN_MAX |
76 | for (pid = 0; pid < OPEN_MAX; pid++) close(pid); | 73 | for (pid = 0; pid < OPEN_MAX; pid++) close(pid); |
77 | #else | 74 | #else |
diff --git a/uudecode.c b/uudecode.c index 6ac9f1bf3..a4059ddfe 100644 --- a/uudecode.c +++ b/uudecode.c | |||
@@ -201,9 +201,8 @@ static int decode (const char *inname, | |||
201 | const char *forced_outname) | 201 | const char *forced_outname) |
202 | { | 202 | { |
203 | struct passwd *pw; | 203 | struct passwd *pw; |
204 | register int n; | ||
205 | register char *p; | 204 | register char *p; |
206 | int mode, n1; | 205 | int mode; |
207 | char buf[2 * BUFSIZ]; | 206 | char buf[2 * BUFSIZ]; |
208 | char *outname; | 207 | char *outname; |
209 | int do_base64 = 0; | 208 | int do_base64 = 0; |
@@ -249,12 +248,7 @@ static int decode (const char *inname, | |||
249 | error_msg("%s: No user `%s'", inname, buf + 1); | 248 | error_msg("%s: No user `%s'", inname, buf + 1); |
250 | return FALSE; | 249 | return FALSE; |
251 | } | 250 | } |
252 | n = strlen (pw->pw_dir); | 251 | outname = concat_path_file(pw->pw_dir, p); |
253 | n1 = strlen (p); | ||
254 | outname = (char *) xmalloc ((size_t) (n + n1 + 2)); | ||
255 | memcpy (outname + n + 1, p, (size_t) (n1 + 1)); | ||
256 | memcpy (outname, pw->pw_dir, (size_t) n); | ||
257 | outname[n] = '/'; | ||
258 | dofre = TRUE; | 252 | dofre = TRUE; |
259 | } | 253 | } |
260 | } | 254 | } |