From 7523c0015c5ec9bab90372381f4f8afd616c5efa Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Mon, 20 Jan 2025 17:54:06 +0100 Subject: [PATCH] correctly mangle generator calls with parameters containing forbidden characters. Transliterate to get valid SPICE identifiers --- src/actions.c | 1 + src/spice_netlist.c | 2 +- src/token.c | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/actions.c b/src/actions.c index 4275a718..d64c0916 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1797,6 +1797,7 @@ const char *get_sym_name(int inst, int ndir, int ext, int abs_path) sch = tcl_hook2(str_replace(get_tok_value(xctx->inst[inst].prop_ptr,"schematic", 6), "@symname", get_cell(xctx->inst[inst].name, 0), '\\', -1)); + dbg(1, "get_sym_name(): sch=%s\n", sch); if(xctx->tok_size) { /* token exists */ if(abs_path) sym = abs_sym_path(sch, ".sym"); diff --git a/src/spice_netlist.c b/src/spice_netlist.c index b7f751e1..911289d1 100644 --- a/src/spice_netlist.c +++ b/src/spice_netlist.c @@ -653,7 +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 = 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/token.c b/src/token.c index d326377e..73f70ed6 100644 --- a/src/token.c +++ b/src/token.c @@ -120,9 +120,11 @@ const char *sanitize(const char *name) my_free(_ALLOC_ID_, &s); return empty; } - tclvareval("regsub -all { *[(),] *} {", name, "} _", NULL); + dbg(1, "sanitize(): name=%s\n", name); + tclvareval("regsub -all { *[.(),] *} {", name, "} _", NULL); tclvareval("regsub {_$} {", tclresult(), "} {}", NULL); my_strdup2(_ALLOC_ID_, &s, tclresult()); + dbg(1, "sanitize(): s=%s\n", s); return s; }