From 9ed7ce4e9e22cdac722ee3f4ae53f980fb6e4fe8 Mon Sep 17 00:00:00 2001 From: rlar Date: Fri, 3 Aug 2012 21:45:44 +0200 Subject: [PATCH] wlist.c, `const' ness --- src/include/ngspice/wordlist.h | 6 +++--- src/misc/wlist.c | 15 ++++++--------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/include/ngspice/wordlist.h b/src/include/ngspice/wordlist.h index 286b8a841..c1c22b720 100644 --- a/src/include/ngspice/wordlist.h +++ b/src/include/ngspice/wordlist.h @@ -11,11 +11,11 @@ struct wordlist { typedef struct wordlist wordlist; -int wl_length(wordlist *wlist); +int wl_length(const wordlist *wlist); void wl_free(wordlist *wlist); wordlist * wl_copy(wordlist *wlist); 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); char ** wl_mkvec(wordlist *wl); 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_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); diff --git a/src/misc/wlist.c b/src/misc/wlist.c index d7de3784f..ebd448cd0 100644 --- a/src/misc/wlist.c +++ b/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. */ int -wl_length(wordlist *wlist) +wl_length(const wordlist *wl) { int i = 0; - wordlist *wl; - for (wl = wlist; wl; wl = wl->wl_next) + for (; wl; wl = wl->wl_next) i++; return (i); } @@ -90,11 +89,9 @@ printword(char *string, FILE *fp) /* Print a word list. (No \n at the end...) */ 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); if (wl->wl_next) putc(' ', fp); @@ -360,12 +357,12 @@ wl_chop_rest(wordlist *wl) */ wordlist * -wl_find(const char *string, wordlist *wl) +wl_find(const char *string, const wordlist *wl) { for (; wl; wl = wl->wl_next) if (eq(string, wl->wl_word)) break; - return wl; + return (wordlist *) wl; }