diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-03-02 14:33:26 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-03-02 14:33:26 +0000 |
commit | 4aafd5f4e30ee7f3b224652bfeaf26aa25382229 (patch) | |
tree | dfd5b5d966c411c179b3268cc8423dbe79a4425a | |
parent | d18f52bd182ac163a4ca87e7f8ffcb047fd063a3 (diff) | |
download | busybox-w32-4aafd5f4e30ee7f3b224652bfeaf26aa25382229.tar.gz busybox-w32-4aafd5f4e30ee7f3b224652bfeaf26aa25382229.tar.bz2 busybox-w32-4aafd5f4e30ee7f3b224652bfeaf26aa25382229.zip |
msh: a few fields renamed; short->int conversion for a field
holding file descriptors; short->smalling for flag field
synio 263 264 +1
readc 247 242 -5
forkexec 1339 1307 -32
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 1/-37) Total: -36 bytes
-rw-r--r-- | shell/msh.c | 119 |
1 files changed, 59 insertions, 60 deletions
diff --git a/shell/msh.c b/shell/msh.c index 52a11bc48..5ed6dfd1d 100644 --- a/shell/msh.c +++ b/shell/msh.c | |||
@@ -173,8 +173,8 @@ typedef void xint; /* base type of jmp_buf, for not broken | |||
173 | * redirection | 173 | * redirection |
174 | */ | 174 | */ |
175 | struct ioword { | 175 | struct ioword { |
176 | short io_unit; /* unit affected */ | 176 | smallint io_flag; /* action (below) */ |
177 | short io_flag; /* action (below) */ | 177 | int io_fd; /* fd affected */ |
178 | char *io_name; /* file name */ | 178 | char *io_name; /* file name */ |
179 | }; | 179 | }; |
180 | 180 | ||
@@ -186,7 +186,7 @@ struct ioword { | |||
186 | #define IODUP 32 /* >&digit */ | 186 | #define IODUP 32 /* >&digit */ |
187 | #define IOCLOSE 64 /* >&- */ | 187 | #define IOCLOSE 64 /* >&- */ |
188 | 188 | ||
189 | #define IODEFAULT (-1) /* token for default IO unit */ | 189 | #define IODEFAULT (-1) /* "default" IO fd */ |
190 | 190 | ||
191 | 191 | ||
192 | /* | 192 | /* |
@@ -194,7 +194,7 @@ struct ioword { | |||
194 | * Might eventually use a union. | 194 | * Might eventually use a union. |
195 | */ | 195 | */ |
196 | struct op { | 196 | struct op { |
197 | smallint type; /* operation type, see Txxxx below */ | 197 | smallint op_type; /* operation type, see Txxxx below */ |
198 | char **op_words; /* arguments to a command */ | 198 | char **op_words; /* arguments to a command */ |
199 | struct ioword **ioact; /* IO actions (eg, < > >>) */ | 199 | struct ioword **ioact; /* IO actions (eg, < > >>) */ |
200 | struct op *left; | 200 | struct op *left; |
@@ -1302,7 +1302,7 @@ struct op *scantree(struct op *head) | |||
1302 | 1302 | ||
1303 | DBGPRINTF5(("SCANTREE: checking node %p\n", head)); | 1303 | DBGPRINTF5(("SCANTREE: checking node %p\n", head)); |
1304 | 1304 | ||
1305 | if ((head->type != TDOT) && LONE_CHAR(head->op_words[0], '.')) { | 1305 | if ((head->op_type != TDOT) && LONE_CHAR(head->op_words[0], '.')) { |
1306 | DBGPRINTF5(("SCANTREE: dot found in node %p\n", head)); | 1306 | DBGPRINTF5(("SCANTREE: dot found in node %p\n", head)); |
1307 | return head; | 1307 | return head; |
1308 | } | 1308 | } |
@@ -1325,9 +1325,9 @@ static void onecommand(void) | |||
1325 | freehere(areanum); | 1325 | freehere(areanum); |
1326 | freearea(areanum); | 1326 | freearea(areanum); |
1327 | garbage(); | 1327 | garbage(); |
1328 | wdlist = 0; | 1328 | wdlist = NULL; |
1329 | iolist = 0; | 1329 | iolist = NULL; |
1330 | global_env.errpt = 0; | 1330 | global_env.errpt = NULL; |
1331 | global_env.linep = line; | 1331 | global_env.linep = line; |
1332 | yynerrs = 0; | 1332 | yynerrs = 0; |
1333 | multiline = 0; | 1333 | multiline = 0; |
@@ -1593,7 +1593,7 @@ static struct op *pipeline(int cf) | |||
1593 | zzerr(); | 1593 | zzerr(); |
1594 | } | 1594 | } |
1595 | 1595 | ||
1596 | if (t->type != TPAREN && t->type != TCOM) { | 1596 | if (t->op_type != TPAREN && t->op_type != TCOM) { |
1597 | /* shell statement */ | 1597 | /* shell statement */ |
1598 | t = block(TPAREN, t, NOBLOCK, NOWORDS); | 1598 | t = block(TPAREN, t, NOBLOCK, NOWORDS); |
1599 | } | 1599 | } |
@@ -1627,7 +1627,7 @@ static struct op *andor(void) | |||
1627 | } | 1627 | } |
1628 | 1628 | ||
1629 | t = block(c == LOGAND ? TAND : TOR, t, p, NOWORDS); | 1629 | t = block(c == LOGAND ? TAND : TOR, t, p, NOWORDS); |
1630 | } /* WHILE */ | 1630 | } |
1631 | 1631 | ||
1632 | peeksym = c; | 1632 | peeksym = c; |
1633 | } | 1633 | } |
@@ -1723,7 +1723,7 @@ static struct op *simple(void) | |||
1723 | case WORD: | 1723 | case WORD: |
1724 | if (t == NULL) { | 1724 | if (t == NULL) { |
1725 | t = newtp(); | 1725 | t = newtp(); |
1726 | t->type = TCOM; | 1726 | t->op_type = TCOM; |
1727 | } | 1727 | } |
1728 | peeksym = 0; | 1728 | peeksym = 0; |
1729 | word(yylval.cp); | 1729 | word(yylval.cp); |
@@ -1775,7 +1775,7 @@ static struct op *command(int cf) | |||
1775 | if (iolist == NULL) | 1775 | if (iolist == NULL) |
1776 | return NULL; | 1776 | return NULL; |
1777 | t = newtp(); | 1777 | t = newtp(); |
1778 | t->type = TCOM; | 1778 | t->op_type = TCOM; |
1779 | } | 1779 | } |
1780 | break; | 1780 | break; |
1781 | 1781 | ||
@@ -1789,7 +1789,7 @@ static struct op *command(int cf) | |||
1789 | 1789 | ||
1790 | case FOR: | 1790 | case FOR: |
1791 | t = newtp(); | 1791 | t = newtp(); |
1792 | t->type = TFOR; | 1792 | t->op_type = TFOR; |
1793 | musthave(WORD, 0); | 1793 | musthave(WORD, 0); |
1794 | startl = 1; | 1794 | startl = 1; |
1795 | t->str = yylval.cp; | 1795 | t->str = yylval.cp; |
@@ -1806,7 +1806,7 @@ static struct op *command(int cf) | |||
1806 | case UNTIL: | 1806 | case UNTIL: |
1807 | multiline++; | 1807 | multiline++; |
1808 | t = newtp(); | 1808 | t = newtp(); |
1809 | t->type = (c == WHILE ? TWHILE : TUNTIL); | 1809 | t->op_type = (c == WHILE ? TWHILE : TUNTIL); |
1810 | t->left = c_list(); | 1810 | t->left = c_list(); |
1811 | t->right = dogroup(1); | 1811 | t->right = dogroup(1); |
1812 | /* t->op_words = NULL; - newtp() did this */ | 1812 | /* t->op_words = NULL; - newtp() did this */ |
@@ -1815,7 +1815,7 @@ static struct op *command(int cf) | |||
1815 | 1815 | ||
1816 | case CASE: | 1816 | case CASE: |
1817 | t = newtp(); | 1817 | t = newtp(); |
1818 | t->type = TCASE; | 1818 | t->op_type = TCASE; |
1819 | musthave(WORD, 0); | 1819 | musthave(WORD, 0); |
1820 | t->str = yylval.cp; | 1820 | t->str = yylval.cp; |
1821 | startl++; | 1821 | startl++; |
@@ -1832,7 +1832,7 @@ static struct op *command(int cf) | |||
1832 | case IF: | 1832 | case IF: |
1833 | multiline++; | 1833 | multiline++; |
1834 | t = newtp(); | 1834 | t = newtp(); |
1835 | t->type = TIF; | 1835 | t->op_type = TIF; |
1836 | t->left = c_list(); | 1836 | t->left = c_list(); |
1837 | t->right = thenpart(); | 1837 | t->right = thenpart(); |
1838 | musthave(FI, 0); | 1838 | musthave(FI, 0); |
@@ -1841,7 +1841,7 @@ static struct op *command(int cf) | |||
1841 | 1841 | ||
1842 | case DOT: | 1842 | case DOT: |
1843 | t = newtp(); | 1843 | t = newtp(); |
1844 | t->type = TDOT; | 1844 | t->op_type = TDOT; |
1845 | 1845 | ||
1846 | musthave(WORD, 0); /* gets name of file */ | 1846 | musthave(WORD, 0); /* gets name of file */ |
1847 | DBGPRINTF7(("COMMAND: DOT clause, yylval.cp is %s\n", yylval.cp)); | 1847 | DBGPRINTF7(("COMMAND: DOT clause, yylval.cp is %s\n", yylval.cp)); |
@@ -1904,7 +1904,7 @@ static struct op *thenpart(void) | |||
1904 | return NULL; | 1904 | return NULL; |
1905 | } | 1905 | } |
1906 | t = newtp(); | 1906 | t = newtp(); |
1907 | /*t->type = 0; - newtp() did this */ | 1907 | /*t->op_type = 0; - newtp() did this */ |
1908 | t->left = c_list(); | 1908 | t->left = c_list(); |
1909 | if (t->left == NULL) | 1909 | if (t->left == NULL) |
1910 | zzerr(); | 1910 | zzerr(); |
@@ -1926,7 +1926,7 @@ static struct op *elsepart(void) | |||
1926 | 1926 | ||
1927 | case ELIF: | 1927 | case ELIF: |
1928 | t = newtp(); | 1928 | t = newtp(); |
1929 | t->type = TELIF; | 1929 | t->op_type = TELIF; |
1930 | t->left = c_list(); | 1930 | t->left = c_list(); |
1931 | t->right = thenpart(); | 1931 | t->right = thenpart(); |
1932 | return t; | 1932 | return t; |
@@ -1958,7 +1958,7 @@ static struct op *casepart(void) | |||
1958 | DBGPRINTF7(("CASEPART: enter...\n")); | 1958 | DBGPRINTF7(("CASEPART: enter...\n")); |
1959 | 1959 | ||
1960 | t = newtp(); | 1960 | t = newtp(); |
1961 | t->type = TPAT; | 1961 | t->op_type = TPAT; |
1962 | t->op_words = pattern(); | 1962 | t->op_words = pattern(); |
1963 | musthave(')', 0); | 1963 | musthave(')', 0); |
1964 | t->left = c_list(); | 1964 | t->left = c_list(); |
@@ -2027,7 +2027,7 @@ static struct op *block(int type, struct op *t1, struct op *t2, char **wp) | |||
2027 | DBGPRINTF7(("BLOCK: enter, type=%d (%s)\n", type, T_CMD_NAMES[type])); | 2027 | DBGPRINTF7(("BLOCK: enter, type=%d (%s)\n", type, T_CMD_NAMES[type])); |
2028 | 2028 | ||
2029 | t = newtp(); | 2029 | t = newtp(); |
2030 | t->type = type; | 2030 | t->op_type = type; |
2031 | t->left = t1; | 2031 | t->left = t1; |
2032 | t->right = t2; | 2032 | t->right = t2; |
2033 | t->op_words = wp; | 2033 | t->op_words = wp; |
@@ -2096,7 +2096,7 @@ static struct op *newtp(void) | |||
2096 | static struct op *namelist(struct op *t) | 2096 | static struct op *namelist(struct op *t) |
2097 | { | 2097 | { |
2098 | DBGPRINTF7(("NAMELIST: enter, t=%p, type %s, iolist=%p\n", t, | 2098 | DBGPRINTF7(("NAMELIST: enter, t=%p, type %s, iolist=%p\n", t, |
2099 | T_CMD_NAMES[t->type], iolist)); | 2099 | T_CMD_NAMES[t->op_type], iolist)); |
2100 | 2100 | ||
2101 | if (iolist) { | 2101 | if (iolist) { |
2102 | iolist = addword((char *) NULL, iolist); | 2102 | iolist = addword((char *) NULL, iolist); |
@@ -2104,8 +2104,8 @@ static struct op *namelist(struct op *t) | |||
2104 | } else | 2104 | } else |
2105 | t->ioact = NULL; | 2105 | t->ioact = NULL; |
2106 | 2106 | ||
2107 | if (t->type != TCOM) { | 2107 | if (t->op_type != TCOM) { |
2108 | if (t->type != TPAREN && t->ioact != NULL) { | 2108 | if (t->op_type != TPAREN && t->ioact != NULL) { |
2109 | t = block(TPAREN, t, NOBLOCK, NOWORDS); | 2109 | t = block(TPAREN, t, NOBLOCK, NOWORDS); |
2110 | t->ioact = t->left->ioact; | 2110 | t->ioact = t->left->ioact; |
2111 | t->left->ioact = NULL; | 2111 | t->left->ioact = NULL; |
@@ -2124,7 +2124,7 @@ static char **copyw(void) | |||
2124 | char **wd; | 2124 | char **wd; |
2125 | 2125 | ||
2126 | wd = getwords(wdlist); | 2126 | wd = getwords(wdlist); |
2127 | wdlist = 0; | 2127 | wdlist = NULL; |
2128 | return wd; | 2128 | return wd; |
2129 | } | 2129 | } |
2130 | 2130 | ||
@@ -2138,7 +2138,7 @@ static struct ioword **copyio(void) | |||
2138 | struct ioword **iop; | 2138 | struct ioword **iop; |
2139 | 2139 | ||
2140 | iop = (struct ioword **) getwords(iolist); | 2140 | iop = (struct ioword **) getwords(iolist); |
2141 | iolist = 0; | 2141 | iolist = NULL; |
2142 | return iop; | 2142 | return iop; |
2143 | } | 2143 | } |
2144 | 2144 | ||
@@ -2147,7 +2147,7 @@ static struct ioword *io(int u, int f, char *cp) | |||
2147 | struct ioword *iop; | 2147 | struct ioword *iop; |
2148 | 2148 | ||
2149 | iop = (struct ioword *) tree(sizeof(*iop)); | 2149 | iop = (struct ioword *) tree(sizeof(*iop)); |
2150 | iop->io_unit = u; | 2150 | iop->io_fd = u; |
2151 | iop->io_flag = f; | 2151 | iop->io_flag = f; |
2152 | iop->io_name = cp; | 2152 | iop->io_name = cp; |
2153 | iolist = addword((char *) iop, iolist); | 2153 | iolist = addword((char *) iop, iolist); |
@@ -2194,7 +2194,7 @@ static int yylex(int cf) | |||
2194 | } | 2194 | } |
2195 | break; | 2195 | break; |
2196 | 2196 | ||
2197 | case '#': /* Comment, skip to next newline or End-of-string */ | 2197 | case '#': /* Comment, skip to next newline or End-of-string */ |
2198 | while ((c = my_getc(0)) != '\0' && c != '\n') | 2198 | while ((c = my_getc(0)) != '\0' && c != '\n') |
2199 | continue; | 2199 | continue; |
2200 | unget(c); | 2200 | unget(c); |
@@ -2400,10 +2400,10 @@ static struct op **find1case(struct op *t, const char *w) | |||
2400 | return NULL; | 2400 | return NULL; |
2401 | } | 2401 | } |
2402 | 2402 | ||
2403 | DBGPRINTF3(("FIND1CASE: enter, t->type=%d (%s)\n", t->type, | 2403 | DBGPRINTF3(("FIND1CASE: enter, t->op_type=%d (%s)\n", t->op_type, |
2404 | T_CMD_NAMES[t->type])); | 2404 | T_CMD_NAMES[t->op_type])); |
2405 | 2405 | ||
2406 | if (t->type == TLIST) { | 2406 | if (t->op_type == TLIST) { |
2407 | tp = find1case(t->left, w); | 2407 | tp = find1case(t->left, w); |
2408 | if (tp != NULL) { | 2408 | if (tp != NULL) { |
2409 | DBGPRINTF3(("FIND1CASE: found one to the left, returning tp=%p\n", tp)); | 2409 | DBGPRINTF3(("FIND1CASE: found one to the left, returning tp=%p\n", tp)); |
@@ -2458,18 +2458,18 @@ static int execute(struct op *t, int *pin, int *pout, int no_fork) | |||
2458 | return 0; | 2458 | return 0; |
2459 | } | 2459 | } |
2460 | 2460 | ||
2461 | DBGPRINTF(("EXECUTE: t=%p, t->type=%d (%s), t->op_words is %s\n", t, | 2461 | DBGPRINTF(("EXECUTE: t=%p, t->op_type=%d (%s), t->op_words is %s\n", t, |
2462 | t->type, T_CMD_NAMES[t->type], | 2462 | t->op_type, T_CMD_NAMES[t->op_type], |
2463 | ((t->op_words == NULL) ? "NULL" : t->op_words[0]))); | 2463 | ((t->op_words == NULL) ? "NULL" : t->op_words[0]))); |
2464 | 2464 | ||
2465 | rv = 0; | 2465 | rv = 0; |
2466 | a = areanum++; | 2466 | a = areanum++; |
2467 | wp2 = t->op_words; | 2467 | wp2 = t->op_words; |
2468 | wp = (wp2 != NULL) | 2468 | wp = (wp2 != NULL) |
2469 | ? eval(wp2, t->type == TCOM ? DOALL : DOALL & ~DOKEY) | 2469 | ? eval(wp2, t->op_type == TCOM ? DOALL : DOALL & ~DOKEY) |
2470 | : NULL; | 2470 | : NULL; |
2471 | 2471 | ||
2472 | switch (t->type) { | 2472 | switch (t->op_type) { |
2473 | case TDOT: | 2473 | case TDOT: |
2474 | DBGPRINTF3(("EXECUTE: TDOT\n")); | 2474 | DBGPRINTF3(("EXECUTE: TDOT\n")); |
2475 | 2475 | ||
@@ -2552,7 +2552,7 @@ static int execute(struct op *t, int *pin, int *pout, int no_fork) | |||
2552 | case TAND: | 2552 | case TAND: |
2553 | rv = execute(t->left, pin, pout, /* no_fork: */ 0); | 2553 | rv = execute(t->left, pin, pout, /* no_fork: */ 0); |
2554 | t1 = t->right; | 2554 | t1 = t->right; |
2555 | if (t1 != NULL && (rv == 0) == (t->type == TAND)) | 2555 | if (t1 != NULL && (rv == 0) == (t->op_type == TAND)) |
2556 | rv = execute(t1, pin, pout, /* no_fork: */ 0); | 2556 | rv = execute(t1, pin, pout, /* no_fork: */ 0); |
2557 | break; | 2557 | break; |
2558 | 2558 | ||
@@ -2586,7 +2586,7 @@ static int execute(struct op *t, int *pin, int *pout, int no_fork) | |||
2586 | goto broken; | 2586 | goto broken; |
2587 | brkset(&bc); | 2587 | brkset(&bc); |
2588 | t1 = t->left; | 2588 | t1 = t->left; |
2589 | while ((execute(t1, pin, pout, /* no_fork: */ 0) == 0) == (t->type == TWHILE)) | 2589 | while ((execute(t1, pin, pout, /* no_fork: */ 0) == 0) == (t->op_type == TWHILE)) |
2590 | rv = execute(t->right, pin, pout, /* no_fork: */ 0); | 2590 | rv = execute(t->right, pin, pout, /* no_fork: */ 0); |
2591 | brklist = brklist->nextlev; | 2591 | brklist = brklist->nextlev; |
2592 | break; | 2592 | break; |
@@ -2707,7 +2707,7 @@ static int forkexec(struct op *t, int *pin, int *pout, int no_fork, char **wp) | |||
2707 | ((t->op_words == NULL) ? "NULL" : t->op_words[0]))); | 2707 | ((t->op_words == NULL) ? "NULL" : t->op_words[0]))); |
2708 | owp = wp; | 2708 | owp = wp; |
2709 | resetsig = 0; | 2709 | resetsig = 0; |
2710 | if (t->type == TCOM) { | 2710 | if (t->op_type == TCOM) { |
2711 | while (*wp++ != NULL) | 2711 | while (*wp++ != NULL) |
2712 | continue; | 2712 | continue; |
2713 | cp = *wp; | 2713 | cp = *wp; |
@@ -2851,7 +2851,7 @@ static int forkexec(struct op *t, int *pin, int *pout, int no_fork, char **wp) | |||
2851 | signal(SIGQUIT, SIG_DFL); | 2851 | signal(SIGQUIT, SIG_DFL); |
2852 | } | 2852 | } |
2853 | 2853 | ||
2854 | if (t->type == TPAREN) | 2854 | if (t->op_type == TPAREN) |
2855 | _exit(execute(t->left, NOPIPE, NOPIPE, /* no_fork: */ 1)); | 2855 | _exit(execute(t->left, NOPIPE, NOPIPE, /* no_fork: */ 1)); |
2856 | if (wp[0] == NULL) | 2856 | if (wp[0] == NULL) |
2857 | _exit(0); | 2857 | _exit(0); |
@@ -2883,13 +2883,13 @@ static int iosetup(struct ioword *iop, int pipein, int pipeout) | |||
2883 | DBGPRINTF(("IOSETUP: iop %p, pipein %i, pipeout %i\n", iop, | 2883 | DBGPRINTF(("IOSETUP: iop %p, pipein %i, pipeout %i\n", iop, |
2884 | pipein, pipeout)); | 2884 | pipein, pipeout)); |
2885 | 2885 | ||
2886 | if (iop->io_unit == IODEFAULT) /* take default */ | 2886 | if (iop->io_fd == IODEFAULT) /* take default */ |
2887 | iop->io_unit = iop->io_flag & (IOREAD | IOHERE) ? 0 : 1; | 2887 | iop->io_fd = iop->io_flag & (IOREAD | IOHERE) ? 0 : 1; |
2888 | 2888 | ||
2889 | if (pipein && iop->io_unit == 0) | 2889 | if (pipein && iop->io_fd == 0) |
2890 | return 0; | 2890 | return 0; |
2891 | 2891 | ||
2892 | if (pipeout && iop->io_unit == 1) | 2892 | if (pipeout && iop->io_fd == 1) |
2893 | return 0; | 2893 | return 0; |
2894 | 2894 | ||
2895 | msg = iop->io_flag & (IOREAD | IOHERE) ? "open" : "create"; | 2895 | msg = iop->io_flag & (IOREAD | IOHERE) ? "open" : "create"; |
@@ -2935,11 +2935,11 @@ static int iosetup(struct ioword *iop, int pipein, int pipeout) | |||
2935 | break; | 2935 | break; |
2936 | 2936 | ||
2937 | case IODUP: | 2937 | case IODUP: |
2938 | u = dup2(*cp - '0', iop->io_unit); | 2938 | u = dup2(*cp - '0', iop->io_fd); |
2939 | break; | 2939 | break; |
2940 | 2940 | ||
2941 | case IOCLOSE: | 2941 | case IOCLOSE: |
2942 | close(iop->io_unit); | 2942 | close(iop->io_fd); |
2943 | return 0; | 2943 | return 0; |
2944 | } | 2944 | } |
2945 | 2945 | ||
@@ -2949,10 +2949,7 @@ static int iosetup(struct ioword *iop, int pipein, int pipeout) | |||
2949 | warn(msg); | 2949 | warn(msg); |
2950 | return 1; | 2950 | return 1; |
2951 | } | 2951 | } |
2952 | if (u != iop->io_unit) { | 2952 | xmove_fd(u, iop->io_fd); |
2953 | dup2(u, iop->io_unit); | ||
2954 | close(u); | ||
2955 | } | ||
2956 | return 0; | 2953 | return 0; |
2957 | } | 2954 | } |
2958 | 2955 | ||
@@ -3130,8 +3127,8 @@ static int run(struct ioarg *argp, int (*f) (struct ioarg *)) | |||
3130 | 3127 | ||
3131 | errpt = ev; | 3128 | errpt = ev; |
3132 | if (newenv(setjmp(errpt)) == 0) { | 3129 | if (newenv(setjmp(errpt)) == 0) { |
3133 | wdlist = 0; | 3130 | wdlist = NULL; |
3134 | iolist = 0; | 3131 | iolist = NULL; |
3135 | pushio(argp, f); | 3132 | pushio(argp, f); |
3136 | global_env.iobase = global_env.iop; | 3133 | global_env.iobase = global_env.iop; |
3137 | yynerrs = 0; | 3134 | yynerrs = 0; |
@@ -4486,7 +4483,7 @@ static int readc(void) | |||
4486 | if (global_env.iop == iostack) | 4483 | if (global_env.iop == iostack) |
4487 | ioecho(c); | 4484 | ioecho(c); |
4488 | global_env.iop->prev = c; | 4485 | global_env.iop->prev = c; |
4489 | return global_env.iop->prev; | 4486 | return c; |
4490 | } | 4487 | } |
4491 | if (global_env.iop->task == XIO && global_env.iop->prev != '\n') { | 4488 | if (global_env.iop->task == XIO && global_env.iop->prev != '\n') { |
4492 | global_env.iop->prev = 0; | 4489 | global_env.iop->prev = 0; |
@@ -4498,7 +4495,7 @@ static int readc(void) | |||
4498 | if (global_env.iop->task == XIO) { | 4495 | if (global_env.iop->task == XIO) { |
4499 | if (multiline) { | 4496 | if (multiline) { |
4500 | global_env.iop->prev = 0; | 4497 | global_env.iop->prev = 0; |
4501 | return global_env.iop->prev; | 4498 | return 0; |
4502 | } | 4499 | } |
4503 | if (interactive && global_env.iop == iostack + 1) { | 4500 | if (interactive && global_env.iop == iostack + 1) { |
4504 | #if ENABLE_FEATURE_EDITING | 4501 | #if ENABLE_FEATURE_EDITING |
@@ -4584,7 +4581,7 @@ static void pushio(struct ioarg *argp, int (*fn) (struct ioarg *)) | |||
4584 | if (fn == filechar || fn == linechar) | 4581 | if (fn == filechar || fn == linechar) |
4585 | global_env.iop->task = XIO; | 4582 | global_env.iop->task = XIO; |
4586 | else if (fn == (int (*)(struct ioarg *)) gravechar | 4583 | else if (fn == (int (*)(struct ioarg *)) gravechar |
4587 | || fn == (int (*)(struct ioarg *)) qgravechar) | 4584 | || fn == (int (*)(struct ioarg *)) qgravechar) |
4588 | global_env.iop->task = XGRAVE; | 4585 | global_env.iop->task = XGRAVE; |
4589 | else | 4586 | else |
4590 | global_env.iop->task = XOTHER; | 4587 | global_env.iop->task = XOTHER; |
@@ -4604,16 +4601,16 @@ static struct io *setbase(struct io *ip) | |||
4604 | */ | 4601 | */ |
4605 | 4602 | ||
4606 | /* | 4603 | /* |
4607 | * Produce the characters of a string, then a newline, then EOF. | 4604 | * Produce the characters of a string, then a newline, then NUL. |
4608 | */ | 4605 | */ |
4609 | static int nlchar(struct ioarg *ap) | 4606 | static int nlchar(struct ioarg *ap) |
4610 | { | 4607 | { |
4611 | int c; | 4608 | char c; |
4612 | 4609 | ||
4613 | if (ap->aword == NULL) | 4610 | if (ap->aword == NULL) |
4614 | return 0; | 4611 | return '\0'; |
4615 | c = *ap->aword++; | 4612 | c = *ap->aword++; |
4616 | if (c == 0) { | 4613 | if (c == '\0') { |
4617 | ap->aword = NULL; | 4614 | ap->aword = NULL; |
4618 | return '\n'; | 4615 | return '\n'; |
4619 | } | 4616 | } |
@@ -5057,7 +5054,7 @@ static void freehere(int area) | |||
5057 | DBGPRINTF6(("FREEHERE: enter, area=%d\n", area)); | 5054 | DBGPRINTF6(("FREEHERE: enter, area=%d\n", area)); |
5058 | 5055 | ||
5059 | hl = NULL; | 5056 | hl = NULL; |
5060 | for (h = acthere; h != NULL; h = h->h_next) | 5057 | for (h = acthere; h != NULL; h = h->h_next) { |
5061 | if (getarea((char *) h) >= area) { | 5058 | if (getarea((char *) h) >= area) { |
5062 | if (h->h_iop->io_name != NULL) | 5059 | if (h->h_iop->io_name != NULL) |
5063 | unlink(h->h_iop->io_name); | 5060 | unlink(h->h_iop->io_name); |
@@ -5065,8 +5062,10 @@ static void freehere(int area) | |||
5065 | acthere = h->h_next; | 5062 | acthere = h->h_next; |
5066 | else | 5063 | else |
5067 | hl->h_next = h->h_next; | 5064 | hl->h_next = h->h_next; |
5068 | } else | 5065 | } else { |
5069 | hl = h; | 5066 | hl = h; |
5067 | } | ||
5068 | } | ||
5070 | } | 5069 | } |
5071 | 5070 | ||
5072 | 5071 | ||