1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-12-23 08:38:58 +02:00

b2/: resolve FN in subst_init and don't consider an FN match evidence of existance

This commit is contained in:
Werner Almesberger 2012-06-03 02:04:27 -03:00
parent c6e394436c
commit c2414a5d2c
4 changed files with 17 additions and 3 deletions

View File

@ -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] != '-') {

View File

@ -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);

View File

@ -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");
}

View File

@ -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 */