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 /shell | |
parent | 489f93ebae0b02edbb7c654c7950f2bfba6bb18b (diff) | |
download | busybox-6b50f73171a30a3837c09b73af911a76e7d3b429.tar.gz |
msh: cleaning up for -Wwrite-strings part #3
Diffstat (limited to 'shell')
-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 */ static int newenv(int f); static void quitenv(void); -static void err(const char *s); static int anys(const char *s1, const char *s2); static int any(int c, const char *s); static void next(int f); @@ -344,8 +343,6 @@ typedef union { /* flags to yylex */ #define CONTIN 01 /* skip new lines to complete command */ -#define SYNTAXERR zzerr() - static struct op *pipeline(int cf); static struct op *andor(void); static struct op *c_list(void); @@ -369,8 +366,6 @@ static char **copyw(void); static void word(char *cp); static struct ioword **copyio(void); static struct ioword *io(int u, int f, char *cp); -static void zzerr(void); -static void yyerror(char *s); static int yylex(int cf); static int collect(int c, int c1); static int dual(int c); @@ -461,17 +456,10 @@ static int herein(char *hname, int xdoll); static int run(struct ioarg *argp, int (*f) (struct ioarg *)); -/* - * IO functions - */ static int eofc(void); static int readc(void); static void unget(int c); static void ioecho(char c); -static void prs(const char *s); -static void prn(unsigned u); -static void closef(int i); -static void closeall(void); /* @@ -734,10 +722,40 @@ void print_tree(struct op *head) if (head->right) print_tree(head->right); } -#endif /* MSHDEBUG */ +#endif /* MSHDEBUG */ + + +/* + * IO functions + */ +static void prs(const char *s) +{ + if (*s) + write(2, s, strlen(s)); +} + +static void prn(unsigned u) +{ + prs(itoa(u)); +} + +static void closef(int i) +{ + if (i > 2) + close(i); +} + +static void closeall(void) +{ + int u; + + for (u = NUFILE; u < NOFILE;) + close(u++); +} /* fail but return to process next command */ +static void fail(void) ATTRIBUTE_NORETURN; static void fail(void) { longjmp(failpt, 1); @@ -783,6 +801,7 @@ static void err(const char *s) e.iop = e.iobase = iostack; } + /* -------- area.c -------- */ /* @@ -967,6 +986,7 @@ static char *strsave(const char *s, int a) return ""; } + /* -------- var.c -------- */ static int eqname(const char *n1, const char *n2) @@ -1487,6 +1507,24 @@ static char *cclass(char *p, int sub) * shell: syntax (C version) */ +static void yyerror(const char *s) ATTRIBUTE_NORETURN; +static void yyerror(const char *s) +{ + yynerrs++; + if (interactive && e.iop <= iostack) { + multiline = 0; + while (eofc() == 0 && yylex(0) != '\n'); + } + err(s); + fail(); +} + +static void zzerr(void) ATTRIBUTE_NORETURN; +static void zzerr(void) +{ + yyerror("syntax error"); +} + int yyparse(void) { DBGPRINTF7(("YYPARSE: enter...\n")); @@ -1515,7 +1553,7 @@ static struct op *pipeline(int cf) p = command(CONTIN); if (p == NULL) { DBGPRINTF8(("PIPELINE: error!\n")); - SYNTAXERR; + zzerr(); } if (t->type != TPAREN && t->type != TCOM) { @@ -1548,7 +1586,7 @@ static struct op *andor(void) p = pipeline(CONTIN); if (p == NULL) { DBGPRINTF8(("ANDOR: error!\n")); - SYNTAXERR; + zzerr(); } t = block(c == LOGAND ? TAND : TOR, t, p, NOWORDS); @@ -1627,7 +1665,7 @@ static void musthave(int c, int cf) peeksym = yylex(cf); if (peeksym != c) { DBGPRINTF7(("MUSTHAVE: error!\n")); - SYNTAXERR; + zzerr(); } peeksym = 0; @@ -1811,7 +1849,7 @@ static struct op *dogroup(int onlydone) if (c == DONE && onlydone) return NULL; if (c != DO) - SYNTAXERR; + zzerr(); mylist = c_list(); musthave(DONE, 0); return mylist; @@ -1831,7 +1869,7 @@ static struct op *thenpart(void) t->type = 0; t->left = c_list(); if (t->left == NULL) - SYNTAXERR; + zzerr(); t->right = elsepart(); return t; } @@ -1845,7 +1883,7 @@ static struct op *elsepart(void) case ELSE: t = c_list(); if (t == NULL) - SYNTAXERR; + zzerr(); return t; case ELIF: @@ -2058,22 +2096,6 @@ static struct ioword *io(int u, int f, char *cp) return iop; } -static void zzerr(void) -{ - yyerror("syntax error"); -} - -static void yyerror(char *s) -{ - yynerrs++; - if (interactive && e.iop <= iostack) { - multiline = 0; - while (eofc() == 0 && yylex(0) != '\n'); - } - err(s); - fail(); -} - static int yylex(int cf) { int c, c1; @@ -4803,32 +4825,6 @@ static int linechar(struct ioarg *ap) return c; } -static void prs(const char *s) -{ - if (*s) - write(2, s, strlen(s)); -} - -static void prn(unsigned u) -{ - prs(itoa(u)); -} - -static void closef(int i) -{ - if (i > 2) - close(i); -} - -static void closeall(void) -{ - int u; - - for (u = NUFILE; u < NOFILE;) - close(u++); -} - - /* * remap fd into Shell's fd space */ |