From a7c2253c8a52186dffac8b613afead0dabc685c2 Mon Sep 17 00:00:00 2001 From: rlar Date: Thu, 23 Nov 2017 18:25:01 +0100 Subject: [PATCH] findsubname(), k ==> p - (const) s - 1 --- src/frontend/numparam/spicenum.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/frontend/numparam/spicenum.c b/src/frontend/numparam/spicenum.c index 200f0cd65..0c671b7b7 100644 --- a/src/frontend/numparam/spicenum.c +++ b/src/frontend/numparam/spicenum.c @@ -155,42 +155,42 @@ findsubname(dico_t *dico, SPICE_DSTRINGPTR dstr_p) char * const s = spice_dstring_value(dstr_p); char * const ls_ptr = s + spice_dstring_length(dstr_p); - int k = (int) (ls_ptr - s) - 1; + int (p - s - 1) = (int) (ls_ptr - s) - 1; spice_dstring_init(&name); - while (k >= 0) { + while ((p - s - 1) >= 0) { /* skip space, then non-space */ - while ((k >= 0) && (s[k] <= ' ')) - k--; + while (((p - s - 1) >= 0) && (s[(p - s - 1)] <= ' ')) + (p - s - 1)--; - int h = k + 1; /* at h: space */ - while ((k >= 0) && (s[k] > ' ')) { + int h = (int) (p - s - 1) + 1; /* at h: space */ + while (((p - s - 1) >= 0) && (s[(p - s - 1)] > ' ')) { - if (s[k] == '}') { + if (s[(p - s - 1)] == '}') { int nest = 1; - k--; + (p - s - 1)--; - while ((nest > 0) && (k >= 0)) { - if (s[k] == '{') + while ((nest > 0) && ((p - s - 1) >= 0)) { + if (s[(p - s - 1)] == '{') nest--; - else if (s[k] == '}') + else if (s[(p - s - 1)] == '}') nest++; - k--; + (p - s - 1)--; } - h = k + 1; /* h points to '{' */ + h = (int) (p - s - 1) + 1; /* h points to '{' */ } else { - k--; + (p - s - 1)--; } } - if ((k >= 0) && alfanum(s[k + 1])) { /* suppose an identifier */ + if (((p - s - 1) >= 0) && alfanum(s[(p - s - 1) + 1])) { /* suppose an identifier */ entry_t *entry; /* check for known subckt name */ spice_dstring_reinit(&name); - int j = k + 1; + int j = (int) (p - s - 1) + 1; while (alfanum(s[j])) { cadd(&name, toupper_c(s[j])); j++;