scc

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

commit 56004d247cb4b3fde3efb52717d570864af2c073
parent 976603250601c41b01e0c99788cbac58dc66d723
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 16 Jan 2017 09:22:19 +0100

[cc1] Remove extra level of indentation in copymacro

This extra level had no sense because it could be done directly
with a switch. It seems this code is some modification over some
older version which needed.

Diffstat:
Mcc1/cpp.c | 48++++++++++++++++++++++++------------------------
1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/cc1/cpp.c b/cc1/cpp.c @@ -190,31 +190,25 @@ copymacro(char *buffer, char *s, size_t bufsiz, char *arglist[]) size_t size; for (prevc = '\0'; c = *s; prevc = c, ++s) { - if (c != '@') { - switch (c) { - case '$': - while (bp[-1] == ' ') - --bp, ++bufsiz; - while (s[1] == ' ') - ++s; - case '#': - continue; - case '\"': - for (p = s; *++s != '"'; ) - /* nothing */; - size = s - p + 1; - if (size > bufsiz) - goto expansion_too_long; - memcpy(bp, p, size); - bufsiz -= size; - bp += size; - continue; - // case '\''; - } - if (bufsiz-- == 0) + switch (c) { + case '$': + while (bp[-1] == ' ') + --bp, ++bufsiz; + while (s[1] == ' ') + ++s; + case '#': + break; + case '\"': + for (p = s; *++s != '"'; ) + /* nothing */; + size = s - p + 1; + if (size > bufsiz) goto expansion_too_long; - *bp++ = c; - } else { + memcpy(bp, p, size); + bufsiz -= size; + bp += size; + break; + case '@': if (prevc == '#') bufsiz -= 2; arg = arglist[atoi(++s)]; @@ -229,6 +223,12 @@ copymacro(char *buffer, char *s, size_t bufsiz, char *arglist[]) *bp++ = '"'; bufsiz -= size; s += 2; + break; + default: + if (bufsiz-- == 0) + goto expansion_too_long; + *bp++ = c; + break; } } *bp = '\0';