From 6da961c3f165560dc2726ebc57865bf7679f44ed Mon Sep 17 00:00:00 2001 From: rlar Date: Fri, 29 Apr 2016 21:26:06 +0200 Subject: [PATCH] numparam/xpressn.c, evaluate(), drop local `numeric' and return instantly when formula() reports an error --- src/frontend/numparam/xpressn.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/frontend/numparam/xpressn.c b/src/frontend/numparam/xpressn.c index f6a5c6fae..81899dcdb 100644 --- a/src/frontend/numparam/xpressn.c +++ b/src/frontend/numparam/xpressn.c @@ -1105,14 +1105,9 @@ static bool evaluate(dico_t *dico, SPICE_DSTRINGPTR qstr_p, char *t, unsigned char mode) { /* transform t to result q. mode 0: expression, mode 1: simple variable */ - double u = 0.0; entry_t *entry; - bool numeric; - bool err; spice_dstring_reinit(qstr_p); - numeric = 0; - err = 0; if (mode == 1) { /* string? */ @@ -1125,8 +1120,8 @@ evaluate(dico_t *dico, SPICE_DSTRINGPTR qstr_p, char *t, unsigned char mode) /* data type: Real or String */ if (entry->tp == NUPA_REAL) { - u = entry->vl; - numeric = 1; + double_to_string(qstr_p, entry->vl); + return 0; } else if (entry->tp == NUPA_STRING) { /* suppose source text "..." at */ int j = entry->ivl + 1; @@ -1135,20 +1130,20 @@ evaluate(dico_t *dico, SPICE_DSTRINGPTR qstr_p, char *t, unsigned char mode) char c = entry->sbbase[j++]; if ((c == '\"') || (c < ' ')) - break; + return 0; cadd(qstr_p, c); } } } else { - u = formula(dico, t, t + strlen(t), &err); - numeric = 1; - } - - if (numeric) + bool err = 0; + double u = formula(dico, t, t + strlen(t), &err); + if (err) + return err; double_to_string(qstr_p, u); - - return err; + return 0; + } + return 0; }