From 0024dc2759c009b9b7a43a7522a4bd0fa324f781 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Fri, 7 Feb 2025 14:23:58 +0100 Subject: [PATCH] more comments and refactoring in token.c --- src/spice_netlist.c | 2 ++ src/token.c | 18 ++---------------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/spice_netlist.c b/src/spice_netlist.c index 6e17771d..7c864c63 100644 --- a/src/spice_netlist.c +++ b/src/spice_netlist.c @@ -455,11 +455,13 @@ int global_spice_netlist(int global, int alert) /* netlister driver */ if(lvs_ignore && (xctx->sym[i].flags & LVS_IGNORE)) continue; if(!xctx->sym[i].type) continue; /* store parent symbol template attr (before descending into it) and parent instance prop_ptr + * into xctx->hier_attr[0].templ and xctx->hier_attr[0.prop_ptr, * to resolve subschematic instances with model=@modp in format string, * modp will be first looked up in instance prop_ptr string, and if not found * in parent symbol template string */ my_strdup(_ALLOC_ID_, &xctx->hier_attr[xctx->currsch - 1].templ, tcl_hook2(xctx->sym[i].templ)); + /* only additional symbols (created with instance schematic=... attr) will have this attribute */ my_strdup(_ALLOC_ID_, &xctx->hier_attr[xctx->currsch - 1].prop_ptr, tcl_hook2(xctx->sym[i].parent_prop_ptr)); my_strdup(_ALLOC_ID_, &abs_path, abs_sym_path(xctx->sym[i].name, "")); diff --git a/src/token.c b/src/token.c index 0d304135..e0d1482a 100644 --- a/src/token.c +++ b/src/token.c @@ -2212,14 +2212,6 @@ int print_spice_element(FILE *fd, int inst) token[token_pos]='\0'; token_pos=0; - - - - - - - - if(strcmp(token,"@symref")==0) { const char *s = get_sym_name(inst, 9999, 1, 0); @@ -2376,9 +2368,6 @@ int print_spice_element(FILE *fd, int inst) /* else tcl var spiceprefix is enabled */ } - - - else { /* here a @token in format string will be replaced by value in instance prop_ptr * or symbol template */ @@ -4662,7 +4651,6 @@ const char *translate3(const char *s, int eat_escapes, const char *s1, const cha size_t token_pos=0; const char *value; int escape=0; - char *value1 = NULL; const char *escape_pos = NULL; @@ -4684,7 +4672,7 @@ const char *translate3(const char *s, int eat_escapes, const char *s1, const cha } space=SPACE(c); - if( state==TOK_BEGIN && (c=='@' || c=='%' ) && !escape ) state=TOK_TOKEN; /* 20161210 escape */ + if( state==TOK_BEGIN && (c=='@' || c=='%' ) && !escape ) state=TOK_TOKEN; else if(state==TOK_TOKEN && token_pos > 1 && ( ( (space || c == '%' || c == '@') && !escape ) || @@ -4712,9 +4700,7 @@ const char *translate3(const char *s, int eat_escapes, const char *s1, const cha /* no definition found -> keep token */ my_strcat(_ALLOC_ID_, &result, token); } else { - my_strdup2(_ALLOC_ID_, &value1, value); - my_strcat(_ALLOC_ID_, &result, value1); - my_free(_ALLOC_ID_, &value1); + my_strcat(_ALLOC_ID_, &result, value); } token_pos = 0; if(c == '@' || c == '%') s--; /* these token separators are also identifiers for next token: push them back */