changed attribute text_n_size to text_size_n (for efficienty reasons), improved get_tok_val() (use strstr for quick return "" if no token found)

This commit is contained in:
stefan schippers 2023-12-03 23:11:36 +01:00
parent 28ed1351f1
commit b2aad10650
4 changed files with 18 additions and 12 deletions

View File

@ -127,7 +127,7 @@ name="mchanged_name" model=\"nmos\" w="20u" l="3u" m="10"
<p> A <kbd>hide=true</kbd> attribute will only display the symbol bounding box.</p>
<li><kbd>hide_texts</kbd></li>
<p> A <kbd>hide_texts=true</kbd> attribute will hide all symbol texts.</p>
<li><kbd>text_&lt;n&gt;_size</kbd></li>
<li><kbd>text_size_&lt;n&gt;</kbd></li>
<p> This attribute sets the size of symbol text item number <kbd>n</kbd>. This allows
instance based symbol text sizing.</p>
<li><kbd>highlight</kbd></li>

View File

@ -808,42 +808,42 @@ int set_inst_flags(xInstance *inst)
my_strdup2(_ALLOC_ID_, &(inst->lab), get_tok_value(inst->prop_ptr,"lab",0));
}
}
if(!strboolcmp(get_tok_value(inst->prop_ptr,"hide",0), "true"))
inst->flags |= HIDE_INST;
if(!strboolcmp(get_tok_value(inst->prop_ptr,"hide_texts",0), "true"))
inst->flags |= HIDE_SYMBOL_TEXTS;
ptr = get_tok_value(inst->prop_ptr,"spice_ignore",0);
if(!strcmp(ptr, "short"))
inst->flags |= SPICE_SHORT;
else if(!strboolcmp(ptr, "true") || !strcmp(ptr, "open"))
inst->flags |= SPICE_IGNORE;
ptr = get_tok_value(inst->prop_ptr,"verilog_ignore",0);
if(!strcmp(ptr, "short"))
inst->flags |= VERILOG_SHORT;
else if(!strboolcmp(ptr, "true") || !strcmp(ptr, "open"))
inst->flags |= VERILOG_IGNORE;
ptr = get_tok_value(inst->prop_ptr,"vhdl_ignore",0);
if(!strcmp(ptr, "short"))
inst->flags |= VHDL_SHORT;
else if(!strboolcmp(ptr, "true") || !strcmp(ptr, "open"))
inst->flags |= VHDL_IGNORE;
ptr = get_tok_value(inst->prop_ptr,"tedax_ignore",0);
if(!strcmp(ptr, "short"))
inst->flags |= TEDAX_SHORT;
else if(!strboolcmp(ptr, "true") || !strcmp(ptr, "open"))
inst->flags |= TEDAX_IGNORE;
ptr = get_tok_value(inst->prop_ptr,"lvs_ignore",0);
if(!strcmp(ptr, "short"))
inst->flags |= LVS_IGNORE_SHORT;
else if(!strboolcmp(ptr, "true") || !strcmp(ptr, "open"))
inst->flags |= LVS_IGNORE_OPEN;
if(!strboolcmp(get_tok_value(inst->prop_ptr,"hide_texts",0), "true"))
inst->flags |= HIDE_SYMBOL_TEXTS;
if(!strboolcmp(get_tok_value(inst->prop_ptr,"highlight",0), "true"))
inst->flags |= HILIGHT_CONN;

View File

@ -420,17 +420,21 @@ void get_sym_text_size(int inst, int text_n, double *xscale, double *yscale)
const char *ts;
double size;
int sym_n = xctx->inst[inst].ptr;
xText *txtptr;
if(sym_n >= 0 && xctx->sym[sym_n].texts > text_n) {
txtptr = &(xctx->sym[sym_n].text[text_n]);
my_snprintf(attr, S(attr), "text_%d_size", text_n);
ts = get_tok_value(xctx->inst[inst].prop_ptr, attr, 0);
if(strstr(xctx->inst[inst].prop_ptr, "text_size_")) {
my_snprintf(attr, S(attr), "text_size_%d", text_n);
ts = get_tok_value(xctx->inst[inst].prop_ptr, attr, 0);
} else {
xctx->tok_size = 0;
}
if(xctx->tok_size) {
size = atof(ts);
*xscale = size;
*yscale = size;
} else {
xText *txtptr;
txtptr = &(xctx->sym[sym_n].text[text_n]);
*xscale = txtptr->xscale;
*yscale = txtptr->yscale;
}

View File

@ -440,6 +440,7 @@ const char *get_tok_value(const char *s,const char *tok, int with_quotes)
static char *translated_tok = NULL;
xctx->tok_size = 0;
if(s==NULL) {
if(tok == NULL) {
my_free(_ALLOC_ID_, &result);
@ -450,6 +451,7 @@ const char *get_tok_value(const char *s,const char *tok, int with_quotes)
}
return "";
}
if(!tok || !strstr(s, tok)) return "";
/* dbg(0, "get_tok_value(): looking for <%s> in <%.30s>\n",tok,s); */
if( size == 0 ) {
sizetok = size = CADCHUNKALLOC;