Some more global state into Xctx
This commit is contained in:
parent
4687133b5f
commit
bcf8986314
|
|
@ -216,8 +216,6 @@ int pending_fullzoom=0;
|
||||||
double color_dim=0.0;
|
double color_dim=0.0;
|
||||||
int no_undo=0;
|
int no_undo=0;
|
||||||
int enable_drill=0; /* pass net hilights through components with 'propagate_to' property set on pins */
|
int enable_drill=0; /* pass net hilights through components with 'propagate_to' property set on pins */
|
||||||
size_t get_tok_value_size;
|
|
||||||
size_t get_tok_size;
|
|
||||||
int batch_mode = 0; /* no tcl console if set; batch mode */
|
int batch_mode = 0; /* no tcl console if set; batch mode */
|
||||||
int show_erc=1;
|
int show_erc=1;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -501,7 +501,7 @@ int search(const char *tok, const char *val, int sub, int sel)
|
||||||
str = xctx->inst[i].name;
|
str = xctx->inst[i].name;
|
||||||
} else if(!strncmp(tok,"cell::", 6)) { /* cell::xxx looks for xxx in global symbol attributes */
|
} 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));
|
my_strdup(142, &tmpname,get_tok_value((xctx->inst[i].ptr+ xctx->sym)->prop_ptr,tok+6,0));
|
||||||
has_token = get_tok_size;
|
has_token = xctx->get_tok_size;
|
||||||
if(tmpname) {
|
if(tmpname) {
|
||||||
str = tmpname;
|
str = tmpname;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -512,7 +512,7 @@ int search(const char *tok, const char *val, int sub, int sel)
|
||||||
str = xctx->inst[i].prop_ptr;
|
str = xctx->inst[i].prop_ptr;
|
||||||
} else {
|
} else {
|
||||||
str = get_tok_value(xctx->inst[i].prop_ptr, tok,0);
|
str = get_tok_value(xctx->inst[i].prop_ptr, tok,0);
|
||||||
has_token = get_tok_size;
|
has_token = xctx->get_tok_size;
|
||||||
}
|
}
|
||||||
dbg(1, "search(): inst=%d, tok=%s, val=%s \n", i,tok, str);
|
dbg(1, "search(): inst=%d, tok=%s, val=%s \n", i,tok, str);
|
||||||
|
|
||||||
|
|
@ -552,7 +552,7 @@ int search(const char *tok, const char *val, int sub, int sel)
|
||||||
}
|
}
|
||||||
for(i=0;i<xctx->wires;i++) {
|
for(i=0;i<xctx->wires;i++) {
|
||||||
str = get_tok_value(xctx->wire[i].prop_ptr, tok,0);
|
str = get_tok_value(xctx->wire[i].prop_ptr, tok,0);
|
||||||
if(get_tok_size ) {
|
if(xctx->get_tok_size ) {
|
||||||
#ifdef __unix__
|
#ifdef __unix__
|
||||||
if( (!regexec(&re, str,0 , NULL, 0) && !sub ) || /* 20071120 regex instead of strcmp */
|
if( (!regexec(&re, str,0 , NULL, 0) && !sub ) || /* 20071120 regex instead of strcmp */
|
||||||
( !strcmp(str, val) && sub ) )
|
( !strcmp(str, val) && sub ) )
|
||||||
|
|
@ -581,7 +581,7 @@ int search(const char *tok, const char *val, int sub, int sel)
|
||||||
if(!sel) propagate_hilights(1, 0, XINSERT_NOREPLACE);
|
if(!sel) propagate_hilights(1, 0, XINSERT_NOREPLACE);
|
||||||
if(sel) for(c = 0; c < cadlayers; c++) for(i=0;i<xctx->lines[c];i++) {
|
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);
|
str = get_tok_value(xctx->line[c][i].prop_ptr, tok,0);
|
||||||
if(get_tok_size) {
|
if(xctx->get_tok_size) {
|
||||||
#ifdef __unix__
|
#ifdef __unix__
|
||||||
if( (!regexec(&re, str,0 , NULL, 0) && !sub ) ||
|
if( (!regexec(&re, str,0 , NULL, 0) && !sub ) ||
|
||||||
( !strcmp(str, val) && sub ))
|
( !strcmp(str, val) && sub ))
|
||||||
|
|
@ -607,7 +607,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++) {
|
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);
|
str = get_tok_value(xctx->rect[c][i].prop_ptr, tok,0);
|
||||||
if(get_tok_size) {
|
if(xctx->get_tok_size) {
|
||||||
#ifdef __unix__
|
#ifdef __unix__
|
||||||
if( (!regexec(&re, str,0 , NULL, 0) && !sub ) ||
|
if( (!regexec(&re, str,0 , NULL, 0) && !sub ) ||
|
||||||
( !strcmp(str, val) && sub ))
|
( !strcmp(str, val) && sub ))
|
||||||
|
|
|
||||||
|
|
@ -415,7 +415,7 @@ void write_xschem_file(FILE *fd)
|
||||||
|
|
||||||
if(xctx->schvhdlprop && !xctx->schsymbolprop) {
|
if(xctx->schvhdlprop && !xctx->schsymbolprop) {
|
||||||
get_tok_value(xctx->schvhdlprop,"type",0);
|
get_tok_value(xctx->schvhdlprop,"type",0);
|
||||||
ty = get_tok_size;
|
ty = xctx->get_tok_size;
|
||||||
if(ty && !strcmp(xctx->sch[xctx->currsch] + strlen(xctx->sch[xctx->currsch]) - 4,".sym") ) {
|
if(ty && !strcmp(xctx->sch[xctx->currsch] + strlen(xctx->sch[xctx->currsch]) - 4,".sym") ) {
|
||||||
fprintf(fd, "G {}\nK ");
|
fprintf(fd, "G {}\nK ");
|
||||||
save_ascii_string(xctx->schvhdlprop,fd);
|
save_ascii_string(xctx->schvhdlprop,fd);
|
||||||
|
|
@ -848,7 +848,7 @@ void read_xschem_file(FILE *fd)
|
||||||
if(xctx->schvhdlprop) {
|
if(xctx->schvhdlprop) {
|
||||||
char *str = xctx->sch[xctx->currsch];
|
char *str = xctx->sch[xctx->currsch];
|
||||||
get_tok_value(xctx->schvhdlprop, "type",0);
|
get_tok_value(xctx->schvhdlprop, "type",0);
|
||||||
ty = get_tok_size;
|
ty = xctx->get_tok_size;
|
||||||
if(!xctx->schsymbolprop && ty && !strcmp(str + strlen(str) - 4,".sym")) {
|
if(!xctx->schsymbolprop && ty && !strcmp(str + strlen(str) - 4,".sym")) {
|
||||||
str = xctx->schsymbolprop;
|
str = xctx->schsymbolprop;
|
||||||
xctx->schsymbolprop = xctx->schvhdlprop;
|
xctx->schsymbolprop = xctx->schvhdlprop;
|
||||||
|
|
|
||||||
|
|
@ -760,7 +760,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
||||||
{
|
{
|
||||||
char s[30];
|
char s[30];
|
||||||
cmd_found = 1;
|
cmd_found = 1;
|
||||||
my_snprintf(s, S(s), "%d", (int)get_tok_size);
|
my_snprintf(s, S(s), "%d", (int)xctx->get_tok_size);
|
||||||
Tcl_SetResult(interp, s, TCL_VOLATILE);
|
Tcl_SetResult(interp, s, TCL_VOLATILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
86
src/token.c
86
src/token.c
|
|
@ -357,7 +357,7 @@ int set_different_token(char **s,const char *new, const char *old, int object, i
|
||||||
token_pos=0;
|
token_pos=0;
|
||||||
}
|
}
|
||||||
get_tok_value(new,token,1);
|
get_tok_value(new,token,1);
|
||||||
if(get_tok_size == 0 ) {
|
if(xctx->get_tok_size == 0 ) {
|
||||||
mod=1;
|
mod=1;
|
||||||
my_strdup(443, s, subst_token(*s, token, NULL) );
|
my_strdup(443, s, subst_token(*s, token, NULL) );
|
||||||
}
|
}
|
||||||
|
|
@ -457,10 +457,10 @@ const char *get_tok_value(const char *s,const char *tok, int with_quotes)
|
||||||
my_free(976, &result);
|
my_free(976, &result);
|
||||||
my_free(977, &token);
|
my_free(977, &token);
|
||||||
size = sizetok = 0;
|
size = sizetok = 0;
|
||||||
get_tok_value_size = get_tok_size = 0;
|
xctx->get_tok_value_size = xctx->get_tok_size = 0;
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
get_tok_value_size = get_tok_size = 0;
|
xctx->get_tok_value_size = xctx->get_tok_size = 0;
|
||||||
dbg(2, "get_tok_value(): looking for <%s> in <%s>\n",tok,s);
|
dbg(2, "get_tok_value(): looking for <%s> in <%s>\n",tok,s);
|
||||||
if( size == 0 ) {
|
if( size == 0 ) {
|
||||||
sizetok = size = CADCHUNKALLOC;
|
sizetok = size = CADCHUNKALLOC;
|
||||||
|
|
@ -488,9 +488,9 @@ const char *get_tok_value(const char *s,const char *tok, int with_quotes)
|
||||||
if(!escape) quote=!quote;
|
if(!escape) quote=!quote;
|
||||||
}
|
}
|
||||||
if(state==TOK_TOKEN) {
|
if(state==TOK_TOKEN) {
|
||||||
if(!cmp) { /* previous token matched search and was without value, return get_tok_size */
|
if(!cmp) { /* previous token matched search and was without value, return xctx->get_tok_size */
|
||||||
result[0] = '\0';
|
result[0] = '\0';
|
||||||
get_tok_value_size = 0;
|
xctx->get_tok_value_size = 0;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if(with_quotes || escape || (c != '\\' && c != '"')) token[token_pos++]=c;
|
if(with_quotes || escape || (c != '\\' && c != '"')) token[token_pos++]=c;
|
||||||
|
|
@ -501,7 +501,7 @@ const char *get_tok_value(const char *s,const char *tok, int with_quotes)
|
||||||
token[token_pos] = '\0';
|
token[token_pos] = '\0';
|
||||||
if( !(cmp = strcmp(token,tok)) ) {
|
if( !(cmp = strcmp(token,tok)) ) {
|
||||||
/* report back also token size, useful to check if requested token exists */
|
/* report back also token size, useful to check if requested token exists */
|
||||||
get_tok_size = token_pos;
|
xctx->get_tok_size = token_pos;
|
||||||
}
|
}
|
||||||
dbg(2, "get_tok_value(): token=%s\n", token);
|
dbg(2, "get_tok_value(): token=%s\n", token);
|
||||||
token_pos=0;
|
token_pos=0;
|
||||||
|
|
@ -509,7 +509,7 @@ const char *get_tok_value(const char *s,const char *tok, int with_quotes)
|
||||||
} else if(state==TOK_END) {
|
} else if(state==TOK_END) {
|
||||||
result[value_pos]='\0';
|
result[value_pos]='\0';
|
||||||
if( !cmp ) {
|
if( !cmp ) {
|
||||||
get_tok_value_size = value_pos; /* return also size so to avoid using strlen */
|
xctx->get_tok_value_size = value_pos; /* return also size so to avoid using strlen */
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
value_pos=0;
|
value_pos=0;
|
||||||
|
|
@ -518,8 +518,8 @@ const char *get_tok_value(const char *s,const char *tok, int with_quotes)
|
||||||
escape = (c=='\\' && !escape);
|
escape = (c=='\\' && !escape);
|
||||||
if(c=='\0') {
|
if(c=='\0') {
|
||||||
result[0]='\0';
|
result[0]='\0';
|
||||||
get_tok_size = 0;
|
xctx->get_tok_size = 0;
|
||||||
get_tok_value_size = 0; /* return also size so to avoid using strlen */
|
xctx->get_tok_value_size = 0; /* return also size so to avoid using strlen */
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -630,19 +630,19 @@ char *get_pin_attr_from_inst(int inst, int pin, const char *attr)
|
||||||
if(str[0]) {
|
if(str[0]) {
|
||||||
attr_size = strlen(attr);
|
attr_size = strlen(attr);
|
||||||
my_strdup(498, &pinname, str);
|
my_strdup(498, &pinname, str);
|
||||||
pname =my_malloc(49, get_tok_value_size + attr_size + 30);
|
pname =my_malloc(49, xctx->get_tok_value_size + attr_size + 30);
|
||||||
my_snprintf(pname, get_tok_value_size + attr_size + 30, "%s(%s)", attr, pinname);
|
my_snprintf(pname, xctx->get_tok_value_size + attr_size + 30, "%s(%s)", attr, pinname);
|
||||||
my_free(981, &pinname);
|
my_free(981, &pinname);
|
||||||
str = get_tok_value(xctx->inst[inst].prop_ptr, pname, 0);
|
str = get_tok_value(xctx->inst[inst].prop_ptr, pname, 0);
|
||||||
my_free(982, &pname);
|
my_free(982, &pname);
|
||||||
if(get_tok_size) my_strdup2(51, &pin_attr_value, str);
|
if(xctx->get_tok_size) my_strdup2(51, &pin_attr_value, str);
|
||||||
else {
|
else {
|
||||||
pnumber = my_malloc(52, attr_size + 100);
|
pnumber = my_malloc(52, attr_size + 100);
|
||||||
my_snprintf(pnumber, attr_size + 100, "%s(%d)", attr, pin);
|
my_snprintf(pnumber, attr_size + 100, "%s(%d)", attr, pin);
|
||||||
str = get_tok_value(xctx->inst[inst].prop_ptr, pnumber, 0);
|
str = get_tok_value(xctx->inst[inst].prop_ptr, pnumber, 0);
|
||||||
dbg(1, "get_pin_attr_from_inst(): pnumber=%s\n", pnumber);
|
dbg(1, "get_pin_attr_from_inst(): pnumber=%s\n", pnumber);
|
||||||
my_free(983, &pnumber);
|
my_free(983, &pnumber);
|
||||||
if(get_tok_size) my_strdup2(40, &pin_attr_value, str);
|
if(xctx->get_tok_size) my_strdup2(40, &pin_attr_value, str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pin_attr_value; /* caller is responsible for freeing up storage for pin_attr_value */
|
return pin_attr_value; /* caller is responsible for freeing up storage for pin_attr_value */
|
||||||
|
|
@ -1053,7 +1053,7 @@ void print_vhdl_element(FILE *fd, int inst)
|
||||||
value[value_pos]='\0';
|
value[value_pos]='\0';
|
||||||
value_pos=0;
|
value_pos=0;
|
||||||
get_tok_value(template, token, 0);
|
get_tok_value(template, token, 0);
|
||||||
if(get_tok_size) {
|
if(xctx->get_tok_size) {
|
||||||
if(strcmp(token, "name") && value[0] != '\0') /* token has a value */
|
if(strcmp(token, "name") && value[0] != '\0') /* token has a value */
|
||||||
{
|
{
|
||||||
if(tmp == 0) {fprintf(fd, "generic map(\n");tmp++;tmp1=0;}
|
if(tmp == 0) {fprintf(fd, "generic map(\n");tmp++;tmp1=0;}
|
||||||
|
|
@ -1629,13 +1629,13 @@ void print_spice_element(FILE *fd, int inst)
|
||||||
dbg(1, "print_spice_element(): token: |%s|\n", token);
|
dbg(1, "print_spice_element(): token: |%s|\n", token);
|
||||||
value = get_tok_value(xctx->inst[inst].prop_ptr, token+1, 0);
|
value = get_tok_value(xctx->inst[inst].prop_ptr, token+1, 0);
|
||||||
if(!strcmp(token, "@spiceprefix")) {
|
if(!strcmp(token, "@spiceprefix")) {
|
||||||
spiceprefixtag = my_malloc(301, get_tok_value_size+22);
|
spiceprefixtag = my_malloc(301, xctx->get_tok_value_size+22);
|
||||||
my_snprintf(spiceprefixtag, get_tok_value_size+22, "**** spice_prefix %s\n", value);
|
my_snprintf(spiceprefixtag, xctx->get_tok_value_size+22, "**** spice_prefix %s\n", value);
|
||||||
value = spiceprefixtag;
|
value = spiceprefixtag;
|
||||||
}
|
}
|
||||||
/* get_tok_size==0 indicates that token(+1) does not exist in instance attributes */
|
/* xctx->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 (!xctx->get_tok_size) value=get_tok_value(template, token+1, 0);
|
||||||
token_exists = get_tok_size;
|
token_exists = xctx->get_tok_size;
|
||||||
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);
|
||||||
my_strdup2(466, &translatedvalue, value);
|
my_strdup2(466, &translatedvalue, value);
|
||||||
|
|
@ -1926,7 +1926,7 @@ void print_tedax_element(FILE *fd, int inst)
|
||||||
my_strdup2(500, &pinnumber,
|
my_strdup2(500, &pinnumber,
|
||||||
get_tok_value((xctx->inst[inst].ptr+ xctx->sym)->rect[PINLAYER][i].prop_ptr,"pinnumber",0));
|
get_tok_value((xctx->inst[inst].ptr+ xctx->sym)->rect[PINLAYER][i].prop_ptr,"pinnumber",0));
|
||||||
}
|
}
|
||||||
if(!get_tok_size) my_strdup(501, &pinnumber, "--UNDEF--");
|
if(!xctx->get_tok_size) my_strdup(501, &pinnumber, "--UNDEF--");
|
||||||
tmp = net_name(inst,i, &multip, 0, 1);
|
tmp = net_name(inst,i, &multip, 0, 1);
|
||||||
if(tmp && strcmp(tmp, "__UNCONNECTED_PIN__")) {
|
if(tmp && strcmp(tmp, "__UNCONNECTED_PIN__")) {
|
||||||
fprintf(fd, "conn %s %s %s %s %d\n",
|
fprintf(fd, "conn %s %s %s %s %d\n",
|
||||||
|
|
@ -2002,9 +2002,9 @@ void print_tedax_element(FILE *fd, int inst)
|
||||||
token_pos=0;
|
token_pos=0;
|
||||||
|
|
||||||
value = get_tok_value(xctx->inst[inst].prop_ptr, token+1, 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 */
|
/* xctx->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(!xctx->get_tok_size) value=get_tok_value(template, token+1, 0);
|
||||||
if(!get_tok_size && token[0] =='$') {
|
if(!xctx->get_tok_size && token[0] =='$') {
|
||||||
fputs(token + 1, fd);
|
fputs(token + 1, fd);
|
||||||
} else if(value[0]!='\0')
|
} else if(value[0]!='\0')
|
||||||
{
|
{
|
||||||
|
|
@ -2220,7 +2220,7 @@ void print_verilog_element(FILE *fd, int inst)
|
||||||
value[value_pos]='\0';
|
value[value_pos]='\0';
|
||||||
value_pos=0;
|
value_pos=0;
|
||||||
get_tok_value(template, token, 0);
|
get_tok_value(template, token, 0);
|
||||||
if(strcmp(token, "name") && get_tok_size) {
|
if(strcmp(token, "name") && xctx->get_tok_size) {
|
||||||
if(value[0] != '\0') /* token has a value */
|
if(value[0] != '\0') /* token has a value */
|
||||||
{
|
{
|
||||||
if(strcmp(token,"spice_ignore") && strcmp(token,"vhdl_ignore") && strcmp(token,"tedax_ignore")) {
|
if(strcmp(token,"spice_ignore") && strcmp(token,"vhdl_ignore") && strcmp(token,"tedax_ignore")) {
|
||||||
|
|
@ -2402,10 +2402,10 @@ void print_vhdl_primitive(FILE *fd, int inst) /* netlist primitives, 20071217 *
|
||||||
token_pos=0;
|
token_pos=0;
|
||||||
|
|
||||||
value = get_tok_value(xctx->inst[inst].prop_ptr, token+1, 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 */
|
/* xctx->get_tok_size==0 indicates that token(+1) does not exist in instance attributes */
|
||||||
if(!get_tok_size)
|
if(!xctx->get_tok_size)
|
||||||
value=get_tok_value(template, token+1, 0);
|
value=get_tok_value(template, token+1, 0);
|
||||||
if(!get_tok_size && token[0] =='$') {
|
if(!xctx->get_tok_size && token[0] =='$') {
|
||||||
fputs(token + 1, fd);
|
fputs(token + 1, fd);
|
||||||
} else if(value && value[0]!='\0')
|
} else if(value && value[0]!='\0')
|
||||||
{ /* instance names (name) and node labels (lab) go thru the expandlabel function. */
|
{ /* instance names (name) and node labels (lab) go thru the expandlabel function. */
|
||||||
|
|
@ -2576,10 +2576,10 @@ void print_verilog_primitive(FILE *fd, int inst) /* netlist switch level primiti
|
||||||
token_pos=0;
|
token_pos=0;
|
||||||
|
|
||||||
value = get_tok_value(xctx->inst[inst].prop_ptr, token+1, 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 */
|
/* xctx->get_tok_size==0 indicates that token(+1) does not exist in instance attributes */
|
||||||
if(!get_tok_size)
|
if(!xctx->get_tok_size)
|
||||||
value=get_tok_value(template, token+1, 0);
|
value=get_tok_value(template, token+1, 0);
|
||||||
if(!get_tok_size && token[0] =='$') {
|
if(!xctx->get_tok_size && token[0] =='$') {
|
||||||
fputs(token + 1, fd);
|
fputs(token + 1, fd);
|
||||||
} else if(value && value[0]!='\0') {
|
} else if(value && value[0]!='\0') {
|
||||||
/* instance names (name) and node labels (lab) go thru the expandlabel function. */
|
/* instance names (name) and node labels (lab) go thru the expandlabel function. */
|
||||||
|
|
@ -2783,13 +2783,13 @@ const char *translate(int inst, const char* s)
|
||||||
/* if spiceprefix==0 and token == @spiceprefix then set empty value */
|
/* if spiceprefix==0 and token == @spiceprefix then set empty value */
|
||||||
if(!spiceprefix && !strcmp(token, "@spiceprefix")) {
|
if(!spiceprefix && !strcmp(token, "@spiceprefix")) {
|
||||||
value = NULL;
|
value = NULL;
|
||||||
get_tok_size = 0;
|
xctx->get_tok_size = 0;
|
||||||
} else {
|
} else {
|
||||||
value = get_tok_value(xctx->inst[inst].prop_ptr, token+1, 0);
|
value = get_tok_value(xctx->inst[inst].prop_ptr, token+1, 0);
|
||||||
if(!get_tok_size) value=get_tok_value((xctx->inst[inst].ptr+ xctx->sym)->templ, token+1, 0);
|
if(!xctx->get_tok_size) value=get_tok_value((xctx->inst[inst].ptr+ xctx->sym)->templ, token+1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!get_tok_size && token[0] =='$') {
|
if(!xctx->get_tok_size && token[0] =='$') {
|
||||||
char *env = getenv(token + 1);
|
char *env = getenv(token + 1);
|
||||||
if(env) { /* do environment var substitution if no xschem definition for $token */
|
if(env) { /* do environment var substitution if no xschem definition for $token */
|
||||||
tmp = strlen(env);
|
tmp = strlen(env);
|
||||||
|
|
@ -2804,8 +2804,8 @@ const char *translate(int inst, const char* s)
|
||||||
result_pos+=tmp;
|
result_pos+=tmp;
|
||||||
}
|
}
|
||||||
token_pos = 0;
|
token_pos = 0;
|
||||||
if(get_tok_size) {
|
if(xctx->get_tok_size) {
|
||||||
tmp=get_tok_value_size; /* strlen(value); */
|
tmp=xctx->get_tok_value_size; /* strlen(value); */
|
||||||
STR_ALLOC(&result, tmp + result_pos, &size);
|
STR_ALLOC(&result, tmp + result_pos, &size);
|
||||||
memcpy(result+result_pos, value, tmp+1);
|
memcpy(result+result_pos, value, tmp+1);
|
||||||
result_pos+=tmp;
|
result_pos+=tmp;
|
||||||
|
|
@ -3060,30 +3060,30 @@ const char *translate2(struct Lcc *lcc, int level, char* s)
|
||||||
/* if spiceprefix==0 and token == @spiceprefix then set empty value */
|
/* if spiceprefix==0 and token == @spiceprefix then set empty value */
|
||||||
if(!spiceprefix && !strcmp(token, "@spiceprefix")) {
|
if(!spiceprefix && !strcmp(token, "@spiceprefix")) {
|
||||||
my_free(1069, &value1);
|
my_free(1069, &value1);
|
||||||
get_tok_size = 0;
|
xctx->get_tok_size = 0;
|
||||||
} else {
|
} else {
|
||||||
my_strdup2(332, &value1, get_tok_value(lcc[level].prop_ptr, token + 1, 0));
|
my_strdup2(332, &value1, get_tok_value(lcc[level].prop_ptr, token + 1, 0));
|
||||||
}
|
}
|
||||||
value = "";
|
value = "";
|
||||||
if(get_tok_size) {
|
if(xctx->get_tok_size) {
|
||||||
value = value1;
|
value = value1;
|
||||||
i = level;
|
i = level;
|
||||||
/* recursive substitution of value using parent level prop_str attributes */
|
/* recursive substitution of value using parent level prop_str attributes */
|
||||||
while(i > 1) {
|
while(i > 1) {
|
||||||
save_tok_size = get_tok_size;
|
save_tok_size = xctx->get_tok_size;
|
||||||
save_value_size = get_tok_value_size;
|
save_value_size = xctx->get_tok_value_size;
|
||||||
my_strdup2(440, &value2, get_tok_value(lcc[i-1].prop_ptr, value, 0));
|
my_strdup2(440, &value2, get_tok_value(lcc[i-1].prop_ptr, value, 0));
|
||||||
if(get_tok_size && value2[0]) {
|
if(xctx->get_tok_size && value2[0]) {
|
||||||
value = value2;
|
value = value2;
|
||||||
} else {
|
} else {
|
||||||
/* restore last successful get_tok_value() size parameters */
|
/* restore last successful get_tok_value() size parameters */
|
||||||
get_tok_size = save_tok_size;
|
xctx->get_tok_size = save_tok_size;
|
||||||
get_tok_value_size = save_value_size;
|
xctx->get_tok_value_size = save_value_size;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
tmp = get_tok_value_size; /* strlen(value); */
|
tmp = xctx->get_tok_value_size; /* strlen(value); */
|
||||||
STR_ALLOC(&result, tmp + 1 + result_pos, &size); /* +1 to add leading '$' */
|
STR_ALLOC(&result, tmp + 1 + result_pos, &size); /* +1 to add leading '$' */
|
||||||
/* prefix substituted token with a '$' so it will be recognized by translate()
|
/* prefix substituted token with a '$' so it will be recognized by translate()
|
||||||
* for last level translation with instance placement prop_ptr attributes at
|
* for last level translation with instance placement prop_ptr attributes at
|
||||||
|
|
|
||||||
|
|
@ -409,6 +409,8 @@ void alloc_xschem_data()
|
||||||
xctx->prep_hash_wires = 0;
|
xctx->prep_hash_wires = 0;
|
||||||
xctx->modified = 0;
|
xctx->modified = 0;
|
||||||
xctx->semaphore = 0;
|
xctx->semaphore = 0;
|
||||||
|
xctx->get_tok_size = 0;
|
||||||
|
xctx->get_tok_value_size = 0;
|
||||||
xctx->netlist_name[0] = '\0';
|
xctx->netlist_name[0] = '\0';
|
||||||
xctx->current_dirname[0] = '\0';
|
xctx->current_dirname[0] = '\0';
|
||||||
for(i = 0; i < NBOXES; i++) {
|
for(i = 0; i < NBOXES; i++) {
|
||||||
|
|
@ -572,6 +574,7 @@ void xwin_exit(void)
|
||||||
dbg(1, "xwin_exit(): clearing drawing data structures\n");
|
dbg(1, "xwin_exit(): clearing drawing data structures\n");
|
||||||
clear_drawing();
|
clear_drawing();
|
||||||
remove_symbols();
|
remove_symbols();
|
||||||
|
get_tok_value(NULL, NULL, 0); /* clear static data in function */
|
||||||
free_xschem_data();
|
free_xschem_data();
|
||||||
|
|
||||||
/* global context - graphic preferences/settings */
|
/* global context - graphic preferences/settings */
|
||||||
|
|
@ -589,7 +592,6 @@ void xwin_exit(void)
|
||||||
my_free(1138, &tcl_command);
|
my_free(1138, &tcl_command);
|
||||||
clear_expandlabel_data();
|
clear_expandlabel_data();
|
||||||
get_sym_template(NULL, NULL); /* clear static data in function */
|
get_sym_template(NULL, NULL); /* clear static data in function */
|
||||||
get_tok_value(NULL, NULL, 0); /* clear static data in function */
|
|
||||||
list_tokens(NULL, 0); /* clear static data in function */
|
list_tokens(NULL, 0); /* clear static data in function */
|
||||||
translate(0, NULL); /* clear static data in function */
|
translate(0, NULL); /* clear static data in function */
|
||||||
translate2(NULL, 0, NULL); /* clear static data in function */
|
translate2(NULL, 0, NULL); /* clear static data in function */
|
||||||
|
|
|
||||||
|
|
@ -536,6 +536,8 @@ typedef struct {
|
||||||
int prep_hash_wires;
|
int prep_hash_wires;
|
||||||
int modified;
|
int modified;
|
||||||
int semaphore;
|
int semaphore;
|
||||||
|
int get_tok_size;
|
||||||
|
int get_tok_value_size;
|
||||||
char netlist_name[PATH_MAX];
|
char netlist_name[PATH_MAX];
|
||||||
char current_dirname[PATH_MAX];
|
char current_dirname[PATH_MAX];
|
||||||
struct instpinentry *instpintable[NBOXES][NBOXES];
|
struct instpinentry *instpintable[NBOXES][NBOXES];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue