From cb652adb5f5b5d782ca855eec2ad89508c29991e Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Fri, 21 Oct 2022 17:48:54 +0200 Subject: [PATCH] skip NULL or empty texts in draw_symbol, translate2() skip @@... and @#... tokens (return empty) --- src/draw.c | 4 ++-- src/save.c | 6 +++--- src/token.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/draw.c b/src/draw.c index 2d70c396..32cf2937 100644 --- a/src/draw.c +++ b/src/draw.c @@ -555,7 +555,7 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, for(j=0;j< symptr->texts;j++) { text = symptr->text[j]; - if(text.xscale*FONTWIDTH*xctx->mooz<1) continue; + if(!text.txt_ptr || !text.txt_ptr[0] || text.xscale*FONTWIDTH*xctx->mooz<1) continue; if(!xctx->show_hidden_texts && (text.flags & HIDE_TEXT)) continue; if( hide && text.txt_ptr && strcmp(text.txt_ptr, "@symname") && strcmp(text.txt_ptr, "@name") ) continue; txtptr= translate(n, text.txt_ptr); @@ -715,8 +715,8 @@ void draw_temp_symbol(int what, GC gc, int n,int layer,short tmp_flip, short rot for(j=0;j< symptr->texts;j++) { text = symptr->text[j]; + if(!text.txt_ptr || !text.txt_ptr[0] || text.xscale*FONTWIDTH*xctx->mooz<1) continue; if(!xctx->show_hidden_texts && (text.flags & HIDE_TEXT)) continue; - if(text.xscale*FONTWIDTH*xctx->mooz<1) continue; txtptr= translate(n, text.txt_ptr); ROTATION(rot, flip, 0.0,0.0,text.x0,text.y0,x1,y1); #if HAS_CAIRO==1 diff --git a/src/save.c b/src/save.c index 379392d3..f8f50623 100644 --- a/src/save.c +++ b/src/save.c @@ -3128,10 +3128,10 @@ int load_sym_def(const char *name, FILE *embed_fd) const char* tmp = translate2(lcc, level, tt[i].txt_ptr); dbg(1, "l_s_d(): txt2: tt[i].txt_ptr=%s, i=%d\n", tt[i].txt_ptr, i); rot = lcc[level].rot; flip = lcc[level].flip; - if (tmp) my_strdup(651, &tt[i].txt_ptr, tmp); + my_strdup2(651, &tt[i].txt_ptr, tmp); dbg(1, "l_s_d(): txt3: tt[i].txt_ptr=%s, i=%d\n", tt[i].txt_ptr, i); /* allow annotation inside LCC instances. */ - if(tt[i].txt_ptr && !strcmp(tt[i].txt_ptr, "@spice_get_voltage")) { + if(!strcmp(tt[i].txt_ptr, "@spice_get_voltage")) { /* prop_ptr is the attribute string of last loaded LCC component */ const char *lab; size_t new_size = 0; @@ -3152,7 +3152,7 @@ int load_sym_def(const char *name, FILE *embed_fd) my_free(1589, &path); dbg(1, " --> tt[i].txt_ptr=%s\n", tt[i].txt_ptr); } - if(tt[i].txt_ptr && !strcmp(tt[i].txt_ptr, "@spice_get_current")) { + if(!strcmp(tt[i].txt_ptr, "@spice_get_current")) { /* prop_ptr is the attribute string of last loaded LCC component */ const char *dev; size_t new_size = 0; diff --git a/src/token.c b/src/token.c index e1464d30..95f92558 100644 --- a/src/token.c +++ b/src/token.c @@ -3431,12 +3431,12 @@ const char *translate2(Lcc *lcc, int level, char* s) token[token_pos] = '\0'; token_pos = 0; - dbg(1, "translate2(): lcc[%d].prop_ptr=%s\n", level, lcc[level].prop_ptr); + dbg(1, "translate2(): lcc[%d].prop_ptr=%s token=%s\n", level, lcc[level].prop_ptr, token); /* if spiceprefix==0 and token == @spiceprefix then set empty value */ if(!tclgetboolvar("spiceprefix") && !strcmp(token, "@spiceprefix")) { if(value) my_free(1069, &value); xctx->tok_size = 0; - } else if(!strncmp(token, "@#",2)) { /* get rid of pin attribute info */ + } else if(token[0] == '@' && (token[1] == '@' || token[1] == '#')) { /* get rid of pin attribute info */ if(value) my_free(1572, &value); xctx->tok_size = 0; } else {