evaluate_expr(), change signature, pass substring instead of string
This commit is contained in:
parent
7aa3664157
commit
3f7951d187
|
|
@ -1131,14 +1131,14 @@ evaluate_variable(dico_t *dico, SPICE_DSTRINGPTR qstr_p, char *t)
|
||||||
|
|
||||||
/* transform exression in string `t' to result q */
|
/* transform exression in string `t' to result q */
|
||||||
static bool
|
static bool
|
||||||
evaluate_expr(dico_t *dico, SPICE_DSTRINGPTR qstr_p, char *t)
|
evaluate_expr(dico_t *dico, SPICE_DSTRINGPTR qstr_p, const char *t, const char * const t_end)
|
||||||
{
|
{
|
||||||
bool err = 0;
|
bool err = 0;
|
||||||
double u;
|
double u;
|
||||||
|
|
||||||
spice_dstring_reinit(qstr_p);
|
spice_dstring_reinit(qstr_p);
|
||||||
|
|
||||||
u = formula(dico, t, t + strlen(t), &err);
|
u = formula(dico, t, t_end, &err);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
|
@ -1234,7 +1234,8 @@ nupa_substitute(dico_t *dico, char *s, char *r, bool err)
|
||||||
sadd(&qstr, "last");
|
sadd(&qstr, "last");
|
||||||
err = 0;
|
err = 0;
|
||||||
} else {
|
} else {
|
||||||
err = evaluate_expr(dico, &qstr, spice_dstring_value(&tstr));
|
const char *xx = spice_dstring_value(&tstr);
|
||||||
|
err = evaluate_expr(dico, &qstr, xx, xx + strlen(xx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1281,7 +1282,8 @@ nupa_substitute(dico_t *dico, char *s, char *r, bool err)
|
||||||
err = message(dico, "Closing \")\" not found.\n");
|
err = message(dico, "Closing \")\" not found.\n");
|
||||||
} else {
|
} else {
|
||||||
pscopy(&tstr, s, i, k - i - 1);
|
pscopy(&tstr, s, i, k - i - 1);
|
||||||
err = evaluate_expr(dico, &qstr, spice_dstring_value(&tstr));
|
const char *xx = spice_dstring_value(&tstr);
|
||||||
|
err = evaluate_expr(dico, &qstr, xx, xx + strlen(xx));
|
||||||
}
|
}
|
||||||
|
|
||||||
i = k;
|
i = k;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue