1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-26 07:54:06 +02:00

b2/: move implicit initialization of FN, F1, ... to explicit function subex_init

This commit is contained in:
Werner Almesberger 2012-06-03 02:00:56 -03:00
parent cae92bba03
commit c6e394436c
3 changed files with 16 additions and 9 deletions

View File

@ -136,6 +136,7 @@ int main(int argc, char **argv)
int i; int i;
dollar = unique("$"); dollar = unique("$");
subex_init();
for (i = 1; i != argc; i++) { for (i = 1; i != argc; i++) {
if (*argv[i] != '-') { if (*argv[i] != '-') {
process(argv[i]); process(argv[i]);

View File

@ -235,18 +235,22 @@ static const struct subst *recurse_sub(const struct subst *sub,
int substitute(const struct subst *sub, const struct param *in, int substitute(const struct subst *sub, const struct param *in,
struct param **out) struct param **out)
{ {
int i;
char tmp[4];
enum subst_type cause = 0; enum subst_type cause = 0;
if (!fn) { *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"); fn = unique("FN");
for (i = 0; i != FIELDS; i++) { for (i = 0; i != FIELDS; i++) {
sprintf(tmp, "F%d", i); sprintf(tmp, "F%d", i);
f[i] = unique(tmp); f[i] = unique(tmp);
} }
} }
*out = NULL;
return recurse_sub(sub, in, NULL, NULL, NULL, NULL, out, &cause)
!= &jump_ignore;
}

View File

@ -20,4 +20,6 @@
int substitute(const struct subst *sub, const struct param *in, int substitute(const struct subst *sub, const struct param *in,
struct param **out); struct param **out);
void subex_init(void);
#endif /* !SUBEX_H */ #endif /* !SUBEX_H */