diff --git a/src/frontend/numparam/general.h b/src/frontend/numparam/general.h index 1a9018f5a..0528e34aa 100644 --- a/src/frontend/numparam/general.h +++ b/src/frontend/numparam/general.h @@ -25,7 +25,6 @@ void cadd(SPICE_DSTRINGPTR s, char c); void naddll(SPICE_DSTRINGPTR s, long long n); void cins(SPICE_DSTRINGPTR s, char c); void sins(SPICE_DSTRINGPTR s, const char *t); -int cpos(char c, char *s); int spos_(char *sub, const char *s); bool ci_prefix(const char *p, const char *s); int length(const char *s); diff --git a/src/frontend/numparam/mystring.c b/src/frontend/numparam/mystring.c index 57f80b2db..a0786c084 100644 --- a/src/frontend/numparam/mystring.c +++ b/src/frontend/numparam/mystring.c @@ -154,24 +154,6 @@ sins(SPICE_DSTRINGPTR dstr_p, const char *t) } -int -cpos(char c, char *s) -/* return position of c in s, or 0 if not found. - * BUG, Pascal inherited: first char is at 1, not 0 ! - * No longer! Now position is C-based to make life easier. - */ -{ - int i = 0; - while ((s[i] != c) && (s[i] != '\0')) - i++; - - if (s[i] == c) - return i; - else - return -1; -} - - char upcase(char c) { diff --git a/src/frontend/numparam/spicenum.c b/src/frontend/numparam/spicenum.c index e45a4c52c..9ff1f4688 100644 --- a/src/frontend/numparam/spicenum.c +++ b/src/frontend/numparam/spicenum.c @@ -371,7 +371,7 @@ transform(dico_t *dico, SPICE_DSTRINGPTR dstr_p, bool incontrol, category = 'X'; } else if (s[0] == '+') { /* continuation line */ category = '+'; - } else if (cpos(s[0], "*$#") < 0) { + } else if (!strchr("*$#", s[0])) { /* not a comment line! */ n = stripbraces(dstr_p); if (n > 0) diff --git a/src/frontend/numparam/xpressn.c b/src/frontend/numparam/xpressn.c index 4b12cfc09..5cdddcf45 100644 --- a/src/frontend/numparam/xpressn.c +++ b/src/frontend/numparam/xpressn.c @@ -732,7 +732,7 @@ fetchoperator(dico_t *dico, } else if (c == '^') { state = S_binop; level = 2; - } else if (cpos(c, "=<>#GL") >= 0) { + } else if (strchr("=<>#GL", c)) { state = S_binop; level = 5; } else if (c == 'A') { @@ -1419,7 +1419,7 @@ getexpress(char *s, SPICE_DSTRINGPTR tstr_p, int *pi) } while ((i <= ls) && !((d == ')') && (level <= 0))); } - } while (!(cpos (c, ",;)}") >= 0)); /* legal separators */ + } while (!strchr(",;)}", c)); /* legal separators */ tpe = NUPA_REAL; } @@ -1703,9 +1703,10 @@ nupa_subcktcall(dico_t *dico, char *s, char *x, char *inst_name) u_p = spice_dstring_value(&ustr); if (u_p[0]) { + char *dollar = strchr(spice_dstring_value(&idlist), '$'); narg++; - k = cpos('$', spice_dstring_value(&idlist)); - if (k >= 0) { + if (dollar) { + k = (int) (dollar - spice_dstring_value(&idlist)); /* replace dollar with expression string u */ pscopy(&vstr, spice_dstring_value(&idlist), 0, k); sadd(&vstr, spice_dstring_value(&ustr));