Browse Source

Enable math characters also in tokens like i(z/z) by

temporarily putting " around the token.

Improve error message on missing vector
pre-master-46
Holger Vogt 4 years ago
parent
commit
bb9f1669f6
  1. 38
      src/frontend/parse.c

38
src/frontend/parse.c

@ -102,7 +102,7 @@ struct pnode* ft_getpnames_quotes(wordlist* wl, bool check)
{ {
struct pnode* names = NULL, * tmpnode = NULL; struct pnode* names = NULL, * tmpnode = NULL;
char* sz = wl_flatten(wl); char* sz = wl_flatten(wl);
if ((strstr(sz, "v(") || strstr(sz, "V(")) && !cp_getvar("noquotesinoutput", CP_BOOL, NULL, 0))
if ((strstr(sz, "v(") || strstr(sz, "V(") || strstr(sz, "i(") || strstr(sz, "I(")) && !cp_getvar("noquotesinoutput", CP_BOOL, NULL, 0))
{ {
char* tmpstr; char* tmpstr;
char* nsz = tmpstr = stripWhiteSpacesInsideParens(sz); char* nsz = tmpstr = stripWhiteSpacesInsideParens(sz);
@ -165,6 +165,36 @@ struct pnode* ft_getpnames_quotes(wordlist* wl, bool check)
tfree(partoken1); tfree(partoken1);
tfree(partoken2); tfree(partoken2);
} }
else if ((tmpstr[0] == 'i' || tmpstr[0] == 'I') && tmpstr[1] == '(' && tmpstr[2] != '\"' &&
(nsz == tmpstr || isspace_c(tmpstr[-1]) || is_arith_char(tmpstr[-1]) || tmpstr[-1] == '.')) {
char* tmpstr2, *tmpstr3;
tmpstr3 = tmpstr;
tmpstr += 2;
/* get the complete zzz of i(zzz) */
tmpstr2 = gettok_char(&tmpstr, ')', FALSE, FALSE);
/* missing final ) ?*/
if (!tmpstr2) {
fprintf(stderr, "Error: closing ) is missing in %s,\n ignored\n", tmpstr3);
tmpstr = ++tmpstr3;
continue;
}
/* check if this is i(zzz) or v(xx,yy) */
sadd(&ds1, "i(");
bool hac = has_arith_char(tmpstr2);
if (is_all_digits(tmpstr2)) {
sadd(&ds1, tmpstr2);
}
else if (isdigit_c(*tmpstr2) || hac) {
cadd(&ds1, '\"');
sadd(&ds1, tmpstr2);
cadd(&ds1, '\"');
}
else
sadd(&ds1, tmpstr2);
tfree(tmpstr2);
}
cadd(&ds1, *tmpstr); cadd(&ds1, *tmpstr);
tmpstr++; tmpstr++;
} }
@ -175,7 +205,7 @@ struct pnode* ft_getpnames_quotes(wordlist* wl, bool check)
tfree(nsz); tfree(nsz);
/* restore the old node name after parsing */ /* restore the old node name after parsing */
for (tmpnode = names; tmpnode; tmpnode = tmpnode->pn_next) { for (tmpnode = names; tmpnode; tmpnode = tmpnode->pn_next) {
if (strstr(tmpnode->pn_name, "v(\"")) {
if (strstr(tmpnode->pn_name, "v(\"") || strstr(tmpnode->pn_name, "i(\"")) {
char newstr[100]; char newstr[100];
char* tmp = tmpnode->pn_name; char* tmp = tmpnode->pn_name;
int ii = 0; int ii = 0;
@ -454,8 +484,10 @@ struct pnode *PP_mkfnode(const char *func, struct pnode *arg)
d = vec_get(buf); d = vec_get(buf);
if (d == NULL) { if (d == NULL) {
/* Well, too bad. */ /* Well, too bad. */
fprintf(cp_err, "Error: no such function as %s.\n",
fprintf(cp_err, "\nError: no such function as %s,\n",
func); func);
fprintf(cp_err, " or %s is not available.\n",
buf);
return (struct pnode *) NULL; return (struct pnode *) NULL;
} }
/* (void) strcpy(buf, d->v_name); XXX */ /* (void) strcpy(buf, d->v_name); XXX */

Loading…
Cancel
Save