use get_tok_size instead of returned value from get_tok_value() to decide if token was existing or not in attribute string

This commit is contained in:
Stefan Frederik 2020-11-21 01:23:00 +01:00
parent 84134e0d97
commit 427bce91e7
3 changed files with 39 additions and 13 deletions

View File

@ -1188,9 +1188,17 @@ void print_hilight_net(int show)
my_free(780, &filetmp2);
return;
}
#ifdef __unix__
my_snprintf(cmd, S(cmd), "\"%s/order_labels.awk\"", tclgetvar("XSCHEM_SHAREDIR"));
#else
my_snprintf(cmd, S(cmd), "awk -f \"%s/order_labels.awk\"", tclgetvar("XSCHEM_SHAREDIR"));
#endif
my_snprintf(cmd2, S(cmd2), "%s %s > %s", cmd, filetmp1, filetmp2);
#ifdef __unix__
my_snprintf(cmd3, S(cmd3), "\"%s/sort_labels.awk\" %s", tclgetvar("XSCHEM_SHAREDIR"), filetmp1);
#else
my_snprintf(cmd3, S(cmd3), "awk -f \"%s/sort_labels.awk\" %s", tclgetvar("XSCHEM_SHAREDIR"), filetmp1);
#endif
for(i=0;i<HASHSIZE;i++) {
entry=hilight_table[i];
while(entry) {

View File

@ -786,6 +786,19 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
}
Tcl_AppendResult(interp, res, NULL);
my_free(925, &res);
} else if(!strcmp(argv[1],"selected_wire")) {
int n, i;
char *res = NULL;
rebuild_selected_array();
for(n=0; n < lastselected; n++) {
if(selectedgroup[n].type == WIRE) {
i = selectedgroup[n].n;
my_strcat(434, &res, get_tok_value(xctx->wire[i].prop_ptr,"lab",0));
if(n < lastselected-1) my_strcat(442, &res, " ");
}
}
Tcl_AppendResult(interp, res, NULL);
my_free(453, &res);
} else if(!strcmp(argv[1],"select")) {
if(argc<3) {
Tcl_AppendResult(interp, "xschem select: missing arguments.", NULL);

View File

@ -792,18 +792,18 @@ const char *subst_token(const char *s, const char *tok, const char *new_val)
/* parsing state machine */
/* states: */
/* TOK_BEGIN TOK_TOKEN TOK_ENDTOK TOK_SEP TOK_VALUE */
/* TOK_BEGIN TOK_TOKEN TOK_ENDTOK TOK_SEP TOK_VALUE */
/* */
/* */
/* TOK_BEGIN */
/* | TOK_TOKEN */
/* | | TOK_ENDTOK */
/* | | | TOK_SEP */
/* | | | | TOK_VALUE */
/* | TOK_TOKEN */
/* | | TOK_ENDTOK */
/* | | | TOK_SEP */
/* | | | | TOK_VALUE */
/* | | | | | TOK_BEGIN */
/* | | | | | | TOK_TOKEN */
/* | | | | | | | TOK_ENDTOK */
/* | | | | | | | | TOK_TOKEN */
/* | | | | | | TOK_TOKEN */
/* | | | | | | | TOK_ENDTOK */
/* | | | | | | | | TOK_TOKEN */
/* | | | | | | | | | */
/* .......name...=.x1....format...type..=..subcircuit.... */
/* . : space */
@ -1493,6 +1493,7 @@ void print_spice_element(FILE *fd, int inst)
}
else if (state==TOK_SEP) /* got a token */
{
int token_exists = 0;
token[token_pos]='\0';
token_pos=0;
@ -1501,8 +1502,9 @@ void print_spice_element(FILE *fd, int inst)
} else {
dbg(1, "print_spice_element(): token: |%s|\n", token);
value = get_tok_value(xctx->inst[inst].prop_ptr, token+1, 2);
if (value[0] == '\0') value=get_tok_value(template, token+1, 0);
/* get_tok_size==0 indicates that token(+1) does not exist in instance attributes */
if (!get_tok_size) value=get_tok_value(template, token+1, 0);
token_exists = get_tok_size;
if (!strncmp(value,"tcleval(", 8)) {
dbg(1, "print_spice_element(): value=%s\n", value);
my_strdup2(442, &translatedvalue, value);
@ -1510,7 +1512,7 @@ void print_spice_element(FILE *fd, int inst)
value = translatedvalue;
}
}
if(!value[0] && token[0] =='$') {
if(!token_exists && token[0] =='$') {
tmp = strlen(token + 1) +100 ; /* always make room for some extra chars
@ -1833,6 +1835,7 @@ void print_tedax_element(FILE *fd, int inst)
token_pos=0;
value = get_tok_value(xctx->inst[inst].prop_ptr, token+1, 0);
/* get_tok_size==0 indicates that token(+1) does not exist in instance attributes */
if(!get_tok_size) value=get_tok_value(template, token+1, 0);
if(!get_tok_size && token[0] =='$') {
fputs(token + 1, fd);
@ -2232,7 +2235,8 @@ 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, 2);
if(value[0] == '\0')
/* get_tok_size==0 indicates that token(+1) does not exist in instance attributes */
if(!get_tok_size)
value=get_tok_value(template, token+1, 0);
if(!get_tok_size && token[0] =='$') {
fputs(token + 1, fd);
@ -2405,7 +2409,8 @@ 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, 2);
if(value[0] == '\0')
/* get_tok_size==0 indicates that token(+1) does not exist in instance attributes */
if(!get_tok_size)
value=get_tok_value(template, token+1, 0);
if(!get_tok_size && token[0] =='$') {
fputs(token + 1, fd);