From e88e75a8d4abad3bbc3c460705183e430e20c3af Mon Sep 17 00:00:00 2001 From: rlar Date: Sat, 30 Apr 2016 20:29:13 +0200 Subject: [PATCH] numparam, use `toupper_c()' --- src/frontend/numparam/general.h | 1 - src/frontend/numparam/mystring.c | 16 +++------------- src/frontend/numparam/spicenum.c | 4 ++-- src/frontend/numparam/xpressn.c | 6 +++--- 4 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/frontend/numparam/general.h b/src/frontend/numparam/general.h index 2aa8aa978..e85aa757a 100644 --- a/src/frontend/numparam/general.h +++ b/src/frontend/numparam/general.h @@ -30,7 +30,6 @@ bool steq(const char *s, const char *t); bool stne(const char *s, const char *t); void stri(long n, SPICE_DSTRINGPTR s); -char upcase(char c); bool alfa(char c); bool num(char c); bool alfanum(char c); diff --git a/src/frontend/numparam/mystring.c b/src/frontend/numparam/mystring.c index bb46dd1e8..d0c8015eb 100644 --- a/src/frontend/numparam/mystring.c +++ b/src/frontend/numparam/mystring.c @@ -147,16 +147,6 @@ sins(SPICE_DSTRINGPTR dstr_p, const char *t) } -char -upcase(char c) -{ - if ((c >= 'a') && (c <= 'z')) - return (char) (c + 'A' - 'a'); - else - return c; -} - - /* ----------------------------------------------------------------- * Create copy of the dynamic string. Dynamic strings are always NULL * terminated. @@ -195,7 +185,7 @@ scopy_up(SPICE_DSTRINGPTR dstr_p, const char *str) /* returns success flag */ spice_dstring_reinit(dstr_p); up[1] = '\0'; for (ptr = str; ptr && *ptr; ptr++) { - up[0] = upcase(*ptr); + up[0] = toupper_c(*ptr); spice_dstring_append(dstr_p, up, 1); } } @@ -275,7 +265,7 @@ pscopy_up(SPICE_DSTRINGPTR dstr_p, const char *t, int start, int leng) s_p = spice_dstring_value(dstr_p); for (i = 0; i < leng; i++) - s_p[i] = upcase(t[start + i]); + s_p[i] = toupper_c(t[start + i]); s_p[leng] = '\0'; @@ -449,7 +439,7 @@ stupcase(char *s) int i = 0; while (s[i] != '\0') { - s[i] = upcase(s[i]); + s[i] = toupper_c(s[i]); i++; } diff --git a/src/frontend/numparam/spicenum.c b/src/frontend/numparam/spicenum.c index 409e1c064..ab6af5835 100644 --- a/src/frontend/numparam/spicenum.c +++ b/src/frontend/numparam/spicenum.c @@ -216,7 +216,7 @@ findsubname(dico_t *dico, SPICE_DSTRINGPTR dstr_p) spice_dstring_reinit(&name); j = k + 1; while (alfanum(s[j])) { - cadd(&name, upcase(s[j])); + cadd(&name, toupper_c(s[j])); j++; } entry = entrynb(dico, spice_dstring_value(&name)); @@ -365,7 +365,7 @@ transform(dico_t *dico, SPICE_DSTRINGPTR dstr_p, bool incontrol, /* private style preprocessor line */ s[0] = '*'; category = 'P'; - } else if (upcase(s[0]) == 'X') { + } else if (toupper_c(s[0]) == 'X') { /* strip actual parameters */ findsubname(dico, dstr_p); /* i= index following last identifier in s */ category = 'X'; diff --git a/src/frontend/numparam/xpressn.c b/src/frontend/numparam/xpressn.c index 0cfeaf9f7..a861d18ad 100644 --- a/src/frontend/numparam/xpressn.c +++ b/src/frontend/numparam/xpressn.c @@ -600,7 +600,7 @@ keyword(const char *keys, const char *s, const char *s_end) for (;;) { const char *p = s; - while ((p < s_end) && (upcase(*p) == *keys)) + while ((p < s_end) && (toupper_c(*p) == *keys)) p++, keys++; if ((p >= s_end) && (*keys <= ' ')) return j; @@ -976,7 +976,7 @@ formula(dico_t *dico, const char *s, const char *s_end, bool *perror) } else { spice_dstring_reinit(&tstr); while (s < s_next) - cadd(&tstr, upcase(*s++)); + cadd(&tstr, toupper_c(*s++)); u = fetchnumentry(dico, spice_dstring_value(&tstr), &error); state = S_atom; } @@ -1343,7 +1343,7 @@ getword(char *s, SPICE_DSTRINGPTR tstr_p, int after, int *pi) spice_dstring_reinit(tstr_p); while ((i <= ls) && (alfa(s[i - 1]) || num(s[i - 1]))) { - cadd(tstr_p, upcase(s[i - 1])); + cadd(tstr_p, toupper_c(s[i - 1])); i++; }