From 427bce91e7e60b7c105c3dfba2da90b8d0de978b Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Sat, 21 Nov 2020 01:23:00 +0100 Subject: [PATCH] use get_tok_size instead of returned value from get_tok_value() to decide if token was existing or not in attribute string --- src/hilight.c | 8 ++++++++ src/scheduler.c | 13 +++++++++++++ src/token.c | 31 ++++++++++++++++++------------- 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/src/hilight.c b/src/hilight.c index 98eb10c7..994b0367 100644 --- a/src/hilight.c +++ b/src/hilight.c @@ -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;iwire[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); diff --git a/src/token.c b/src/token.c index 1e974cf6..4d5d594c 100644 --- a/src/token.c +++ b/src/token.c @@ -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);