vsource.sym and ammeter.sym no more use tcleval() to handle @savecurrent attribute (calling tcleval() is overkill for such a trivial task and may expose to side effects if $ (and other) characters are used )

This commit is contained in:
stefan schippers 2023-11-27 12:13:53 +01:00
parent 26fbb82f6b
commit fdc3ceefeb
3 changed files with 21 additions and 6 deletions

View File

@ -2032,6 +2032,11 @@ int print_spice_element(FILE *fd, int inst)
if (!xctx->tok_size) value=get_tok_value(template, token+1, 0); if (!xctx->tok_size) value=get_tok_value(template, token+1, 0);
token_exists = xctx->tok_size; token_exists = xctx->tok_size;
if(!strcmp("@savecurrent", token)) {
token_exists = 0; /* processed later */
value = NULL;
}
/* /*
if (!strncmp(value,"tcleval(", 8)) { if (!strncmp(value,"tcleval(", 8)) {
dbg(1, "print_spice_element(): value=%s\n", value); dbg(1, "print_spice_element(): value=%s\n", value);
@ -2124,6 +2129,18 @@ int print_spice_element(FILE *fd, int inst)
result_pos += my_snprintf(result + result_pos, tmp, "%s", xctx->current_name); result_pos += my_snprintf(result + result_pos, tmp, "%s", xctx->current_name);
/* fputs(xctx->current_name, fd); */ /* fputs(xctx->current_name, fd); */
} }
else if(strcmp(token,"@savecurrent")==0)
{
char *instname = xctx->inst[inst].instname;
const char *sc = get_tok_value(xctx->inst[inst].prop_ptr, "savecurrent", 0);
if(!sc[0]) sc = get_tok_value(template, "savecurrent", 0);
if(!strboolcmp(sc , "true")) {
tmp = strlen(instname) + 25;
STR_ALLOC(&result, tmp + result_pos, &size);
result_pos += my_snprintf(result + result_pos, tmp, "\n.save I( ?1 %s )", instname);
}
}
else if(strcmp(token,"@schname")==0) /* of course schname must not be present in attributes */ else if(strcmp(token,"@schname")==0) /* of course schname must not be present in attributes */
{ {
const char *schname = get_cell(xctx->current_name, 0); const char *schname = get_cell(xctx->current_name, 0);

View File

@ -1,4 +1,4 @@
v {xschem version=3.4.4 file_version=1.2 v {xschem version=3.4.5 file_version=1.2
* *
* This file is part of XSCHEM, * This file is part of XSCHEM,
* a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit * a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit
@ -21,8 +21,7 @@ v {xschem version=3.4.4 file_version=1.2
} }
G {} G {}
K {type=ammeter K {type=ammeter
format="tcleval([expr \{@savecurrent ? \\"@name @pinlist 0 format="@name @pinlist 0@savecurrent"
.save I( ?1 @name )\\" : \\"@name @pinlist 0\\"\}])"
template="name=Vmeas savecurrent=true" template="name=Vmeas savecurrent=true"
} }
V {} V {}

View File

@ -1,4 +1,4 @@
v {xschem version=3.4.4 file_version=1.2 v {xschem version=3.4.5 file_version=1.2
* *
* This file is part of XSCHEM, * This file is part of XSCHEM,
* a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit * a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit
@ -21,8 +21,7 @@ v {xschem version=3.4.4 file_version=1.2
} }
G {} G {}
K {type=vsource K {type=vsource
format="tcleval([expr \{@savecurrent ? \\"@name @pinlist @value format="@name @pinlist @value@savecurrent"
.save I( ?1 @name )\\" : \\"@name @pinlist @value \\"\}])"
template="name=V1 value=3 savecurrent=false" template="name=V1 value=3 savecurrent=false"
} }
V {} V {}