diff --git a/src/spice_netlist.c b/src/spice_netlist.c index 902db32a..ca17e364 100644 --- a/src/spice_netlist.c +++ b/src/spice_netlist.c @@ -211,18 +211,22 @@ static int spice_netlist(FILE *fd, int spice_stop ) print_spice_element(fd, i) ; /* this is the element line */ fprintf(fd,"**** end user architecture code\n"); } else { + char *val = NULL; const char *m; if(print_spice_element(fd, i)) { fprintf(fd, "**** end_element\n"); } /* hash device_model attribute if any */ - m = translate(i, get_tok_value(xctx->inst[i].prop_ptr, "device_model", 2)); + my_strdup2(_ALLOC_ID_, &val, get_tok_value(xctx->inst[i].prop_ptr, "device_model", 2)); + m = val; + if(strchr(val, '@')) m = translate(i, val); if(m[0]) str_hash_lookup(&model_table, model_name(m), m, XINSERT); else { m = get_tok_value( (xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "device_model", 0); if(m[0]) str_hash_lookup(&model_table, model_name(m), m, XINSERT); } my_free(_ALLOC_ID_, &model_name_result); + my_free(_ALLOC_ID_, &val); } } } diff --git a/src/token.c b/src/token.c index d5f696f4..d241fc05 100644 --- a/src/token.c +++ b/src/token.c @@ -2138,6 +2138,7 @@ int print_spice_element(FILE *fd, int inst) } else if (state==TOK_SEP) /* got a token */ { + char *val = NULL; size_t token_exists = 0; token[token_pos]='\0'; token_pos=0; @@ -2147,11 +2148,11 @@ int print_spice_element(FILE *fd, int inst) value=NULL; } else { size_t tok_val_len; - dbg(1, "print_spice_element(): token: |%s|\n", token); - value = get_tok_value(xctx->inst[inst].prop_ptr, token+1, 0); + my_strdup2(_ALLOC_ID_, &val, get_tok_value(xctx->inst[inst].prop_ptr, token+1, 0)); + value = val; + if(strchr(value, '@')) value = translate(inst, val); tok_val_len = strlen(value); - if(!strcmp(token, "@spiceprefix")) { my_realloc(_ALLOC_ID_, &spiceprefixtag, tok_val_len+22); my_snprintf(spiceprefixtag, tok_val_len+22, "**** spice_prefix %s\n", value); @@ -2386,6 +2387,7 @@ int print_spice_element(FILE *fd, int inst) } if(c == '@' || c == '%' ) s--; state=TOK_BEGIN; + my_free(_ALLOC_ID_, &val); } else if(state==TOK_BEGIN && c!='\0') { char str[2];