scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit ac0fa861813f8101072d96af883e47e610365ebc
parent d56373f248e2f819620ae0e192bc09f79500398b
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date:   Wed, 17 Jun 2026 19:40:14 +0200

cc1: Fix intersect()

Intersect() was assuming that hidesets were NULL terminated, but
addhideset() ran over the full array filling all the possible
positions. Having NULL terminated arrays make easier to run over
them, and as we have plenty of space in the hidesets instead of
changing intersect() is better to change addhideset() and have
NULL terminated arrays. This simplifies sethideset() and
unsethideset().

Diffstat:
Msrc/cmd/scc-cc/cc1/cpp.c | 12+++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/cmd/scc-cc/cc1/cpp.c b/src/cmd/scc-cc/cc1/cpp.c @@ -510,7 +510,7 @@ addhideset(Symbol *sym) Symbol **set, **p; set = input->hideset; - for (p = set; p < &set[NR_MACROARG] && *p; ++p) { + for (p = set; p < &set[NR_MACROARG-1] && *p; ++p) { if (*p == sym) return; } @@ -540,20 +540,18 @@ unhide(Symbol *sym) void unsethideset(Input *ip) { - Symbol **set, **p; + Symbol **p; - set = ip->hideset; - for (p = set; p < &set[NR_MACROARG] && *p; ++p) + for (p = ip->hideset; *p; ++p) unhide(*p); } void sethideset(Input *ip) { - Symbol **set, **p; + Symbol **p; - set = ip->hideset; - for (p = set; p < &set[NR_MACROARG] && *p; ++p) + for (p = ip->hideset; *p; ++p) hide(*p); }