diff options
author | Martin Mares <mj@ucw.cz> | 1999-03-26 22:37:29 +0100 |
---|---|---|
committer | Martin Mares <mj@ucw.cz> | 1999-03-26 22:37:29 +0100 |
commit | 4ba84ebc8285c3a5c556fc769101cc29cb3d3708 (patch) | |
tree | a8f532314dbde727e7865e005863da28f58269c2 /conf | |
parent | 241b7311ec5a091b7f3e1a1f2a776f3ef403c500 (diff) | |
download | bird-4ba84ebc8285c3a5c556fc769101cc29cb3d3708.tar bird-4ba84ebc8285c3a5c556fc769101cc29cb3d3708.zip |
Slightly better generator of default protocol instance names.
Diffstat (limited to 'conf')
-rw-r--r-- | conf/cf-lex.l | 13 | ||||
-rw-r--r-- | conf/conf.h | 2 |
2 files changed, 8 insertions, 7 deletions
diff --git a/conf/cf-lex.l b/conf/cf-lex.l index 426f528..d000f97 100644 --- a/conf/cf-lex.l +++ b/conf/cf-lex.l @@ -33,7 +33,6 @@ static struct keyword { static struct keyword *kw_hash[KW_HASH_SIZE]; static struct symbol **sym_hash; static int allow_new_symbols; -static int default_counter; int conf_lino; @@ -163,8 +162,11 @@ cf_find_sym(byte *c, unsigned int h0) int l; while (s) - if (!strcmp(s->name, c)) - return s; + { + if (!strcmp(s->name, c)) + return s; + s = s->next; + } if (!allow_new_symbols) return NULL; l = strlen(c); @@ -181,14 +183,14 @@ cf_find_sym(byte *c, unsigned int h0) } struct symbol * -cf_default_name(char *prefix) +cf_default_name(char *prefix, int *counter) { char buf[32]; struct symbol *s; do { - sprintf(buf, "%s%d", prefix, default_counter++); + sprintf(buf, "%s%d", prefix, ++(*counter)); s = cf_find_sym(buf, cf_hash(buf)); if (!s) cf_error("Unable to generate default name"); } @@ -202,7 +204,6 @@ cf_lex_init(int flag) if (allow_new_symbols = flag) sym_hash = cfg_allocz(SYM_HASH_SIZE * sizeof(struct keyword *)); conf_lino = 1; - default_counter = 1; } void diff --git a/conf/conf.h b/conf/conf.h index 69f4a02..5ceb4af 100644 --- a/conf/conf.h +++ b/conf/conf.h @@ -67,7 +67,7 @@ extern int conf_lino; void cf_lex_init_tables(void); int cf_lex(void); void cf_lex_init(int flag); -struct symbol *cf_default_name(char *prefix); +struct symbol *cf_default_name(char *prefix, int *counter); /* Parser */ |