From 39b7a441b326fe139ae25d866f1f8aa6457f6469 Mon Sep 17 00:00:00 2001 From: Stefan Schippers Date: Wed, 23 Sep 2020 00:58:39 +0200 Subject: [PATCH] fix regression: hilight/rename duplicated instance names was no more functional --- src/spice_netlist.c | 3 ++- src/token.c | 5 +++-- src/xschem.h | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/spice_netlist.c b/src/spice_netlist.c index bea64714..113936b2 100644 --- a/src/spice_netlist.c +++ b/src/spice_netlist.c @@ -437,6 +437,7 @@ static unsigned int hash(const char *tok) * "whatever" "whatever" XINSERT insert in hash table if not in. * if already present update value if not NULL, * return entry address. + * "whatever" "whatever" XINSERT_NOREPLACE same as XINSERT but do not replace existing value * return NULL if not found. * "whatever" "whatever" XLOOKUP lookup in hash table,return entry addr. * return NULL if not found @@ -457,7 +458,7 @@ struct hashentry *hash_lookup(struct hashentry **table, const char *token, const { if( !entry ) /* empty slot */ { - if(what==XINSERT) /* insert data */ + if(what==XINSERT || what == XINSERT_NOREPLACE) /* insert data */ { s=sizeof( struct hashentry ); entry=(struct hashentry *)my_malloc(313, s); diff --git a/src/token.c b/src/token.c index af6ad562..d5bd4e49 100644 --- a/src/token.c +++ b/src/token.c @@ -75,6 +75,7 @@ int name_strcmp(char *s, char *d) /* compare strings up to '\0' or'[' */ /* remove: * 0,XINSERT : lookup and insert in hash table (return NULL if token was not found) * if token was found update value + 3,XINSERT_NOREPLACE : same as XINSERT but do not replace existing value if token found. * 1,XDELETE : delete token entry, return NULL * 2,XLOOKUP : lookup only */ @@ -92,7 +93,7 @@ static struct inst_hashentry *inst_hash_lookup(struct inst_hashentry **table, ch preventry=&table[index]; while(1) { if( !entry ) { /* empty slot */ - if(remove == XINSERT) { /* insert data */ + if(remove == XINSERT || remove == XINSERT_NOREPLACE) { /* insert data */ s=sizeof( struct inst_hashentry ); entry=(struct inst_hashentry *) my_malloc(425, s); *preventry=entry; @@ -198,7 +199,7 @@ void check_unique_names(int rename) comma_pos = strchr(start, ','); if(comma_pos) *comma_pos = '\0'; dbg(1, "check_unique_names: checking %s\n", start); - if( (entry = inst_hash_lookup(table, start, i, XINSERT, strlen(start)) ) && entry->value != i) { + if( (entry = inst_hash_lookup(table, start, i, XINSERT_NOREPLACE, strlen(start)) ) && entry->value != i) { inst_ptr[i].flags |=4; hilight_nets=1; if(rename == 1) { diff --git a/src/xschem.h b/src/xschem.h index 33236ef9..e2993f0b 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -238,6 +238,7 @@ extern char win_temp_dir[PATH_MAX]; #define XINSERT 0 #define XLOOKUP 1 #define XDELETE 2 +#define XINSERT_NOREPLACE 3 /* do not replace token value in hash if already present */ #define S(a) (sizeof(a)/sizeof(char)) #define BUS_WIDTH 4