summaryrefslogtreecommitdiff
path: root/sys/src/cmd/cpp
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2020-04-25 10:43:39 -0700
committerOri Bernstein <ori@eigenstate.org>2020-04-25 10:43:39 -0700
commit2de164c51dc3330859c160b80440e1363fb5b566 (patch)
tree1b29adb88299efdcca44ede060ec5d4756f4542a /sys/src/cmd/cpp
parent5d7e9bee3ce75cce5727c0283a192b344800cc07 (diff)
fix typos in time calculation
the results of the time calculation were garbled -- and apparently negative on my system when testing, so the test passed when it shouldn't have.
Diffstat (limited to 'sys/src/cmd/cpp')
-rw-r--r--sys/src/cmd/cpp/macro.c16
-rw-r--r--sys/src/cmd/cpp/test.c5
2 files changed, 15 insertions, 6 deletions
diff --git a/sys/src/cmd/cpp/macro.c b/sys/src/cmd/cpp/macro.c
index 67af0bd0c..85e544151 100644
--- a/sys/src/cmd/cpp/macro.c
+++ b/sys/src/cmd/cpp/macro.c
@@ -350,7 +350,7 @@ ispaste(Tokenrow *rtr, Token **ap, Token **an, int *ntok)
void
substargs(Nlist *np, Tokenrow *rtr, Tokenrow **atr)
{
- Tokenrow ttr;
+ Tokenrow ttr, rp, rn;
Token *tp, *ap, *an, *pp, *pn;
int ntok, argno, hs;
@@ -369,19 +369,25 @@ substargs(Nlist *np, Tokenrow *rtr, Tokenrow **atr)
insertrow(rtr, ntok, stringify(atr[argno]));
} else if (ispaste(rtr, &ap, &an, &ntok)) { /* first token, just do the next one */
pp = ap;
+ rp.tp = nil;
pn = an;
+ rn.tp = nil;
if (ap && (argno = lookuparg(np, ap)) >= 0){
pp = nil;
- if(atr[argno]->tp != atr[argno]->lp)
- pp = atr[argno]->lp - 1;
+ rp = *atr[argno];
+ if(rp.tp != rp.lp)
+ pp = --rp.lp;
}
if (an && (argno = lookuparg(np, an)) >= 0) {
pn = nil;
- if(atr[argno]->tp != atr[argno]->lp)
- pn = atr[argno]->lp - 1;
+ rn = *atr[argno];
+ if(rn.tp != rn.lp)
+ pn = rn.bp++;
}
glue(&ttr, pp, pn);
+ insertrow(rtr, 0, &rp);
insertrow(rtr, ntok, &ttr);
+ insertrow(rtr, 0, &rn);
free(ttr.bp);
} else if (rtr->tp->type==NAME) {
if((argno = lookuparg(np, rtr->tp)) >= 0) {
diff --git a/sys/src/cmd/cpp/test.c b/sys/src/cmd/cpp/test.c
index 451e364f4..510419050 100644
--- a/sys/src/cmd/cpp/test.c
+++ b/sys/src/cmd/cpp/test.c
@@ -21,6 +21,9 @@ CAT3(blah)
#define FOO CAT(BAR, 3)
FOO
+/* Expected: a bc d */
+CAT(a b, c d)
+
/*
* CURRENTLY BROKEN:
* __VA_ARGS__ requires at least one item.
@@ -58,4 +61,4 @@ g(x+(3,4)-w) | h 5) & m
* It should treat no args as a single empty arg list.
p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,) };
char c[2][6] = { str(hello), str() };
-*/ \ No newline at end of file
+*/