diff --git a/src/frontend/numparam/general.h b/src/frontend/numparam/general.h index a3309eb34..7f4fb3667 100644 --- a/src/frontend/numparam/general.h +++ b/src/frontend/numparam/general.h @@ -13,25 +13,25 @@ typedef char string[258]; void sfix(SPICE_DSTRINGPTR dstr_p, int len); -char *pscopy(SPICE_DSTRINGPTR s, char *a, int i, int j); -char *pscopy_up(SPICE_DSTRINGPTR s, char *a, int i, int j); +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); bool scopyd(SPICE_DSTRINGPTR a, SPICE_DSTRINGPTR b); -bool scopys(SPICE_DSTRINGPTR a, char *b); -bool scopy_up(SPICE_DSTRINGPTR a, char *str); -bool scopy_lower(SPICE_DSTRINGPTR a, char *str); +bool scopys(SPICE_DSTRINGPTR a, const char *b); +bool scopy_up(SPICE_DSTRINGPTR a, const char *str); +bool scopy_lower(SPICE_DSTRINGPTR a, const char *str); bool ccopy(SPICE_DSTRINGPTR a, char c); -bool sadd(SPICE_DSTRINGPTR s, char *t); +bool sadd(SPICE_DSTRINGPTR s, const char *t); bool nadd(SPICE_DSTRINGPTR s, long n); bool cadd(SPICE_DSTRINGPTR s, char c); bool naddll(SPICE_DSTRINGPTR s, long long n); bool cins(SPICE_DSTRINGPTR s, char c); -bool sins(SPICE_DSTRINGPTR s, char *t); +bool sins(SPICE_DSTRINGPTR s, const char *t); int cpos(char c, char *s); -int spos_(char *sub, char *s); -bool ci_prefix(register char *p, register char *s); -int length(char *s); -bool steq(char *s, char *t); -bool stne(char *s, char *t); +int spos_(char *sub, const char *s); +bool ci_prefix(const char *p, const char *s); +int length(const char *s); +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); diff --git a/src/frontend/numparam/mystring.c b/src/frontend/numparam/mystring.c index daa716929..c7d4fc891 100644 --- a/src/frontend/numparam/mystring.c +++ b/src/frontend/numparam/mystring.c @@ -25,7 +25,7 @@ /***** primitive input-output ***/ bool -ci_prefix(register char *p, register char *s) +ci_prefix(const char *p, const char *s) { while (*p) { if ((isupper(*p) ? tolower(*p) : *p) != @@ -93,7 +93,7 @@ sfix(SPICE_DSTRINGPTR dstr_p, int len) int -length(char *s) +length(const char *s) { return (int) strlen(s); } @@ -103,7 +103,7 @@ length(char *s) * Function: add string t to dynamic string dstr_p. * ----------------------------------------------------------------- */ bool -sadd(SPICE_DSTRINGPTR dstr_p, char *t) +sadd(SPICE_DSTRINGPTR dstr_p, const char *t) { spice_dstring_append(dstr_p, t, -1); return 1; @@ -148,7 +148,7 @@ cins(SPICE_DSTRINGPTR dstr_p, char c) * Function: insert string t at front of dynamic string dstr_p * ----------------------------------------------------------------- */ bool -sins(SPICE_DSTRINGPTR dstr_p, char *t) +sins(SPICE_DSTRINGPTR dstr_p, const char *t) { int i; int ls; @@ -214,7 +214,7 @@ scopyd(SPICE_DSTRINGPTR s, SPICE_DSTRINGPTR t) /* returns success flag */ * are always NULLterminated. * ----------------------------------------------------------------- */ bool -scopys(SPICE_DSTRINGPTR s, char *t) /* returns success flag */ +scopys(SPICE_DSTRINGPTR s, const char *t) /* returns success flag */ { spice_dstring_reinit(s); spice_dstring_append(s, t, -1); @@ -227,10 +227,10 @@ scopys(SPICE_DSTRINGPTR s, char *t) /* returns success flag */ * Dynamic strings are always NULL * terminated. * ----------------------------------------------------------------- */ bool -scopy_up(SPICE_DSTRINGPTR dstr_p, char *str) /* returns success flag */ +scopy_up(SPICE_DSTRINGPTR dstr_p, const char *str) /* returns success flag */ { char up[2]; /* short string */ - char *ptr; /* position in string */ + const char *ptr; /* position in string */ spice_dstring_reinit(dstr_p); up[1] = '\0'; @@ -247,10 +247,10 @@ scopy_up(SPICE_DSTRINGPTR dstr_p, char *str) /* returns success flag */ * Dynamic strings are always NULL * terminated. * ----------------------------------------------------------------- */ bool -scopy_lower(SPICE_DSTRINGPTR dstr_p, char *str) /* returns success flag */ +scopy_lower(SPICE_DSTRINGPTR dstr_p, const char *str) /* returns success flag */ { char low[2]; /* short string */ - char *ptr; /* position in string */ + const char *ptr; /* position in string */ spice_dstring_reinit(dstr_p); low[1] = '\0'; @@ -275,7 +275,7 @@ ccopy(SPICE_DSTRINGPTR dstr_p, char c) /* returns success flag */ char * -pscopy(SPICE_DSTRINGPTR dstr_p, char *t, int start, int leng) +pscopy(SPICE_DSTRINGPTR dstr_p, const char *t, int start, 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 @@ -313,7 +313,7 @@ pscopy(SPICE_DSTRINGPTR dstr_p, char *t, int start, int leng) char * -pscopy_up(SPICE_DSTRINGPTR dstr_p, char *t, int start, int leng) +pscopy_up(SPICE_DSTRINGPTR dstr_p, const char *t, int start, int leng) /* partial string copy to upper case, with C convention for start. */ { int i; /* counter */ @@ -439,14 +439,14 @@ stri(long n, SPICE_DSTRINGPTR dstr_p) bool -steq(char *a, char *b) /* string a==b test */ +steq(const char *a, const char *b) /* string a==b test */ { return strcmp(a, b) == 0; } bool -stne(char *s, char *t) +stne(const char *s, const char *t) { return strcmp(s, t) != 0; } @@ -576,7 +576,7 @@ absi(long i) int -spos_(char *sub, char *s) +spos_(char *sub, const char *s) /* equivalent to Turbo Pascal pos(). BUG: counts 1 ... length(s), not from 0 like C */ diff --git a/src/frontend/numparam/xpressn.c b/src/frontend/numparam/xpressn.c index 2bf417b6e..4d37e2c28 100644 --- a/src/frontend/numparam/xpressn.c +++ b/src/frontend/numparam/xpressn.c @@ -736,7 +736,7 @@ keyword(SPICE_DSTRINGPTR keys_p, SPICE_DSTRINGPTR tstr_p) static double -parseunit(char *s) +parseunit(const char *s) /* the Spice suffixes */ { switch (toupper(s[0])) @@ -754,7 +754,7 @@ parseunit(char *s) static int -fetchid(char *s, SPICE_DSTRINGPTR t, int ls, int i) +fetchid(const char *s, SPICE_DSTRINGPTR t, int ls, int i) /* copy next identifier from s into t, advance and return scan index i */ { char c; @@ -791,7 +791,7 @@ fetchid(char *s, SPICE_DSTRINGPTR t, int ls, int i) static double -exists(tdico *d, char *s, int *pi, bool *perror) +exists(tdico *d, const char *s, int *pi, bool *perror) /* check if s in simboltable 'defined': expect (ident) and return 0 or 1 */ { bool error = *perror; @@ -853,7 +853,7 @@ exists(tdico *d, char *s, int *pi, bool *perror) static double -fetchnumber(tdico *dico, char *s, int *pi, bool *perror) +fetchnumber(tdico *dico, const char *s, int *pi, bool *perror) /* parse a Spice number in string s */ { double u; @@ -887,7 +887,7 @@ fetchnumber(tdico *dico, char *s, int *pi, bool *perror) static char fetchoperator(tdico *dico, - char *s, int ls, + const char *s, int ls, int *pi, unsigned char *pstate, unsigned char *plevel, bool *perror) @@ -1122,7 +1122,7 @@ operate(char op, double x, double y) static double -formula(tdico *dico, char *s, bool *perror) +formula(tdico *dico, const char *s, bool *perror) { /* Expression parser. s is a formula with parentheses and math ops +-* / ... diff --git a/src/include/ngspice/dstring.h b/src/include/ngspice/dstring.h index 443970971..6ac03e39e 100644 --- a/src/include/ngspice/dstring.h +++ b/src/include/ngspice/dstring.h @@ -25,10 +25,10 @@ typedef struct spice_dstring { * spice_dstring_xxxx routines. Used to manipulate dynamic strings. ----------------------------------------------------------------- */ extern void spice_dstring_init(SPICE_DSTRINGPTR dsPtr) ; -extern char *spice_dstring_append(SPICE_DSTRINGPTR dsPtr,char *string,int length) ; -extern char *spice_dstring_append_lower(SPICE_DSTRINGPTR dsPtr,char *string,int length) ; +extern char *spice_dstring_append(SPICE_DSTRINGPTR dsPtr,const char *string,int length) ; +extern char *spice_dstring_append_lower(SPICE_DSTRINGPTR dsPtr,const char *string,int length) ; extern char *spice_dstring_append_char(SPICE_DSTRINGPTR dsPtr,char c) ; -extern char *spice_dstring_print(SPICE_DSTRINGPTR dsPtr,char *format, ... ) ; +extern char *spice_dstring_print(SPICE_DSTRINGPTR dsPtr,const char *format, ... ) ; extern char *spice_dstring_setlength(SPICE_DSTRINGPTR dsPtr,int length) ; extern char *_spice_dstring_setlength(SPICE_DSTRINGPTR dsPtr,int length) ; extern void spice_dstring_free(SPICE_DSTRINGPTR dsPtr) ; diff --git a/src/misc/dstring.c b/src/misc/dstring.c index 6b79ce723..3aca84a55 100644 --- a/src/misc/dstring.c +++ b/src/misc/dstring.c @@ -59,12 +59,12 @@ void spice_dstring_init(SPICE_DSTRINGPTR dsPtr) * *---------------------------------------------------------------------- */ -char *spice_dstring_append(SPICE_DSTRINGPTR dsPtr,char *string,int length) +char *spice_dstring_append(SPICE_DSTRINGPTR dsPtr, const char *string, int length) { int newSize ; /* needed size */ char *newString ; /* newly allocated string buffer */ char *dst ; /* destination */ - char *end ; /* end of string */ + const char *end ; /* end of string */ if( length < 0){ length = (int) strlen(string) ; @@ -124,12 +124,12 @@ char *spice_dstring_append(SPICE_DSTRINGPTR dsPtr,char *string,int length) * *---------------------------------------------------------------------- */ -char *spice_dstring_append_lower(SPICE_DSTRINGPTR dsPtr,char *string,int length) +char *spice_dstring_append_lower(SPICE_DSTRINGPTR dsPtr, const char *string, int length) { int newSize ; /* needed size */ char *newString ; /* newly allocated string buffer */ char *dst ; /* destination */ - char *end ; /* end of string */ + const char *end ; /* end of string */ if( length < 0){ length = (int) strlen(string) ; @@ -178,7 +178,7 @@ char *spice_dstring_append_char( SPICE_DSTRINGPTR dstr_p, char c) return spice_dstring_append( dstr_p, &c, 1 ) ; } /* end spice_dstring_append_char() */ -static int spice_format_length( va_list args, char *fmt ) +static int spice_format_length( va_list args, const char *fmt ) { int i ; /* integer */ int len ; /* length of format */ @@ -263,7 +263,7 @@ static int spice_format_length( va_list args, char *fmt ) } /* end Ymessage_format_length() */ -char *spice_dstring_print( SPICE_DSTRINGPTR dsPtr,char *format, ... ) +char *spice_dstring_print( SPICE_DSTRINGPTR dsPtr, const char *format, ... ) { va_list args ; int format_len ; /* length of format */