From 8f09de4e4a2bd9ad46e7ac674d733c00d1919f9f Mon Sep 17 00:00:00 2001 From: rlar Date: Sat, 3 Dec 2011 09:10:07 +0000 Subject: [PATCH] bug fix, parameter assignment was broken for expressions containing one of '<=' '>=' or '!=' --- ChangeLog | 4 +++ src/frontend/numparam/xpressn.c | 46 +++++++++++++++++++++------------ 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index a31506082..3c27bd92c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-12-03 Robert Larice + * src/frontend/numparam/xpressn.c : + bug fix, parameter assignment was broken for expressions containing one of '<=' '>=' or '!=' + 2011-12-03 Robert Larice * visualc/vngspice.vcproj : remove some unused `vcproj' dependencies diff --git a/src/frontend/numparam/xpressn.c b/src/frontend/numparam/xpressn.c index b5afa22f1..2455a5aee 100644 --- a/src/frontend/numparam/xpressn.c +++ b/src/frontend/numparam/xpressn.c @@ -1957,7 +1957,7 @@ nupa_subcktcall (tdico * dico, char *s, char *x, bool err) x= a matching subckt call line, with actual params */ { - int n, m, i, j, k, g, h, narg = 0, ls, nest; + int n, i, j, k, g, h, narg = 0, ls, nest; SPICE_DSTRING subname ; SPICE_DSTRING tstr ; SPICE_DSTRING ustr ; @@ -2012,36 +2012,48 @@ nupa_subcktcall (tdico * dico, char *s, char *x, bool err) if (i >= 0) { + const char *optr, *jptr; + pscopy (&tstr, spice_dstring_value(&tstr), i + 7, spice_dstring_length (&tstr)); - while (j = cpos ('=', spice_dstring_value(&tstr)), j >= 0) + + /* search identifier to the left of '=' assignments */ + + for (optr = spice_dstring_value(&tstr); + (jptr = strchr(optr, '=')) != NULL; optr = jptr + 1) { - /* isolate idents to the left of =-signs */ - k = j - 1; - t_p = spice_dstring_value(&tstr) ; - while ((k >= 0) && (t_p[k] <= ' ')) - k--; + const char *kptr, *hptr; - h = k; + /* skip "==" */ + if(jptr[1] == '=') { + jptr++; + continue; + } - while ((h >= 0) && alfanum (t_p[h])) - h--; + /* skip "<=" ">=" "!=" */ + if(jptr > optr && strchr("<>!", jptr[-1])) + continue; - if (alfa (t_p[h + 1]) && (k > h)) + kptr = jptr; + while (--kptr >= optr && isspace(*kptr)) + ; + + hptr = kptr; + while (hptr >= optr && alfanum(*hptr)) + hptr--; + + if (hptr < kptr && alfa(hptr[1])) { - /* we have some id */ - for (m = (h + 1); m <= k; m++) - cadd (&idlist, t_p[m]); + while(hptr++ < kptr) + cadd (&idlist, *hptr); sadd (&idlist, "=$;"); n++; } else message (dico, "identifier expected."); - - /* It is j+1 to skip over the '=' */ - pscopy (&tstr, spice_dstring_value(&tstr), j+1, spice_dstring_length (&tstr)); } } + /***** next, analyze the circuit call line */ if (!err) {