From c9f60ce1c87225081285b28b6b901b876d0a9feb Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Mon, 20 Jan 2025 18:39:46 +0100 Subject: [PATCH] clanup / better implementation of previous fix --- src/psprint.c | 2 +- src/spice_netlist.c | 7 +------ src/tedax_netlist.c | 2 +- src/token.c | 7 ++++++- src/vhdl_netlist.c | 12 ++++++------ 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/psprint.c b/src/psprint.c index c944ec7d..07daae01 100644 --- a/src/psprint.c +++ b/src/psprint.c @@ -906,7 +906,7 @@ static void ps_draw_symbol(int c, int n,int layer, int what, short tmp_flip, sho "/Subtype /Link " "/ANN pdfmark\n", x1, y1, x2, y2, - sanitize(get_cell_w_ext(fname, 0))); + get_cell_w_ext(sanitize(fname), 0)); } } } diff --git a/src/spice_netlist.c b/src/spice_netlist.c index fbc0a156..911289d1 100644 --- a/src/spice_netlist.c +++ b/src/spice_netlist.c @@ -653,12 +653,7 @@ int spice_block_netlist(FILE *fd, int i, int alert) fprintf(fd, "%s\n", translated_sym_def); my_free(_ALLOC_ID_, &sym_def); } else { - const char *s; - if(is_generator(name)) { - s = get_cell(sanitize(name), 0); - } else { - s = sanitize(get_cell(name, 0)); - } + const char *s = get_cell(sanitize(name), 0); fprintf(fd, "** sch_path: %s\n", sanitized_abs_sym_path(filename, "")); fprintf(fd, ".subckt %s ", s); print_spice_subckt_nodes(fd, i); diff --git a/src/tedax_netlist.c b/src/tedax_netlist.c index 090830b8..e023ba10 100644 --- a/src/tedax_netlist.c +++ b/src/tedax_netlist.c @@ -94,7 +94,7 @@ static int tedax_block_netlist(FILE *fd, int i, int alert) else fprintf(fd, "## sym_path: %s\n", sanitized_abs_sym_path(xctx->sym[i].name, "")); fprintf(fd, "## sch_path: %s\n", sanitized_abs_sym_path(filename, "")); - fprintf(fd, "begin netlist v1 %s\n",sanitize(get_cell(xctx->sym[i].name, 0))); + fprintf(fd, "begin netlist v1 %s\n",get_cell(sanitize(xctx->sym[i].name), 0)); print_tedax_subckt(fd, i); my_strdup(_ALLOC_ID_, &extra, get_tok_value(xctx->sym[i].prop_ptr,"extra",0) ); diff --git a/src/token.c b/src/token.c index 73f70ed6..40dc0565 100644 --- a/src/token.c +++ b/src/token.c @@ -116,6 +116,11 @@ const char *sanitize(const char *name) { static char *s = NULL; static char *empty=""; + + if(!is_generator(name)) { + my_strdup2(_ALLOC_ID_, &s, name); + return s; + } if(name == NULL) { my_free(_ALLOC_ID_, &s); return empty; @@ -1634,7 +1639,7 @@ void print_generic(FILE *fd, char *ent_or_comp, int symbol) my_strdup(_ALLOC_ID_, &generic_type, get_tok_value(xctx->sym[symbol].prop_ptr,"generic_type",0)); dbg(2, "print_generic(): symbol=%d template=%s \n", symbol, template); - fprintf(fd, "%s %s ",ent_or_comp, sanitize(get_cell(xctx->sym[symbol].name, 0))); + fprintf(fd, "%s %s ",ent_or_comp, get_cell(sanitize(xctx->sym[symbol].name), 0)); if(!strcmp(ent_or_comp,"entity")) fprintf(fd, "is\n"); else diff --git a/src/vhdl_netlist.c b/src/vhdl_netlist.c index 45ea3989..5db254b2 100644 --- a/src/vhdl_netlist.c +++ b/src/vhdl_netlist.c @@ -297,8 +297,8 @@ int global_vhdl_netlist(int global, int alert) /* netlister driver */ fprintf(fd,"end %s ;\n\n", get_cell( xctx->sch[xctx->currsch], 0) ); fprintf(fd,"architecture arch_%s of %s is\n\n", - sanitize(get_cell( xctx->sch[xctx->currsch], 0)), - sanitize(get_cell( xctx->sch[xctx->currsch], 0))); + get_cell( sanitize(xctx->sch[xctx->currsch]), 0), + get_cell( sanitize(xctx->sch[xctx->currsch]), 0)); dbg(1, "global_vhdl_netlist(): printing top level used components\n"); /* print all components */ @@ -615,12 +615,12 @@ int vhdl_block_netlist(FILE *fd, int i, int alert) if(xctx->inst[l].prop_ptr) fprintf(fd, "%s\n", xctx->inst[l].prop_ptr); } } - fprintf(fd,"end %s ;\n\n", sanitize(get_cell(xctx->sym[i].name, 0)) ); + fprintf(fd,"end %s ;\n\n", get_cell(sanitize(xctx->sym[i].name), 0) ); dbg(1, "vhdl_block_netlist(): architecture\n"); fprintf(fd,"architecture arch_%s of %s is\n\n", - sanitize(get_cell(xctx->sym[i].name, 0)), - sanitize(get_cell(xctx->sym[i].name, 0)) ); + get_cell(sanitize(xctx->sym[i].name), 0), + get_cell(sanitize(xctx->sym[i].name), 0) ); /* get_cell( xctx->sch[xctx->currsch], 0), get_cell( xctx->sch[xctx->currsch], 0)); */ /* load current schematic to print used components */ @@ -704,7 +704,7 @@ int vhdl_block_netlist(FILE *fd, int i, int alert) } if(xctx->schvhdlprop && xctx->schvhdlprop[0]) fprintf(fd, "%s\n", xctx->schvhdlprop); - fprintf(fd, "end arch_%s ;\n\n", sanitize(get_cell(xctx->sym[i].name, 0)) ); + fprintf(fd, "end arch_%s ;\n\n", get_cell(sanitize(xctx->sym[i].name), 0) ); my_free(_ALLOC_ID_, &sig_type); my_free(_ALLOC_ID_, &port_value); my_free(_ALLOC_ID_, &type);