From d3d966b0272c6af18872ae551b3a2171e2951c84 Mon Sep 17 00:00:00 2001 From: rlar Date: Fri, 6 May 2016 19:42:35 +0200 Subject: [PATCH] getword(), cleanup --- src/frontend/numparam/xpressn.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/frontend/numparam/xpressn.c b/src/frontend/numparam/xpressn.c index fc8e9d717..48e3e1164 100644 --- a/src/frontend/numparam/xpressn.c +++ b/src/frontend/numparam/xpressn.c @@ -1320,24 +1320,21 @@ static void getword(const char * const s, SPICE_DSTRINGPTR tstr_p, const char **pi) /* isolate a word from s after position "after". return i= last read+1 */ { - const char *iptr; - iptr = *pi; - const char *ls_ptr; - - ls_ptr = s + (int) strlen(s); + const char *iptr = *pi; + const char * const ls_ptr = s + (int) strlen(s); do iptr++; - while (((iptr - s) < (ls_ptr - s)) && !alfa(s[(iptr - s) - 1])); + while ((iptr < ls_ptr) && !alfa(iptr[-1])); spice_dstring_reinit(tstr_p); - while (((iptr - s) <= (ls_ptr - s)) && (alfa(s[(iptr - s) - 1]) || isdigit_c(s[(iptr - s) - 1]))) { - cadd(tstr_p, toupper_c(s[(iptr - s) - 1])); + while ((iptr <= ls_ptr) && (alfa(iptr[-1]) || isdigit_c(iptr[-1]))) { + cadd(tstr_p, toupper_c(iptr[-1])); iptr++; } - *pi = s + (iptr - s); + *pi = iptr; }