diff options
author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-11-27 16:49:31 +0000 |
---|---|---|
committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-11-27 16:49:31 +0000 |
commit | bb89b301143fe9deb962bb2d48264b27a945fcf4 (patch) | |
tree | 0d8cba8e45b1a8b975e0b8c7a8377703ab5547a6 /shell | |
parent | 09d6cecd11b71856abab9bb68e74f0dd87a425fa (diff) | |
download | busybox-w32-bb89b301143fe9deb962bb2d48264b27a945fcf4.tar.gz busybox-w32-bb89b301143fe9deb962bb2d48264b27a945fcf4.tar.bz2 busybox-w32-bb89b301143fe9deb962bb2d48264b27a945fcf4.zip |
style cleanup: return(a) -> return a, part 1
git-svn-id: svn://busybox.net/trunk/busybox@16690 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 11 | ||||
-rw-r--r-- | shell/cmdedit.c | 3 | ||||
-rw-r--r-- | shell/hush.c | 4 | ||||
-rw-r--r-- | shell/msh.c | 178 |
4 files changed, 99 insertions, 97 deletions
diff --git a/shell/ash.c b/shell/ash.c index 4fef0f2d3..704d03bec 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -2129,10 +2129,10 @@ unalias(const char *name) | |||
2129 | INTOFF; | 2129 | INTOFF; |
2130 | *app = freealias(*app); | 2130 | *app = freealias(*app); |
2131 | INTON; | 2131 | INTON; |
2132 | return (0); | 2132 | return 0; |
2133 | } | 2133 | } |
2134 | 2134 | ||
2135 | return (1); | 2135 | return 1; |
2136 | } | 2136 | } |
2137 | 2137 | ||
2138 | static void | 2138 | static void |
@@ -2181,7 +2181,7 @@ aliascmd(int argc, char **argv) | |||
2181 | for (ap = atab[i]; ap; ap = ap->next) { | 2181 | for (ap = atab[i]; ap; ap = ap->next) { |
2182 | printalias(ap); | 2182 | printalias(ap); |
2183 | } | 2183 | } |
2184 | return (0); | 2184 | return 0; |
2185 | } | 2185 | } |
2186 | while ((n = *++argv) != NULL) { | 2186 | while ((n = *++argv) != NULL) { |
2187 | if ((v = strchr(n+1, '=')) == NULL) { /* n+1: funny ksh stuff */ | 2187 | if ((v = strchr(n+1, '=')) == NULL) { /* n+1: funny ksh stuff */ |
@@ -2207,7 +2207,7 @@ unaliascmd(int argc, char **argv) | |||
2207 | while ((i = nextopt("a")) != '\0') { | 2207 | while ((i = nextopt("a")) != '\0') { |
2208 | if (i == 'a') { | 2208 | if (i == 'a') { |
2209 | rmaliases(); | 2209 | rmaliases(); |
2210 | return (0); | 2210 | return 0; |
2211 | } | 2211 | } |
2212 | } | 2212 | } |
2213 | for (i = 0; *argptr; argptr++) { | 2213 | for (i = 0; *argptr; argptr++) { |
@@ -13420,7 +13420,8 @@ static int arith_apply(operator op, v_n_t *numstack, v_n_t **numstackptr) | |||
13420 | /* protect geting var value, is number now */ | 13420 | /* protect geting var value, is number now */ |
13421 | numptr_m1->var = NULL; | 13421 | numptr_m1->var = NULL; |
13422 | return 0; | 13422 | return 0; |
13423 | err: return(-1); | 13423 | err: |
13424 | return -1; | ||
13424 | } | 13425 | } |
13425 | 13426 | ||
13426 | /* longest must first */ | 13427 | /* longest must first */ |
diff --git a/shell/cmdedit.c b/shell/cmdedit.c index dda6f6958..ceaa2e885 100644 --- a/shell/cmdedit.c +++ b/shell/cmdedit.c | |||
@@ -1180,7 +1180,8 @@ static int get_next_history(void) | |||
1180 | 1180 | ||
1181 | if (ch < n_history) { | 1181 | if (ch < n_history) { |
1182 | get_previous_history(); /* save the current history line */ | 1182 | get_previous_history(); /* save the current history line */ |
1183 | return (cur_history = ch+1); | 1183 | cur_history = ch + 1; |
1184 | return cur_history; | ||
1184 | } else { | 1185 | } else { |
1185 | beep(); | 1186 | beep(); |
1186 | return 0; | 1187 | return 0; |
diff --git a/shell/hush.c b/shell/hush.c index 2013a9d2b..57b4a7ac3 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -1225,7 +1225,7 @@ static int checkjobs(struct pipe* fg_pipe) | |||
1225 | if (i==fg_pipe->num_progs-1) | 1225 | if (i==fg_pipe->num_progs-1) |
1226 | rcode=WEXITSTATUS(status); | 1226 | rcode=WEXITSTATUS(status); |
1227 | (fg_pipe->num_progs)--; | 1227 | (fg_pipe->num_progs)--; |
1228 | return(rcode); | 1228 | return rcode; |
1229 | } | 1229 | } |
1230 | } | 1230 | } |
1231 | } | 1231 | } |
@@ -2768,7 +2768,7 @@ int hush_main(int argc, char **argv) | |||
2768 | #endif | 2768 | #endif |
2769 | 2769 | ||
2770 | final_return: | 2770 | final_return: |
2771 | return(opt?opt:last_return_code); | 2771 | return opt ? opt : last_return_code; |
2772 | } | 2772 | } |
2773 | 2773 | ||
2774 | static char *insert_var_value(char *inp) | 2774 | static char *insert_var_value(char *inp) |
diff --git a/shell/msh.c b/shell/msh.c index c0f013e98..8f58e9457 100644 --- a/shell/msh.c +++ b/shell/msh.c | |||
@@ -1007,13 +1007,13 @@ static int newfile(char *s) | |||
1007 | if (f < 0) { | 1007 | if (f < 0) { |
1008 | prs(s); | 1008 | prs(s); |
1009 | err(": cannot open"); | 1009 | err(": cannot open"); |
1010 | return (1); | 1010 | return 1; |
1011 | } | 1011 | } |
1012 | } else | 1012 | } else |
1013 | f = 0; | 1013 | f = 0; |
1014 | 1014 | ||
1015 | next(remap(f)); | 1015 | next(remap(f)); |
1016 | return (0); | 1016 | return 0; |
1017 | } | 1017 | } |
1018 | 1018 | ||
1019 | 1019 | ||
@@ -1162,7 +1162,7 @@ static int newenv(int f) | |||
1162 | 1162 | ||
1163 | if (f) { | 1163 | if (f) { |
1164 | quitenv(); | 1164 | quitenv(); |
1165 | return (1); | 1165 | return 1; |
1166 | } | 1166 | } |
1167 | 1167 | ||
1168 | ep = (struct env *) space(sizeof(*ep)); | 1168 | ep = (struct env *) space(sizeof(*ep)); |
@@ -1175,7 +1175,7 @@ static int newenv(int f) | |||
1175 | e.oenv = ep; | 1175 | e.oenv = ep; |
1176 | e.errpt = errpt; | 1176 | e.errpt = errpt; |
1177 | 1177 | ||
1178 | return (0); | 1178 | return 0; |
1179 | } | 1179 | } |
1180 | 1180 | ||
1181 | static void quitenv(void) | 1181 | static void quitenv(void) |
@@ -1202,8 +1202,8 @@ static int anys(char *s1, char *s2) | |||
1202 | { | 1202 | { |
1203 | while (*s1) | 1203 | while (*s1) |
1204 | if (any(*s1++, s2)) | 1204 | if (any(*s1++, s2)) |
1205 | return (1); | 1205 | return 1; |
1206 | return (0); | 1206 | return 0; |
1207 | } | 1207 | } |
1208 | 1208 | ||
1209 | /* | 1209 | /* |
@@ -1213,8 +1213,8 @@ static int any(int c, char *s) | |||
1213 | { | 1213 | { |
1214 | while (*s) | 1214 | while (*s) |
1215 | if (*s++ == c) | 1215 | if (*s++ == c) |
1216 | return (1); | 1216 | return 1; |
1217 | return (0); | 1217 | return 0; |
1218 | } | 1218 | } |
1219 | 1219 | ||
1220 | static char *putn(int n) | 1220 | static char *putn(int n) |
@@ -1396,12 +1396,12 @@ static int isassign(char *s) | |||
1396 | DBGPRINTF7(("ISASSIGN: enter, s=%s\n", s)); | 1396 | DBGPRINTF7(("ISASSIGN: enter, s=%s\n", s)); |
1397 | 1397 | ||
1398 | if (!isalpha((int) *s) && *s != '_') | 1398 | if (!isalpha((int) *s) && *s != '_') |
1399 | return (0); | 1399 | return 0; |
1400 | for (; *s != '='; s++) | 1400 | for (; *s != '='; s++) |
1401 | if (*s == 0 || (!isalnum(*s) && *s != '_')) | 1401 | if (*s == 0 || (!isalnum(*s) && *s != '_')) |
1402 | return (0); | 1402 | return 0; |
1403 | 1403 | ||
1404 | return (1); | 1404 | return 1; |
1405 | } | 1405 | } |
1406 | 1406 | ||
1407 | static int assign(char *s, int cf) | 1407 | static int assign(char *s, int cf) |
@@ -1412,15 +1412,15 @@ static int assign(char *s, int cf) | |||
1412 | DBGPRINTF7(("ASSIGN: enter, s=%s, cf=%d\n", s, cf)); | 1412 | DBGPRINTF7(("ASSIGN: enter, s=%s, cf=%d\n", s, cf)); |
1413 | 1413 | ||
1414 | if (!isalpha(*s) && *s != '_') | 1414 | if (!isalpha(*s) && *s != '_') |
1415 | return (0); | 1415 | return 0; |
1416 | for (cp = s; *cp != '='; cp++) | 1416 | for (cp = s; *cp != '='; cp++) |
1417 | if (*cp == 0 || (!isalnum(*cp) && *cp != '_')) | 1417 | if (*cp == 0 || (!isalnum(*cp) && *cp != '_')) |
1418 | return (0); | 1418 | return 0; |
1419 | vp = lookup(s); | 1419 | vp = lookup(s); |
1420 | nameval(vp, ++cp, cf == COPYV ? (char *) NULL : s); | 1420 | nameval(vp, ++cp, cf == COPYV ? (char *) NULL : s); |
1421 | if (cf != COPYV) | 1421 | if (cf != COPYV) |
1422 | vp->status &= ~GETCELL; | 1422 | vp->status &= ~GETCELL; |
1423 | return (1); | 1423 | return 1; |
1424 | } | 1424 | } |
1425 | 1425 | ||
1426 | static int checkname(char *cp) | 1426 | static int checkname(char *cp) |
@@ -1428,11 +1428,11 @@ static int checkname(char *cp) | |||
1428 | DBGPRINTF7(("CHECKNAME: enter, cp=%s\n", cp)); | 1428 | DBGPRINTF7(("CHECKNAME: enter, cp=%s\n", cp)); |
1429 | 1429 | ||
1430 | if (!isalpha(*cp++) && *(cp - 1) != '_') | 1430 | if (!isalpha(*cp++) && *(cp - 1) != '_') |
1431 | return (0); | 1431 | return 0; |
1432 | while (*cp) | 1432 | while (*cp) |
1433 | if (!isalnum(*cp++) && *(cp - 1) != '_') | 1433 | if (!isalnum(*cp++) && *(cp - 1) != '_') |
1434 | return (0); | 1434 | return 0; |
1435 | return (1); | 1435 | return 1; |
1436 | } | 1436 | } |
1437 | 1437 | ||
1438 | static void putvlist(int f, int out) | 1438 | static void putvlist(int f, int out) |
@@ -1454,7 +1454,7 @@ static int eqname(char *n1, char *n2) | |||
1454 | { | 1454 | { |
1455 | for (; *n1 != '=' && *n1 != 0; n1++) | 1455 | for (; *n1 != '=' && *n1 != 0; n1++) |
1456 | if (*n2++ != *n1) | 1456 | if (*n2++ != *n1) |
1457 | return (0); | 1457 | return 0; |
1458 | return (*n2 == 0 || *n2 == '='); | 1458 | return (*n2 == 0 || *n2 == '='); |
1459 | } | 1459 | } |
1460 | 1460 | ||
@@ -1483,31 +1483,31 @@ static int gmatch(char *s, char *p) | |||
1483 | int sc, pc; | 1483 | int sc, pc; |
1484 | 1484 | ||
1485 | if (s == NULL || p == NULL) | 1485 | if (s == NULL || p == NULL) |
1486 | return (0); | 1486 | return 0; |
1487 | while ((pc = *p++ & CMASK) != '\0') { | 1487 | while ((pc = *p++ & CMASK) != '\0') { |
1488 | sc = *s++ & QMASK; | 1488 | sc = *s++ & QMASK; |
1489 | switch (pc) { | 1489 | switch (pc) { |
1490 | case '[': | 1490 | case '[': |
1491 | if ((p = cclass(p, sc)) == NULL) | 1491 | if ((p = cclass(p, sc)) == NULL) |
1492 | return (0); | 1492 | return 0; |
1493 | break; | 1493 | break; |
1494 | 1494 | ||
1495 | case '?': | 1495 | case '?': |
1496 | if (sc == 0) | 1496 | if (sc == 0) |
1497 | return (0); | 1497 | return 0; |
1498 | break; | 1498 | break; |
1499 | 1499 | ||
1500 | case '*': | 1500 | case '*': |
1501 | s--; | 1501 | s--; |
1502 | do { | 1502 | do { |
1503 | if (*p == '\0' || gmatch(s, p)) | 1503 | if (*p == '\0' || gmatch(s, p)) |
1504 | return (1); | 1504 | return 1; |
1505 | } while (*s++ != '\0'); | 1505 | } while (*s++ != '\0'); |
1506 | return (0); | 1506 | return 0; |
1507 | 1507 | ||
1508 | default: | 1508 | default: |
1509 | if (sc != (pc & ~QUOTE)) | 1509 | if (sc != (pc & ~QUOTE)) |
1510 | return (0); | 1510 | return 0; |
1511 | } | 1511 | } |
1512 | } | 1512 | } |
1513 | return (*s == 0); | 1513 | return (*s == 0); |
@@ -1805,7 +1805,7 @@ static int synio(int cf) | |||
1805 | 1805 | ||
1806 | if ((c = yylex(cf)) != '<' && c != '>') { | 1806 | if ((c = yylex(cf)) != '<' && c != '>') { |
1807 | peeksym = c; | 1807 | peeksym = c; |
1808 | return (0); | 1808 | return 0; |
1809 | } | 1809 | } |
1810 | 1810 | ||
1811 | i = yylval.i; | 1811 | i = yylval.i; |
@@ -1817,7 +1817,7 @@ static int synio(int cf) | |||
1817 | markhere(yylval.cp, iop); | 1817 | markhere(yylval.cp, iop); |
1818 | 1818 | ||
1819 | DBGPRINTF7(("SYNIO: returning 1\n")); | 1819 | DBGPRINTF7(("SYNIO: returning 1\n")); |
1820 | return (1); | 1820 | return 1; |
1821 | } | 1821 | } |
1822 | 1822 | ||
1823 | static void musthave(int c, int cf) | 1823 | static void musthave(int c, int cf) |
@@ -2166,7 +2166,7 @@ static int rlookup(char *n) | |||
2166 | } | 2166 | } |
2167 | 2167 | ||
2168 | DBGPRINTF7(("RLOOKUP: NO match, returning 0\n")); | 2168 | DBGPRINTF7(("RLOOKUP: NO match, returning 0\n")); |
2169 | return (0); /* Not a shell multiline */ | 2169 | return 0; /* Not a shell multiline */ |
2170 | } | 2170 | } |
2171 | 2171 | ||
2172 | static struct op *newtp(void) | 2172 | static struct op *newtp(void) |
@@ -2428,7 +2428,7 @@ static int collect(int c, int c1) | |||
2428 | 2428 | ||
2429 | DBGPRINTF8(("COLLECT: return 0, line is %s\n", line)); | 2429 | DBGPRINTF8(("COLLECT: return 0, line is %s\n", line)); |
2430 | 2430 | ||
2431 | return (0); | 2431 | return 0; |
2432 | } | 2432 | } |
2433 | 2433 | ||
2434 | /* "multiline commands" helper func */ | 2434 | /* "multiline commands" helper func */ |
@@ -2510,7 +2510,7 @@ static int execute(struct op *t, int *pin, int *pout, int act) | |||
2510 | 2510 | ||
2511 | if (t == NULL) { | 2511 | if (t == NULL) { |
2512 | DBGPRINTF4(("EXECUTE: enter, t==null, returning.\n")); | 2512 | DBGPRINTF4(("EXECUTE: enter, t==null, returning.\n")); |
2513 | return (0); | 2513 | return 0; |
2514 | } | 2514 | } |
2515 | 2515 | ||
2516 | DBGPRINTF(("EXECUTE: t=%p, t->type=%d (%s), t->words is %s\n", t, | 2516 | DBGPRINTF(("EXECUTE: t=%p, t->type=%d (%s), t->words is %s\n", t, |
@@ -2787,7 +2787,7 @@ forkexec(struct op *t, int *pin, int *pout, int act, char **wp) | |||
2787 | 2787 | ||
2788 | if (newpid == -1) { | 2788 | if (newpid == -1) { |
2789 | DBGPRINTF(("FORKEXEC: ERROR, cannot vfork()!\n")); | 2789 | DBGPRINTF(("FORKEXEC: ERROR, cannot vfork()!\n")); |
2790 | return (-1); | 2790 | return -1; |
2791 | } | 2791 | } |
2792 | 2792 | ||
2793 | 2793 | ||
@@ -2804,7 +2804,7 @@ forkexec(struct op *t, int *pin, int *pout, int act, char **wp) | |||
2804 | 2804 | ||
2805 | /* moved up | 2805 | /* moved up |
2806 | if (i == -1) | 2806 | if (i == -1) |
2807 | return(rv); | 2807 | return rv; |
2808 | */ | 2808 | */ |
2809 | 2809 | ||
2810 | if (pin != NULL) | 2810 | if (pin != NULL) |
@@ -2839,7 +2839,7 @@ forkexec(struct op *t, int *pin, int *pout, int act, char **wp) | |||
2839 | err("piping to/from shell builtins not yet done"); | 2839 | err("piping to/from shell builtins not yet done"); |
2840 | if (forked) | 2840 | if (forked) |
2841 | _exit(-1); | 2841 | _exit(-1); |
2842 | return (-1); | 2842 | return -1; |
2843 | } | 2843 | } |
2844 | #endif | 2844 | #endif |
2845 | 2845 | ||
@@ -2858,7 +2858,7 @@ forkexec(struct op *t, int *pin, int *pout, int act, char **wp) | |||
2858 | err(": cannot redirect shell command"); | 2858 | err(": cannot redirect shell command"); |
2859 | if (forked) | 2859 | if (forked) |
2860 | _exit(-1); | 2860 | _exit(-1); |
2861 | return (-1); | 2861 | return -1; |
2862 | } | 2862 | } |
2863 | while (*iopp) | 2863 | while (*iopp) |
2864 | if (iosetup(*iopp++, pin != NULL, pout != NULL)) { | 2864 | if (iosetup(*iopp++, pin != NULL, pout != NULL)) { |
@@ -2919,23 +2919,23 @@ static int iosetup(struct ioword *iop, int pipein, int pipeout) | |||
2919 | iop->io_unit = iop->io_flag & (IOREAD | IOHERE) ? 0 : 1; | 2919 | iop->io_unit = iop->io_flag & (IOREAD | IOHERE) ? 0 : 1; |
2920 | 2920 | ||
2921 | if (pipein && iop->io_unit == 0) | 2921 | if (pipein && iop->io_unit == 0) |
2922 | return (0); | 2922 | return 0; |
2923 | 2923 | ||
2924 | if (pipeout && iop->io_unit == 1) | 2924 | if (pipeout && iop->io_unit == 1) |
2925 | return (0); | 2925 | return 0; |
2926 | 2926 | ||
2927 | msg = iop->io_flag & (IOREAD | IOHERE) ? "open" : "create"; | 2927 | msg = iop->io_flag & (IOREAD | IOHERE) ? "open" : "create"; |
2928 | if ((iop->io_flag & IOHERE) == 0) { | 2928 | if ((iop->io_flag & IOHERE) == 0) { |
2929 | cp = iop->io_name; | 2929 | cp = iop->io_name; |
2930 | if ((cp = evalstr(cp, DOSUB | DOTRIM)) == NULL) | 2930 | if ((cp = evalstr(cp, DOSUB | DOTRIM)) == NULL) |
2931 | return (1); | 2931 | return 1; |
2932 | } | 2932 | } |
2933 | 2933 | ||
2934 | if (iop->io_flag & IODUP) { | 2934 | if (iop->io_flag & IODUP) { |
2935 | if (cp[1] || (!isdigit(*cp) && *cp != '-')) { | 2935 | if (cp[1] || (!isdigit(*cp) && *cp != '-')) { |
2936 | prs(cp); | 2936 | prs(cp); |
2937 | err(": illegal >& argument"); | 2937 | err(": illegal >& argument"); |
2938 | return (1); | 2938 | return 1; |
2939 | } | 2939 | } |
2940 | if (*cp == '-') | 2940 | if (*cp == '-') |
2941 | iop->io_flag = IOCLOSE; | 2941 | iop->io_flag = IOCLOSE; |
@@ -2967,20 +2967,20 @@ static int iosetup(struct ioword *iop, int pipein, int pipeout) | |||
2967 | 2967 | ||
2968 | case IOCLOSE: | 2968 | case IOCLOSE: |
2969 | close(iop->io_unit); | 2969 | close(iop->io_unit); |
2970 | return (0); | 2970 | return 0; |
2971 | } | 2971 | } |
2972 | if (u < 0) { | 2972 | if (u < 0) { |
2973 | prs(cp); | 2973 | prs(cp); |
2974 | prs(": cannot "); | 2974 | prs(": cannot "); |
2975 | warn(msg); | 2975 | warn(msg); |
2976 | return (1); | 2976 | return 1; |
2977 | } else { | 2977 | } else { |
2978 | if (u != iop->io_unit) { | 2978 | if (u != iop->io_unit) { |
2979 | dup2(u, iop->io_unit); | 2979 | dup2(u, iop->io_unit); |
2980 | close(u); | 2980 | close(u); |
2981 | } | 2981 | } |
2982 | } | 2982 | } |
2983 | return (0); | 2983 | return 0; |
2984 | } | 2984 | } |
2985 | 2985 | ||
2986 | static void echo(char **wp) | 2986 | static void echo(char **wp) |
@@ -3281,7 +3281,7 @@ static int dohelp(struct op *t) | |||
3281 | 3281 | ||
3282 | static int dolabel(struct op *t) | 3282 | static int dolabel(struct op *t) |
3283 | { | 3283 | { |
3284 | return (0); | 3284 | return 0; |
3285 | } | 3285 | } |
3286 | 3286 | ||
3287 | static int dochdir(struct op *t) | 3287 | static int dochdir(struct op *t) |
@@ -3293,10 +3293,10 @@ static int dochdir(struct op *t) | |||
3293 | else if (chdir(cp) < 0) | 3293 | else if (chdir(cp) < 0) |
3294 | er = ": bad directory"; | 3294 | er = ": bad directory"; |
3295 | else | 3295 | else |
3296 | return (0); | 3296 | return 0; |
3297 | prs(cp != NULL ? cp : "cd"); | 3297 | prs(cp != NULL ? cp : "cd"); |
3298 | err(er); | 3298 | err(er); |
3299 | return (1); | 3299 | return 1; |
3300 | } | 3300 | } |
3301 | 3301 | ||
3302 | static int doshift(struct op *t) | 3302 | static int doshift(struct op *t) |
@@ -3306,13 +3306,13 @@ static int doshift(struct op *t) | |||
3306 | n = t->words[1] ? getn(t->words[1]) : 1; | 3306 | n = t->words[1] ? getn(t->words[1]) : 1; |
3307 | if (dolc < n) { | 3307 | if (dolc < n) { |
3308 | err("nothing to shift"); | 3308 | err("nothing to shift"); |
3309 | return (1); | 3309 | return 1; |
3310 | } | 3310 | } |
3311 | dolv[n] = dolv[0]; | 3311 | dolv[n] = dolv[0]; |
3312 | dolv += n; | 3312 | dolv += n; |
3313 | dolc -= n; | 3313 | dolc -= n; |
3314 | setval(lookup("#"), putn(dolc)); | 3314 | setval(lookup("#"), putn(dolc)); |
3315 | return (0); | 3315 | return 0; |
3316 | } | 3316 | } |
3317 | 3317 | ||
3318 | /* | 3318 | /* |
@@ -3330,7 +3330,7 @@ static int dologin(struct op *t) | |||
3330 | prs(t->words[0]); | 3330 | prs(t->words[0]); |
3331 | prs(": "); | 3331 | prs(": "); |
3332 | err(cp); | 3332 | err(cp); |
3333 | return (1); | 3333 | return 1; |
3334 | } | 3334 | } |
3335 | 3335 | ||
3336 | static int doumask(struct op *t) | 3336 | static int doumask(struct op *t) |
@@ -3349,7 +3349,7 @@ static int doumask(struct op *t) | |||
3349 | n = n * 8 + (*cp - '0'); | 3349 | n = n * 8 + (*cp - '0'); |
3350 | umask(n); | 3350 | umask(n); |
3351 | } | 3351 | } |
3352 | return (0); | 3352 | return 0; |
3353 | } | 3353 | } |
3354 | 3354 | ||
3355 | static int doexec(struct op *t) | 3355 | static int doexec(struct op *t) |
@@ -3361,14 +3361,14 @@ static int doexec(struct op *t) | |||
3361 | t->ioact = NULL; | 3361 | t->ioact = NULL; |
3362 | for (i = 0; (t->words[i] = t->words[i + 1]) != NULL; i++); | 3362 | for (i = 0; (t->words[i] = t->words[i + 1]) != NULL; i++); |
3363 | if (i == 0) | 3363 | if (i == 0) |
3364 | return (1); | 3364 | return 1; |
3365 | execflg = 1; | 3365 | execflg = 1; |
3366 | ofail = failpt; | 3366 | ofail = failpt; |
3367 | if (setjmp(failpt = ex) == 0) | 3367 | if (setjmp(failpt = ex) == 0) |
3368 | execute(t, NOPIPE, NOPIPE, FEXEC); | 3368 | execute(t, NOPIPE, NOPIPE, FEXEC); |
3369 | failpt = ofail; | 3369 | failpt = ofail; |
3370 | execflg = 0; | 3370 | execflg = 0; |
3371 | return (1); | 3371 | return 1; |
3372 | } | 3372 | } |
3373 | 3373 | ||
3374 | static int dodot(struct op *t) | 3374 | static int dodot(struct op *t) |
@@ -3382,7 +3382,7 @@ static int dodot(struct op *t) | |||
3382 | 3382 | ||
3383 | if ((cp = t->words[1]) == NULL) { | 3383 | if ((cp = t->words[1]) == NULL) { |
3384 | DBGPRINTF(("DODOT: bad args, ret 0\n")); | 3384 | DBGPRINTF(("DODOT: bad args, ret 0\n")); |
3385 | return (0); | 3385 | return 0; |
3386 | } else { | 3386 | } else { |
3387 | DBGPRINTF(("DODOT: cp is %s\n", cp)); | 3387 | DBGPRINTF(("DODOT: cp is %s\n", cp)); |
3388 | } | 3388 | } |
@@ -3420,7 +3420,7 @@ static int dodot(struct op *t) | |||
3420 | prs(cp); | 3420 | prs(cp); |
3421 | err(": not found"); | 3421 | err(": not found"); |
3422 | 3422 | ||
3423 | return (-1); | 3423 | return -1; |
3424 | } | 3424 | } |
3425 | 3425 | ||
3426 | static int dowait(struct op *t) | 3426 | static int dowait(struct op *t) |
@@ -3431,11 +3431,11 @@ static int dowait(struct op *t) | |||
3431 | if ((cp = t->words[1]) != NULL) { | 3431 | if ((cp = t->words[1]) != NULL) { |
3432 | i = getn(cp); | 3432 | i = getn(cp); |
3433 | if (i == 0) | 3433 | if (i == 0) |
3434 | return (0); | 3434 | return 0; |
3435 | } else | 3435 | } else |
3436 | i = -1; | 3436 | i = -1; |
3437 | setstatus(waitfor(i, 1)); | 3437 | setstatus(waitfor(i, 1)); |
3438 | return (0); | 3438 | return 0; |
3439 | } | 3439 | } |
3440 | 3440 | ||
3441 | static int doread(struct op *t) | 3441 | static int doread(struct op *t) |
@@ -3446,7 +3446,7 @@ static int doread(struct op *t) | |||
3446 | 3446 | ||
3447 | if (t->words[1] == NULL) { | 3447 | if (t->words[1] == NULL) { |
3448 | err("Usage: read name ..."); | 3448 | err("Usage: read name ..."); |
3449 | return (1); | 3449 | return 1; |
3450 | } | 3450 | } |
3451 | for (wp = t->words + 1; *wp; wp++) { | 3451 | for (wp = t->words + 1; *wp; wp++) { |
3452 | for (cp = e.linep; !nl && cp < elinep - 1; cp++) | 3452 | for (cp = e.linep; !nl && cp < elinep - 1; cp++) |
@@ -3479,7 +3479,7 @@ static int dotrap(struct op *t) | |||
3479 | prs(trap[i]); | 3479 | prs(trap[i]); |
3480 | prs("\n"); | 3480 | prs("\n"); |
3481 | } | 3481 | } |
3482 | return (0); | 3482 | return 0; |
3483 | } | 3483 | } |
3484 | resetsig = isdigit(*t->words[1]); | 3484 | resetsig = isdigit(*t->words[1]); |
3485 | for (i = resetsig ? 1 : 2; t->words[i] != NULL; ++i) { | 3485 | for (i = resetsig ? 1 : 2; t->words[i] != NULL; ++i) { |
@@ -3502,7 +3502,7 @@ static int dotrap(struct op *t) | |||
3502 | setsig(n, SIG_DFL); | 3502 | setsig(n, SIG_DFL); |
3503 | } | 3503 | } |
3504 | } | 3504 | } |
3505 | return (0); | 3505 | return 0; |
3506 | } | 3506 | } |
3507 | 3507 | ||
3508 | static int getsig(char *s) | 3508 | static int getsig(char *s) |
@@ -3571,7 +3571,7 @@ static int brkcontin(char *cp, int val) | |||
3571 | } while (--nl); | 3571 | } while (--nl); |
3572 | if (nl) { | 3572 | if (nl) { |
3573 | err("bad break/continue level"); | 3573 | err("bad break/continue level"); |
3574 | return (1); | 3574 | return 1; |
3575 | } | 3575 | } |
3576 | isbreak = val; | 3576 | isbreak = val; |
3577 | longjmp(bc->brkpt, 1); | 3577 | longjmp(bc->brkpt, 1); |
@@ -3590,19 +3590,19 @@ static int doexit(struct op *t) | |||
3590 | 3590 | ||
3591 | leave(); | 3591 | leave(); |
3592 | /* NOTREACHED */ | 3592 | /* NOTREACHED */ |
3593 | return (0); | 3593 | return 0; |
3594 | } | 3594 | } |
3595 | 3595 | ||
3596 | static int doexport(struct op *t) | 3596 | static int doexport(struct op *t) |
3597 | { | 3597 | { |
3598 | rdexp(t->words + 1, export, EXPORT); | 3598 | rdexp(t->words + 1, export, EXPORT); |
3599 | return (0); | 3599 | return 0; |
3600 | } | 3600 | } |
3601 | 3601 | ||
3602 | static int doreadonly(struct op *t) | 3602 | static int doreadonly(struct op *t) |
3603 | { | 3603 | { |
3604 | rdexp(t->words + 1, ronly, RONLY); | 3604 | rdexp(t->words + 1, ronly, RONLY); |
3605 | return (0); | 3605 | return 0; |
3606 | } | 3606 | } |
3607 | 3607 | ||
3608 | static void rdexp(char **wp, void (*f) (struct var *), int key) | 3608 | static void rdexp(char **wp, void (*f) (struct var *), int key) |
@@ -3643,7 +3643,7 @@ static int doset(struct op *t) | |||
3643 | if ((cp = t->words[1]) == NULL) { | 3643 | if ((cp = t->words[1]) == NULL) { |
3644 | for (vp = vlist; vp; vp = vp->next) | 3644 | for (vp = vlist; vp; vp = vp->next) |
3645 | varput(vp->name, 1); | 3645 | varput(vp->name, 1); |
3646 | return (0); | 3646 | return 0; |
3647 | } | 3647 | } |
3648 | if (*cp == '-') { | 3648 | if (*cp == '-') { |
3649 | /* bad: t->words++; */ | 3649 | /* bad: t->words++; */ |
@@ -3674,7 +3674,7 @@ static int doset(struct op *t) | |||
3674 | setval(lookup("#"), putn(dolc)); | 3674 | setval(lookup("#"), putn(dolc)); |
3675 | setarea((char *) (dolv - 1), 0); | 3675 | setarea((char *) (dolv - 1), 0); |
3676 | } | 3676 | } |
3677 | return (0); | 3677 | return 0; |
3678 | } | 3678 | } |
3679 | 3679 | ||
3680 | static void varput(char *s, int out) | 3680 | static void varput(char *s, int out) |
@@ -3818,7 +3818,7 @@ static int expand(char *cp, struct wdblock **wbp, int f) | |||
3818 | gflg = 0; | 3818 | gflg = 0; |
3819 | 3819 | ||
3820 | if (cp == NULL) | 3820 | if (cp == NULL) |
3821 | return (0); | 3821 | return 0; |
3822 | 3822 | ||
3823 | if (!anys("$`'\"", cp) && | 3823 | if (!anys("$`'\"", cp) && |
3824 | !anys(ifs->value, cp) && ((f & DOGLOB) == 0 || !anys("[*?", cp))) { | 3824 | !anys(ifs->value, cp) && ((f & DOGLOB) == 0 || !anys("[*?", cp))) { |
@@ -3826,7 +3826,7 @@ static int expand(char *cp, struct wdblock **wbp, int f) | |||
3826 | if (f & DOTRIM) | 3826 | if (f & DOTRIM) |
3827 | unquote(cp); | 3827 | unquote(cp); |
3828 | *wbp = addword(cp, *wbp); | 3828 | *wbp = addword(cp, *wbp); |
3829 | return (1); | 3829 | return 1; |
3830 | } | 3830 | } |
3831 | if (newenv(setjmp(errpt = ev)) == 0) { | 3831 | if (newenv(setjmp(errpt = ev)) == 0) { |
3832 | PUSHIO(aword, cp, strchar); | 3832 | PUSHIO(aword, cp, strchar); |
@@ -3866,7 +3866,7 @@ static char *blank(int f) | |||
3866 | switch (c = subgetc('"', foundequals)) { | 3866 | switch (c = subgetc('"', foundequals)) { |
3867 | case 0: | 3867 | case 0: |
3868 | if (sp == e.linep) | 3868 | if (sp == e.linep) |
3869 | return (0); | 3869 | return 0; |
3870 | *e.linep++ = 0; | 3870 | *e.linep++ = 0; |
3871 | return (sp); | 3871 | return (sp); |
3872 | 3872 | ||
@@ -3930,7 +3930,7 @@ static int subgetc(char ec, int quoted) | |||
3930 | if (!INSUB() && ec != '\'') { | 3930 | if (!INSUB() && ec != '\'') { |
3931 | if (c == '`') { | 3931 | if (c == '`') { |
3932 | if (grave(quoted) == 0) | 3932 | if (grave(quoted) == 0) |
3933 | return (0); | 3933 | return 0; |
3934 | e.iop->task = XGRAVE; | 3934 | e.iop->task = XGRAVE; |
3935 | goto again; | 3935 | goto again; |
3936 | } | 3936 | } |
@@ -4001,7 +4001,7 @@ static int dollar(int quoted) | |||
4001 | /* should check dollar */ | 4001 | /* should check dollar */ |
4002 | e.linep = s; | 4002 | e.linep = s; |
4003 | PUSHIO(awordlist, dolv + 1, dolchar); | 4003 | PUSHIO(awordlist, dolv + 1, dolchar); |
4004 | return (0); | 4004 | return 0; |
4005 | } else { /* trap the nasty ${=} */ | 4005 | } else { /* trap the nasty ${=} */ |
4006 | s[0] = '1'; | 4006 | s[0] = '1'; |
4007 | s[1] = 0; | 4007 | s[1] = 0; |
@@ -4042,7 +4042,7 @@ static int dollar(int quoted) | |||
4042 | } | 4042 | } |
4043 | e.linep = s; | 4043 | e.linep = s; |
4044 | PUSHIO(aword, dolp, quoted ? qstrchar : strchar); | 4044 | PUSHIO(aword, dolp, quoted ? qstrchar : strchar); |
4045 | return (0); | 4045 | return 0; |
4046 | } | 4046 | } |
4047 | 4047 | ||
4048 | /* | 4048 | /* |
@@ -4072,7 +4072,7 @@ static int grave(int quoted) | |||
4072 | for (cp = e.iop->argp->aword; *cp != '`'; cp++) | 4072 | for (cp = e.iop->argp->aword; *cp != '`'; cp++) |
4073 | if (*cp == 0) { | 4073 | if (*cp == 0) { |
4074 | err("no closing `"); | 4074 | err("no closing `"); |
4075 | return (0); | 4075 | return 0; |
4076 | } | 4076 | } |
4077 | 4077 | ||
4078 | /* string copy with dollar expansion */ | 4078 | /* string copy with dollar expansion */ |
@@ -4119,7 +4119,7 @@ static int grave(int quoted) | |||
4119 | break; | 4119 | break; |
4120 | default: | 4120 | default: |
4121 | err("unclosed ${\n"); | 4121 | err("unclosed ${\n"); |
4122 | return (0); | 4122 | return 0; |
4123 | } | 4123 | } |
4124 | if (operator) { | 4124 | if (operator) { |
4125 | src++; | 4125 | src++; |
@@ -4129,7 +4129,7 @@ static int grave(int quoted) | |||
4129 | alt_value[alt_index] = 0; | 4129 | alt_value[alt_index] = 0; |
4130 | if (*src != '}') { | 4130 | if (*src != '}') { |
4131 | err("unclosed ${\n"); | 4131 | err("unclosed ${\n"); |
4132 | return (0); | 4132 | return 0; |
4133 | } | 4133 | } |
4134 | } | 4134 | } |
4135 | src++; | 4135 | src++; |
@@ -4164,7 +4164,7 @@ static int grave(int quoted) | |||
4164 | alt_value : vp->value; | 4164 | alt_value : vp->value; |
4165 | else if (operator == '?') { | 4165 | else if (operator == '?') { |
4166 | err(alt_value); | 4166 | err(alt_value); |
4167 | return (0); | 4167 | return 0; |
4168 | } else if (alt_index && (operator != '+')) { | 4168 | } else if (alt_index && (operator != '+')) { |
4169 | value = alt_value; | 4169 | value = alt_value; |
4170 | if (operator == '=') | 4170 | if (operator == '=') |
@@ -4186,7 +4186,7 @@ static int grave(int quoted) | |||
4186 | *dest = '\0'; | 4186 | *dest = '\0'; |
4187 | 4187 | ||
4188 | if (openpipe(pf) < 0) | 4188 | if (openpipe(pf) < 0) |
4189 | return (0); | 4189 | return 0; |
4190 | 4190 | ||
4191 | while ((i = vfork()) == -1 && errno == EAGAIN); | 4191 | while ((i = vfork()) == -1 && errno == EAGAIN); |
4192 | 4192 | ||
@@ -4195,7 +4195,7 @@ static int grave(int quoted) | |||
4195 | if (i < 0) { | 4195 | if (i < 0) { |
4196 | closepipe(pf); | 4196 | closepipe(pf); |
4197 | err((char *) bb_msg_memory_exhausted); | 4197 | err((char *) bb_msg_memory_exhausted); |
4198 | return (0); | 4198 | return 0; |
4199 | } | 4199 | } |
4200 | if (i != 0) { | 4200 | if (i != 0) { |
4201 | waitpid(i, NULL, 0); | 4201 | waitpid(i, NULL, 0); |
@@ -4204,7 +4204,7 @@ static int grave(int quoted) | |||
4204 | PUSHIO(afile, remap(pf[0]), | 4204 | PUSHIO(afile, remap(pf[0]), |
4205 | (int (*)(struct ioarg *)) ((quoted) ? qgravechar : | 4205 | (int (*)(struct ioarg *)) ((quoted) ? qgravechar : |
4206 | gravechar)); | 4206 | gravechar)); |
4207 | return (1); | 4207 | return 1; |
4208 | } | 4208 | } |
4209 | /* allow trapped signals */ | 4209 | /* allow trapped signals */ |
4210 | /* XXX - Maybe this signal stuff should go as well? */ | 4210 | /* XXX - Maybe this signal stuff should go as well? */ |
@@ -4379,8 +4379,8 @@ static int anyspcl(struct wdblock *wb) | |||
4379 | wd = wb->w_words; | 4379 | wd = wb->w_words; |
4380 | for (i = 0; i < wb->w_nword; i++) | 4380 | for (i = 0; i < wb->w_nword; i++) |
4381 | if (anys(spcl, *wd++)) | 4381 | if (anys(spcl, *wd++)) |
4382 | return (1); | 4382 | return 1; |
4383 | return (0); | 4383 | return 0; |
4384 | } | 4384 | } |
4385 | 4385 | ||
4386 | static int xstrcmp(char *p1, char *p2) | 4386 | static int xstrcmp(char *p1, char *p2) |
@@ -4634,14 +4634,14 @@ static int readc(void) | |||
4634 | 4634 | ||
4635 | if (e.iop >= iostack) { | 4635 | if (e.iop >= iostack) { |
4636 | RCPRINTF(("READC: return 0, e.iop %p\n", e.iop)); | 4636 | RCPRINTF(("READC: return 0, e.iop %p\n", e.iop)); |
4637 | return (0); | 4637 | return 0; |
4638 | } | 4638 | } |
4639 | 4639 | ||
4640 | DBGPRINTF(("READC: leave()...\n")); | 4640 | DBGPRINTF(("READC: leave()...\n")); |
4641 | leave(); | 4641 | leave(); |
4642 | 4642 | ||
4643 | /* NOTREACHED */ | 4643 | /* NOTREACHED */ |
4644 | return (0); | 4644 | return 0; |
4645 | } | 4645 | } |
4646 | 4646 | ||
4647 | static void ioecho(char c) | 4647 | static void ioecho(char c) |
@@ -4737,7 +4737,7 @@ static int nlchar(struct ioarg *ap) | |||
4737 | int c; | 4737 | int c; |
4738 | 4738 | ||
4739 | if (ap->aword == NULL) | 4739 | if (ap->aword == NULL) |
4740 | return (0); | 4740 | return 0; |
4741 | if ((c = *ap->aword++) == 0) { | 4741 | if ((c = *ap->aword++) == 0) { |
4742 | ap->aword = NULL; | 4742 | ap->aword = NULL; |
4743 | return ('\n'); | 4743 | return ('\n'); |
@@ -4755,7 +4755,7 @@ static int wdchar(struct ioarg *ap) | |||
4755 | char **wl; | 4755 | char **wl; |
4756 | 4756 | ||
4757 | if ((wl = ap->awordlist) == NULL) | 4757 | if ((wl = ap->awordlist) == NULL) |
4758 | return (0); | 4758 | return 0; |
4759 | if (*wl != NULL) { | 4759 | if (*wl != NULL) { |
4760 | if ((c = *(*wl)++) != 0) | 4760 | if ((c = *(*wl)++) != 0) |
4761 | return (c & 0177); | 4761 | return (c & 0177); |
@@ -4776,9 +4776,9 @@ static int dolchar(struct ioarg *ap) | |||
4776 | 4776 | ||
4777 | if ((wp = *ap->awordlist++) != NULL) { | 4777 | if ((wp = *ap->awordlist++) != NULL) { |
4778 | PUSHIO(aword, wp, *ap->awordlist == NULL ? strchar : xxchar); | 4778 | PUSHIO(aword, wp, *ap->awordlist == NULL ? strchar : xxchar); |
4779 | return (-1); | 4779 | return -1; |
4780 | } | 4780 | } |
4781 | return (0); | 4781 | return 0; |
4782 | } | 4782 | } |
4783 | 4783 | ||
4784 | static int xxchar(struct ioarg *ap) | 4784 | static int xxchar(struct ioarg *ap) |
@@ -4786,7 +4786,7 @@ static int xxchar(struct ioarg *ap) | |||
4786 | int c; | 4786 | int c; |
4787 | 4787 | ||
4788 | if (ap->aword == NULL) | 4788 | if (ap->aword == NULL) |
4789 | return (0); | 4789 | return 0; |
4790 | if ((c = *ap->aword++) == '\0') { | 4790 | if ((c = *ap->aword++) == '\0') { |
4791 | ap->aword = NULL; | 4791 | ap->aword = NULL; |
4792 | return (' '); | 4792 | return (' '); |
@@ -4802,7 +4802,7 @@ static int strchar(struct ioarg *ap) | |||
4802 | int c; | 4802 | int c; |
4803 | 4803 | ||
4804 | if (ap->aword == NULL || (c = *ap->aword++) == 0) | 4804 | if (ap->aword == NULL || (c = *ap->aword++) == 0) |
4805 | return (0); | 4805 | return 0; |
4806 | return (c); | 4806 | return (c); |
4807 | } | 4807 | } |
4808 | 4808 | ||
@@ -4814,7 +4814,7 @@ static int qstrchar(struct ioarg *ap) | |||
4814 | int c; | 4814 | int c; |
4815 | 4815 | ||
4816 | if (ap->aword == NULL || (c = *ap->aword++) == 0) | 4816 | if (ap->aword == NULL || (c = *ap->aword++) == 0) |
4817 | return (0); | 4817 | return 0; |
4818 | return (c | QUOTE); | 4818 | return (c | QUOTE); |
4819 | } | 4819 | } |
4820 | 4820 | ||
@@ -5143,13 +5143,13 @@ static int herein(char *hname, int xdoll) | |||
5143 | (void) &tf; | 5143 | (void) &tf; |
5144 | #endif | 5144 | #endif |
5145 | if (hname == NULL) | 5145 | if (hname == NULL) |
5146 | return (-1); | 5146 | return -1; |
5147 | 5147 | ||
5148 | DBGPRINTF7(("HEREIN: hname is %s, xdoll=%d\n", hname, xdoll)); | 5148 | DBGPRINTF7(("HEREIN: hname is %s, xdoll=%d\n", hname, xdoll)); |
5149 | 5149 | ||
5150 | hf = open(hname, 0); | 5150 | hf = open(hname, 0); |
5151 | if (hf < 0) | 5151 | if (hf < 0) |
5152 | return (-1); | 5152 | return -1; |
5153 | 5153 | ||
5154 | if (xdoll) { | 5154 | if (xdoll) { |
5155 | char c; | 5155 | char c; |
@@ -5158,7 +5158,7 @@ static int herein(char *hname, int xdoll) | |||
5158 | 5158 | ||
5159 | tf = mkstemp(tname); | 5159 | tf = mkstemp(tname); |
5160 | if (tf < 0) | 5160 | if (tf < 0) |
5161 | return (-1); | 5161 | return -1; |
5162 | if (newenv(setjmp(errpt = ev)) == 0) { | 5162 | if (newenv(setjmp(errpt = ev)) == 0) { |
5163 | PUSHIO(afile, hf, herechar); | 5163 | PUSHIO(afile, hf, herechar); |
5164 | setbase(e.iop); | 5164 | setbase(e.iop); |