From 4859f7d8dfec39289ebd68b20abe63f2755736b9 Mon Sep 17 00:00:00 2001 From: rlar Date: Thu, 23 Nov 2017 18:41:43 +0100 Subject: [PATCH] findsubname(), cleanup and use isspace_c() --- src/frontend/numparam/spicenum.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/frontend/numparam/spicenum.c b/src/frontend/numparam/spicenum.c index 3789151b9..246c905d6 100644 --- a/src/frontend/numparam/spicenum.c +++ b/src/frontend/numparam/spicenum.c @@ -151,10 +151,11 @@ findsubname(dico_t *dico, SPICE_DSTRINGPTR dstr_p) /* scan a string from the end, skipping non-idents and {expressions} */ /* then truncate s after the last subckt(?) identifier */ { - SPICE_DSTRING name; /* extract a name */ char * const s = spice_dstring_value(dstr_p); - char *p = s + spice_dstring_length(dstr_p); + + SPICE_DSTRING name; /* extract a name */ + spice_dstring_init(&name); while (p > s) { @@ -162,8 +163,7 @@ findsubname(dico_t *dico, SPICE_DSTRINGPTR dstr_p) /* skip space, then non-space */ char *p_end = p = skip_back_ws(p, s); /* at p_end: space */ - while ((p > s) && (p[-1] > ' ')) { - + while ((p > s) && !isspace_c(p[-1])) if (p[-1] == '}') { int nest = 1; while (--p > s) { @@ -177,11 +177,9 @@ findsubname(dico_t *dico, SPICE_DSTRINGPTR dstr_p) } } p_end = p; /* p_end points to '{' */ - } else { p--; } - } if ((p > s) && alfanum(*p)) { /* suppose an identifier */ char *t;