Browse Source

wlist.c, `const' ness

rlar 14 years ago
parent
commit
9ed7ce4e9e
  1. 6
      src/include/ngspice/wordlist.h
  2. 15
      src/misc/wlist.c

6
src/include/ngspice/wordlist.h

@ -11,11 +11,11 @@ struct wordlist {
typedef struct wordlist wordlist; typedef struct wordlist wordlist;
int wl_length(wordlist *wlist);
int wl_length(const wordlist *wlist);
void wl_free(wordlist *wlist); void wl_free(wordlist *wlist);
wordlist * wl_copy(wordlist *wlist); wordlist * wl_copy(wordlist *wlist);
wordlist * wl_splice(wordlist *elt, wordlist *list); wordlist * wl_splice(wordlist *elt, wordlist *list);
void wl_print(wordlist *wlist, FILE *fp);
void wl_print(const wordlist *wlist, FILE *fp);
wordlist * wl_build(char **v); wordlist * wl_build(char **v);
char ** wl_mkvec(wordlist *wl); char ** wl_mkvec(wordlist *wl);
wordlist * wl_append(wordlist *wlist, wordlist *nwl); wordlist * wl_append(wordlist *wlist, wordlist *nwl);
@ -31,7 +31,7 @@ void wl_append_word(wordlist **first, wordlist **last, char *word);
wordlist *wl_chop(wordlist *wlist); wordlist *wl_chop(wordlist *wlist);
wordlist *wl_chop_rest(wordlist *wlist); wordlist *wl_chop_rest(wordlist *wlist);
wordlist *wl_find(const char *string, wordlist *wlist);
wordlist *wl_find(const char *string, const wordlist *wlist);
void wl_delete_slice(wordlist *from, wordlist *to); void wl_delete_slice(wordlist *from, wordlist *to);

15
src/misc/wlist.c

@ -13,12 +13,11 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
/* Determine the length of a word list. */ /* Determine the length of a word list. */
int int
wl_length(wordlist *wlist)
wl_length(const wordlist *wl)
{ {
int i = 0; int i = 0;
wordlist *wl;
for (wl = wlist; wl; wl = wl->wl_next)
for (; wl; wl = wl->wl_next)
i++; i++;
return (i); return (i);
} }
@ -90,11 +89,9 @@ printword(char *string, FILE *fp)
/* Print a word list. (No \n at the end...) */ /* Print a word list. (No \n at the end...) */
void void
wl_print(wordlist *wlist, FILE *fp)
wl_print(const wordlist *wl, FILE *fp)
{ {
wordlist *wl;
for (wl = wlist; wl; wl = wl->wl_next) {
for (; wl; wl = wl->wl_next) {
printword(wl->wl_word, fp); printword(wl->wl_word, fp);
if (wl->wl_next) if (wl->wl_next)
putc(' ', fp); putc(' ', fp);
@ -360,12 +357,12 @@ wl_chop_rest(wordlist *wl)
*/ */
wordlist * wordlist *
wl_find(const char *string, wordlist *wl)
wl_find(const char *string, const wordlist *wl)
{ {
for (; wl; wl = wl->wl_next) for (; wl; wl = wl->wl_next)
if (eq(string, wl->wl_word)) if (eq(string, wl->wl_word))
break; break;
return wl;
return (wordlist *) wl;
} }

Loading…
Cancel
Save