From: ori@eigenstate.org
To: 9front@9front.org
Subject: Re: [9front] x509.c for ape in libsec.a
Date: Thu, 9 Jul 2020 21:12:40 -0700 [thread overview]
Message-ID: <3D93F0DE46D6A592DD3A6D46B07136EE@eigenstate.org> (raw)
In-Reply-To: <2FA65B5D5E2F244D28960EE0246D34B9@hera.eonet.ne.jp>
>> The cpp time stamped Oct 7, 2019 does right thing, but that of Jul 17,
>> 2020 fails.
> s/Jul 17 2020/Jun 17 2020/
>
> sorry
>
> Kenji
Alright, I think I have a fix for this issue. We need to put the
macro into the hideset before doing the final pass, or there's
potential for macro expansion to cycle in some cases.
expand(A) => B
expand(B) => A
expand(A) => B
...
This diff seems to work, but it's late and it needs more testing.
I've run it against our base system, netsurf, and perl.
diff -r 7bd3f3b9dc76 sys/src/cmd/cpp/macro.c
--- a/sys/src/cmd/cpp/macro.c Sun Jul 05 22:15:02 2020 +0200
+++ b/sys/src/cmd/cpp/macro.c Thu Jul 09 21:10:36 2020 -0700
@@ -169,15 +169,32 @@
}
if (np->flag&ISMAC)
builtin(trp, np->val);
- else {
+ else
expand(trp, np);
- }
tp = trp->tp;
}
if (flag)
unsetsource();
}
+void
+hsspread(Tokenrow *ntr, Tokenrow *trp, Nlist *np)
+{
+ Token *tp;
+ int hs;
+
+ hs = newhideset(trp->tp->hideset, np);
+ /* distribute hidesets */
+ for (tp=ntr->bp; tp<ntr->lp; tp++) {
+ if (tp->type!=NAME)
+ continue;
+ if (tp->hideset==0)
+ tp->hideset = hs;
+ else
+ tp->hideset = unionhideset(tp->hideset, hs);
+ }
+}
+
/*
* Expand the macro whose name is np, at token trp->tp, in the tokenrow.
* Return trp->tp at the first token next to be expanded
@@ -186,17 +203,18 @@
void
expand(Tokenrow *trp, Nlist *np)
{
+ static int depth;
Tokenrow ntr;
int ntokc, narg, i;
- Token *tp;
Tokenrow *atr[NARG+1];
- int hs;
+ depth++;
copytokenrow(&ntr, np->vp); /* copy macro value */
if (np->ap==NULL) { /* parameterless */
ntokc = 1;
/* substargs for handling # and ## */
atr[0] = nil;
+ hsspread(&ntr, trp, np);
substargs(np, &ntr, atr);
} else {
ntokc = gatherargs(trp, atr, (np->flag&ISVARMAC) ? rowlen(np->ap) : 0, &narg);
@@ -215,16 +233,9 @@
dofree(atr[i]->bp);
dofree(atr[i]);
}
+ hsspread(&ntr, trp, np);
}
- hs = newhideset(trp->tp->hideset, np);
- for (tp=ntr.bp; tp<ntr.lp; tp++) { /* distribute hidesets */
- if (tp->type==NAME) {
- if (tp->hideset==0)
- tp->hideset = hs;
- else
- tp->hideset = unionhideset(tp->hideset, hs);
- }
- }
+
ntr.tp = ntr.bp;
insertrow(trp, ntokc, &ntr);
trp->tp -= rowlen(&ntr);
@@ -343,6 +354,7 @@
}
return 0;
}
+
/*
* substitute the argument list into the replacement string
* This would be simple except for ## and #
@@ -408,7 +420,7 @@
if(ttr.tp->hideset == 0)
ttr.tp->hideset = hs;
else
- ttr.tp->hideset = unionhideset(ttr.tp->hideset, hs);
+ ttr.tp->hideset = unionhideset(rtr->tp->hideset, hs);
expandrow(&ttr, (char*)np->name);
for(tp = ttr.bp; tp != ttr.lp; tp++)
if(tp->type == COMMA)
next prev parent reply other threads:[~2020-07-10 4:12 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-01 5:37 kokamoto
2020-07-02 4:54 ` [9front] " kokamoto
2020-07-02 14:48 ` Ori Bernstein
2020-07-04 0:39 ` kokamoto
2020-07-08 5:19 ` kokamoto
2020-07-09 4:19 ` kokamoto
2020-07-09 4:25 ` ori
2020-07-09 23:31 ` kokamoto
2020-07-10 0:23 ` kokamoto
2020-07-10 0:27 ` ori
2020-07-10 0:53 ` Dr. Kenji Okamoto
2020-07-10 1:31 ` kokamoto
2020-07-10 4:12 ` ori [this message]
2020-07-10 4:36 ` kokamoto
2020-07-13 1:39 ` ori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3D93F0DE46D6A592DD3A6D46B07136EE@eigenstate.org \
--to=ori@eigenstate.org \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).