diff options
author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-11-27 16:49:55 +0000 |
---|---|---|
committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-11-27 16:49:55 +0000 |
commit | db172fe425634b7d784ae1d5af6d88b96b4e747e (patch) | |
tree | ffdef7f5ab4a33038d0a62c9355b48f362aa463e /shell | |
parent | bb89b301143fe9deb962bb2d48264b27a945fcf4 (diff) | |
download | busybox-w32-db172fe425634b7d784ae1d5af6d88b96b4e747e.tar.gz busybox-w32-db172fe425634b7d784ae1d5af6d88b96b4e747e.tar.bz2 busybox-w32-db172fe425634b7d784ae1d5af6d88b96b4e747e.zip |
style cleanup: return(a) -> return a, part 2
git-svn-id: svn://busybox.net/trunk/busybox@16691 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 18 | ||||
-rw-r--r-- | shell/hush.c | 4 | ||||
-rw-r--r-- | shell/msh.c | 279 |
3 files changed, 151 insertions, 150 deletions
diff --git a/shell/ash.c b/shell/ash.c index 704d03bec..0704353f5 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -2160,8 +2160,8 @@ lookupalias(const char *name, int check) | |||
2160 | struct alias *ap = *__lookupalias(name); | 2160 | struct alias *ap = *__lookupalias(name); |
2161 | 2161 | ||
2162 | if (check && ap && (ap->flag & ALIASINUSE)) | 2162 | if (check && ap && (ap->flag & ALIASINUSE)) |
2163 | return (NULL); | 2163 | return NULL; |
2164 | return (ap); | 2164 | return ap; |
2165 | } | 2165 | } |
2166 | 2166 | ||
2167 | /* | 2167 | /* |
@@ -2196,7 +2196,7 @@ aliascmd(int argc, char **argv) | |||
2196 | } | 2196 | } |
2197 | } | 2197 | } |
2198 | 2198 | ||
2199 | return (ret); | 2199 | return ret; |
2200 | } | 2200 | } |
2201 | 2201 | ||
2202 | static int | 2202 | static int |
@@ -2217,7 +2217,7 @@ unaliascmd(int argc, char **argv) | |||
2217 | } | 2217 | } |
2218 | } | 2218 | } |
2219 | 2219 | ||
2220 | return (i); | 2220 | return i; |
2221 | } | 2221 | } |
2222 | 2222 | ||
2223 | static struct alias * | 2223 | static struct alias * |
@@ -4831,10 +4831,10 @@ done: | |||
4831 | startloc = expdest - (char *)stackblock(); | 4831 | startloc = expdest - (char *)stackblock(); |
4832 | strtodest(home, SQSYNTAX, quotes); | 4832 | strtodest(home, SQSYNTAX, quotes); |
4833 | recordregion(startloc, expdest - (char *)stackblock(), 0); | 4833 | recordregion(startloc, expdest - (char *)stackblock(), 0); |
4834 | return (p); | 4834 | return p; |
4835 | lose: | 4835 | lose: |
4836 | *p = c; | 4836 | *p = c; |
4837 | return (startp); | 4837 | return startp; |
4838 | } | 4838 | } |
4839 | 4839 | ||
4840 | 4840 | ||
@@ -9969,7 +9969,7 @@ out: | |||
9969 | else | 9969 | else |
9970 | TRACE(("reread token %s %s\n", tokname(t), t == TWORD ? wordtext : "")); | 9970 | TRACE(("reread token %s %s\n", tokname(t), t == TWORD ? wordtext : "")); |
9971 | #endif | 9971 | #endif |
9972 | return (t); | 9972 | return t; |
9973 | } | 9973 | } |
9974 | 9974 | ||
9975 | 9975 | ||
@@ -12531,7 +12531,7 @@ dash_arith(const char *s) | |||
12531 | } | 12531 | } |
12532 | INTON; | 12532 | INTON; |
12533 | 12533 | ||
12534 | return (result); | 12534 | return result; |
12535 | } | 12535 | } |
12536 | 12536 | ||
12537 | 12537 | ||
@@ -12555,7 +12555,7 @@ letcmd(int argc, char **argv) | |||
12555 | i = dash_arith(*ap); | 12555 | i = dash_arith(*ap); |
12556 | } | 12556 | } |
12557 | 12557 | ||
12558 | return (!i); | 12558 | return !i; |
12559 | } | 12559 | } |
12560 | #endif /* CONFIG_ASH_MATH_SUPPORT */ | 12560 | #endif /* CONFIG_ASH_MATH_SUPPORT */ |
12561 | 12561 | ||
diff --git a/shell/hush.c b/shell/hush.c index 57b4a7ac3..a6e029e4e 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -507,7 +507,7 @@ static int builtin_export(struct child_prog *child) | |||
507 | char *name = child->argv[1]; | 507 | char *name = child->argv[1]; |
508 | 508 | ||
509 | if (name == NULL) { | 509 | if (name == NULL) { |
510 | return (builtin_env(child)); | 510 | return builtin_env(child); |
511 | } | 511 | } |
512 | 512 | ||
513 | name = strdup(name); | 513 | name = strdup(name); |
@@ -730,7 +730,7 @@ static int builtin_source(struct child_prog *child) | |||
730 | status = parse_file_outer(input); | 730 | status = parse_file_outer(input); |
731 | mark_closed(fileno(input)); | 731 | mark_closed(fileno(input)); |
732 | fclose(input); | 732 | fclose(input); |
733 | return (status); | 733 | return status; |
734 | } | 734 | } |
735 | 735 | ||
736 | static int builtin_umask(struct child_prog *child) | 736 | static int builtin_umask(struct child_prog *child) |
diff --git a/shell/msh.c b/shell/msh.c index 8f58e9457..492d3cf43 100644 --- a/shell/msh.c +++ b/shell/msh.c | |||
@@ -1022,31 +1022,31 @@ struct op *scantree(struct op *head) | |||
1022 | struct op *dotnode; | 1022 | struct op *dotnode; |
1023 | 1023 | ||
1024 | if (head == NULL) | 1024 | if (head == NULL) |
1025 | return (NULL); | 1025 | return NULL; |
1026 | 1026 | ||
1027 | if (head->left != NULL) { | 1027 | if (head->left != NULL) { |
1028 | dotnode = scantree(head->left); | 1028 | dotnode = scantree(head->left); |
1029 | if (dotnode) | 1029 | if (dotnode) |
1030 | return (dotnode); | 1030 | return dotnode; |
1031 | } | 1031 | } |
1032 | 1032 | ||
1033 | if (head->right != NULL) { | 1033 | if (head->right != NULL) { |
1034 | dotnode = scantree(head->right); | 1034 | dotnode = scantree(head->right); |
1035 | if (dotnode) | 1035 | if (dotnode) |
1036 | return (dotnode); | 1036 | return dotnode; |
1037 | } | 1037 | } |
1038 | 1038 | ||
1039 | if (head->words == NULL) | 1039 | if (head->words == NULL) |
1040 | return (NULL); | 1040 | return NULL; |
1041 | 1041 | ||
1042 | DBGPRINTF5(("SCANTREE: checking node %p\n", head)); | 1042 | DBGPRINTF5(("SCANTREE: checking node %p\n", head)); |
1043 | 1043 | ||
1044 | if ((head->type != TDOT) && (strcmp(".", head->words[0]) == 0)) { | 1044 | if ((head->type != TDOT) && (strcmp(".", head->words[0]) == 0)) { |
1045 | DBGPRINTF5(("SCANTREE: dot found in node %p\n", head)); | 1045 | DBGPRINTF5(("SCANTREE: dot found in node %p\n", head)); |
1046 | return (head); | 1046 | return head; |
1047 | } | 1047 | } |
1048 | 1048 | ||
1049 | return (NULL); | 1049 | return NULL; |
1050 | } | 1050 | } |
1051 | 1051 | ||
1052 | 1052 | ||
@@ -1219,7 +1219,7 @@ static int any(int c, char *s) | |||
1219 | 1219 | ||
1220 | static char *putn(int n) | 1220 | static char *putn(int n) |
1221 | { | 1221 | { |
1222 | return (itoa(n)); | 1222 | return itoa(n); |
1223 | } | 1223 | } |
1224 | 1224 | ||
1225 | static void next(int f) | 1225 | static void next(int f) |
@@ -1248,7 +1248,7 @@ static char *space(int n) | |||
1248 | 1248 | ||
1249 | if ((cp = getcell(n)) == 0) | 1249 | if ((cp = getcell(n)) == 0) |
1250 | err("out of string space"); | 1250 | err("out of string space"); |
1251 | return (cp); | 1251 | return cp; |
1252 | } | 1252 | } |
1253 | 1253 | ||
1254 | static char *strsave(char *s, int a) | 1254 | static char *strsave(char *s, int a) |
@@ -1258,9 +1258,9 @@ static char *strsave(char *s, int a) | |||
1258 | if ((cp = space(strlen(s) + 1)) != NULL) { | 1258 | if ((cp = space(strlen(s) + 1)) != NULL) { |
1259 | setarea((char *) cp, a); | 1259 | setarea((char *) cp, a); |
1260 | for (xp = cp; (*xp++ = *s++) != '\0';); | 1260 | for (xp = cp; (*xp++ = *s++) != '\0';); |
1261 | return (cp); | 1261 | return cp; |
1262 | } | 1262 | } |
1263 | return (""); | 1263 | return ""; |
1264 | } | 1264 | } |
1265 | 1265 | ||
1266 | /* | 1266 | /* |
@@ -1306,16 +1306,16 @@ static struct var *lookup(char *n) | |||
1306 | c = c * 10 + *n - '0'; | 1306 | c = c * 10 + *n - '0'; |
1307 | dummy.status = RONLY; | 1307 | dummy.status = RONLY; |
1308 | dummy.value = c <= dolc ? dolv[c] : null; | 1308 | dummy.value = c <= dolc ? dolv[c] : null; |
1309 | return (&dummy); | 1309 | return &dummy; |
1310 | } | 1310 | } |
1311 | for (vp = vlist; vp; vp = vp->next) | 1311 | for (vp = vlist; vp; vp = vp->next) |
1312 | if (eqname(vp->name, n)) | 1312 | if (eqname(vp->name, n)) |
1313 | return (vp); | 1313 | return vp; |
1314 | cp = findeq(n); | 1314 | cp = findeq(n); |
1315 | vp = (struct var *) space(sizeof(*vp)); | 1315 | vp = (struct var *) space(sizeof(*vp)); |
1316 | if (vp == 0 || (vp->name = space((int) (cp - n) + 2)) == 0) { | 1316 | if (vp == 0 || (vp->name = space((int) (cp - n) + 2)) == 0) { |
1317 | dummy.name = dummy.value = ""; | 1317 | dummy.name = dummy.value = ""; |
1318 | return (&dummy); | 1318 | return &dummy; |
1319 | } | 1319 | } |
1320 | for (cp = vp->name; (*cp = *n++) && *cp != '='; cp++); | 1320 | for (cp = vp->name; (*cp = *n++) && *cp != '='; cp++); |
1321 | if (*cp == 0) | 1321 | if (*cp == 0) |
@@ -1327,7 +1327,7 @@ static struct var *lookup(char *n) | |||
1327 | vp->next = vlist; | 1327 | vp->next = vlist; |
1328 | vp->status = GETCELL; | 1328 | vp->status = GETCELL; |
1329 | vlist = vp; | 1329 | vlist = vp; |
1330 | return (vp); | 1330 | return vp; |
1331 | } | 1331 | } |
1332 | 1332 | ||
1333 | /* | 1333 | /* |
@@ -1455,14 +1455,14 @@ static int eqname(char *n1, char *n2) | |||
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 | ||
1461 | static char *findeq(char *cp) | 1461 | static char *findeq(char *cp) |
1462 | { | 1462 | { |
1463 | while (*cp != '\0' && *cp != '=') | 1463 | while (*cp != '\0' && *cp != '=') |
1464 | cp++; | 1464 | cp++; |
1465 | return (cp); | 1465 | return cp; |
1466 | } | 1466 | } |
1467 | 1467 | ||
1468 | /* -------- gmatch.c -------- */ | 1468 | /* -------- gmatch.c -------- */ |
@@ -1510,7 +1510,7 @@ static int gmatch(char *s, char *p) | |||
1510 | return 0; | 1510 | return 0; |
1511 | } | 1511 | } |
1512 | } | 1512 | } |
1513 | return (*s == 0); | 1513 | return *s == 0; |
1514 | } | 1514 | } |
1515 | 1515 | ||
1516 | static char *cclass(char *p, int sub) | 1516 | static char *cclass(char *p, int sub) |
@@ -1522,7 +1522,7 @@ static char *cclass(char *p, int sub) | |||
1522 | found = not; | 1522 | found = not; |
1523 | do { | 1523 | do { |
1524 | if (*p == '\0') | 1524 | if (*p == '\0') |
1525 | return ((char *) NULL); | 1525 | return NULL; |
1526 | c = *p & CMASK; | 1526 | c = *p & CMASK; |
1527 | if (p[1] == '-' && p[2] != ']') { | 1527 | if (p[1] == '-' && p[2] != ']') { |
1528 | d = p[2] & CMASK; | 1528 | d = p[2] & CMASK; |
@@ -1532,7 +1532,7 @@ static char *cclass(char *p, int sub) | |||
1532 | if (c == sub || (c <= sub && sub <= d)) | 1532 | if (c == sub || (c <= sub && sub <= d)) |
1533 | found = !not; | 1533 | found = !not; |
1534 | } while (*++p != ']'); | 1534 | } while (*++p != ']'); |
1535 | return (found ? p + 1 : (char *) NULL); | 1535 | return found ? p + 1 : NULL; |
1536 | } | 1536 | } |
1537 | 1537 | ||
1538 | 1538 | ||
@@ -1596,7 +1596,7 @@ char *getcell(unsigned nbytes) | |||
1596 | i = nregio >= GROWBY ? nregio : GROWBY; | 1596 | i = nregio >= GROWBY ? nregio : GROWBY; |
1597 | p = (struct region *) sbrk(i * REGSIZE); | 1597 | p = (struct region *) sbrk(i * REGSIZE); |
1598 | if (p == (struct region *) -1) | 1598 | if (p == (struct region *) -1) |
1599 | return ((char *) NULL); | 1599 | return NULL; |
1600 | p--; | 1600 | p--; |
1601 | if (p != areatop) { | 1601 | if (p != areatop) { |
1602 | puts("not contig"); | 1602 | puts("not contig"); |
@@ -1608,7 +1608,7 @@ char *getcell(unsigned nbytes) | |||
1608 | q->next = areabot; | 1608 | q->next = areabot; |
1609 | q->area = BUSY; | 1609 | q->area = BUSY; |
1610 | areatop = q; | 1610 | areatop = q; |
1611 | found: | 1611 | found: |
1612 | /* | 1612 | /* |
1613 | * we found a FREE area big enough, pointed to by 'p', and up to 'q' | 1613 | * we found a FREE area big enough, pointed to by 'p', and up to 'q' |
1614 | */ | 1614 | */ |
@@ -1626,7 +1626,7 @@ char *getcell(unsigned nbytes) | |||
1626 | p->next = areanxt; | 1626 | p->next = areanxt; |
1627 | } | 1627 | } |
1628 | p->area = areanum; | 1628 | p->area = areanum; |
1629 | return ((char *) (p + 1)); | 1629 | return (char *) (p + 1); |
1630 | } | 1630 | } |
1631 | 1631 | ||
1632 | static void freecell(char *cp) | 1632 | static void freecell(char *cp) |
@@ -1732,7 +1732,7 @@ static struct op *pipeline(int cf) | |||
1732 | } | 1732 | } |
1733 | 1733 | ||
1734 | DBGPRINTF7(("PIPELINE: returning t=%p\n", t)); | 1734 | DBGPRINTF7(("PIPELINE: returning t=%p\n", t)); |
1735 | return (t); | 1735 | return t; |
1736 | } | 1736 | } |
1737 | 1737 | ||
1738 | static struct op *andor(void) | 1738 | static struct op *andor(void) |
@@ -1760,7 +1760,7 @@ static struct op *andor(void) | |||
1760 | } | 1760 | } |
1761 | 1761 | ||
1762 | DBGPRINTF7(("ANDOR: returning t=%p\n", t)); | 1762 | DBGPRINTF7(("ANDOR: returning t=%p\n", t)); |
1763 | return (t); | 1763 | return t; |
1764 | } | 1764 | } |
1765 | 1765 | ||
1766 | static struct op *c_list(void) | 1766 | static struct op *c_list(void) |
@@ -1780,7 +1780,7 @@ static struct op *c_list(void) | |||
1780 | || (multiline && c == '\n')) { | 1780 | || (multiline && c == '\n')) { |
1781 | 1781 | ||
1782 | if ((p = andor()) == NULL) | 1782 | if ((p = andor()) == NULL) |
1783 | return (t); | 1783 | return t; |
1784 | 1784 | ||
1785 | if ((peeksym = yylex(0)) == '&') | 1785 | if ((peeksym = yylex(0)) == '&') |
1786 | p = block(TASYNC, p, NOBLOCK, NOWORDS); | 1786 | p = block(TASYNC, p, NOBLOCK, NOWORDS); |
@@ -1792,7 +1792,7 @@ static struct op *c_list(void) | |||
1792 | } | 1792 | } |
1793 | /* IF */ | 1793 | /* IF */ |
1794 | DBGPRINTF7(("C_LIST: returning t=%p\n", t)); | 1794 | DBGPRINTF7(("C_LIST: returning t=%p\n", t)); |
1795 | return (t); | 1795 | return t; |
1796 | } | 1796 | } |
1797 | 1797 | ||
1798 | static int synio(int cf) | 1798 | static int synio(int cf) |
@@ -1852,7 +1852,7 @@ static struct op *simple(void) | |||
1852 | break; | 1852 | break; |
1853 | 1853 | ||
1854 | default: | 1854 | default: |
1855 | return (t); | 1855 | return t; |
1856 | } | 1856 | } |
1857 | } | 1857 | } |
1858 | } | 1858 | } |
@@ -1867,7 +1867,7 @@ static struct op *nested(int type, int mark) | |||
1867 | t = c_list(); | 1867 | t = c_list(); |
1868 | musthave(mark, 0); | 1868 | musthave(mark, 0); |
1869 | multiline--; | 1869 | multiline--; |
1870 | return (block(type, t, NOBLOCK, NOWORDS)); | 1870 | return block(type, t, NOBLOCK, NOWORDS); |
1871 | } | 1871 | } |
1872 | 1872 | ||
1873 | static struct op *command(int cf) | 1873 | static struct op *command(int cf) |
@@ -1894,7 +1894,7 @@ static struct op *command(int cf) | |||
1894 | peeksym = c; | 1894 | peeksym = c; |
1895 | if ((t = simple()) == NULL) { | 1895 | if ((t = simple()) == NULL) { |
1896 | if (iolist == NULL) | 1896 | if (iolist == NULL) |
1897 | return ((struct op *) NULL); | 1897 | return NULL; |
1898 | t = newtp(); | 1898 | t = newtp(); |
1899 | t->type = TCOM; | 1899 | t->type = TCOM; |
1900 | } | 1900 | } |
@@ -1980,7 +1980,7 @@ static struct op *command(int cf) | |||
1980 | 1980 | ||
1981 | DBGPRINTF(("COMMAND: returning %p\n", t)); | 1981 | DBGPRINTF(("COMMAND: returning %p\n", t)); |
1982 | 1982 | ||
1983 | return (t); | 1983 | return t; |
1984 | } | 1984 | } |
1985 | 1985 | ||
1986 | static struct op *dowholefile(int type, int mark) | 1986 | static struct op *dowholefile(int type, int mark) |
@@ -1994,7 +1994,7 @@ static struct op *dowholefile(int type, int mark) | |||
1994 | multiline--; | 1994 | multiline--; |
1995 | t = block(type, t, NOBLOCK, NOWORDS); | 1995 | t = block(type, t, NOBLOCK, NOWORDS); |
1996 | DBGPRINTF(("DOWHOLEFILE: return t=%p\n", t)); | 1996 | DBGPRINTF(("DOWHOLEFILE: return t=%p\n", t)); |
1997 | return (t); | 1997 | return t; |
1998 | } | 1998 | } |
1999 | 1999 | ||
2000 | static struct op *dogroup(int onlydone) | 2000 | static struct op *dogroup(int onlydone) |
@@ -2004,12 +2004,12 @@ static struct op *dogroup(int onlydone) | |||
2004 | 2004 | ||
2005 | c = yylex(CONTIN); | 2005 | c = yylex(CONTIN); |
2006 | if (c == DONE && onlydone) | 2006 | if (c == DONE && onlydone) |
2007 | return ((struct op *) NULL); | 2007 | return NULL; |
2008 | if (c != DO) | 2008 | if (c != DO) |
2009 | SYNTAXERR; | 2009 | SYNTAXERR; |
2010 | mylist = c_list(); | 2010 | mylist = c_list(); |
2011 | musthave(DONE, 0); | 2011 | musthave(DONE, 0); |
2012 | return (mylist); | 2012 | return mylist; |
2013 | } | 2013 | } |
2014 | 2014 | ||
2015 | static struct op *thenpart(void) | 2015 | static struct op *thenpart(void) |
@@ -2019,7 +2019,7 @@ static struct op *thenpart(void) | |||
2019 | 2019 | ||
2020 | if ((c = yylex(0)) != THEN) { | 2020 | if ((c = yylex(0)) != THEN) { |
2021 | peeksym = c; | 2021 | peeksym = c; |
2022 | return ((struct op *) NULL); | 2022 | return NULL; |
2023 | } | 2023 | } |
2024 | t = newtp(); | 2024 | t = newtp(); |
2025 | t->type = 0; | 2025 | t->type = 0; |
@@ -2027,7 +2027,7 @@ static struct op *thenpart(void) | |||
2027 | if (t->left == NULL) | 2027 | if (t->left == NULL) |
2028 | SYNTAXERR; | 2028 | SYNTAXERR; |
2029 | t->right = elsepart(); | 2029 | t->right = elsepart(); |
2030 | return (t); | 2030 | return t; |
2031 | } | 2031 | } |
2032 | 2032 | ||
2033 | static struct op *elsepart(void) | 2033 | static struct op *elsepart(void) |
@@ -2039,18 +2039,18 @@ static struct op *elsepart(void) | |||
2039 | case ELSE: | 2039 | case ELSE: |
2040 | if ((t = c_list()) == NULL) | 2040 | if ((t = c_list()) == NULL) |
2041 | SYNTAXERR; | 2041 | SYNTAXERR; |
2042 | return (t); | 2042 | return t; |
2043 | 2043 | ||
2044 | case ELIF: | 2044 | case ELIF: |
2045 | t = newtp(); | 2045 | t = newtp(); |
2046 | t->type = TELIF; | 2046 | t->type = TELIF; |
2047 | t->left = c_list(); | 2047 | t->left = c_list(); |
2048 | t->right = thenpart(); | 2048 | t->right = thenpart(); |
2049 | return (t); | 2049 | return t; |
2050 | 2050 | ||
2051 | default: | 2051 | default: |
2052 | peeksym = c; | 2052 | peeksym = c; |
2053 | return ((struct op *) NULL); | 2053 | return NULL; |
2054 | } | 2054 | } |
2055 | } | 2055 | } |
2056 | 2056 | ||
@@ -2065,7 +2065,7 @@ static struct op *caselist(void) | |||
2065 | } | 2065 | } |
2066 | 2066 | ||
2067 | DBGPRINTF(("CASELIST, returning t=%p\n", t)); | 2067 | DBGPRINTF(("CASELIST, returning t=%p\n", t)); |
2068 | return (t); | 2068 | return t; |
2069 | } | 2069 | } |
2070 | 2070 | ||
2071 | static struct op *casepart(void) | 2071 | static struct op *casepart(void) |
@@ -2084,7 +2084,7 @@ static struct op *casepart(void) | |||
2084 | 2084 | ||
2085 | DBGPRINTF7(("CASEPART: made newtp(TPAT, t=%p)\n", t)); | 2085 | DBGPRINTF7(("CASEPART: made newtp(TPAT, t=%p)\n", t)); |
2086 | 2086 | ||
2087 | return (t); | 2087 | return t; |
2088 | } | 2088 | } |
2089 | 2089 | ||
2090 | static char **pattern(void) | 2090 | static char **pattern(void) |
@@ -2100,7 +2100,7 @@ static char **pattern(void) | |||
2100 | peeksym = c; | 2100 | peeksym = c; |
2101 | word(NOWORD); | 2101 | word(NOWORD); |
2102 | 2102 | ||
2103 | return (copyw()); | 2103 | return copyw(); |
2104 | } | 2104 | } |
2105 | 2105 | ||
2106 | static char **wordlist(void) | 2106 | static char **wordlist(void) |
@@ -2109,14 +2109,14 @@ static char **wordlist(void) | |||
2109 | 2109 | ||
2110 | if ((c = yylex(0)) != IN) { | 2110 | if ((c = yylex(0)) != IN) { |
2111 | peeksym = c; | 2111 | peeksym = c; |
2112 | return ((char **) NULL); | 2112 | return NULL; |
2113 | } | 2113 | } |
2114 | startl = 0; | 2114 | startl = 0; |
2115 | while ((c = yylex(0)) == WORD) | 2115 | while ((c = yylex(0)) == WORD) |
2116 | word(yylval.cp); | 2116 | word(yylval.cp); |
2117 | word(NOWORD); | 2117 | word(NOWORD); |
2118 | peeksym = c; | 2118 | peeksym = c; |
2119 | return (copyw()); | 2119 | return copyw(); |
2120 | } | 2120 | } |
2121 | 2121 | ||
2122 | /* | 2122 | /* |
@@ -2127,11 +2127,11 @@ static struct op *list(struct op *t1, struct op *t2) | |||
2127 | DBGPRINTF7(("LIST: enter, t1=%p, t2=%p\n", t1, t2)); | 2127 | DBGPRINTF7(("LIST: enter, t1=%p, t2=%p\n", t1, t2)); |
2128 | 2128 | ||
2129 | if (t1 == NULL) | 2129 | if (t1 == NULL) |
2130 | return (t2); | 2130 | return t2; |
2131 | if (t2 == NULL) | 2131 | if (t2 == NULL) |
2132 | return (t1); | 2132 | return t1; |
2133 | 2133 | ||
2134 | return (block(TLIST, t1, t2, NOWORDS)); | 2134 | return block(TLIST, t1, t2, NOWORDS); |
2135 | } | 2135 | } |
2136 | 2136 | ||
2137 | static struct op *block(int type, struct op *t1, struct op *t2, char **wp) | 2137 | static struct op *block(int type, struct op *t1, struct op *t2, char **wp) |
@@ -2149,7 +2149,7 @@ static struct op *block(int type, struct op *t1, struct op *t2, char **wp) | |||
2149 | DBGPRINTF7(("BLOCK: inserted %p between %p and %p\n", t, t1, | 2149 | DBGPRINTF7(("BLOCK: inserted %p between %p and %p\n", t, t1, |
2150 | t2)); | 2150 | t2)); |
2151 | 2151 | ||
2152 | return (t); | 2152 | return t; |
2153 | } | 2153 | } |
2154 | 2154 | ||
2155 | /* See if given string is a shell multiline (FOR, IF, etc) */ | 2155 | /* See if given string is a shell multiline (FOR, IF, etc) */ |
@@ -2162,7 +2162,7 @@ static int rlookup(char *n) | |||
2162 | for (rp = restab; rp->r_name; rp++) | 2162 | for (rp = restab; rp->r_name; rp++) |
2163 | if (strcmp(rp->r_name, n) == 0) { | 2163 | if (strcmp(rp->r_name, n) == 0) { |
2164 | DBGPRINTF7(("RLOOKUP: match, returning %d\n", rp->r_val)); | 2164 | DBGPRINTF7(("RLOOKUP: match, returning %d\n", rp->r_val)); |
2165 | return (rp->r_val); /* Return numeric code for shell multiline */ | 2165 | return rp->r_val; /* Return numeric code for shell multiline */ |
2166 | } | 2166 | } |
2167 | 2167 | ||
2168 | DBGPRINTF7(("RLOOKUP: NO match, returning 0\n")); | 2168 | DBGPRINTF7(("RLOOKUP: NO match, returning 0\n")); |
@@ -2183,7 +2183,7 @@ static struct op *newtp(void) | |||
2183 | 2183 | ||
2184 | DBGPRINTF3(("NEWTP: allocated %p\n", t)); | 2184 | DBGPRINTF3(("NEWTP: allocated %p\n", t)); |
2185 | 2185 | ||
2186 | return (t); | 2186 | return t; |
2187 | } | 2187 | } |
2188 | 2188 | ||
2189 | static struct op *namelist(struct op *t) | 2189 | static struct op *namelist(struct op *t) |
@@ -2204,14 +2204,14 @@ static struct op *namelist(struct op *t) | |||
2204 | t->ioact = t->left->ioact; | 2204 | t->ioact = t->left->ioact; |
2205 | t->left->ioact = NULL; | 2205 | t->left->ioact = NULL; |
2206 | } | 2206 | } |
2207 | return (t); | 2207 | return t; |
2208 | } | 2208 | } |
2209 | 2209 | ||
2210 | word(NOWORD); | 2210 | word(NOWORD); |
2211 | t->words = copyw(); | 2211 | t->words = copyw(); |
2212 | 2212 | ||
2213 | 2213 | ||
2214 | return (t); | 2214 | return t; |
2215 | } | 2215 | } |
2216 | 2216 | ||
2217 | static char **copyw(void) | 2217 | static char **copyw(void) |
@@ -2220,7 +2220,7 @@ static char **copyw(void) | |||
2220 | 2220 | ||
2221 | wd = getwords(wdlist); | 2221 | wd = getwords(wdlist); |
2222 | wdlist = 0; | 2222 | wdlist = 0; |
2223 | return (wd); | 2223 | return wd; |
2224 | } | 2224 | } |
2225 | 2225 | ||
2226 | static void word(char *cp) | 2226 | static void word(char *cp) |
@@ -2234,7 +2234,7 @@ static struct ioword **copyio(void) | |||
2234 | 2234 | ||
2235 | iop = (struct ioword **) getwords(iolist); | 2235 | iop = (struct ioword **) getwords(iolist); |
2236 | iolist = 0; | 2236 | iolist = 0; |
2237 | return (iop); | 2237 | return iop; |
2238 | } | 2238 | } |
2239 | 2239 | ||
2240 | static struct ioword *io(int u, int f, char *cp) | 2240 | static struct ioword *io(int u, int f, char *cp) |
@@ -2246,7 +2246,7 @@ static struct ioword *io(int u, int f, char *cp) | |||
2246 | iop->io_flag = f; | 2246 | iop->io_flag = f; |
2247 | iop->io_name = cp; | 2247 | iop->io_name = cp; |
2248 | iolist = addword((char *) iop, iolist); | 2248 | iolist = addword((char *) iop, iolist); |
2249 | return (iop); | 2249 | return iop; |
2250 | } | 2250 | } |
2251 | 2251 | ||
2252 | static void zzerr(void) | 2252 | static void zzerr(void) |
@@ -2274,7 +2274,7 @@ static int yylex(int cf) | |||
2274 | peeksym = 0; | 2274 | peeksym = 0; |
2275 | if (c == '\n') | 2275 | if (c == '\n') |
2276 | startl = 1; | 2276 | startl = 1; |
2277 | return (c); | 2277 | return c; |
2278 | } | 2278 | } |
2279 | 2279 | ||
2280 | 2280 | ||
@@ -2311,14 +2311,14 @@ static int yylex(int cf) | |||
2311 | 2311 | ||
2312 | case 0: | 2312 | case 0: |
2313 | DBGPRINTF5(("YYLEX: return 0, c=%d\n", c)); | 2313 | DBGPRINTF5(("YYLEX: return 0, c=%d\n", c)); |
2314 | return (c); | 2314 | return c; |
2315 | 2315 | ||
2316 | case '$': | 2316 | case '$': |
2317 | DBGPRINTF9(("YYLEX: found $\n")); | 2317 | DBGPRINTF9(("YYLEX: found $\n")); |
2318 | *e.linep++ = c; | 2318 | *e.linep++ = c; |
2319 | if ((c = my_getc(0)) == '{') { | 2319 | if ((c = my_getc(0)) == '{') { |
2320 | if ((c = collect(c, '}')) != '\0') | 2320 | if ((c = collect(c, '}')) != '\0') |
2321 | return (c); | 2321 | return c; |
2322 | goto pack; | 2322 | goto pack; |
2323 | } | 2323 | } |
2324 | break; | 2324 | break; |
@@ -2327,7 +2327,7 @@ static int yylex(int cf) | |||
2327 | case '\'': | 2327 | case '\'': |
2328 | case '"': | 2328 | case '"': |
2329 | if ((c = collect(c, c)) != '\0') | 2329 | if ((c = collect(c, c)) != '\0') |
2330 | return (c); | 2330 | return c; |
2331 | goto pack; | 2331 | goto pack; |
2332 | 2332 | ||
2333 | case '|': | 2333 | case '|': |
@@ -2336,17 +2336,17 @@ static int yylex(int cf) | |||
2336 | startl = 1; | 2336 | startl = 1; |
2337 | /* If more chars process them, else return NULL char */ | 2337 | /* If more chars process them, else return NULL char */ |
2338 | if ((c1 = dual(c)) != '\0') | 2338 | if ((c1 = dual(c)) != '\0') |
2339 | return (c1); | 2339 | return c1; |
2340 | else | 2340 | else |
2341 | return (c); | 2341 | return c; |
2342 | 2342 | ||
2343 | case '^': | 2343 | case '^': |
2344 | startl = 1; | 2344 | startl = 1; |
2345 | return ('|'); | 2345 | return '|'; |
2346 | case '>': | 2346 | case '>': |
2347 | case '<': | 2347 | case '<': |
2348 | diag(c); | 2348 | diag(c); |
2349 | return (c); | 2349 | return c; |
2350 | 2350 | ||
2351 | case '\n': | 2351 | case '\n': |
2352 | nlseen++; | 2352 | nlseen++; |
@@ -2363,12 +2363,12 @@ static int yylex(int cf) | |||
2363 | if (cf & CONTIN) | 2363 | if (cf & CONTIN) |
2364 | goto loop; | 2364 | goto loop; |
2365 | } | 2365 | } |
2366 | return (c); | 2366 | return c; |
2367 | 2367 | ||
2368 | case '(': | 2368 | case '(': |
2369 | case ')': | 2369 | case ')': |
2370 | startl = 1; | 2370 | startl = 1; |
2371 | return (c); | 2371 | return c; |
2372 | } | 2372 | } |
2373 | 2373 | ||
2374 | unget(c); | 2374 | unget(c); |
@@ -2390,11 +2390,11 @@ static int yylex(int cf) | |||
2390 | 2390 | ||
2391 | if (atstart && (c = rlookup(line)) != 0) { | 2391 | if (atstart && (c = rlookup(line)) != 0) { |
2392 | startl = 1; | 2392 | startl = 1; |
2393 | return (c); | 2393 | return c; |
2394 | } | 2394 | } |
2395 | 2395 | ||
2396 | yylval.cp = strsave(line, areanum); | 2396 | yylval.cp = strsave(line, areanum); |
2397 | return (WORD); | 2397 | return WORD; |
2398 | } | 2398 | } |
2399 | 2399 | ||
2400 | 2400 | ||
@@ -2412,7 +2412,7 @@ static int collect(int c, int c1) | |||
2412 | s[1] = 0; | 2412 | s[1] = 0; |
2413 | prs("no closing "); | 2413 | prs("no closing "); |
2414 | yyerror(s); | 2414 | yyerror(s); |
2415 | return (YYERRCODE); | 2415 | return YYERRCODE; |
2416 | } | 2416 | } |
2417 | if (interactive && c == '\n' && e.iop <= iostack) { | 2417 | if (interactive && c == '\n' && e.iop <= iostack) { |
2418 | #ifdef CONFIG_FEATURE_COMMAND_EDITING | 2418 | #ifdef CONFIG_FEATURE_COMMAND_EDITING |
@@ -2448,7 +2448,7 @@ static int dual(int c) | |||
2448 | if (c == 0) | 2448 | if (c == 0) |
2449 | unget(*--cp); /* String is not a shell multiline, put peek char back */ | 2449 | unget(*--cp); /* String is not a shell multiline, put peek char back */ |
2450 | 2450 | ||
2451 | return (c); /* String is multiline, return numeric multiline (restab) code */ | 2451 | return c; /* String is multiline, return numeric multiline (restab) code */ |
2452 | } | 2452 | } |
2453 | 2453 | ||
2454 | static void diag(int ec) | 2454 | static void diag(int ec) |
@@ -2481,7 +2481,7 @@ static char *tree(unsigned size) | |||
2481 | fail(); | 2481 | fail(); |
2482 | /* NOTREACHED */ | 2482 | /* NOTREACHED */ |
2483 | } | 2483 | } |
2484 | return (t); | 2484 | return t; |
2485 | } | 2485 | } |
2486 | 2486 | ||
2487 | /* VARARGS1 */ | 2487 | /* VARARGS1 */ |
@@ -2701,7 +2701,7 @@ static int execute(struct op *t, int *pin, int *pout, int act) | |||
2701 | } | 2701 | } |
2702 | 2702 | ||
2703 | DBGPRINTF(("EXECUTE: returning from t=%p, rv=%d\n", t, rv)); | 2703 | DBGPRINTF(("EXECUTE: returning from t=%p, rv=%d\n", t, rv)); |
2704 | return (rv); | 2704 | return rv; |
2705 | } | 2705 | } |
2706 | 2706 | ||
2707 | static int | 2707 | static int |
@@ -2759,7 +2759,7 @@ forkexec(struct op *t, int *pin, int *pout, int act, char **wp) | |||
2759 | if (cp == NULL && t->ioact == NULL) { | 2759 | if (cp == NULL && t->ioact == NULL) { |
2760 | while ((cp = *owp++) != NULL && assign(cp, COPYV)); | 2760 | while ((cp = *owp++) != NULL && assign(cp, COPYV)); |
2761 | DBGPRINTF(("FORKEXEC: returning setstatus()\n")); | 2761 | DBGPRINTF(("FORKEXEC: returning setstatus()\n")); |
2762 | return (setstatus(0)); | 2762 | return setstatus(0); |
2763 | } else if (cp != NULL) { | 2763 | } else if (cp != NULL) { |
2764 | shcom = inbuilt(cp); | 2764 | shcom = inbuilt(cp); |
2765 | } | 2765 | } |
@@ -2864,7 +2864,7 @@ forkexec(struct op *t, int *pin, int *pout, int act, char **wp) | |||
2864 | if (iosetup(*iopp++, pin != NULL, pout != NULL)) { | 2864 | if (iosetup(*iopp++, pin != NULL, pout != NULL)) { |
2865 | if (forked) | 2865 | if (forked) |
2866 | _exit(rv); | 2866 | _exit(rv); |
2867 | return (rv); | 2867 | return rv; |
2868 | } | 2868 | } |
2869 | } | 2869 | } |
2870 | 2870 | ||
@@ -2873,7 +2873,7 @@ forkexec(struct op *t, int *pin, int *pout, int act, char **wp) | |||
2873 | if (forked) | 2873 | if (forked) |
2874 | _exit(i); | 2874 | _exit(i); |
2875 | DBGPRINTF(("FORKEXEC: returning i=%d\n", i)); | 2875 | DBGPRINTF(("FORKEXEC: returning i=%d\n", i)); |
2876 | return (i); | 2876 | return i; |
2877 | } | 2877 | } |
2878 | 2878 | ||
2879 | /* should use FIOCEXCL */ | 2879 | /* should use FIOCEXCL */ |
@@ -3005,7 +3005,7 @@ static struct op **find1case(struct op *t, char *w) | |||
3005 | 3005 | ||
3006 | if (t == NULL) { | 3006 | if (t == NULL) { |
3007 | DBGPRINTF3(("FIND1CASE: enter, t==NULL, returning.\n")); | 3007 | DBGPRINTF3(("FIND1CASE: enter, t==NULL, returning.\n")); |
3008 | return ((struct op **) NULL); | 3008 | return NULL; |
3009 | } | 3009 | } |
3010 | 3010 | ||
3011 | DBGPRINTF3(("FIND1CASE: enter, t->type=%d (%s)\n", t->type, | 3011 | DBGPRINTF3(("FIND1CASE: enter, t->type=%d (%s)\n", t->type, |
@@ -3014,7 +3014,7 @@ static struct op **find1case(struct op *t, char *w) | |||
3014 | if (t->type == TLIST) { | 3014 | if (t->type == TLIST) { |
3015 | if ((tp = find1case(t->left, w)) != NULL) { | 3015 | if ((tp = find1case(t->left, w)) != NULL) { |
3016 | DBGPRINTF3(("FIND1CASE: found one to the left, returning tp=%p\n", tp)); | 3016 | DBGPRINTF3(("FIND1CASE: found one to the left, returning tp=%p\n", tp)); |
3017 | return (tp); | 3017 | return tp; |
3018 | } | 3018 | } |
3019 | t1 = t->right; /* TPAT */ | 3019 | t1 = t->right; /* TPAT */ |
3020 | } else | 3020 | } else |
@@ -3024,18 +3024,19 @@ static struct op **find1case(struct op *t, char *w) | |||
3024 | if ((cp = evalstr(*wp++, DOSUB)) && gmatch(w, cp)) { | 3024 | if ((cp = evalstr(*wp++, DOSUB)) && gmatch(w, cp)) { |
3025 | DBGPRINTF3(("FIND1CASE: returning &t1->left= %p.\n", | 3025 | DBGPRINTF3(("FIND1CASE: returning &t1->left= %p.\n", |
3026 | &t1->left)); | 3026 | &t1->left)); |
3027 | return (&t1->left); | 3027 | return &t1->left; |
3028 | } | 3028 | } |
3029 | 3029 | ||
3030 | DBGPRINTF(("FIND1CASE: returning NULL\n")); | 3030 | DBGPRINTF(("FIND1CASE: returning NULL\n")); |
3031 | return ((struct op **) NULL); | 3031 | return NULL; |
3032 | } | 3032 | } |
3033 | 3033 | ||
3034 | static struct op *findcase(struct op *t, char *w) | 3034 | static struct op *findcase(struct op *t, char *w) |
3035 | { | 3035 | { |
3036 | struct op **tp; | 3036 | struct op **tp; |
3037 | 3037 | ||
3038 | return ((tp = find1case(t, w)) != NULL ? *tp : (struct op *) NULL); | 3038 | tp = find1case(t, w); |
3039 | return tp != NULL ? *tp : NULL; | ||
3039 | } | 3040 | } |
3040 | 3041 | ||
3041 | /* | 3042 | /* |
@@ -3106,14 +3107,14 @@ static int waitfor(int lastpid, int canintr) | |||
3106 | onintr(0); | 3107 | onintr(0); |
3107 | } | 3108 | } |
3108 | } | 3109 | } |
3109 | return (rv); | 3110 | return rv; |
3110 | } | 3111 | } |
3111 | 3112 | ||
3112 | static int setstatus(int s) | 3113 | static int setstatus(int s) |
3113 | { | 3114 | { |
3114 | exstat = s; | 3115 | exstat = s; |
3115 | setval(lookup("?"), putn(s)); | 3116 | setval(lookup("?"), putn(s)); |
3116 | return (s); | 3117 | return s; |
3117 | } | 3118 | } |
3118 | 3119 | ||
3119 | /* | 3120 | /* |
@@ -3165,20 +3166,20 @@ static char *rexecve(char *c, char **v, char **envp) | |||
3165 | *v = e.linep; | 3166 | *v = e.linep; |
3166 | execve(DEFAULT_SHELL, v, envp); | 3167 | execve(DEFAULT_SHELL, v, envp); |
3167 | *v = tp; | 3168 | *v = tp; |
3168 | return ("no Shell"); | 3169 | return "no Shell"; |
3169 | 3170 | ||
3170 | case ENOMEM: | 3171 | case ENOMEM: |
3171 | return ((char *) bb_msg_memory_exhausted); | 3172 | return (char *) bb_msg_memory_exhausted; |
3172 | 3173 | ||
3173 | case E2BIG: | 3174 | case E2BIG: |
3174 | return ("argument list too long"); | 3175 | return "argument list too long"; |
3175 | 3176 | ||
3176 | case EACCES: | 3177 | case EACCES: |
3177 | eacces++; | 3178 | eacces++; |
3178 | break; | 3179 | break; |
3179 | } | 3180 | } |
3180 | } | 3181 | } |
3181 | return (errno == ENOENT ? "not found" : "cannot execute"); | 3182 | return errno == ENOENT ? "not found" : "cannot execute"; |
3182 | } | 3183 | } |
3183 | 3184 | ||
3184 | /* | 3185 | /* |
@@ -3228,7 +3229,7 @@ static int run(struct ioarg *argp, int (*f) (struct ioarg *)) | |||
3228 | outtree = otree; | 3229 | outtree = otree; |
3229 | freearea(areanum--); | 3230 | freearea(areanum--); |
3230 | 3231 | ||
3231 | return (rv); | 3232 | return rv; |
3232 | } | 3233 | } |
3233 | 3234 | ||
3234 | /* -------- do.c -------- */ | 3235 | /* -------- do.c -------- */ |
@@ -3412,7 +3413,7 @@ static int dodot(struct op *t) | |||
3412 | 3413 | ||
3413 | DBGPRINTF(("DODOT: returning exstat=%d\n", exstat)); | 3414 | DBGPRINTF(("DODOT: returning exstat=%d\n", exstat)); |
3414 | 3415 | ||
3415 | return (exstat); | 3416 | return exstat; |
3416 | } | 3417 | } |
3417 | 3418 | ||
3418 | } /* While */ | 3419 | } /* While */ |
@@ -3458,12 +3459,12 @@ static int doread(struct op *t) | |||
3458 | break; | 3459 | break; |
3459 | setval(lookup(*wp), e.linep); | 3460 | setval(lookup(*wp), e.linep); |
3460 | } | 3461 | } |
3461 | return (nb <= 0); | 3462 | return nb <= 0; |
3462 | } | 3463 | } |
3463 | 3464 | ||
3464 | static int doeval(struct op *t) | 3465 | static int doeval(struct op *t) |
3465 | { | 3466 | { |
3466 | return (RUN(awordlist, t->words + 1, wdchar)); | 3467 | return RUN(awordlist, t->words + 1, wdchar); |
3467 | } | 3468 | } |
3468 | 3469 | ||
3469 | static int dotrap(struct op *t) | 3470 | static int dotrap(struct op *t) |
@@ -3513,7 +3514,7 @@ static int getsig(char *s) | |||
3513 | err("trap: bad signal number"); | 3514 | err("trap: bad signal number"); |
3514 | n = 0; | 3515 | n = 0; |
3515 | } | 3516 | } |
3516 | return (n); | 3517 | return n; |
3517 | } | 3518 | } |
3518 | 3519 | ||
3519 | static void setsig(int n, sighandler_t f) | 3520 | static void setsig(int n, sighandler_t f) |
@@ -3543,17 +3544,17 @@ static int getn(char *as) | |||
3543 | prs(as); | 3544 | prs(as); |
3544 | err(": bad number"); | 3545 | err(": bad number"); |
3545 | } | 3546 | } |
3546 | return (n * m); | 3547 | return n * m; |
3547 | } | 3548 | } |
3548 | 3549 | ||
3549 | static int dobreak(struct op *t) | 3550 | static int dobreak(struct op *t) |
3550 | { | 3551 | { |
3551 | return (brkcontin(t->words[1], 1)); | 3552 | return brkcontin(t->words[1], 1); |
3552 | } | 3553 | } |
3553 | 3554 | ||
3554 | static int docontinue(struct op *t) | 3555 | static int docontinue(struct op *t) |
3555 | { | 3556 | { |
3556 | return (brkcontin(t->words[1], 0)); | 3557 | return brkcontin(t->words[1], 0); |
3557 | } | 3558 | } |
3558 | 3559 | ||
3559 | static int brkcontin(char *cp, int val) | 3560 | static int brkcontin(char *cp, int val) |
@@ -3714,9 +3715,9 @@ static int (*inbuilt(char *s)) (struct op *) { | |||
3714 | 3715 | ||
3715 | for (bp = builtincmds; bp->name != NULL; bp++) | 3716 | for (bp = builtincmds; bp->name != NULL; bp++) |
3716 | if (strcmp(bp->name, s) == 0) | 3717 | if (strcmp(bp->name, s) == 0) |
3717 | return (bp->builtinfunc); | 3718 | return bp->builtinfunc; |
3718 | 3719 | ||
3719 | return (NULL); | 3720 | return NULL; |
3720 | } | 3721 | } |
3721 | 3722 | ||
3722 | /* -------- eval.c -------- */ | 3723 | /* -------- eval.c -------- */ |
@@ -3766,7 +3767,7 @@ static char **eval(char **ap, int f) | |||
3766 | } else | 3767 | } else |
3767 | gflg = 1; | 3768 | gflg = 1; |
3768 | 3769 | ||
3769 | return (gflg ? (char **) NULL : wp); | 3770 | return gflg ? (char **) NULL : wp; |
3770 | } | 3771 | } |
3771 | 3772 | ||
3772 | /* | 3773 | /* |
@@ -3784,7 +3785,7 @@ static char **makenv(int all, struct wdblock *wb) | |||
3784 | if (all || vp->status & EXPORT) | 3785 | if (all || vp->status & EXPORT) |
3785 | wb = addword(vp->name, wb); | 3786 | wb = addword(vp->name, wb); |
3786 | wb = addword((char *) 0, wb); | 3787 | wb = addword((char *) 0, wb); |
3787 | return (getwords(wb)); | 3788 | return getwords(wb); |
3788 | } | 3789 | } |
3789 | 3790 | ||
3790 | static char *evalstr(char *cp, int f) | 3791 | static char *evalstr(char *cp, int f) |
@@ -3801,7 +3802,7 @@ static char *evalstr(char *cp, int f) | |||
3801 | DELETE(wb); | 3802 | DELETE(wb); |
3802 | } else | 3803 | } else |
3803 | cp = NULL; | 3804 | cp = NULL; |
3804 | return (cp); | 3805 | return cp; |
3805 | } | 3806 | } |
3806 | 3807 | ||
3807 | static int expand(char *cp, struct wdblock **wbp, int f) | 3808 | static int expand(char *cp, struct wdblock **wbp, int f) |
@@ -3844,7 +3845,7 @@ static int expand(char *cp, struct wdblock **wbp, int f) | |||
3844 | quitenv(); | 3845 | quitenv(); |
3845 | } else | 3846 | } else |
3846 | gflg = 1; | 3847 | gflg = 1; |
3847 | return (gflg == 0); | 3848 | return gflg == 0; |
3848 | } | 3849 | } |
3849 | 3850 | ||
3850 | /* | 3851 | /* |
@@ -3868,7 +3869,7 @@ static char *blank(int f) | |||
3868 | if (sp == e.linep) | 3869 | if (sp == e.linep) |
3869 | return 0; | 3870 | return 0; |
3870 | *e.linep++ = 0; | 3871 | *e.linep++ = 0; |
3871 | return (sp); | 3872 | return sp; |
3872 | 3873 | ||
3873 | default: | 3874 | default: |
3874 | if (f & DOBLANK && any(c, ifs->value)) | 3875 | if (f & DOBLANK && any(c, ifs->value)) |
@@ -3913,7 +3914,7 @@ static char *blank(int f) | |||
3913 | *e.linep++ = c; | 3914 | *e.linep++ = c; |
3914 | } | 3915 | } |
3915 | *e.linep++ = 0; | 3916 | *e.linep++ = 0; |
3916 | return (sp); | 3917 | return sp; |
3917 | } | 3918 | } |
3918 | 3919 | ||
3919 | /* | 3920 | /* |
@@ -3939,7 +3940,7 @@ static int subgetc(char ec, int quoted) | |||
3939 | goto again; | 3940 | goto again; |
3940 | } | 3941 | } |
3941 | } | 3942 | } |
3942 | return (c); | 3943 | return c; |
3943 | } | 3944 | } |
3944 | 3945 | ||
3945 | /* | 3946 | /* |
@@ -3979,7 +3980,7 @@ static int dollar(int quoted) | |||
3979 | if (c != '}') { | 3980 | if (c != '}') { |
3980 | err("unclosed ${"); | 3981 | err("unclosed ${"); |
3981 | gflg++; | 3982 | gflg++; |
3982 | return (c); | 3983 | return c; |
3983 | } | 3984 | } |
3984 | } | 3985 | } |
3985 | if (e.linep >= elinep) { | 3986 | if (e.linep >= elinep) { |
@@ -4235,7 +4236,7 @@ static char *unquote(char *as) | |||
4235 | if ((s = as) != NULL) | 4236 | if ((s = as) != NULL) |
4236 | while (*s) | 4237 | while (*s) |
4237 | *s++ &= ~QUOTE; | 4238 | *s++ &= ~QUOTE; |
4238 | return (as); | 4239 | return as; |
4239 | } | 4240 | } |
4240 | 4241 | ||
4241 | /* -------- glob.c -------- */ | 4242 | /* -------- glob.c -------- */ |
@@ -4257,7 +4258,7 @@ static struct wdblock *glob(char *cp, struct wdblock *wb) | |||
4257 | char *pp; | 4258 | char *pp; |
4258 | 4259 | ||
4259 | if (cp == 0) | 4260 | if (cp == 0) |
4260 | return (wb); | 4261 | return wb; |
4261 | i = 0; | 4262 | i = 0; |
4262 | for (pp = cp; *pp; pp++) | 4263 | for (pp = cp; *pp; pp++) |
4263 | if (any(*pp, spcl)) | 4264 | if (any(*pp, spcl)) |
@@ -4288,11 +4289,11 @@ static struct wdblock *glob(char *cp, struct wdblock *wb) | |||
4288 | for (i = 0; i < cl->w_nword; i++) | 4289 | for (i = 0; i < cl->w_nword; i++) |
4289 | wb = addword(cl->w_words[i], wb); | 4290 | wb = addword(cl->w_words[i], wb); |
4290 | DELETE(cl); | 4291 | DELETE(cl); |
4291 | return (wb); | 4292 | return wb; |
4292 | } | 4293 | } |
4293 | } | 4294 | } |
4294 | wb = addword(unquote(cp), wb); | 4295 | wb = addword(unquote(cp), wb); |
4295 | return (wb); | 4296 | return wb; |
4296 | } | 4297 | } |
4297 | 4298 | ||
4298 | static void globname(char *we, char *pp) | 4299 | static void globname(char *we, char *pp) |
@@ -4368,7 +4369,7 @@ static char *generate(char *start1, char *end1, char *middle, char *end) | |||
4368 | for (xp = middle; (*op++ = *xp++) != '\0';); | 4369 | for (xp = middle; (*op++ = *xp++) != '\0';); |
4369 | op--; | 4370 | op--; |
4370 | for (xp = end; (*op++ = *xp++) != '\0';); | 4371 | for (xp = end; (*op++ = *xp++) != '\0';); |
4371 | return (p); | 4372 | return p; |
4372 | } | 4373 | } |
4373 | 4374 | ||
4374 | static int anyspcl(struct wdblock *wb) | 4375 | static int anyspcl(struct wdblock *wb) |
@@ -4385,7 +4386,7 @@ static int anyspcl(struct wdblock *wb) | |||
4385 | 4386 | ||
4386 | static int xstrcmp(char *p1, char *p2) | 4387 | static int xstrcmp(char *p1, char *p2) |
4387 | { | 4388 | { |
4388 | return (strcmp(*(char **) p1, *(char **) p2)); | 4389 | return strcmp(*(char **) p1, *(char **) p2); |
4389 | } | 4390 | } |
4390 | 4391 | ||
4391 | /* -------- word.c -------- */ | 4392 | /* -------- word.c -------- */ |
@@ -4397,7 +4398,7 @@ static struct wdblock *newword(int nw) | |||
4397 | wb = (struct wdblock *) space(sizeof(*wb) + nw * sizeof(char *)); | 4398 | wb = (struct wdblock *) space(sizeof(*wb) + nw * sizeof(char *)); |
4398 | wb->w_bsize = nw; | 4399 | wb->w_bsize = nw; |
4399 | wb->w_nword = 0; | 4400 | wb->w_nword = 0; |
4400 | return (wb); | 4401 | return wb; |
4401 | } | 4402 | } |
4402 | 4403 | ||
4403 | static struct wdblock *addword(char *wd, struct wdblock *wb) | 4404 | static struct wdblock *addword(char *wd, struct wdblock *wb) |
@@ -4416,7 +4417,7 @@ static struct wdblock *addword(char *wd, struct wdblock *wb) | |||
4416 | wb = wb2; | 4417 | wb = wb2; |
4417 | } | 4418 | } |
4418 | wb->w_words[wb->w_nword++] = wd; | 4419 | wb->w_words[wb->w_nword++] = wd; |
4419 | return (wb); | 4420 | return wb; |
4420 | } | 4421 | } |
4421 | 4422 | ||
4422 | static | 4423 | static |
@@ -4426,15 +4427,15 @@ char **getwords(struct wdblock *wb) | |||
4426 | int nb; | 4427 | int nb; |
4427 | 4428 | ||
4428 | if (wb == NULL) | 4429 | if (wb == NULL) |
4429 | return ((char **) NULL); | 4430 | return NULL; |
4430 | if (wb->w_nword == 0) { | 4431 | if (wb->w_nword == 0) { |
4431 | DELETE(wb); | 4432 | DELETE(wb); |
4432 | return ((char **) NULL); | 4433 | return NULL; |
4433 | } | 4434 | } |
4434 | wd = (char **) space(nb = sizeof(*wd) * wb->w_nword); | 4435 | wd = (char **) space(nb = sizeof(*wd) * wb->w_nword); |
4435 | memcpy((char *) wd, (char *) wb->w_words, nb); | 4436 | memcpy((char *) wd, (char *) wb->w_words, nb); |
4436 | DELETE(wb); /* perhaps should done by caller */ | 4437 | DELETE(wb); /* perhaps should done by caller */ |
4437 | return (wd); | 4438 | return wd; |
4438 | } | 4439 | } |
4439 | 4440 | ||
4440 | static int (*func) (char *, char *); | 4441 | static int (*func) (char *, char *); |
@@ -4563,18 +4564,18 @@ static int my_getc(int ec) | |||
4563 | while ((c = readc()) != '\n' && c); | 4564 | while ((c = readc()) != '\n' && c); |
4564 | err("input line too long"); | 4565 | err("input line too long"); |
4565 | gflg++; | 4566 | gflg++; |
4566 | return (c); | 4567 | return c; |
4567 | } | 4568 | } |
4568 | c = readc(); | 4569 | c = readc(); |
4569 | if ((ec != '\'') && (ec != '`') && (e.iop->task != XGRAVE)) { | 4570 | if ((ec != '\'') && (ec != '`') && (e.iop->task != XGRAVE)) { |
4570 | if (c == '\\') { | 4571 | if (c == '\\') { |
4571 | c = readc(); | 4572 | c = readc(); |
4572 | if (c == '\n' && ec != '\"') | 4573 | if (c == '\n' && ec != '\"') |
4573 | return (my_getc(ec)); | 4574 | return my_getc(ec); |
4574 | c |= QUOTE; | 4575 | c |= QUOTE; |
4575 | } | 4576 | } |
4576 | } | 4577 | } |
4577 | return (c); | 4578 | return c; |
4578 | } | 4579 | } |
4579 | 4580 | ||
4580 | static void unget(int c) | 4581 | static void unget(int c) |
@@ -4598,7 +4599,7 @@ static int readc(void) | |||
4598 | RCPRINTF(("READC: e.iop %p, peekc 0x%x\n", e.iop, e.iop->peekc)); | 4599 | RCPRINTF(("READC: e.iop %p, peekc 0x%x\n", e.iop, e.iop->peekc)); |
4599 | if ((c = e.iop->peekc) != '\0') { | 4600 | if ((c = e.iop->peekc) != '\0') { |
4600 | e.iop->peekc = 0; | 4601 | e.iop->peekc = 0; |
4601 | return (c); | 4602 | return c; |
4602 | } else { | 4603 | } else { |
4603 | if (e.iop->prev != 0) { | 4604 | if (e.iop->prev != 0) { |
4604 | if ((c = (*e.iop->iofn) (e.iop->argp, e.iop)) != '\0') { | 4605 | if ((c = (*e.iop->iofn) (e.iop->argp, e.iop)) != '\0') { |
@@ -4722,7 +4723,7 @@ static struct io *setbase(struct io *ip) | |||
4722 | 4723 | ||
4723 | xp = e.iobase; | 4724 | xp = e.iobase; |
4724 | e.iobase = ip; | 4725 | e.iobase = ip; |
4725 | return (xp); | 4726 | return xp; |
4726 | } | 4727 | } |
4727 | 4728 | ||
4728 | /* | 4729 | /* |
@@ -4740,9 +4741,9 @@ static int nlchar(struct ioarg *ap) | |||
4740 | return 0; | 4741 | return 0; |
4741 | if ((c = *ap->aword++) == 0) { | 4742 | if ((c = *ap->aword++) == 0) { |
4742 | ap->aword = NULL; | 4743 | ap->aword = NULL; |
4743 | return ('\n'); | 4744 | return '\n'; |
4744 | } | 4745 | } |
4745 | return (c); | 4746 | return c; |
4746 | } | 4747 | } |
4747 | 4748 | ||
4748 | /* | 4749 | /* |
@@ -4758,12 +4759,12 @@ static int wdchar(struct ioarg *ap) | |||
4758 | return 0; | 4759 | return 0; |
4759 | if (*wl != NULL) { | 4760 | if (*wl != NULL) { |
4760 | if ((c = *(*wl)++) != 0) | 4761 | if ((c = *(*wl)++) != 0) |
4761 | return (c & 0177); | 4762 | return c & 0177; |
4762 | ap->awordlist++; | 4763 | ap->awordlist++; |
4763 | return (' '); | 4764 | return ' '; |
4764 | } | 4765 | } |
4765 | ap->awordlist = NULL; | 4766 | ap->awordlist = NULL; |
4766 | return ('\n'); | 4767 | return '\n'; |
4767 | } | 4768 | } |
4768 | 4769 | ||
4769 | /* | 4770 | /* |
@@ -4789,9 +4790,9 @@ static int xxchar(struct ioarg *ap) | |||
4789 | return 0; | 4790 | return 0; |
4790 | if ((c = *ap->aword++) == '\0') { | 4791 | if ((c = *ap->aword++) == '\0') { |
4791 | ap->aword = NULL; | 4792 | ap->aword = NULL; |
4792 | return (' '); | 4793 | return ' '; |
4793 | } | 4794 | } |
4794 | return (c); | 4795 | return c; |
4795 | } | 4796 | } |
4796 | 4797 | ||
4797 | /* | 4798 | /* |
@@ -4803,7 +4804,7 @@ static int strchar(struct ioarg *ap) | |||
4803 | 4804 | ||
4804 | if (ap->aword == NULL || (c = *ap->aword++) == 0) | 4805 | if (ap->aword == NULL || (c = *ap->aword++) == 0) |
4805 | return 0; | 4806 | return 0; |
4806 | return (c); | 4807 | return c; |
4807 | } | 4808 | } |
4808 | 4809 | ||
4809 | /* | 4810 | /* |
@@ -4815,7 +4816,7 @@ static int qstrchar(struct ioarg *ap) | |||
4815 | 4816 | ||
4816 | if (ap->aword == NULL || (c = *ap->aword++) == 0) | 4817 | if (ap->aword == NULL || (c = *ap->aword++) == 0) |
4817 | return 0; | 4818 | return 0; |
4818 | return (c | QUOTE); | 4819 | return c | QUOTE; |
4819 | } | 4820 | } |
4820 | 4821 | ||
4821 | /* | 4822 | /* |
@@ -4859,13 +4860,13 @@ static int filechar(struct ioarg *ap) | |||
4859 | } | 4860 | } |
4860 | c = mycommand[position]; | 4861 | c = mycommand[position]; |
4861 | position++; | 4862 | position++; |
4862 | return (c); | 4863 | return c; |
4863 | } else | 4864 | } else |
4864 | #endif | 4865 | #endif |
4865 | 4866 | ||
4866 | { | 4867 | { |
4867 | i = safe_read(ap->afile, &c, sizeof(c)); | 4868 | i = safe_read(ap->afile, &c, sizeof(c)); |
4868 | return (i == sizeof(c) ? (c & 0x7f) : (closef(ap->afile), 0)); | 4869 | return i == sizeof(c) ? (c & 0x7f) : (closef(ap->afile), 0); |
4869 | } | 4870 | } |
4870 | } | 4871 | } |
4871 | 4872 | ||
@@ -4881,7 +4882,7 @@ static int herechar(struct ioarg *ap) | |||
4881 | close(ap->afile); | 4882 | close(ap->afile); |
4882 | c = 0; | 4883 | c = 0; |
4883 | } | 4884 | } |
4884 | return (c); | 4885 | return c; |
4885 | 4886 | ||
4886 | } | 4887 | } |
4887 | 4888 | ||
@@ -4895,7 +4896,7 @@ static int gravechar(struct ioarg *ap, struct io *iop) | |||
4895 | 4896 | ||
4896 | if ((c = qgravechar(ap, iop) & ~QUOTE) == '\n') | 4897 | if ((c = qgravechar(ap, iop) & ~QUOTE) == '\n') |
4897 | c = ' '; | 4898 | c = ' '; |
4898 | return (c); | 4899 | return c; |
4899 | } | 4900 | } |
4900 | 4901 | ||
4901 | static int qgravechar(struct ioarg *ap, struct io *iop) | 4902 | static int qgravechar(struct ioarg *ap, struct io *iop) |
@@ -4907,7 +4908,7 @@ static int qgravechar(struct ioarg *ap, struct io *iop) | |||
4907 | if (iop->xchar) { | 4908 | if (iop->xchar) { |
4908 | if (iop->nlcount) { | 4909 | if (iop->nlcount) { |
4909 | iop->nlcount--; | 4910 | iop->nlcount--; |
4910 | return ('\n' | QUOTE); | 4911 | return '\n' | QUOTE; |
4911 | } | 4912 | } |
4912 | c = iop->xchar; | 4913 | c = iop->xchar; |
4913 | iop->xchar = 0; | 4914 | iop->xchar = 0; |
@@ -4917,11 +4918,11 @@ static int qgravechar(struct ioarg *ap, struct io *iop) | |||
4917 | iop->nlcount++; | 4918 | iop->nlcount++; |
4918 | iop->xchar = c; | 4919 | iop->xchar = c; |
4919 | if (c == 0) | 4920 | if (c == 0) |
4920 | return (c); | 4921 | return c; |
4921 | iop->nlcount--; | 4922 | iop->nlcount--; |
4922 | c = '\n'; | 4923 | c = '\n'; |
4923 | } | 4924 | } |
4924 | return (c != 0 ? c | QUOTE : 0); | 4925 | return c != 0 ? c | QUOTE : 0; |
4925 | } | 4926 | } |
4926 | 4927 | ||
4927 | /* | 4928 | /* |
@@ -4937,7 +4938,7 @@ static int linechar(struct ioarg *ap) | |||
4937 | ap->afile = -1; /* illegal value */ | 4938 | ap->afile = -1; /* illegal value */ |
4938 | } | 4939 | } |
4939 | } | 4940 | } |
4940 | return (c); | 4941 | return c; |
4941 | } | 4942 | } |
4942 | 4943 | ||
4943 | static void prs(const char *s) | 4944 | static void prs(const char *s) |
@@ -4996,7 +4997,7 @@ static int remap(int fd) | |||
4996 | err("too many files open in shell"); | 4997 | err("too many files open in shell"); |
4997 | } | 4998 | } |
4998 | 4999 | ||
4999 | return (fd); | 5000 | return fd; |
5000 | } | 5001 | } |
5001 | 5002 | ||
5002 | static int openpipe(int *pv) | 5003 | static int openpipe(int *pv) |
@@ -5005,7 +5006,7 @@ static int openpipe(int *pv) | |||
5005 | 5006 | ||
5006 | if ((i = pipe(pv)) < 0) | 5007 | if ((i = pipe(pv)) < 0) |
5007 | err("can't create pipe - try again"); | 5008 | err("can't create pipe - try again"); |
5008 | return (i); | 5009 | return i; |
5009 | } | 5010 | } |
5010 | 5011 | ||
5011 | static void closepipe(int *pv) | 5012 | static void closepipe(int *pv) |
@@ -5172,9 +5173,9 @@ static int herein(char *hname, int xdoll) | |||
5172 | close(tf); | 5173 | close(tf); |
5173 | tf = open(tname, 0); | 5174 | tf = open(tname, 0); |
5174 | unlink(tname); | 5175 | unlink(tname); |
5175 | return (tf); | 5176 | return tf; |
5176 | } else | 5177 | } else |
5177 | return (hf); | 5178 | return hf; |
5178 | } | 5179 | } |
5179 | 5180 | ||
5180 | static void scraphere(void) | 5181 | static void scraphere(void) |