From adbb3cd58daf629f2e36d14de60a7c3d07e0110a Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Tue, 20 May 2025 10:18:11 +0200 Subject: [PATCH] Use has_token() instead of strstr when checking token against (parent_sym_extra --- src/token.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/token.c b/src/token.c index 83f60353..4485e278 100644 --- a/src/token.c +++ b/src/token.c @@ -2147,6 +2147,26 @@ void print_spice_subckt_nodes(FILE *fd, int symbol) my_free(_ALLOC_ID_, &token); } + +int has_token(const char *s, const char *tok) +{ + int i = 1; + int ret = 0; + char *item; + + while(1) { + item = find_nth(s, " ", "", 1, i); + dbg(1, "item=%s, tok=%s\n", item, tok); + if(!item[0]) break; + else if(!strcmp(tok, item)) { + ret = 1; + break; + } + i++; + } + return ret; +} + int print_spice_element(FILE *fd, int inst) { int i=0, multip, itmp; @@ -2398,7 +2418,6 @@ int print_spice_element(FILE *fd, int inst) parent_templ = xctx->hier_attr[xctx->currsch - 1].templ; parent_sym_extra = xctx->hier_attr[xctx->currsch - 1].sym_extra; } - dbg(1, "print_spice_element(): token: |%s|\n", token); /* consider this scenario: * instance of passgate.sym: W_N=5 L_N=0.2 W_P=10 L_P=0.3 m=1 @@ -2417,8 +2436,10 @@ int print_spice_element(FILE *fd, int inst) * model=nfet_01v8 */ - if(parent_sym_extra && strstr(parent_sym_extra, token + 1)) { + + if(parent_sym_extra && has_token(parent_sym_extra, token + 1)) { /* do not translate extra pins with parent instance attributes */ + dbg(1, "print_spice_element(): token: |%s|, parent_sym_extra=|%s|\n", token, parent_sym_extra); my_strdup2(_ALLOC_ID_, &val, translate3(token, 0, xctx->inst[inst].prop_ptr, NULL, NULL, NULL)); } else {