We now remove all quotes from tokens after generating the parse tree in

plot, write, print lines if they look like V("...")
This commit is contained in:
Holger Vogt 2021-11-05 12:01:01 +01:00
parent 028515cc22
commit e4e8bc53b6
1 changed files with 3 additions and 20 deletions

View File

@ -107,7 +107,6 @@ struct pnode* ft_getpnames_quotes(wordlist* wl, bool check)
char* tmpstr; char* tmpstr;
char* nsz = tmpstr = stripWhiteSpacesInsideParens(sz); char* nsz = tmpstr = stripWhiteSpacesInsideParens(sz);
DS_CREATE(ds1, 100); /* the new name string*/ DS_CREATE(ds1, 100); /* the new name string*/
DS_CREATE(dsquote, 100); /* only the quoted strings*/
/* put double quotes around tokens which start with number chars or include a math char */ /* put double quotes around tokens which start with number chars or include a math char */
while (*tmpstr != '\0') { while (*tmpstr != '\0') {
/*check if we have v(something) at the beginning, after arithchar, after space, /*check if we have v(something) at the beginning, after arithchar, after space,
@ -133,11 +132,6 @@ struct pnode* ft_getpnames_quotes(wordlist* wl, bool check)
cadd(&ds1, '\"'); cadd(&ds1, '\"');
sadd(&ds1, partoken1); sadd(&ds1, partoken1);
cadd(&ds1, '\"'); cadd(&ds1, '\"');
/* save all hyphenated strings only */
cadd(&dsquote, '\"');
sadd(&dsquote, partoken1);
cadd(&dsquote, '\"');
cadd(&dsquote, ' ');
} }
else else
sadd(&ds1, partoken1); sadd(&ds1, partoken1);
@ -149,11 +143,6 @@ struct pnode* ft_getpnames_quotes(wordlist* wl, bool check)
cadd(&ds1, '\"'); cadd(&ds1, '\"');
sadd(&ds1, partoken2); sadd(&ds1, partoken2);
cadd(&ds1, '\"'); cadd(&ds1, '\"');
/* save all hyphenated strings only */
cadd(&dsquote, '\"');
sadd(&dsquote, partoken2);
cadd(&dsquote, '\"');
cadd(&dsquote, ' ');
} }
else else
sadd(&ds1, partoken2); sadd(&ds1, partoken2);
@ -167,11 +156,6 @@ struct pnode* ft_getpnames_quotes(wordlist* wl, bool check)
cadd(&ds1, '\"'); cadd(&ds1, '\"');
sadd(&ds1, tmpstr2); sadd(&ds1, tmpstr2);
cadd(&ds1, '\"'); cadd(&ds1, '\"');
/* save all hyphenated strings only */
sadd(&dsquote, "v(\"");
sadd(&dsquote, tmpstr2);
sadd(&dsquote, "\")");
cadd(&dsquote, ' ');
} }
else else
sadd(&ds1, tmpstr2); sadd(&ds1, tmpstr2);
@ -190,13 +174,13 @@ struct pnode* ft_getpnames_quotes(wordlist* wl, bool check)
ds_free(&ds1); ds_free(&ds1);
tfree(nsz); tfree(nsz);
/* restore the old node name after parsing */ /* restore the old node name after parsing */
char* quotedstrings = ds_get_buf(&dsquote);
for (tmpnode = names; tmpnode; tmpnode = tmpnode->pn_next) { for (tmpnode = names; tmpnode; tmpnode = tmpnode->pn_next) {
if (strstr(quotedstrings, tmpnode->pn_name)) { if (strstr(tmpnode->pn_name, "v(\"")) {
// if (strstr(quotedstrings, tmpnode->pn_name)) {
char newstr[100]; char newstr[100];
char* tmp = tmpnode->pn_name; char* tmp = tmpnode->pn_name;
int ii = 0; int ii = 0;
/* copy to newstr without double quotes */ // copy to newstr without double quotes
while (*tmp && ii < 99) { while (*tmp && ii < 99) {
if (*(tmp) == '\"') { if (*(tmp) == '\"') {
tmp++; tmp++;
@ -210,7 +194,6 @@ struct pnode* ft_getpnames_quotes(wordlist* wl, bool check)
tmpnode->pn_name = copy(newstr); tmpnode->pn_name = copy(newstr);
} }
} }
ds_free(&dsquote);
} }
else { else {
names = ft_getpnames_from_string(sz, check); names = ft_getpnames_from_string(sz, check);