cleanup raw_query sub command, added "values" opcode, speedup some "xschem" subcommands

This commit is contained in:
Stefan Frederik 2022-02-04 17:35:07 +01:00
parent 6fb20b8c5e
commit d7b45bfbf9
10 changed files with 113 additions and 115 deletions

View File

@ -264,14 +264,18 @@ size_t my_strdup2(int id, char **dest, const char *src) /* 20150409 duplicates a
char *itoa(int i)
{
static char s[30];
my_snprintf(s, S(s), "%d", i);
int n;
n = my_snprintf(s, S(s), "%d", i);
if(xctx) xctx->tok_size = n;
return s;
}
char *dtoa(double i)
{
static char s[50];
my_snprintf(s, S(s), "%g", i);
int n;
n = my_snprintf(s, S(s), "%g", i);
if(xctx) xctx->tok_size = n;
return s;
}
@ -1053,7 +1057,7 @@ void update_symbol(const char *result, int x)
to use for inst name (from symbol template) */
prefix=0;
sym_number = -1;
if(xctx->x_strcmp(symbol, xctx->inst[*ii].name)) {
if(strcmp(symbol, xctx->inst[*ii].name)) {
set_modify(1);
sym_number=match_symbol(symbol); /* check if exist */
if(sym_number>=0) {

View File

@ -2,7 +2,7 @@
awk '
BEGIN{
pattern = "(my_free|my_malloc|my_realloc|my_calloc|my_strdup|my_strndup|my_strdup2|my_strcat|my_strncat)\\("
pattern = "(my_free|my_malloc|my_realloc|my_calloc|my_strdup|my_strndup|my_strdup2|my_mstrcat|my_strcat|my_strncat)\\("
}

View File

@ -196,4 +196,4 @@ int cli_opt_load_initfile=1;
/* --------------------------------------------------- */
/* Following data is relative to the current schematic */
/* --------------------------------------------------- */
Xschem_ctx *xctx;
Xschem_ctx *xctx = NULL;

View File

@ -603,7 +603,7 @@ int search(const char *tok, const char *val, int sub, int sel)
has_token = (str = (xctx->inst[i].ptr+ xctx->sym)->prop_ptr) ? 1 : 0;
} else if(!strncmp(tok,"cell::", 6)) { /* cell::xxx looks for xxx in global symbol attributes */
my_strdup(142, &tmpname,get_tok_value((xctx->inst[i].ptr+ xctx->sym)->prop_ptr,tok+6,0));
has_token = xctx->get_tok_size;
has_token = xctx->tok_size;
if(tmpname) {
str = tmpname;
} else {
@ -614,7 +614,7 @@ int search(const char *tok, const char *val, int sub, int sel)
str = xctx->inst[i].prop_ptr;
} else {
str = get_tok_value(xctx->inst[i].prop_ptr, tok,0);
has_token = xctx->get_tok_size;
has_token = xctx->tok_size;
}
dbg(1, "search(): inst=%d, tok=%s, val=%s \n", i,tok, str);
@ -655,7 +655,7 @@ int search(const char *tok, const char *val, int sub, int sel)
}
for(i=0;i<xctx->wires;i++) {
str = get_tok_value(xctx->wire[i].prop_ptr, tok,0);
if(xctx->get_tok_size ) {
if(xctx->tok_size ) {
#ifdef __unix__
if( (!regexec(&re, str,0 , NULL, 0) && !sub ) || /* 20071120 regex instead of strcmp */
( !strcmp(str, val) && sub ) )
@ -684,7 +684,7 @@ int search(const char *tok, const char *val, int sub, int sel)
if(!sel && xctx->hilight_nets) propagate_hilights(1, 0, XINSERT_NOREPLACE);
if(sel) for(c = 0; c < cadlayers; c++) for(i=0;i<xctx->lines[c];i++) {
str = get_tok_value(xctx->line[c][i].prop_ptr, tok,0);
if(xctx->get_tok_size) {
if(xctx->tok_size) {
#ifdef __unix__
if( (!regexec(&re, str,0 , NULL, 0) && !sub ) ||
( !strcmp(str, val) && sub ))
@ -710,7 +710,7 @@ int search(const char *tok, const char *val, int sub, int sel)
}
if(sel) for(c = 0; c < cadlayers; c++) for(i=0;i<xctx->rects[c];i++) {
str = get_tok_value(xctx->rect[c][i].prop_ptr, tok,0);
if(xctx->get_tok_size) {
if(xctx->tok_size) {
#ifdef __unix__
if( (!regexec(&re, str,0 , NULL, 0) && !sub ) ||
( !strcmp(str, val) && sub ))
@ -1078,7 +1078,7 @@ static void send_current_to_graph(char **s, int simtype, const char *node)
}
}
my_free(533, &p);
my_free(534, &t);
my_free(662, &t);
}
static void send_current_to_gaw(int simtype, const char *node)

View File

@ -352,11 +352,11 @@ static int read_dataset(FILE *fd)
if(!xctx->graph_names) xctx->graph_names = my_calloc(426, xctx->graph_nvars, sizeof(char *));
sscanf(line, "%d %s", &i, varname); /* read index and name of saved waveform */
if(xctx->graph_sim_type == 3) { /* AC */
my_strcat(414, &xctx->graph_names[i << 1], varname);
my_strcat(415, &xctx->graph_names[i << 1], varname);
int_hash_lookup(xctx->raw_table, xctx->graph_names[i << 1], (i << 1), XINSERT_NOREPLACE);
if(strstr(varname, "v(") == varname || strstr(varname, "i(") == varname ||
strstr(varname, "V(") == varname || strstr(varname, "I(") == varname)
my_mstrcat(540, &xctx->graph_names[(i << 1) + 1], "ph(", varname + 2, NULL);
my_mstrcat(664, &xctx->graph_names[(i << 1) + 1], "ph(", varname + 2, NULL);
else
my_mstrcat(540, &xctx->graph_names[(i << 1) + 1], "ph(", varname, ")", NULL);
int_hash_lookup(xctx->raw_table, xctx->graph_names[(i << 1) + 1], (i << 1) + 1, XINSERT_NOREPLACE);
@ -773,7 +773,7 @@ static void save_inst(FILE *fd, int select_only)
ptr=xctx->inst;
oldversion = !strcmp(xctx->file_version, "1.0");
for(i=0;i<xctx->symbols;i++) xctx->sym[i].flags &=~EMBEDDED;
embedded_saved = my_calloc(538, xctx->symbols, sizeof(int));
embedded_saved = my_calloc(663, xctx->symbols, sizeof(int));
for(i=0;i<xctx->instances;i++)
{
if (select_only && ptr[i].sel != SELECTED) continue;
@ -919,7 +919,7 @@ static void write_xschem_file(FILE *fd)
if(xctx->schvhdlprop && !xctx->schsymbolprop) {
get_tok_value(xctx->schvhdlprop,"type",0);
ty = xctx->get_tok_size;
ty = xctx->tok_size;
if(ty && !strcmp(xctx->sch[xctx->currsch] + strlen(xctx->sch[xctx->currsch]) - 4,".sym") ) {
fprintf(fd, "G {}\nK ");
save_ascii_string(xctx->schvhdlprop,fd, 1);
@ -1362,7 +1362,7 @@ void read_xschem_file(FILE *fd)
if(xctx->schvhdlprop) {
char *str = xctx->sch[xctx->currsch];
get_tok_value(xctx->schvhdlprop, "type",0);
ty = xctx->get_tok_size;
ty = xctx->tok_size;
if(!xctx->schsymbolprop && ty && !strcmp(str + strlen(str) - 4,".sym")) {
str = xctx->schsymbolprop;
xctx->schsymbolprop = xctx->schvhdlprop;

View File

@ -1112,7 +1112,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
else if(!strcmp(argv[1],"get_tok_size") )
{
Tcl_SetResult(interp, itoa((int)xctx->get_tok_size), TCL_VOLATILE);
Tcl_SetResult(interp, itoa((int)xctx->tok_size), TCL_VOLATILE);
}
else if(!strcmp(argv[1],"globals"))
@ -1323,7 +1323,6 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
else if(!strcmp(argv[1],"instance_nodemap"))
{
/* xschem instance_nodemap [instance_name] */
char *pins = NULL;
int p, no_of_pins;
int inst = -1;
@ -1332,20 +1331,17 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
if(argc > 2) {
inst = get_instance(argv[2]);
if(inst >=0) {
my_mstrcat(573, &pins, "{ {", xctx->inst[inst].instname, "} ", NULL);
Tcl_AppendResult(interp, xctx->inst[inst].instname, " ", NULL);
no_of_pins= (xctx->inst[inst].ptr+ xctx->sym)->rects[PINLAYER];
for(p=0;p<no_of_pins;p++) {
const char *pin;
pin = get_tok_value((xctx->inst[inst].ptr+ xctx->sym)->rect[PINLAYER][p].prop_ptr,"name",0);
if(!pin[0]) pin = "--ERROR--";
if(argc>=4 && strcmp(argv[3], pin)) continue;
my_mstrcat(576, &pins, "{ {", pin, "} {",
xctx->inst[inst].node[p] ? xctx->inst[inst].node[p] : "", "} } ", NULL);
Tcl_AppendResult(interp, pin, " ",
xctx->inst[inst].node && xctx->inst[inst].node[p] ? xctx->inst[inst].node[p] : "{}", " ", NULL);
}
my_strcat(1188, &pins, "} ");
}
Tcl_SetResult(interp, pins, TCL_VOLATILE);
my_free(1189, &pins);
}
}
@ -1428,7 +1424,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
const char *pin;
pin = get_tok_value((xctx->inst[i].ptr+ xctx->sym)->rect[PINLAYER][p].prop_ptr,"name",0);
if(!pin[0]) pin = "--ERROR--";
my_mstrcat(376, &pins, "{", pin, "}", NULL);
my_mstrcat(655, &pins, "{", pin, "}", NULL);
if(p< no_of_pins-1) my_strcat(377, &pins, " ");
}
Tcl_SetResult(interp, pins, TCL_VOLATILE);
@ -2012,58 +2008,64 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
if(argc > 2 && !strcmp(argv[2], "loaded")) {
Tcl_AppendResult(interp, schematic_waves_loaded() ? "1" : "0", NULL);
} else if(xctx->graph_values) {
if(argc > 5) dataset = atoi(argv[5]);
if(argc > 4) {
/* xschem rawfile_query value v(ldcp) 123 */
if(!strcmp(argv[2], "value")) {
int point = atoi(argv[4]);
const char *node = argv[3];
int idx = -1;
if(point >= 0 && point < xctx->graph_npoints[dataset]) {
if(isonlydigit(node)) {
int i = atoi(node);
if(i >= 0 && i < xctx->graph_nvars) {
idx = i;
}
} else {
idx = get_raw_index(node);
}
if(idx >= 0) {
double val = get_raw_value(dataset, idx, point);
Tcl_AppendResult(interp, dtoa(val), NULL);
/* xschem rawfile_query value v(ldcp) 123 */
if(argc > 4 && !strcmp(argv[2], "value")) {
int point = atoi(argv[4]);
const char *node = argv[3];
int idx = -1;
if(argc > 5) dataset = atoi(argv[5]);
if(point >= 0 && point < xctx->graph_npoints[dataset]) {
if(isonlydigit(node)) {
int i = atoi(node);
if(i >= 0 && i < xctx->graph_nvars) {
idx = i;
}
} else {
idx = get_raw_index(node);
}
if(idx >= 0) {
double val = get_raw_value(dataset, idx, point);
Tcl_AppendResult(interp, dtoa(val), NULL);
}
}
} else if(argc > 3) {
/* xschem rawfile_query index v(ldxp) */
if(!strcmp(argv[2], "index")) {
Int_hashentry *entry;
int idx;
entry = int_hash_lookup(xctx->raw_table, argv[3], 0, XLOOKUP);
idx = entry ? entry->value : -1;
Tcl_AppendResult(interp, itoa(idx), NULL);
}
} else if(argc > 2) {
if(!strcmp(argv[2], "datasets")) {
Tcl_AppendResult(interp, itoa(xctx->graph_datasets), NULL);
}
if(!strcmp(argv[2], "points")) {
int i, s = 0;
for(i = 0; i < xctx->graph_datasets; i++) {
s += xctx->graph_npoints[i];
} else if(argc > 3 && !strcmp(argv[2], "index")) {
/* xschem rawfile_query index v(ldcp) */
Int_hashentry *entry;
int idx;
entry = int_hash_lookup(xctx->raw_table, argv[3], 0, XLOOKUP);
idx = entry ? entry->value : -1;
Tcl_AppendResult(interp, itoa(idx), NULL);
} else if(argc > 3 && !strcmp(argv[2], "values")) {
/* xschem raw_query values ldcp [dataset] */
int idx;
int p;
idx = get_raw_index(argv[3]);
if(argc > 4) dataset = atoi(argv[4]);
if(idx >= 0) {
int np = xctx->graph_npoints[dataset];
for(p = 0; p < np; p++) {
Tcl_AppendResult(interp, dtoa(get_raw_value(dataset, idx, p)), " ", NULL);
}
Tcl_AppendResult(interp, itoa(s), NULL);
} else if(!strcmp(argv[2], "vars")) {
Tcl_AppendResult(interp, itoa(xctx->graph_nvars), NULL);
} else if(!strcmp(argv[2], "list")) {
for(i = 0 ; i < xctx->graph_nvars; i++) {
if(i > 0) Tcl_AppendResult(interp, "\n", NULL);
Tcl_AppendResult(interp, xctx->graph_names[i], NULL);
}
}
}
} else if(argc > 2 && !strcmp(argv[2], "datasets")) {
Tcl_AppendResult(interp, itoa(xctx->graph_datasets), NULL);
} else if(argc > 2 && !strcmp(argv[2], "points")) {
int i, s = 0;
for(i = 0; i < xctx->graph_datasets; i++) {
s += xctx->graph_npoints[i];
}
Tcl_AppendResult(interp, itoa(s), NULL);
} else if(argc > 2 && !strcmp(argv[2], "vars")) {
Tcl_AppendResult(interp, itoa(xctx->graph_nvars), NULL);
} else if(argc > 2 && !strcmp(argv[2], "list")) {
for(i = 0 ; i < xctx->graph_nvars; i++) {
if(i > 0) Tcl_AppendResult(interp, "\n", NULL);
Tcl_AppendResult(interp, xctx->graph_names[i], NULL);
}
}
}
}
if(!strcmp(argv[1], "raw_read"))
{
cmd_found = 1;
@ -2371,35 +2373,27 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
else if(!strcmp(argv[1],"selected_set"))
{
int n, i;
char *res = NULL;
cmd_found = 1;
rebuild_selected_array();
for(n=0; n < xctx->lastsel; n++) {
if(xctx->sel_array[n].type == ELEMENT) {
i = xctx->sel_array[n].n;
my_mstrcat(645, &res, "{", xctx->inst[i].instname, "}", NULL);
if(n < xctx->lastsel-1) my_strcat(646, &res, " ");
Tcl_AppendResult(interp, /* "{", */ xctx->inst[i].instname, " ", /* "} ", */ NULL);
}
}
Tcl_SetResult(interp, res, TCL_VOLATILE);
my_free(925, &res);
}
else if(!strcmp(argv[1],"selected_wire"))
{
int n, i;
char *res = NULL;
cmd_found = 1;
rebuild_selected_array();
for(n=0; n < xctx->lastsel; n++) {
if(xctx->sel_array[n].type == WIRE) {
i = xctx->sel_array[n].n;
my_strcat(434, &res, get_tok_value(xctx->wire[i].prop_ptr,"lab",0));
if(n < xctx->lastsel-1) my_strcat(442, &res, " ");
Tcl_AppendResult(interp, get_tok_value(xctx->wire[i].prop_ptr,"lab",0), " ", NULL);
}
}
Tcl_SetResult(interp, res, TCL_VOLATILE);
my_free(453, &res);
}
else if(!strcmp(argv[1],"send_to_viewer"))
@ -2654,7 +2648,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
}
} else {
get_tok_value(r->prop_ptr, argv[5], 0);
if(xctx->get_tok_size) {
if(xctx->tok_size) {
change_done = 1;
if(fast == 3 || fast == 0) xctx->push_undo();
my_strdup2(1478, &r->prop_ptr, subst_token(r->prop_ptr, argv[5], NULL)); /* delete attr */

View File

@ -326,7 +326,7 @@ int set_different_token(char **s,const char *new, const char *old, int object, i
token_pos=0;
}
get_tok_value(new,token,1);
if(xctx->get_tok_size == 0 ) {
if(xctx->tok_size == 0 ) {
mod=1;
my_strdup(443, s, subst_token(*s, token, NULL) );
}
@ -426,7 +426,7 @@ const char *get_tok_value(const char *s,const char *tok, int with_quotes)
int escape=0;
int cmp = 1;
xctx->get_tok_size = 0;
xctx->tok_size = 0;
if(s==NULL) {
if(tok == NULL) {
my_free(976, &result);
@ -463,7 +463,7 @@ const char *get_tok_value(const char *s,const char *tok, int with_quotes)
if(!escape) quote=!quote;
}
if(state==TOK_TOKEN) {
if(!cmp) { /* previous token matched search and was without value, return xctx->get_tok_size */
if(!cmp) { /* previous token matched search and was without value, return xctx->tok_size */
result[0] = '\0';
return result;
}
@ -475,7 +475,7 @@ const char *get_tok_value(const char *s,const char *tok, int with_quotes)
token[token_pos] = '\0';
if( !(cmp = strcmp(token,tok)) ) {
/* report back also token size, useful to check if requested token exists */
xctx->get_tok_size = token_pos;
xctx->tok_size = token_pos;
}
/* dbg(2, "get_tok_value(): token=%s\n", token);*/
token_pos=0;
@ -491,7 +491,7 @@ const char *get_tok_value(const char *s,const char *tok, int with_quotes)
escape = (c=='\\' && !escape);
if(c=='\0') {
result[0]='\0';
xctx->get_tok_size = 0;
xctx->tok_size = 0;
return with_quotes & 2 ? result : tcl_hook2(&result);
}
}
@ -609,14 +609,14 @@ char *get_pin_attr_from_inst(int inst, int pin, const char *attr)
my_free(981, &pinname);
str = get_tok_value(xctx->inst[inst].prop_ptr, pname, 0);
my_free(982, &pname);
if(xctx->get_tok_size) my_strdup2(51, &pin_attr_value, str);
if(xctx->tok_size) my_strdup2(51, &pin_attr_value, str);
else {
pnumber = my_malloc(52, attr_size + 100);
my_snprintf(pnumber, attr_size + 100, "%s(%d)", attr, pin);
str = get_tok_value(xctx->inst[inst].prop_ptr, pnumber, 0);
dbg(1, "get_pin_attr_from_inst(): pnumber=%s\n", pnumber);
my_free(983, &pnumber);
if(xctx->get_tok_size) my_strdup2(40, &pin_attr_value, str);
if(xctx->tok_size) my_strdup2(40, &pin_attr_value, str);
}
}
return pin_attr_value; /* caller is responsible for freeing up storage for pin_attr_value */
@ -1047,7 +1047,7 @@ void print_vhdl_element(FILE *fd, int inst)
value[value_pos]='\0';
value_pos=0;
get_tok_value(template, token, 0);
if(xctx->get_tok_size) {
if(xctx->tok_size) {
if(strcmp(token, "name") && value[0] != '\0') /* token has a value */
{
if(tmp == 0) {fprintf(fd, "generic map(\n");tmp++;tmp1=0;}
@ -1631,10 +1631,10 @@ int print_spice_element(FILE *fd, int inst)
my_snprintf(spiceprefixtag, tok_val_len+22, "**** spice_prefix %s\n", value);
value = spiceprefixtag;
}
/* xctx->get_tok_size==0 indicates that token(+1) does not exist in instance attributes */
/* xctx->tok_size==0 indicates that token(+1) does not exist in instance attributes */
if (!xctx->get_tok_size) value=get_tok_value(template, token+1, 0);
token_exists = xctx->get_tok_size;
if (!xctx->tok_size) value=get_tok_value(template, token+1, 0);
token_exists = xctx->tok_size;
/*
if (!strncmp(value,"tcleval(", 8)) {
dbg(1, "print_spice_element(): value=%s\n", value);
@ -1925,7 +1925,7 @@ void print_tedax_element(FILE *fd, int inst)
my_strdup2(500, &pinnumber,
get_tok_value((xctx->inst[inst].ptr+ xctx->sym)->rect[PINLAYER][i].prop_ptr,"pinnumber",0));
}
if(!xctx->get_tok_size) my_strdup(501, &pinnumber, "--UNDEF--");
if(!xctx->tok_size) my_strdup(501, &pinnumber, "--UNDEF--");
tmp = net_name(inst,i, &multip, 0, 1);
if(tmp && !strstr(tmp, "__UNCONNECTED_PIN__")) {
fprintf(fd, "conn %s %s %s %s %d\n",
@ -2001,9 +2001,9 @@ void print_tedax_element(FILE *fd, int inst)
token_pos=0;
value = get_tok_value(xctx->inst[inst].prop_ptr, token+1, 0);
/* xctx->get_tok_size==0 indicates that token(+1) does not exist in instance attributes */
if(!xctx->get_tok_size) value=get_tok_value(template, token+1, 0);
if(!xctx->get_tok_size && token[0] =='%') {
/* xctx->tok_size==0 indicates that token(+1) does not exist in instance attributes */
if(!xctx->tok_size) value=get_tok_value(template, token+1, 0);
if(!xctx->tok_size && token[0] =='%') {
fputs(token + 1, fd);
} else if(value[0]!='\0')
{
@ -2219,7 +2219,7 @@ void print_verilog_element(FILE *fd, int inst)
value[value_pos]='\0';
value_pos=0;
get_tok_value(template, token, 0);
if(strcmp(token, "name") && xctx->get_tok_size) {
if(strcmp(token, "name") && xctx->tok_size) {
if(value[0] != '\0') /* token has a value */
{
if(strcmp(token,"spice_ignore") && strcmp(token,"vhdl_ignore") && strcmp(token,"tedax_ignore")) {
@ -2407,10 +2407,10 @@ void print_vhdl_primitive(FILE *fd, int inst) /* netlist primitives, 20071217 *
token_pos=0;
value = get_tok_value(xctx->inst[inst].prop_ptr, token+1, 0);
/* xctx->get_tok_size==0 indicates that token(+1) does not exist in instance attributes */
if(!xctx->get_tok_size)
/* xctx->tok_size==0 indicates that token(+1) does not exist in instance attributes */
if(!xctx->tok_size)
value=get_tok_value(template, token+1, 0);
if(!xctx->get_tok_size && token[0] =='%') {
if(!xctx->tok_size && token[0] =='%') {
fputs(token + 1, fd);
} else if(value && value[0]!='\0')
{ /* instance names (name) and node labels (lab) go thru the expandlabel function. */
@ -2581,10 +2581,10 @@ void print_verilog_primitive(FILE *fd, int inst) /* netlist switch level primiti
token_pos=0;
value = get_tok_value(xctx->inst[inst].prop_ptr, token+1, 0);
/* xctx->get_tok_size==0 indicates that token(+1) does not exist in instance attributes */
if(!xctx->get_tok_size)
/* xctx->tok_size==0 indicates that token(+1) does not exist in instance attributes */
if(!xctx->tok_size)
value=get_tok_value(template, token+1, 0);
if(!xctx->get_tok_size && token[0] =='%') {
if(!xctx->tok_size && token[0] =='%') {
fputs(token + 1, fd);
} else if(value && value[0]!='\0') {
/* instance names (name) and node labels (lab) go thru the expandlabel function. */
@ -2989,8 +2989,8 @@ const char *translate(int inst, const char* s)
/* add nothing */
} else {
value = get_tok_value(xctx->inst[inst].prop_ptr, token+1, 0);
if(!xctx->get_tok_size) value=get_tok_value((xctx->inst[inst].ptr+ xctx->sym)->templ, token+1, 0);
if(!xctx->get_tok_size) { /* above lines did not find a value for token */
if(!xctx->tok_size) value=get_tok_value((xctx->inst[inst].ptr+ xctx->sym)->templ, token+1, 0);
if(!xctx->tok_size) { /* above lines did not find a value for token */
if(token[0] =='%') {
/* no definition found -> subst with token without leading % */
tmp=token_pos -1 ; /* we need token_pos -1 chars, ( strlen(token+1) ) , excluding leading '%' */
@ -3072,23 +3072,23 @@ const char *translate2(Lcc *lcc, int level, char* s)
/* if spiceprefix==0 and token == @spiceprefix then set empty value */
if(!tclgetboolvar("spiceprefix") && !strcmp(token, "@spiceprefix")) {
my_free(1069, &value1);
xctx->get_tok_size = 0;
xctx->tok_size = 0;
} else {
my_strdup2(332, &value1, get_tok_value(lcc[level].prop_ptr, token + 1, 0));
}
value = "";
if(xctx->get_tok_size) {
if(xctx->tok_size) {
value = value1;
i = level;
/* recursive substitution of value using parent level prop_str attributes */
while(i > 1) {
save_tok_size = xctx->get_tok_size;
save_tok_size = xctx->tok_size;
my_strdup2(440, &value2, get_tok_value(lcc[i-1].prop_ptr, value, 0));
if(xctx->get_tok_size && value2[0]) {
if(xctx->tok_size && value2[0]) {
value = value2;
} else {
/* restore last successful get_tok_value() size parameters */
xctx->get_tok_size = save_tok_size;
xctx->tok_size = save_tok_size;
break;
}
i--;

View File

@ -476,7 +476,7 @@ static void alloc_xschem_data(const char *top_path, const char *win_path)
xctx->prep_hash_wires = 0;
xctx->modified = 0;
xctx->semaphore = 0;
xctx->get_tok_size = 0;
xctx->tok_size = 0;
xctx->netlist_name[0] = '\0';
xctx->flat_netlist = 0;
xctx->plotfile[0] = '\0';

View File

@ -776,7 +776,7 @@ typedef struct {
int simdata_ninst;
int modified;
int semaphore;
int get_tok_size;
int tok_size;
char netlist_name[PATH_MAX];
int flat_netlist;
char current_dirname[PATH_MAX];

View File

@ -111,9 +111,9 @@ value=".temp 30
.save all @m4[gm] @m5[gm] @m1[gm]
.control
save all
*set appendwrite
*op
*write cmos_example.raw
op
write cmos_example.raw
set appendwrite
* tran 1n 300n
dc vplus 2.3 2.7 0.001
write cmos_example.raw