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"
char *pscopy(SPICE_DSTRINGPTR s, const char *a, int i, int j);
char *pscopy_up(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 *str, int leng);
void scopyd(SPICE_DSTRINGPTR a, SPICE_DSTRINGPTR b);
void scopys(SPICE_DSTRINGPTR a, const char *b);
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 *
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
* start and string may copy outselves, we may need to restore the first
* 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);
if (start < stop) { /* nothing! */
if (0 < stop) { /* nothing! */
if (leng > stop - start)
leng = stop - start;
if (leng > stop)
leng = stop;
_spice_dstring_setlength(dstr_p, leng);
s_p = spice_dstring_value(dstr_p);
for (i = 0; i < leng; i++)
s_p[i] = t[start + i];
s_p[i] = t[i];
s_p[leng] = '\0';
@ -204,7 +204,7 @@ pscopy(SPICE_DSTRINGPTR dstr_p, const char *t, int start, int leng)
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. */
{
int i; /* counter */
@ -213,16 +213,16 @@ pscopy_up(SPICE_DSTRINGPTR dstr_p, const char *t, int start, int leng)
stop = (int) strlen(t);
if (start < stop) { /* nothing! */
if (0 < stop) { /* nothing! */
if (leng > stop - start)
leng = stop - start;
if (leng > stop)
leng = stop;
_spice_dstring_setlength(dstr_p, leng);
s_p = spice_dstring_value(dstr_p);
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';

View File

@ -84,7 +84,7 @@ stripsomespace(SPICE_DSTRINGPTR dstr_p, bool incontrol)
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++;
}
pscopy(&tstr, s, 0, (int) (brace - s));
pscopy(&tstr, s, (int) (brace - s));
if (brace[-1] > ' ')
cadd(&tstr, ' ');
@ -303,7 +303,7 @@ transform(dico_t *dico, SPICE_DSTRINGPTR dstr_p, bool incontrol)
/* split off any "params" tail */
params = strstr(t, "PARAMS:");
if (params)
pscopy(dstr_p, s, 0, (int)(params - t));
pscopy(dstr_p, s, (int)(params - t));
spice_dstring_free(&tstr);
category = 'S';
} else if (ci_prefix(".CONTROL", s)) {
@ -705,7 +705,7 @@ nupa_copy(struct card *deck)
while ((ls > 0) && (s[ls - 1] <= ' '))
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;
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) {
SPICE_DSTRING ustr; /* temp user string */
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);
spice_dstring_free(&ustr);
} else {
@ -556,7 +556,7 @@ findsubckt(dico_t *dico, const char * const s)
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));
if (entry && (entry->tp == NUPA_SUBCKT)) {
@ -1383,7 +1383,7 @@ getexpress(nupa_type *type, SPICE_DSTRINGPTR tstr_p, const char *s)
tpe = NUPA_REAL;
}
pscopy(tstr_p, s, 0, (int) (p - s));
pscopy(tstr_p, s, (int) (p - s));
if (*p == '}')
p++;
@ -1547,7 +1547,7 @@ nupa_subcktcall(dico_t *dico, char *s, char * const x, char * const inst_name)
if (i2) {
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 */
@ -1652,7 +1652,7 @@ nupa_subcktcall(dico_t *dico, char *s, char * const x, char * const inst_name)
if (alfanum(*kp) || *kp == '.') {
/* number, identifier */
jp = skip_non_ws(kp);
pscopy(&ustr, kp, 0, (int) (jp - kp));
pscopy(&ustr, kp, (int) (jp - kp));
} else if (*kp == '{') {
jp = getexpress(NULL, &ustr, jp);
} else {
@ -1667,7 +1667,7 @@ nupa_subcktcall(dico_t *dico, char *s, char * const x, char * const inst_name)
char *dollar = strchr(idlist_p, '$');
if (dollar) {
/* 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, dollar + 1);
scopyd(&idlist, &vstr);