From 98ec9c2fa3c875ae1e616b5d034111996f6fe20e Mon Sep 17 00:00:00 2001 From: rlar Date: Sun, 22 May 2016 21:31:59 +0200 Subject: [PATCH] stripbraces(), use `strchr()' --- src/frontend/numparam/spicenum.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/frontend/numparam/spicenum.c b/src/frontend/numparam/spicenum.c index 2b1743a5c..4dd7ba9c4 100644 --- a/src/frontend/numparam/spicenum.c +++ b/src/frontend/numparam/spicenum.c @@ -95,6 +95,7 @@ stripbraces(SPICE_DSTRINGPTR dstr_p) int n, i, nest, ls, j; char *s; /* value of dynamic string */ char *t_p; /* value of t dynamic string */ + char *brace; SPICE_DSTRING tstr; /* temporary dynamic string */ n = 0; @@ -103,9 +104,10 @@ stripbraces(SPICE_DSTRINGPTR dstr_p) ls = spice_dstring_length(dstr_p); i = 0; - while (i < ls) { + while ((brace = strchr(s + i, '{')) != NULL) { + + i = (int) (brace - s); - if (s[i] == '{') { /* something to strip */ j = i + 1; @@ -143,12 +145,6 @@ stripbraces(SPICE_DSTRINGPTR dstr_p) scopyd(dstr_p, &tstr); s = spice_dstring_value(dstr_p); ls = spice_dstring_length(dstr_p); - - } else { - - i++; - - } } dynsubst = placeholder;