[hackers] [scc] [cc1] Remove extra level of indentation in copymacro || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Mon, 16 Jan 2017 10:02:20 +0100 (CET)

commit 56004d247cb4b3fde3efb52717d570864af2c073
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Mon Jan 16 09:22:19 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Jan 16 10:02:10 2017 +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.

diff --git a/cc1/cpp.c b/cc1/cpp.c
index 3612589..0573fce 100644
--- a/cc1/cpp.c
+++ b/cc1/cpp.c
_AT_@ -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 != '_AT_') {
- 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 '_AT_':
                         if (prevc == '#')
                                 bufsiz -= 2;
                         arg = arglist[atoi(++s)];
_AT_@ -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';
Received on Mon Jan 16 2017 - 10:02:20 CET

This archive was generated by hypermail 2.3.0 : Mon Jan 16 2017 - 10:12:18 CET