allow label expressions in graph (digital) bus signal lists, like: `LDQ; ldq[15:0]`; fix a long standing memory corruption (out of array bound write) if expandlabel() parser is called after a previous call that generated a parse error.
This commit is contained in:
parent
210aea296d
commit
ff88b2a1bc
40
src/draw.c
40
src/draw.c
|
|
@ -2538,16 +2538,18 @@ static SPICE_DATA **get_bus_idx_array(const char *ntok, int *n_bits)
|
|||
int p;
|
||||
char *saven, *nptr, *ntok_copy = NULL;
|
||||
const char *bit_name;
|
||||
*n_bits = count_items(ntok, ";,", "") - 1;
|
||||
p = 0;
|
||||
yyparse_error = -1;
|
||||
my_strdup2(_ALLOC_ID_, &ntok_copy, expandlabel(find_nth(ntok, ";", "\"", 4, 2), NULL));
|
||||
yyparse_error = 0;
|
||||
*n_bits = count_items(ntok_copy, ",", "");
|
||||
idx_arr = my_malloc(_ALLOC_ID_, (*n_bits) * sizeof(SPICE_DATA *));
|
||||
dbg(1, "get_bus_idx_array(): ntok=%s\n", ntok);
|
||||
dbg(1, "get_bus_idx_array(): *n_bits=%d\n", *n_bits);
|
||||
idx_arr = my_malloc(_ALLOC_ID_, (*n_bits) * sizeof(SPICE_DATA *));
|
||||
p = 0;
|
||||
my_strdup2(_ALLOC_ID_, &ntok_copy, ntok);
|
||||
nptr = ntok_copy;
|
||||
my_strtok_r(nptr, ";,", "", 0, &saven); /*strip off bus name (1st field) */
|
||||
while( (bit_name = my_strtok_r(NULL, ";, \\\n", "", 0, &saven)) ) {
|
||||
while( (bit_name = my_strtok_r(nptr, ";, \\\n", "", 0, &saven)) ) {
|
||||
int idx;
|
||||
nptr = NULL;
|
||||
if(p >= *n_bits) break; /* security check to avoid out of bound writing */
|
||||
if( (idx = get_raw_index(bit_name, NULL)) != -1) {
|
||||
idx_arr[p] = xctx->raw->values[idx];
|
||||
|
|
@ -2789,12 +2791,15 @@ int graph_fullyzoom(xRect *r, Graph_ctx *gr, int graph_dataset)
|
|||
my_free(_ALLOC_ID_, &nd);
|
||||
dbg(1, "ntok=|%s|\nntok_copy=|%s|\nnode_dataset=%d\n", ntok, ntok_copy, node_dataset);
|
||||
|
||||
tmp_ptr = find_nth(ntok_copy, ";", "\"", 4, 2);
|
||||
yyparse_error = -1;
|
||||
my_strdup2(_ALLOC_ID_, &tmp_ptr, expandlabel(find_nth(ntok_copy, ";", "\"", 4, 2), NULL));
|
||||
yyparse_error = 0;
|
||||
if(strstr(tmp_ptr, ",")) {
|
||||
tmp_ptr = find_nth(tmp_ptr, ",", "\"", 4, 1);
|
||||
my_strdup2(_ALLOC_ID_, &tmp_ptr, find_nth(tmp_ptr, ",", "\"", 4, 1));
|
||||
/* also trim spaces */
|
||||
my_strdup2(_ALLOC_ID_, &bus_msb, trim_chars(tmp_ptr, "\n "));
|
||||
}
|
||||
my_free(_ALLOC_ID_, &tmp_ptr);
|
||||
dbg(1, "ntok_copy=|%s|, bus_msb=|%s|\n", ntok_copy, bus_msb ? bus_msb : "<NULL>");
|
||||
stok = my_strtok_r(sptr, "\n\t ", "\"", 0, &saves);
|
||||
nptr = sptr = NULL;
|
||||
|
|
@ -3579,22 +3584,19 @@ static void draw_graph_variables(int wcnt, int wave_color, int n_nodes, int swee
|
|||
find_nth(ntok, ";,", "\"", 0, 1), gr->unity_suffix);
|
||||
else my_snprintf(tmpstr, S(tmpstr), "%s",find_nth(ntok, ";,", "\"", 0, 1));
|
||||
} else {
|
||||
char *ntok_ptr = NULL;
|
||||
char *alias_ptr = NULL;
|
||||
dbg(1, "ntok=%s\n", ntok);
|
||||
yyparse_error = -1;
|
||||
if(strstr(ntok, ";")) {
|
||||
my_strdup2(_ALLOC_ID_, &alias_ptr, find_nth(ntok, ";", "\"", 0, 1));
|
||||
my_strdup2(_ALLOC_ID_, &ntok_ptr, find_nth(ntok, ";", "\"", 0, 2));
|
||||
}
|
||||
else {
|
||||
my_strdup2(_ALLOC_ID_, &alias_ptr, ntok);
|
||||
my_strdup2(_ALLOC_ID_, &ntok_ptr, ntok);
|
||||
}
|
||||
yyparse_error = 0;
|
||||
|
||||
if(gr->unity != 1.0) my_snprintf(tmpstr, S(tmpstr), "%s[%c]", alias_ptr, gr->unity_suffix);
|
||||
else my_snprintf(tmpstr, S(tmpstr), "%s", alias_ptr);
|
||||
my_free(_ALLOC_ID_, &alias_ptr);
|
||||
my_free(_ALLOC_ID_, &ntok_ptr);
|
||||
}
|
||||
if(gr->vlegend && !gr->digital) {
|
||||
double xt = gr->rx1 + 5;
|
||||
|
|
@ -3701,15 +3703,12 @@ static void show_node_measures(int measure_p, double measure_x, double measure_p
|
|||
if(!gr->legend && !gr->digital) return;
|
||||
if(measure_p >= 0) {
|
||||
/* draw node values in graph */
|
||||
char *ntok_ptr = NULL;
|
||||
char *alias_ptr = NULL;
|
||||
if(strstr(ntok, ";")) {
|
||||
my_strdup2(_ALLOC_ID_, &alias_ptr, find_nth(ntok, ";", "\"", 0, 1));
|
||||
my_strdup2(_ALLOC_ID_, &ntok_ptr, find_nth(ntok, ";", "\"", 0, 2));
|
||||
}
|
||||
else {
|
||||
my_strdup2(_ALLOC_ID_, &alias_ptr, ntok);
|
||||
my_strdup2(_ALLOC_ID_, &ntok_ptr, ntok);
|
||||
}
|
||||
bbox(START, 0.0, 0.0, 0.0, 0.0);
|
||||
bbox(ADD, gr->rx1, gr->ry1, gr->rx2, gr->ry2);
|
||||
|
|
@ -3789,7 +3788,6 @@ static void show_node_measures(int measure_p, double measure_x, double measure_p
|
|||
}
|
||||
bbox(END, 0.0, 0.0, 0.0, 0.0);
|
||||
my_free(_ALLOC_ID_, &alias_ptr);
|
||||
my_free(_ALLOC_ID_, &ntok_ptr);
|
||||
} /* if(measure_p >= 0) */
|
||||
}
|
||||
|
||||
|
|
@ -4401,12 +4399,16 @@ void draw_graph(int i, int flags, Graph_ctx *gr, void *ct)
|
|||
|
||||
dbg(1, "ntok=|%s|\nntok_copy=|%s|\nnode_dataset=%d\n", ntok, ntok_copy, node_dataset);
|
||||
|
||||
tmp_ptr = find_nth(ntok_copy, ";", "\"", 4, 2);
|
||||
yyparse_error = -1;
|
||||
my_strdup2(_ALLOC_ID_, &tmp_ptr, expandlabel(find_nth(ntok_copy, ";", "\"", 4, 2), NULL));
|
||||
yyparse_error = 0;
|
||||
dbg(1, "tmp_ptr=|%s|\n", tmp_ptr);
|
||||
if(strstr(tmp_ptr, ",")) {
|
||||
tmp_ptr = find_nth(tmp_ptr, ",", "\"", 4, 1);
|
||||
my_strdup2(_ALLOC_ID_, &tmp_ptr, find_nth(tmp_ptr, ",", "\"", 4, 1));
|
||||
/* also trim spaces */
|
||||
my_strdup2(_ALLOC_ID_, &bus_msb, trim_chars(tmp_ptr, "\n "));
|
||||
}
|
||||
my_free(_ALLOC_ID_, &tmp_ptr);
|
||||
dbg(1, "ntok_copy=|%s|, bus_msb=|%s|\n", ntok_copy, bus_msb ? bus_msb : "<NULL>");
|
||||
ctok = my_strtok_r(cptr, " ", "", 0, &savec);
|
||||
stok = my_strtok_r(sptr, "\t\n ", "\"", 0, &saves);
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ typedef struct /* used in expandlabel.y */
|
|||
extern Stringptr dest_string; /* 20140108 */
|
||||
static int idxsize=INITIALIDXSIZE;
|
||||
extern int yylex();
|
||||
extern void reset_lexer(void);
|
||||
/*
|
||||
extern FILE *errfp;
|
||||
extern void *my_malloc(int id, size_t size);
|
||||
|
|
@ -60,9 +61,11 @@ extern int yyparse_error;
|
|||
|
||||
static void yyerror (const char *s) /* Called by yyparse on error */
|
||||
{
|
||||
if(yyparse_error == 0 ) yyparse_error = 1;
|
||||
dbg(0, "yyerror(): yyparse():%s\n", s);
|
||||
dbg(0, " schematic: %s\n", xctx->sch[xctx->currsch]);
|
||||
if(yyparse_error == 0 ) {
|
||||
yyparse_error = 1;
|
||||
dbg(0, "yyerror(): yyparse():%s\n", s);
|
||||
dbg(0, " schematic: %s\n", xctx->sch[xctx->currsch]);
|
||||
}
|
||||
}
|
||||
|
||||
static char *expandlabel_strdup(char *src)
|
||||
|
|
@ -221,8 +224,8 @@ static void check_idx(int **ptr,int n)
|
|||
{
|
||||
if(n>=idxsize)
|
||||
{
|
||||
idxsize*=2;
|
||||
dbg(3, "check_idx(): reallocating idx array: size=%d\n",idxsize);
|
||||
while(idxsize <= n) idxsize*=2;
|
||||
dbg(3, "check_idx(): reallocating idx array: idxsize=%d, n=%d\n",idxsize, n);
|
||||
my_realloc(_ALLOC_ID_, ptr, idxsize*sizeof(int));
|
||||
}
|
||||
}
|
||||
|
|
@ -423,12 +426,13 @@ index: B_IDXNUM ':' B_IDXNUM ':' B_IDXNUM ':' B_IDXNUM
|
|||
/* start : end : extend : repetitions */
|
||||
int r, i, sign, offset;
|
||||
sign = XSIGN($3-$1);
|
||||
$$=my_malloc(_ALLOC_ID_, INITIALIDXSIZE*sizeof(int));
|
||||
$$=my_malloc(_ALLOC_ID_, idxsize*sizeof(int));
|
||||
$$[0]=0;
|
||||
offset = 0;
|
||||
for(r=0; r < $7; r++) {
|
||||
for(i = $1;; i += sign) {
|
||||
check_idx(&$$,++$$[0]);
|
||||
++$$[0];
|
||||
check_idx(&$$, $$[0]);
|
||||
$$[$$[0]] = i + offset;
|
||||
if(i == $3) break;
|
||||
}
|
||||
|
|
@ -441,11 +445,12 @@ index: B_IDXNUM ':' B_IDXNUM ':' B_IDXNUM ':' B_IDXNUM
|
|||
int sign;
|
||||
|
||||
sign = XSIGN($3-$1);
|
||||
$$=my_malloc(_ALLOC_ID_, INITIALIDXSIZE*sizeof(int));
|
||||
$$=my_malloc(_ALLOC_ID_, idxsize*sizeof(int));
|
||||
$$[0]=0;
|
||||
for(i=$1;;i+=sign*$5)
|
||||
{
|
||||
check_idx(&$$,++$$[0]);
|
||||
++$$[0];
|
||||
check_idx(&$$, $$[0]);
|
||||
$$[$$[0]]=i;
|
||||
|
||||
if(sign==1 && i + $5 > $3) break;
|
||||
|
|
@ -455,19 +460,21 @@ index: B_IDXNUM ':' B_IDXNUM ':' B_IDXNUM ':' B_IDXNUM
|
|||
| B_IDXNUM ':' B_IDXNUM
|
||||
{
|
||||
int i;
|
||||
$$=my_malloc(_ALLOC_ID_, INITIALIDXSIZE*sizeof(int));
|
||||
$$=my_malloc(_ALLOC_ID_, idxsize*sizeof(int));
|
||||
$$[0]=0;
|
||||
for(i=$1;;i+=XSIGN($3-$1))
|
||||
{
|
||||
check_idx(&$$,++$$[0]);
|
||||
++$$[0];
|
||||
check_idx(&$$, $$[0]);
|
||||
$$[$$[0]]=i;
|
||||
if(i==$3) break;
|
||||
}
|
||||
}
|
||||
| B_IDXNUM {
|
||||
$$=my_malloc(_ALLOC_ID_, INITIALIDXSIZE*sizeof(int));
|
||||
$$=my_malloc(_ALLOC_ID_, idxsize*sizeof(int));
|
||||
$$[0]=0;
|
||||
check_idx(&$$, ++$$[0]);
|
||||
++$$[0];
|
||||
check_idx(&$$, $$[0]);
|
||||
$$[$$[0]]=$1;
|
||||
}
|
||||
| index ',' B_IDXNUM ':' B_IDXNUM ':' B_IDXNUM ':' B_IDXNUM
|
||||
|
|
@ -478,7 +485,8 @@ index: B_IDXNUM ':' B_IDXNUM ':' B_IDXNUM ':' B_IDXNUM
|
|||
offset = 0;
|
||||
for(r=0; r < $9; r++) {
|
||||
for(i = $3;; i += sign) {
|
||||
check_idx(&$$,++$$[0]);
|
||||
++$$[0];
|
||||
check_idx(&$$, $$[0]);
|
||||
$$[$$[0]] = i + offset;
|
||||
if(i == $5) break;
|
||||
}
|
||||
|
|
@ -493,7 +501,8 @@ index: B_IDXNUM ':' B_IDXNUM ':' B_IDXNUM ':' B_IDXNUM
|
|||
sign = XSIGN($5-$3);
|
||||
for(i=$3;;i+=sign*$7)
|
||||
{
|
||||
check_idx(&$$, ++$$[0]);
|
||||
++$$[0];
|
||||
check_idx(&$$, $$[0]);
|
||||
$$[$$[0]]=i;
|
||||
if(sign==1 && i + $7 > $5) break;
|
||||
if(sign==-1 && i - $7 < $5) break;
|
||||
|
|
@ -504,14 +513,16 @@ index: B_IDXNUM ':' B_IDXNUM ':' B_IDXNUM ':' B_IDXNUM
|
|||
int i;
|
||||
for(i=$3;;i+=XSIGN($5-$3))
|
||||
{
|
||||
check_idx(&$$, ++$$[0]);
|
||||
++$$[0];
|
||||
check_idx(&$$, $$[0]);
|
||||
$$[$$[0]]=i;
|
||||
if(i==$5) break;
|
||||
}
|
||||
}
|
||||
| index ',' B_IDXNUM
|
||||
{
|
||||
check_idx(&$$, ++$$[0]);
|
||||
++$$[0];
|
||||
check_idx(&$$, $$[0]);
|
||||
$$[$$[0]]=$3;
|
||||
}
|
||||
;
|
||||
|
|
@ -520,12 +531,13 @@ index_nobracket: B_IDXNUM B_DOUBLEDOT B_IDXNUM B_DOUBLEDOT B_IDXNUM B_DOUBLEDOT
|
|||
/* start .. end .. offset .. repetitions */
|
||||
int r, i, sign, offset;
|
||||
sign = XSIGN($3-$1);
|
||||
$$=my_malloc(_ALLOC_ID_, INITIALIDXSIZE*sizeof(int));
|
||||
$$=my_malloc(_ALLOC_ID_, idxsize*sizeof(int));
|
||||
$$[0]=0;
|
||||
offset = 0;
|
||||
for(r=0; r < $7; r++) {
|
||||
for(i = $1;; i += sign) {
|
||||
check_idx(&$$,++$$[0]);
|
||||
++$$[0];
|
||||
check_idx(&$$, $$[0]);
|
||||
$$[$$[0]] = i + offset;
|
||||
if(i == $3) break;
|
||||
}
|
||||
|
|
@ -538,11 +550,12 @@ index_nobracket: B_IDXNUM B_DOUBLEDOT B_IDXNUM B_DOUBLEDOT B_IDXNUM B_DOUBLEDOT
|
|||
int sign;
|
||||
|
||||
sign = XSIGN($3-$1);
|
||||
$$=my_malloc(_ALLOC_ID_, INITIALIDXSIZE*sizeof(int));
|
||||
$$=my_malloc(_ALLOC_ID_, idxsize*sizeof(int));
|
||||
$$[0]=0;
|
||||
for(i=$1;;i+=sign*$5)
|
||||
{
|
||||
check_idx(&$$,++$$[0]);
|
||||
++$$[0];
|
||||
check_idx(&$$,$$[0]);
|
||||
$$[$$[0]]=i;
|
||||
|
||||
if(sign==1 && i + $5 > $3) break;
|
||||
|
|
@ -552,11 +565,12 @@ index_nobracket: B_IDXNUM B_DOUBLEDOT B_IDXNUM B_DOUBLEDOT B_IDXNUM B_DOUBLEDOT
|
|||
| B_IDXNUM B_DOUBLEDOT B_IDXNUM
|
||||
{
|
||||
int i;
|
||||
$$=my_malloc(_ALLOC_ID_, INITIALIDXSIZE*sizeof(int));
|
||||
$$=my_malloc(_ALLOC_ID_, idxsize*sizeof(int));
|
||||
$$[0]=0;
|
||||
for(i=$1;;i+=XSIGN($3-$1))
|
||||
{
|
||||
check_idx(&$$,++$$[0]);
|
||||
++$$[0];
|
||||
check_idx(&$$, $$[0]);
|
||||
$$[$$[0]]=i;
|
||||
if(i==$3) break;
|
||||
}
|
||||
|
|
@ -569,7 +583,8 @@ index_nobracket: B_IDXNUM B_DOUBLEDOT B_IDXNUM B_DOUBLEDOT B_IDXNUM B_DOUBLEDOT
|
|||
offset = 0;
|
||||
for(r=0; r < $9; r++) {
|
||||
for(i = $3;; i += sign) {
|
||||
check_idx(&$$,++$$[0]);
|
||||
++$$[0];
|
||||
check_idx(&$$, $$[0]);
|
||||
$$[$$[0]] = i + offset;
|
||||
if(i == $5) break;
|
||||
}
|
||||
|
|
@ -584,7 +599,8 @@ index_nobracket: B_IDXNUM B_DOUBLEDOT B_IDXNUM B_DOUBLEDOT B_IDXNUM B_DOUBLEDOT
|
|||
sign = XSIGN($5-$3);
|
||||
for(i=$3;;i+=sign*$7)
|
||||
{
|
||||
check_idx(&$$, ++$$[0]);
|
||||
++$$[0];
|
||||
check_idx(&$$, $$[0]);
|
||||
$$[$$[0]]=i;
|
||||
if(sign==1 && i + $7 > $5) break;
|
||||
if(sign==-1 && i - $7 < $5) break;
|
||||
|
|
@ -595,14 +611,16 @@ index_nobracket: B_IDXNUM B_DOUBLEDOT B_IDXNUM B_DOUBLEDOT B_IDXNUM B_DOUBLEDOT
|
|||
int i;
|
||||
for(i=$3;;i+=XSIGN($5-$3))
|
||||
{
|
||||
check_idx(&$$, ++$$[0]);
|
||||
++$$[0];
|
||||
check_idx(&$$, $$[0]);
|
||||
$$[$$[0]]=i;
|
||||
if(i==$5) break;
|
||||
}
|
||||
}
|
||||
| index_nobracket ',' B_IDXNUM
|
||||
{
|
||||
check_idx(&$$, ++$$[0]);
|
||||
++$$[0];
|
||||
check_idx(&$$, $$[0]);
|
||||
$$[$$[0]]=$3;
|
||||
}
|
||||
%%
|
||||
|
|
|
|||
|
|
@ -1213,8 +1213,8 @@ static void send_net_to_bespice(int simtype, const char *node)
|
|||
c = get_color(xctx->hilight_color);
|
||||
sprintf(color_str, "#%02x%02x%02x", xctx->xcolor_array[c].red>>8, xctx->xcolor_array[c].green>>8,
|
||||
xctx->xcolor_array[c].blue>>8);
|
||||
expanded_tok = expandlabel(tok, &tok_mult);
|
||||
my_strdup2(_ALLOC_ID_, &p, xctx->sch_path[xctx->currsch]+1);
|
||||
expanded_tok = expandlabel(tok, &tok_mult);
|
||||
for(k=1; k<=tok_mult; ++k) {
|
||||
my_strdup(_ALLOC_ID_, &t, find_nth(expanded_tok, ",", "", 0, k));
|
||||
/* bespice command syntax :
|
||||
|
|
@ -1282,12 +1282,12 @@ static void send_net_to_gaw(int simtype, const char *node)
|
|||
c = get_color(xctx->hilight_color);
|
||||
sprintf(color_str, "%02x%02x%02x", xctx->xcolor_array[c].red>>8, xctx->xcolor_array[c].green>>8,
|
||||
xctx->xcolor_array[c].blue>>8);
|
||||
expanded_tok = expandlabel(tok, &tok_mult);
|
||||
tcleval("setup_tcp_gaw");
|
||||
if(tclresult()[0] == '0') return;
|
||||
my_strdup2(_ALLOC_ID_, &p, xctx->sch_path[xctx->currsch]+1);
|
||||
path = p;
|
||||
strtolower(path);
|
||||
expanded_tok = expandlabel(tok, &tok_mult);
|
||||
for(k=1; k<=tok_mult; ++k) {
|
||||
my_strdup(_ALLOC_ID_, &t, find_nth(expanded_tok, ",", "", 0, k));
|
||||
strtolower(t);
|
||||
|
|
@ -1320,8 +1320,8 @@ static void send_current_to_bespice(int simtype, const char *node)
|
|||
c = get_color(xctx->hilight_color);
|
||||
sprintf(color_str, "#%02x%02x%02x", xctx->xcolor_array[c].red>>8, xctx->xcolor_array[c].green>>8,
|
||||
xctx->xcolor_array[c].blue>>8);
|
||||
expanded_tok = expandlabel(tok, &tok_mult);
|
||||
my_strdup2(_ALLOC_ID_, &p, xctx->sch_path[xctx->currsch]+1);
|
||||
expanded_tok = expandlabel(tok, &tok_mult);
|
||||
for(k=1; k<=tok_mult; ++k) {
|
||||
my_strdup(_ALLOC_ID_, &t, find_nth(expanded_tok, ",", "", 0, k));
|
||||
/* bespice command syntax :
|
||||
|
|
@ -1350,7 +1350,6 @@ static void send_current_to_graph(char **s, int simtype, const char *node)
|
|||
if(!node || !node[0]) return;
|
||||
tok = node;
|
||||
c = get_color(xctx->hilight_color);
|
||||
expanded_tok = expandlabel(tok, &tok_mult);
|
||||
my_strdup2(_ALLOC_ID_, &p, xctx->sch_path[xctx->currsch]+1);
|
||||
path = p;
|
||||
start_level = sch_waves_loaded();
|
||||
|
|
@ -1364,6 +1363,7 @@ static void send_current_to_graph(char **s, int simtype, const char *node)
|
|||
}
|
||||
strtolower(path);
|
||||
there_is_hierarchy = (strstr(path, ".") != NULL);
|
||||
expanded_tok = expandlabel(tok, &tok_mult);
|
||||
for(k=1; k<=tok_mult; ++k) {
|
||||
my_strdup(_ALLOC_ID_, &t, find_nth(expanded_tok, ",", "", 0, k));
|
||||
strtolower(t);
|
||||
|
|
@ -1397,13 +1397,13 @@ static void send_current_to_gaw(int simtype, const char *node)
|
|||
c = get_color(xctx->hilight_color);
|
||||
sprintf(color_str, "%02x%02x%02x", xctx->xcolor_array[c].red>>8, xctx->xcolor_array[c].green>>8,
|
||||
xctx->xcolor_array[c].blue>>8);
|
||||
expanded_tok = expandlabel(tok, &tok_mult);
|
||||
tcleval("setup_tcp_gaw");
|
||||
if(tclresult()[0] == '0') return;
|
||||
my_strdup2(_ALLOC_ID_, &p, xctx->sch_path[xctx->currsch]+1);
|
||||
path = p;
|
||||
strtolower(path);
|
||||
there_is_hierarchy = (xctx->currsch > 0);
|
||||
expanded_tok = expandlabel(tok, &tok_mult);
|
||||
for(k=1; k<=tok_mult; ++k) {
|
||||
my_strdup(_ALLOC_ID_, &t, find_nth(expanded_tok, ",", "", 0, k));
|
||||
strtolower(t);
|
||||
|
|
|
|||
|
|
@ -69,6 +69,8 @@ void clear_expandlabel_data(void)
|
|||
my_free(_ALLOC_ID_, &dest_string.str);
|
||||
}
|
||||
|
||||
void reset_lexer(void);
|
||||
|
||||
static void str_char_replace(char s[], char chr, char repl_chr)
|
||||
{
|
||||
int i=0;
|
||||
|
|
@ -95,6 +97,8 @@ void parse(const char *s)
|
|||
const char *expandlabel(const char *s, int *m)
|
||||
{
|
||||
YY_BUFFER_STATE buf;
|
||||
int mm;
|
||||
if(m == NULL) m = &mm;
|
||||
my_free(_ALLOC_ID_, &dest_string.str); /* 30102004 delete 'memory' of previous execution */
|
||||
|
||||
if(!s) {
|
||||
|
|
@ -124,9 +128,12 @@ const char *expandlabel(const char *s, int *m)
|
|||
my_snprintf(cmd, l,
|
||||
"tk_messageBox -icon error -type ok -parent [xschem get topwindow] "
|
||||
"-message {Syntax error in identifier expansion: %s\nschematic:\n%s}", s, xctx->sch[xctx->currsch]);
|
||||
if(has_x) tcleval(cmd);
|
||||
if(has_x) {
|
||||
xctx->semaphore += 3;
|
||||
tcleval(cmd);
|
||||
xctx->semaphore -= 3;
|
||||
}
|
||||
my_free(_ALLOC_ID_, &cmd);
|
||||
|
||||
}
|
||||
if(parselabel_debug >= 3)
|
||||
fprintf(errfp, "expandlabel(): returning %s from %s mult=%d\n",dest_string.str, s, dest_string.m);
|
||||
|
|
@ -138,7 +145,9 @@ const char *expandlabel(const char *s, int *m)
|
|||
}
|
||||
} else {
|
||||
*m=-1;
|
||||
dest_string.m = -1;
|
||||
my_strdup2(_ALLOC_ID_, &dest_string.str, s);
|
||||
reset_lexer();
|
||||
}
|
||||
return dest_string.str;
|
||||
}
|
||||
|
|
@ -336,3 +345,9 @@ ID_EXT_PARENTHESIS ([-~"#+/=_a-zA-Z][-#!@\\/:.=_+a-zA-Z0-9]*\([-~"#!@\\/:.=_+a-z
|
|||
}
|
||||
%%
|
||||
|
||||
|
||||
void reset_lexer(void)
|
||||
{
|
||||
YY_FLUSH_BUFFER;
|
||||
BEGIN(INITIAL);
|
||||
}
|
||||
|
|
|
|||
16
src/token.c
16
src/token.c
|
|
@ -680,7 +680,7 @@ int get_last_used_index(const char *old_basename, const char *brkt)
|
|||
* action can be XINSERT or XDELETE to insert or remove items */
|
||||
void hash_names(int inst, int action)
|
||||
{
|
||||
int i, xmult, start, stop;
|
||||
int i, start, stop;
|
||||
char *upinst = NULL;
|
||||
char *upinst_ptr, *upinst_state, *single_name;
|
||||
dbg(1, "hash_names(): inst=%d, action=%d\n", inst, action);
|
||||
|
|
@ -699,7 +699,7 @@ void hash_names(int inst, int action)
|
|||
start, stop, xctx->inst[inst].instname? xctx->inst[inst].instname : "<NULL>");
|
||||
for(i = start; i < stop; ++i) {
|
||||
if(xctx->inst[i].instname && xctx->inst[i].instname[0]) {
|
||||
my_strdup(_ALLOC_ID_, &upinst, expandlabel(xctx->inst[i].instname, &xmult));
|
||||
my_strdup(_ALLOC_ID_, &upinst, expandlabel(xctx->inst[i].instname, NULL));
|
||||
strtoupper(upinst);
|
||||
|
||||
upinst_ptr = upinst;
|
||||
|
|
@ -724,11 +724,11 @@ void hash_names(int inst, int action)
|
|||
|
||||
static int name_is_used(char *name, const char *old_basename, const char *brkt, int q)
|
||||
{
|
||||
int xmult, used = -1;
|
||||
int used = -1;
|
||||
char *upinst = NULL;
|
||||
char *upinst_ptr, *upinst_state, *single_name;
|
||||
Int_hashentry *entry;
|
||||
my_strdup(_ALLOC_ID_, &upinst, expandlabel(name, &xmult));
|
||||
my_strdup(_ALLOC_ID_, &upinst, expandlabel(name, NULL));
|
||||
strtoupper(upinst);
|
||||
upinst_ptr = upinst;
|
||||
while( (single_name = my_strtok_r(upinst_ptr, ",", "", 0, &upinst_state)) ) {
|
||||
|
|
@ -977,7 +977,7 @@ static void print_vhdl_primitive(FILE *fd, int inst) /* netlist primitives, 200
|
|||
dbg(1, "print_vhdl_primitive(): name=%s, format=%s xctx->netlist_count=%d\n",name,format, xctx->netlist_count);
|
||||
|
||||
fprintf(fd, "---- start primitive ");
|
||||
lab=expandlabel(name, &tmp);
|
||||
expandlabel(name, &tmp);
|
||||
fprintf(fd, "%d\n",tmp);
|
||||
/* begin parsing format string */
|
||||
while(1)
|
||||
|
|
@ -1876,7 +1876,7 @@ void print_verilog_param(FILE *fd, int symbol)
|
|||
|
||||
void print_tedax_subckt(FILE *fd, int symbol)
|
||||
{
|
||||
int i=0, multip;
|
||||
int i=0;
|
||||
int no_of_pins=0;
|
||||
const char *str_ptr=NULL;
|
||||
|
||||
|
|
@ -1886,7 +1886,7 @@ void print_tedax_subckt(FILE *fd, int symbol)
|
|||
{
|
||||
if(strboolcmp(get_tok_value(xctx->sym[symbol].rect[PINLAYER][i].prop_ptr,"tedax_ignore",0), "true")) {
|
||||
str_ptr=
|
||||
expandlabel(get_tok_value(xctx->sym[symbol].rect[PINLAYER][i].prop_ptr,"name",0), &multip);
|
||||
expandlabel(get_tok_value(xctx->sym[symbol].rect[PINLAYER][i].prop_ptr,"name",0), NULL);
|
||||
fprintf(fd, "%s ", str_ptr);
|
||||
}
|
||||
}
|
||||
|
|
@ -3521,7 +3521,7 @@ static void print_verilog_primitive(FILE *fd, int inst) /* netlist switch level
|
|||
dbg(1, "print_verilog_primitive(): name=%s, format=%s xctx->netlist_count=%d\n",name,format, xctx->netlist_count);
|
||||
|
||||
fprintf(fd, "---- start primitive ");
|
||||
lab=expandlabel(name, &tmp);
|
||||
expandlabel(name, &tmp);
|
||||
fprintf(fd, "%d\n",tmp);
|
||||
/* begin parsing format string */
|
||||
while(1)
|
||||
|
|
|
|||
Loading…
Reference in New Issue