From c6e394436c7cd4a1ec9eff5f7d6818f51e115176 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sun, 3 Jun 2012 02:00:56 -0300 Subject: [PATCH] b2/: move implicit initialization of FN, F1, ... to explicit function subex_init --- b2/boom.c | 1 + b2/subex.c | 22 +++++++++++++--------- b2/subex.h | 2 ++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/b2/boom.c b/b2/boom.c index 2cd6df4..afbd3bf 100644 --- a/b2/boom.c +++ b/b2/boom.c @@ -136,6 +136,7 @@ int main(int argc, char **argv) int i; dollar = unique("$"); + subex_init(); for (i = 1; i != argc; i++) { if (*argv[i] != '-') { process(argv[i]); diff --git a/b2/subex.c b/b2/subex.c index b29ae6c..db886f2 100644 --- a/b2/subex.c +++ b/b2/subex.c @@ -235,18 +235,22 @@ static const struct subst *recurse_sub(const struct subst *sub, int substitute(const struct subst *sub, const struct param *in, struct param **out) { - int i; - char tmp[4]; enum subst_type cause = 0; - if (!fn) { - fn = unique("FN"); - for (i = 0; i != FIELDS; i++) { - sprintf(tmp, "F%d", i); - f[i] = unique(tmp); - } - } *out = NULL; return recurse_sub(sub, in, NULL, NULL, NULL, NULL, out, &cause) != &jump_ignore; } + + +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/subex.h b/b2/subex.h index a664ae0..4fcfa27 100644 --- a/b2/subex.h +++ b/b2/subex.h @@ -20,4 +20,6 @@ int substitute(const struct subst *sub, const struct param *in, struct param **out); +void subex_init(void); + #endif /* !SUBEX_H */