aboutsummaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2020-03-22 13:04:02 -0700
committerMichael Forney <mforney@mforney.org>2020-03-22 13:21:06 -0700
commitdc17fcc04661f3d8ac5c0e9ba870b9d42979f8da (patch)
treefa860afb7eebb2175e48086a5d6d1b6a0c426ac7 /pp.c
parentce589372cbe52399760cf85c46b183caeb17fd45 (diff)
pp: Style
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/pp.c b/pp.c
index 8086d2a..7bc5906 100644
--- a/pp.c
+++ b/pp.c
@@ -65,16 +65,16 @@ ppinit(void)
static bool
macroequal(struct macro *m1, struct macro *m2)
{
+ struct macroparam *p1, *p2;
struct token *t1, *t2;
- size_t i;
if (m1->kind != m2->kind)
return false;
if (m1->kind == MACROFUNC) {
if (m1->nparam != m2->nparam)
return false;
- for (i = 0; i < m1->nparam; ++i) {
- if (strcmp(m1->param[i].name, m2->param[i].name) != 0)
+ for (p1 = m1->param, p2 = m2->param; p1 < m1->param + m1->nparam; ++p1, ++p2) {
+ if (strcmp(p1->name, p2->name) != 0)
return false;
}
}
@@ -404,6 +404,7 @@ static bool
expand(struct token *t)
{
struct macro *m;
+ struct macroparam *p;
struct macroarg *arg;
struct array str, tok;
size_t i, depth, paren;
@@ -427,7 +428,8 @@ expand(struct token *t)
arg = xreallocarray(NULL, m->nparam, sizeof(*arg));
t = rawnext();
for (i = 0; i < m->nparam; ++i) {
- if (m->param[i].flags & PARAMSTR) {
+ p = &m->param[i];
+ if (p->flags & PARAMSTR) {
str = (struct array){0};
arrayaddbuf(&str, "\"", 1);
}
@@ -444,16 +446,16 @@ expand(struct token *t)
case TLPAREN: ++paren; break;
case TRPAREN: --paren; break;
}
- if (m->param[i].flags & PARAMSTR)
+ if (p->flags & PARAMSTR)
stringize(&str, t);
}
- if (m->param[i].flags & PARAMTOK && !expand(t)) {
+ if (p->flags & PARAMTOK && !expand(t)) {
arrayaddbuf(&tok, t, sizeof(*t));
++arg[i].ntoken;
}
t = rawnext();
}
- if (m->param[i].flags & PARAMSTR) {
+ if (p->flags & PARAMSTR) {
arrayaddbuf(&str, "\"", 2);
arg[i].str = (struct token){
.kind = TSTRINGLIT,