aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-02-01 01:43:39 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-02-01 01:43:39 +0000
commit6b50f73171a30a3837c09b73af911a76e7d3b429 (patch)
tree9410da5cfe8960076b41cf9c98bd5d21f186c729
parent489f93ebae0b02edbb7c654c7950f2bfba6bb18b (diff)
downloadbusybox-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.c118
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
285static int newenv(int f); 285static int newenv(int f);
286static void quitenv(void); 286static void quitenv(void);
287static void err(const char *s);
288static int anys(const char *s1, const char *s2); 287static int anys(const char *s1, const char *s2);
289static int any(int c, const char *s); 288static int any(int c, const char *s);
290static void next(int f); 289static 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
349static struct op *pipeline(int cf); 346static struct op *pipeline(int cf);
350static struct op *andor(void); 347static struct op *andor(void);
351static struct op *c_list(void); 348static struct op *c_list(void);
@@ -369,8 +366,6 @@ static char **copyw(void);
369static void word(char *cp); 366static void word(char *cp);
370static struct ioword **copyio(void); 367static struct ioword **copyio(void);
371static struct ioword *io(int u, int f, char *cp); 368static struct ioword *io(int u, int f, char *cp);
372static void zzerr(void);
373static void yyerror(char *s);
374static int yylex(int cf); 369static int yylex(int cf);
375static int collect(int c, int c1); 370static int collect(int c, int c1);
376static int dual(int c); 371static int dual(int c);
@@ -461,17 +456,10 @@ static int herein(char *hname, int xdoll);
461static int run(struct ioarg *argp, int (*f) (struct ioarg *)); 456static int run(struct ioarg *argp, int (*f) (struct ioarg *));
462 457
463 458
464/*
465 * IO functions
466 */
467static int eofc(void); 459static int eofc(void);
468static int readc(void); 460static int readc(void);
469static void unget(int c); 461static void unget(int c);
470static void ioecho(char c); 462static void ioecho(char c);
471static void prs(const char *s);
472static void prn(unsigned u);
473static void closef(int i);
474static 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 */
731static void prs(const char *s)
732{
733 if (*s)
734 write(2, s, strlen(s));
735}
736
737static void prn(unsigned u)
738{
739 prs(itoa(u));
740}
741
742static void closef(int i)
743{
744 if (i > 2)
745 close(i);
746}
747
748static 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 */
758static void fail(void) ATTRIBUTE_NORETURN;
741static void fail(void) 759static 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
972static int eqname(const char *n1, const char *n2) 992static 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
1510static void yyerror(const char *s) ATTRIBUTE_NORETURN;
1511static 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
1522static void zzerr(void) ATTRIBUTE_NORETURN;
1523static void zzerr(void)
1524{
1525 yyerror("syntax error");
1526}
1527
1490int yyparse(void) 1528int 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
2061static void zzerr(void)
2062{
2063 yyerror("syntax error");
2064}
2065
2066static 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
2077static int yylex(int cf) 2099static 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
4806static void prs(const char *s)
4807{
4808 if (*s)
4809 write(2, s, strlen(s));
4810}
4811
4812static void prn(unsigned u)
4813{
4814 prs(itoa(u));
4815}
4816
4817static void closef(int i)
4818{
4819 if (i > 2)
4820 close(i);
4821}
4822
4823static 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 */