[hackers] [scc] [cc1] Avoid calling atoi() in every macro parameter || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Fri, 13 Jan 2017 15:10:54 +0100 (CET)

commit 1ce77f3c342d3c53596b39cd7271da9b21198813
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Fri Jan 13 15:05:47 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Fri Jan 13 15:05:47 2017 +0100

    [cc1] Avoid calling atoi() in every macro parameter
    
    This was a debug loop which remained in this way.

diff --git a/cc1/cpp.c b/cc1/cpp.c
index 63dc281..eb98fcc 100644
--- a/cc1/cpp.c
+++ b/cc1/cpp.c
_AT_@ -243,7 +243,7 @@ int
 expand(char *begin, Symbol *sym)
 {
         size_t elen;
- int n;
+ int n, i;
         char *s = sym->u.s;
         char *arglist[NR_MACROARG], arguments[INPUTSIZ], buffer[INPUTSIZ];
 
_AT_@ -259,10 +259,11 @@ expand(char *begin, Symbol *sym)
         if (!s)
                 return 1;
 
+ n = atoi(s);
         if (!parsepars(arguments, arglist, atoi(s)))
                 return 0;
- for (n = 0; n < atoi(s); ++n)
- DBG("MACRO par%d:%s", n, arglist[n]);
+ for (i = 0; i < n; ++i)
+ DBG("MACRO par%d:%s", i, arglist[i]);
 
         elen = copymacro(buffer, s+3, INPUTSIZ-1, arglist);
 
Received on Fri Jan 13 2017 - 15:10:54 CET

This archive was generated by hypermail 2.3.0 : Fri Jan 13 2017 - 15:12:18 CET