From e212566176d7191108d3502ad27c4c8817ce0ab6 Mon Sep 17 00:00:00 2001 From: rlar Date: Sun, 15 May 2016 20:28:56 +0200 Subject: [PATCH] evaluate_variable(), change signature, pass substring instead of string side effect: string `t' is no longer globally upcased, which is is of no consequence for the single place where evaluate_variable() is invoked --- src/frontend/numparam/xpressn.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/frontend/numparam/xpressn.c b/src/frontend/numparam/xpressn.c index 95cd4cef8..eeb92aea5 100644 --- a/src/frontend/numparam/xpressn.c +++ b/src/frontend/numparam/xpressn.c @@ -1095,18 +1095,20 @@ double_to_string(SPICE_DSTRINGPTR qstr_p, double value) /* expand parameter in string `t' to result `q' */ static bool -evaluate_variable(dico_t *dico, SPICE_DSTRINGPTR qstr_p, char *t) +evaluate_variable(dico_t *dico, SPICE_DSTRINGPTR qstr_p, const char * const t, const char * const t_end) { entry_t *entry; spice_dstring_reinit(qstr_p); - strtoupper(t); - entry = entrynb(dico, t); + char *tx = copy_substring(t, t_end); + strtoupper(tx); + entry = entrynb(dico, tx); + tfree(tx); if (!entry) return message(dico, - "\"%s\" not evaluated. Lookup failure.\n", t); + "\"%.*s\" not evaluated. Lookup failure.\n", (int) (t_end - t), t); if (entry->tp == NUPA_REAL) { double_to_string(qstr_p, entry->vl); @@ -1302,7 +1304,8 @@ nupa_substitute(dico_t *dico, char *s, char *r, bool err) } while ((k <= ls) && (d > ' ')); pscopy(&tstr, s, i-1, k - i); - err = evaluate_variable(dico, &qstr, spice_dstring_value(&tstr)); + const char *xx = spice_dstring_value(&tstr); + err = evaluate_variable(dico, &qstr, xx, xx + strlen(xx)); i = k - 1; }