diff --git a/b2/boom.c b/b2/boom.c index afbd3bf..68c5239 100644 --- a/b2/boom.c +++ b/b2/boom.c @@ -136,6 +136,7 @@ int main(int argc, char **argv) int i; dollar = unique("$"); + subst_init(); subex_init(); for (i = 1; i != argc; i++) { if (*argv[i] != '-') { diff --git a/b2/subex.c b/b2/subex.c index db886f2..b073afb 100644 --- a/b2/subex.c +++ b/b2/subex.c @@ -29,7 +29,7 @@ #define FIELDS 10 /* fields in KiCad schematics */ -static const char *fn = NULL, *f[FIELDS]; +static const char *f[FIELDS]; /* Jump targets that can never be reached. */ static struct subst jump_end; @@ -248,7 +248,6 @@ void subex_init(void) int i; char tmp[4]; - fn = unique("FN"); for (i = 0; i != FIELDS; i++) { sprintf(tmp, "F%d", i); f[i] = unique(tmp); diff --git a/b2/subst.c b/b2/subst.c index 0774801..ff4d7be 100644 --- a/b2/subst.c +++ b/b2/subst.c @@ -25,6 +25,9 @@ #include "subst.h" +const char *fn; + + /* ----- Rule set construction --------------------------------------------- */ @@ -297,7 +300,7 @@ static int find_var_use(const char *var, const struct subst *sub) while (sub) { switch (sub->type) { case st_match: - if (sub->u.match.src == var) + if (sub->u.match.src == var && var != fn) return 1; break; case st_assign: @@ -459,3 +462,9 @@ void subst_dump(FILE *file, const struct subst *sub) { recurse_dump(file, sub, 0); } + + +void subst_init(void) +{ + fn = unique("FN"); +} diff --git a/b2/subst.h b/b2/subst.h index 3a3efbb..0406df3 100644 --- a/b2/subst.h +++ b/b2/subst.h @@ -73,6 +73,9 @@ struct subst { #define MULT_CHARS "GMkmunpf" +extern const char *fn; + + struct subst *subst_match(const char *src, const char *re); struct subst *subst_assign(const char *dst, enum relop op, const char *pat); struct subst *subst_end(void); @@ -84,4 +87,6 @@ void subst_finalize(struct subst *sub); void subst_dump(FILE *file, const struct subst *sub); +void subst_init(void); + #endif /* !SUBST_H */