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