scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit b949267ae25f86333ceaba22e473deb822b4be23
parent bf7035e84c924246113e6d6033b3513bd224f559
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 22 May 2015 10:45:00 +0200

Simplify parseargs() in cc1

Diffstat:
Mcc1/cpp.c | 21+++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/cc1/cpp.c b/cc1/cpp.c @@ -19,19 +19,18 @@ static char * parseargs(char *s, char *args[NR_MACROARG], int *nargs) { - unsigned n ; + int n; size_t len; char *endp, c; - if (*s != '(') { - *nargs = -1; - return s; - } - if (*++s == ')') { - *nargs = 0; - return s+1; - } - + n = -1; + if (*s != '(') + goto set_nargs; + n = 0; + while (isspace(*s++)) + /* nothing */; + if (*s == ')') + goto set_nargs; for (n = 1; n <= NR_MACROARG; ++n) { while (isspace(*s)) @@ -56,6 +55,8 @@ parseargs(char *s, char *args[NR_MACROARG], int *nargs) } if (n > NR_MACROARG) error("too much parameters in macro"); + +set_nargs: *nargs = n; return s; }