pscopy(), pscopy_up(), drop `start' argument

which is always zero
This commit is contained in:
rlar 2017-12-26 15:14:49 +01:00
parent 3bd9c1c858
commit 2cb579cd9f
4 changed files with 22 additions and 22 deletions

View File

@ -9,8 +9,8 @@
#include "ngspice/bool.h" #include "ngspice/bool.h"
char *pscopy(SPICE_DSTRINGPTR s, const char *a, int i, int j); char *pscopy(SPICE_DSTRINGPTR s, const char *str, int leng);
char *pscopy_up(SPICE_DSTRINGPTR s, const char *a, int i, int j); char *pscopy_up(SPICE_DSTRINGPTR s, const char *str, int leng);
void scopyd(SPICE_DSTRINGPTR a, SPICE_DSTRINGPTR b); void scopyd(SPICE_DSTRINGPTR a, SPICE_DSTRINGPTR b);
void scopys(SPICE_DSTRINGPTR a, const char *b); void scopys(SPICE_DSTRINGPTR a, const char *b);
void scopy_up(SPICE_DSTRINGPTR a, const char *str); void scopy_up(SPICE_DSTRINGPTR a, const char *str);

View File

@ -168,7 +168,7 @@ scopy_lower(SPICE_DSTRINGPTR dstr_p, const char *str) /* returns success flag */
char * char *
pscopy(SPICE_DSTRINGPTR dstr_p, const char *t, int start, int leng) pscopy(SPICE_DSTRINGPTR dstr_p, const char *t, int leng)
/* partial string copy, with C-based start - Because we now have a 0 based /* partial string copy, with C-based start - Because we now have a 0 based
* start and string may copy outselves, we may need to restore the first * start and string may copy outselves, we may need to restore the first
* character of the original dstring because resetting string will wipe * character of the original dstring because resetting string will wipe
@ -180,16 +180,16 @@ pscopy(SPICE_DSTRINGPTR dstr_p, const char *t, int start, int leng)
stop = (int) strlen(t); stop = (int) strlen(t);
if (start < stop) { /* nothing! */ if (0 < stop) { /* nothing! */
if (leng > stop - start) if (leng > stop)
leng = stop - start; leng = stop;
_spice_dstring_setlength(dstr_p, leng); _spice_dstring_setlength(dstr_p, leng);
s_p = spice_dstring_value(dstr_p); s_p = spice_dstring_value(dstr_p);
for (i = 0; i < leng; i++) for (i = 0; i < leng; i++)
s_p[i] = t[start + i]; s_p[i] = t[i];
s_p[leng] = '\0'; s_p[leng] = '\0';
@ -204,7 +204,7 @@ pscopy(SPICE_DSTRINGPTR dstr_p, const char *t, int start, int leng)
char * char *
pscopy_up(SPICE_DSTRINGPTR dstr_p, const char *t, int start, int leng) pscopy_up(SPICE_DSTRINGPTR dstr_p, const char *t, int leng)
/* partial string copy to upper case, with C convention for start. */ /* partial string copy to upper case, with C convention for start. */
{ {
int i; /* counter */ int i; /* counter */
@ -213,16 +213,16 @@ pscopy_up(SPICE_DSTRINGPTR dstr_p, const char *t, int start, int leng)
stop = (int) strlen(t); stop = (int) strlen(t);
if (start < stop) { /* nothing! */ if (0 < stop) { /* nothing! */
if (leng > stop - start) if (leng > stop)
leng = stop - start; leng = stop;
_spice_dstring_setlength(dstr_p, leng); _spice_dstring_setlength(dstr_p, leng);
s_p = spice_dstring_value(dstr_p); s_p = spice_dstring_value(dstr_p);
for (i = 0; i < leng; i++) for (i = 0; i < leng; i++)
s_p[i] = toupper_c(t[start + i]); s_p[i] = toupper_c(t[i]);
s_p[leng] = '\0'; s_p[leng] = '\0';

View File

@ -84,7 +84,7 @@ stripsomespace(SPICE_DSTRINGPTR dstr_p, bool incontrol)
i++; i++;
if ((i > 0) && s[i] && strchr(markers, s[i])) if ((i > 0) && s[i] && strchr(markers, s[i]))
pscopy(dstr_p, s + i, 0, (int) strlen(s + i)); pscopy(dstr_p, s + i, (int) strlen(s + i));
} }
@ -115,7 +115,7 @@ stripbraces(SPICE_DSTRINGPTR dstr_p)
j_ptr++; j_ptr++;
} }
pscopy(&tstr, s, 0, (int) (brace - s)); pscopy(&tstr, s, (int) (brace - s));
if (brace[-1] > ' ') if (brace[-1] > ' ')
cadd(&tstr, ' '); cadd(&tstr, ' ');
@ -303,7 +303,7 @@ transform(dico_t *dico, SPICE_DSTRINGPTR dstr_p, bool incontrol)
/* split off any "params" tail */ /* split off any "params" tail */
params = strstr(t, "PARAMS:"); params = strstr(t, "PARAMS:");
if (params) if (params)
pscopy(dstr_p, s, 0, (int)(params - t)); pscopy(dstr_p, s, (int)(params - t));
spice_dstring_free(&tstr); spice_dstring_free(&tstr);
category = 'S'; category = 'S';
} else if (ci_prefix(".CONTROL", s)) { } else if (ci_prefix(".CONTROL", s)) {
@ -705,7 +705,7 @@ nupa_copy(struct card *deck)
while ((ls > 0) && (s[ls - 1] <= ' ')) while ((ls > 0) && (s[ls - 1] <= ' '))
ls--; ls--;
pscopy(&u, s, 0, ls); /* strip trailing space, CrLf and so on */ pscopy(&u, s, ls); /* strip trailing space, CrLf and so on */
dicoS->srcline = linenum; dicoS->srcline = linenum;
if ((!inexpansionS) && (linenum >= 0) && (linenum <= dynmaxline)) { if ((!inexpansionS) && (linenum >= 0) && (linenum <= dynmaxline)) {

View File

@ -532,7 +532,7 @@ defsubckt(dico_t *dico, struct card *card, nupa_type categ)
if (s_end > s) { if (s_end > s) {
SPICE_DSTRING ustr; /* temp user string */ SPICE_DSTRING ustr; /* temp user string */
spice_dstring_init(&ustr); spice_dstring_init(&ustr);
pscopy_up(&ustr, s, 0, (int) (s_end - s)); pscopy_up(&ustr, s, (int) (s_end - s));
err = nupa_define(dico, spice_dstring_value(&ustr), ' ', categ, 0.0, w, NULL); err = nupa_define(dico, spice_dstring_value(&ustr), ' ', categ, 0.0, w, NULL);
spice_dstring_free(&ustr); spice_dstring_free(&ustr);
} else { } else {
@ -556,7 +556,7 @@ findsubckt(dico_t *dico, const char * const s)
spice_dstring_init(&ustr); spice_dstring_init(&ustr);
pscopy_up(&ustr, name_b, 0, (int) (name_e - name_b)); pscopy_up(&ustr, name_b, (int) (name_e - name_b));
entry = entrynb(dico, spice_dstring_value(&ustr)); entry = entrynb(dico, spice_dstring_value(&ustr));
if (entry && (entry->tp == NUPA_SUBCKT)) { if (entry && (entry->tp == NUPA_SUBCKT)) {
@ -1383,7 +1383,7 @@ getexpress(nupa_type *type, SPICE_DSTRINGPTR tstr_p, const char *s)
tpe = NUPA_REAL; tpe = NUPA_REAL;
} }
pscopy(tstr_p, s, 0, (int) (p - s)); pscopy(tstr_p, s, (int) (p - s));
if (*p == '}') if (*p == '}')
p++; p++;
@ -1547,7 +1547,7 @@ nupa_subcktcall(dico_t *dico, char *s, char * const x, char * const inst_name)
if (i2) { if (i2) {
const char *optr, *jptr; const char *optr, *jptr;
pscopy(&tstr, i2 + 7, 0, (int) strlen(i2 + 7)); pscopy(&tstr, i2 + 7, (int) strlen(i2 + 7));
/* search identifier to the left of '=' assignments */ /* search identifier to the left of '=' assignments */
@ -1652,7 +1652,7 @@ nupa_subcktcall(dico_t *dico, char *s, char * const x, char * const inst_name)
if (alfanum(*kp) || *kp == '.') { if (alfanum(*kp) || *kp == '.') {
/* number, identifier */ /* number, identifier */
jp = skip_non_ws(kp); jp = skip_non_ws(kp);
pscopy(&ustr, kp, 0, (int) (jp - kp)); pscopy(&ustr, kp, (int) (jp - kp));
} else if (*kp == '{') { } else if (*kp == '{') {
jp = getexpress(NULL, &ustr, jp); jp = getexpress(NULL, &ustr, jp);
} else { } else {
@ -1667,7 +1667,7 @@ nupa_subcktcall(dico_t *dico, char *s, char * const x, char * const inst_name)
char *dollar = strchr(idlist_p, '$'); char *dollar = strchr(idlist_p, '$');
if (dollar) { if (dollar) {
/* replace dollar with expression string u */ /* replace dollar with expression string u */
pscopy(&vstr, idlist_p, 0, (int) (dollar - idlist_p)); pscopy(&vstr, idlist_p, (int) (dollar - idlist_p));
sadd(&vstr, u_p); sadd(&vstr, u_p);
sadd(&vstr, dollar + 1); sadd(&vstr, dollar + 1);
scopyd(&idlist, &vstr); scopyd(&idlist, &vstr);