diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-02-01 01:43:39 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-02-01 01:43:39 +0000 |
commit | 6b50f73171a30a3837c09b73af911a76e7d3b429 (patch) | |
tree | 9410da5cfe8960076b41cf9c98bd5d21f186c729 | |
parent | 489f93ebae0b02edbb7c654c7950f2bfba6bb18b (diff) | |
download | busybox-w32-6b50f73171a30a3837c09b73af911a76e7d3b429.tar.gz busybox-w32-6b50f73171a30a3837c09b73af911a76e7d3b429.tar.bz2 busybox-w32-6b50f73171a30a3837c09b73af911a76e7d3b429.zip |
msh: cleaning up for -Wwrite-strings part #3
-rw-r--r-- | shell/msh.c | 118 |
1 files changed, 57 insertions, 61 deletions
diff --git a/shell/msh.c b/shell/msh.c index d821dfd20..754a6fc25 100644 --- a/shell/msh.c +++ b/shell/msh.c | |||
@@ -284,7 +284,6 @@ static void onintr(int s); /* SIGINT handler */ | |||
284 | 284 | ||
285 | static int newenv(int f); | 285 | static int newenv(int f); |
286 | static void quitenv(void); | 286 | static void quitenv(void); |
287 | static void err(const char *s); | ||
288 | static int anys(const char *s1, const char *s2); | 287 | static int anys(const char *s1, const char *s2); |
289 | static int any(int c, const char *s); | 288 | static int any(int c, const char *s); |
290 | static void next(int f); | 289 | static void next(int f); |
@@ -344,8 +343,6 @@ typedef union { | |||
344 | /* flags to yylex */ | 343 | /* flags to yylex */ |
345 | #define CONTIN 01 /* skip new lines to complete command */ | 344 | #define CONTIN 01 /* skip new lines to complete command */ |
346 | 345 | ||
347 | #define SYNTAXERR zzerr() | ||
348 | |||
349 | static struct op *pipeline(int cf); | 346 | static struct op *pipeline(int cf); |
350 | static struct op *andor(void); | 347 | static struct op *andor(void); |
351 | static struct op *c_list(void); | 348 | static struct op *c_list(void); |
@@ -369,8 +366,6 @@ static char **copyw(void); | |||
369 | static void word(char *cp); | 366 | static void word(char *cp); |
370 | static struct ioword **copyio(void); | 367 | static struct ioword **copyio(void); |
371 | static struct ioword *io(int u, int f, char *cp); | 368 | static struct ioword *io(int u, int f, char *cp); |
372 | static void zzerr(void); | ||
373 | static void yyerror(char *s); | ||
374 | static int yylex(int cf); | 369 | static int yylex(int cf); |
375 | static int collect(int c, int c1); | 370 | static int collect(int c, int c1); |
376 | static int dual(int c); | 371 | static int dual(int c); |
@@ -461,17 +456,10 @@ static int herein(char *hname, int xdoll); | |||
461 | static int run(struct ioarg *argp, int (*f) (struct ioarg *)); | 456 | static int run(struct ioarg *argp, int (*f) (struct ioarg *)); |
462 | 457 | ||
463 | 458 | ||
464 | /* | ||
465 | * IO functions | ||
466 | */ | ||
467 | static int eofc(void); | 459 | static int eofc(void); |
468 | static int readc(void); | 460 | static int readc(void); |
469 | static void unget(int c); | 461 | static void unget(int c); |
470 | static void ioecho(char c); | 462 | static void ioecho(char c); |
471 | static void prs(const char *s); | ||
472 | static void prn(unsigned u); | ||
473 | static void closef(int i); | ||
474 | static void closeall(void); | ||
475 | 463 | ||
476 | 464 | ||
477 | /* | 465 | /* |
@@ -734,10 +722,40 @@ void print_tree(struct op *head) | |||
734 | if (head->right) | 722 | if (head->right) |
735 | print_tree(head->right); | 723 | print_tree(head->right); |
736 | } | 724 | } |
737 | #endif /* MSHDEBUG */ | 725 | #endif /* MSHDEBUG */ |
726 | |||
727 | |||
728 | /* | ||
729 | * IO functions | ||
730 | */ | ||
731 | static void prs(const char *s) | ||
732 | { | ||
733 | if (*s) | ||
734 | write(2, s, strlen(s)); | ||
735 | } | ||
736 | |||
737 | static void prn(unsigned u) | ||
738 | { | ||
739 | prs(itoa(u)); | ||
740 | } | ||
741 | |||
742 | static void closef(int i) | ||
743 | { | ||
744 | if (i > 2) | ||
745 | close(i); | ||
746 | } | ||
747 | |||
748 | static void closeall(void) | ||
749 | { | ||
750 | int u; | ||
751 | |||
752 | for (u = NUFILE; u < NOFILE;) | ||
753 | close(u++); | ||
754 | } | ||
738 | 755 | ||
739 | 756 | ||
740 | /* fail but return to process next command */ | 757 | /* fail but return to process next command */ |
758 | static void fail(void) ATTRIBUTE_NORETURN; | ||
741 | static void fail(void) | 759 | static void fail(void) |
742 | { | 760 | { |
743 | longjmp(failpt, 1); | 761 | longjmp(failpt, 1); |
@@ -783,6 +801,7 @@ static void err(const char *s) | |||
783 | e.iop = e.iobase = iostack; | 801 | e.iop = e.iobase = iostack; |
784 | } | 802 | } |
785 | 803 | ||
804 | |||
786 | /* -------- area.c -------- */ | 805 | /* -------- area.c -------- */ |
787 | 806 | ||
788 | /* | 807 | /* |
@@ -967,6 +986,7 @@ static char *strsave(const char *s, int a) | |||
967 | return ""; | 986 | return ""; |
968 | } | 987 | } |
969 | 988 | ||
989 | |||
970 | /* -------- var.c -------- */ | 990 | /* -------- var.c -------- */ |
971 | 991 | ||
972 | static int eqname(const char *n1, const char *n2) | 992 | static int eqname(const char *n1, const char *n2) |
@@ -1487,6 +1507,24 @@ static char *cclass(char *p, int sub) | |||
1487 | * shell: syntax (C version) | 1507 | * shell: syntax (C version) |
1488 | */ | 1508 | */ |
1489 | 1509 | ||
1510 | static void yyerror(const char *s) ATTRIBUTE_NORETURN; | ||
1511 | static void yyerror(const char *s) | ||
1512 | { | ||
1513 | yynerrs++; | ||
1514 | if (interactive && e.iop <= iostack) { | ||
1515 | multiline = 0; | ||
1516 | while (eofc() == 0 && yylex(0) != '\n'); | ||
1517 | } | ||
1518 | err(s); | ||
1519 | fail(); | ||
1520 | } | ||
1521 | |||
1522 | static void zzerr(void) ATTRIBUTE_NORETURN; | ||
1523 | static void zzerr(void) | ||
1524 | { | ||
1525 | yyerror("syntax error"); | ||
1526 | } | ||
1527 | |||
1490 | int yyparse(void) | 1528 | int yyparse(void) |
1491 | { | 1529 | { |
1492 | DBGPRINTF7(("YYPARSE: enter...\n")); | 1530 | DBGPRINTF7(("YYPARSE: enter...\n")); |
@@ -1515,7 +1553,7 @@ static struct op *pipeline(int cf) | |||
1515 | p = command(CONTIN); | 1553 | p = command(CONTIN); |
1516 | if (p == NULL) { | 1554 | if (p == NULL) { |
1517 | DBGPRINTF8(("PIPELINE: error!\n")); | 1555 | DBGPRINTF8(("PIPELINE: error!\n")); |
1518 | SYNTAXERR; | 1556 | zzerr(); |
1519 | } | 1557 | } |
1520 | 1558 | ||
1521 | if (t->type != TPAREN && t->type != TCOM) { | 1559 | if (t->type != TPAREN && t->type != TCOM) { |
@@ -1548,7 +1586,7 @@ static struct op *andor(void) | |||
1548 | p = pipeline(CONTIN); | 1586 | p = pipeline(CONTIN); |
1549 | if (p == NULL) { | 1587 | if (p == NULL) { |
1550 | DBGPRINTF8(("ANDOR: error!\n")); | 1588 | DBGPRINTF8(("ANDOR: error!\n")); |
1551 | SYNTAXERR; | 1589 | zzerr(); |
1552 | } | 1590 | } |
1553 | 1591 | ||
1554 | t = block(c == LOGAND ? TAND : TOR, t, p, NOWORDS); | 1592 | t = block(c == LOGAND ? TAND : TOR, t, p, NOWORDS); |
@@ -1627,7 +1665,7 @@ static void musthave(int c, int cf) | |||
1627 | peeksym = yylex(cf); | 1665 | peeksym = yylex(cf); |
1628 | if (peeksym != c) { | 1666 | if (peeksym != c) { |
1629 | DBGPRINTF7(("MUSTHAVE: error!\n")); | 1667 | DBGPRINTF7(("MUSTHAVE: error!\n")); |
1630 | SYNTAXERR; | 1668 | zzerr(); |
1631 | } | 1669 | } |
1632 | 1670 | ||
1633 | peeksym = 0; | 1671 | peeksym = 0; |
@@ -1811,7 +1849,7 @@ static struct op *dogroup(int onlydone) | |||
1811 | if (c == DONE && onlydone) | 1849 | if (c == DONE && onlydone) |
1812 | return NULL; | 1850 | return NULL; |
1813 | if (c != DO) | 1851 | if (c != DO) |
1814 | SYNTAXERR; | 1852 | zzerr(); |
1815 | mylist = c_list(); | 1853 | mylist = c_list(); |
1816 | musthave(DONE, 0); | 1854 | musthave(DONE, 0); |
1817 | return mylist; | 1855 | return mylist; |
@@ -1831,7 +1869,7 @@ static struct op *thenpart(void) | |||
1831 | t->type = 0; | 1869 | t->type = 0; |
1832 | t->left = c_list(); | 1870 | t->left = c_list(); |
1833 | if (t->left == NULL) | 1871 | if (t->left == NULL) |
1834 | SYNTAXERR; | 1872 | zzerr(); |
1835 | t->right = elsepart(); | 1873 | t->right = elsepart(); |
1836 | return t; | 1874 | return t; |
1837 | } | 1875 | } |
@@ -1845,7 +1883,7 @@ static struct op *elsepart(void) | |||
1845 | case ELSE: | 1883 | case ELSE: |
1846 | t = c_list(); | 1884 | t = c_list(); |
1847 | if (t == NULL) | 1885 | if (t == NULL) |
1848 | SYNTAXERR; | 1886 | zzerr(); |
1849 | return t; | 1887 | return t; |
1850 | 1888 | ||
1851 | case ELIF: | 1889 | case ELIF: |
@@ -2058,22 +2096,6 @@ static struct ioword *io(int u, int f, char *cp) | |||
2058 | return iop; | 2096 | return iop; |
2059 | } | 2097 | } |
2060 | 2098 | ||
2061 | static void zzerr(void) | ||
2062 | { | ||
2063 | yyerror("syntax error"); | ||
2064 | } | ||
2065 | |||
2066 | static void yyerror(char *s) | ||
2067 | { | ||
2068 | yynerrs++; | ||
2069 | if (interactive && e.iop <= iostack) { | ||
2070 | multiline = 0; | ||
2071 | while (eofc() == 0 && yylex(0) != '\n'); | ||
2072 | } | ||
2073 | err(s); | ||
2074 | fail(); | ||
2075 | } | ||
2076 | |||
2077 | static int yylex(int cf) | 2099 | static int yylex(int cf) |
2078 | { | 2100 | { |
2079 | int c, c1; | 2101 | int c, c1; |
@@ -4803,32 +4825,6 @@ static int linechar(struct ioarg *ap) | |||
4803 | return c; | 4825 | return c; |
4804 | } | 4826 | } |
4805 | 4827 | ||
4806 | static void prs(const char *s) | ||
4807 | { | ||
4808 | if (*s) | ||
4809 | write(2, s, strlen(s)); | ||
4810 | } | ||
4811 | |||
4812 | static void prn(unsigned u) | ||
4813 | { | ||
4814 | prs(itoa(u)); | ||
4815 | } | ||
4816 | |||
4817 | static void closef(int i) | ||
4818 | { | ||
4819 | if (i > 2) | ||
4820 | close(i); | ||
4821 | } | ||
4822 | |||
4823 | static void closeall(void) | ||
4824 | { | ||
4825 | int u; | ||
4826 | |||
4827 | for (u = NUFILE; u < NOFILE;) | ||
4828 | close(u++); | ||
4829 | } | ||
4830 | |||
4831 | |||
4832 | /* | 4828 | /* |
4833 | * remap fd into Shell's fd space | 4829 | * remap fd into Shell's fd space |
4834 | */ | 4830 | */ |