Enabled NUPA's capability to recognize quoted strings.
NUPA has an options string ( dico->option that must be set to SPICE-3. When not, recognized strings are uppercased before being returned. Facilitated .PARAM to recognize strings in two ways: by sharps #xxx# and now also by quotes "xxx".
This commit is contained in:
parent
0e89d94a9c
commit
4aed813422
|
|
@ -589,8 +589,11 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
|
||||||
/* lines .width, .four, .plot, .print, .save added to wl_first, removed from deck */
|
/* lines .width, .four, .plot, .print, .save added to wl_first, removed from deck */
|
||||||
/* lines .op, .meas, .tf added to wl_first */
|
/* lines .op, .meas, .tf added to wl_first */
|
||||||
inp_casefix(s); /* s: first token from line */
|
inp_casefix(s); /* s: first token from line */
|
||||||
inp_casefix(dd->li_line);
|
if (!ciprefix(".param", s))
|
||||||
if (eq(s, ".width") ||
|
/* mhx: casefix strips quotes(!?), and .PARAM therefore does not see them. */
|
||||||
|
/* maybe .func shold also be allowed? */
|
||||||
|
inp_casefix(dd->li_line);
|
||||||
|
if (eq(s, ".width") ||
|
||||||
ciprefix(".four", s) ||
|
ciprefix(".four", s) ||
|
||||||
eq(s, ".plot") ||
|
eq(s, ".plot") ||
|
||||||
eq(s, ".print") ||
|
eq(s, ".print") ||
|
||||||
|
|
@ -1382,8 +1385,7 @@ com_alterparam(wordlist *wl)
|
||||||
curr_line = dd->li_line;
|
curr_line = dd->li_line;
|
||||||
char *start = gettok_char(&curr_line, '=', TRUE, FALSE);
|
char *start = gettok_char(&curr_line, '=', TRUE, FALSE);
|
||||||
tfree(dd->li_line);
|
tfree(dd->li_line);
|
||||||
/* mhx: re-inserted braces. It works/ed (sometimes) without them. */
|
dd->li_line = tprintf("%s%s", start, pval);
|
||||||
dd->li_line = tprintf("%s{%s}", start, pval);
|
|
||||||
found = TRUE;
|
found = TRUE;
|
||||||
tfree(start);
|
tfree(start);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -251,8 +251,9 @@ initdico(dico_t *dico)
|
||||||
int asize = NESTINGDEPTH; /* default allocation depth of the synbol stack */
|
int asize = NESTINGDEPTH; /* default allocation depth of the synbol stack */
|
||||||
COMPATMODE_T compat_mode;
|
COMPATMODE_T compat_mode;
|
||||||
|
|
||||||
spice_dstring_init(&(dico->option));
|
spice_dstring_init (&(dico->option));
|
||||||
spice_dstring_init(&(dico->srcfile));
|
spice_dstring_value (&dico->option) = "spice-3"; /* mhx: If not, nupa uppercases quoted strings */
|
||||||
|
spice_dstring_init (&(dico->srcfile));
|
||||||
|
|
||||||
dico->srcline = -1;
|
dico->srcline = -1;
|
||||||
dico->errcount = 0;
|
dico->errcount = 0;
|
||||||
|
|
@ -1539,6 +1540,10 @@ nupa_assignment(dico_t *dico, char *s, char mode)
|
||||||
SPICE_DSTRING tstr; /* temporary dstring */
|
SPICE_DSTRING tstr; /* temporary dstring */
|
||||||
SPICE_DSTRING ustr; /* temporary dstring */
|
SPICE_DSTRING ustr; /* temporary dstring */
|
||||||
|
|
||||||
|
#define SHARP(x) (s[x] == '#' || s[x] == '"')
|
||||||
|
#define LBRAC(x) (s[x] == '{')
|
||||||
|
#define RBRAC(x) (s[x] == '}')
|
||||||
|
|
||||||
spice_dstring_init(&tstr);
|
spice_dstring_init(&tstr);
|
||||||
spice_dstring_init(&ustr);
|
spice_dstring_init(&ustr);
|
||||||
ls = length(s);
|
ls = length(s);
|
||||||
|
|
@ -1573,14 +1578,10 @@ nupa_assignment(dico_t *dico, char *s, char mode)
|
||||||
if (i > ls)
|
if (i > ls)
|
||||||
error = message(dico, " = sign expected.\n");
|
error = message(dico, " = sign expected.\n");
|
||||||
|
|
||||||
for (ix = i; ix < ls - 1; ix++) { /* change delimiters {# and #} to double quotes */
|
strptr = strchr(&s[i], '\"'); /* mhx: maybe this is a quoted string already; .param x = "hello" */
|
||||||
int ssharp = 0;
|
for (ix = i; ix < ls - 1; ix++) { /* change possible delimiters {# and #} to double quotes */
|
||||||
if (s[ix] == '{' && s[ix + 1] == '#') { s[ix] = ' '; s[ix + 1] = '"'; strptr = &s[ix + 1]; }
|
if (LBRAC(ix) && SHARP(ix + 1)) { s[ix] = ' '; s[ix + 1] = '"'; strptr = &s[ix + 1]; }
|
||||||
if (s[ix] == '#' && s[ix + 1] == '}') { s[ix] = '"'; s[ix + 1] = '\0'; }
|
if (SHARP(ix) && RBRAC(ix + 1)) { s[ix] = '"'; s[ix + 1] = '\0'; }
|
||||||
if (s[ix] == '#' && !s[ix + 1] == '}') {
|
|
||||||
s[ix] = '"'; ssharp++;
|
|
||||||
if (ssharp == 2) { s[ix + 1] = '\0'; ssharp = 0; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dtype = getexpress(s, &ustr, &i);
|
dtype = getexpress(s, &ustr, &i);
|
||||||
|
|
@ -1611,6 +1612,9 @@ nupa_assignment(dico_t *dico, char *s, char mode)
|
||||||
spice_dstring_free(&ustr);
|
spice_dstring_free(&ustr);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
|
#undef SHARP
|
||||||
|
#undef RBRAC
|
||||||
|
#undef LBRAC
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue