diff --git a/src/frontend/inp.c b/src/frontend/inp.c index 23b3b3b3b..f9adf3fde 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -668,11 +668,10 @@ inp_spsource(FILE *fp, bool comfile, char *filename) } /* Now that the deck is loaded, do the commands, if there are any */ - if (controls) { - for (end = wl = wl_reverse(controls); wl; wl = wl->wl_next) - cp_evloop(wl->wl_word); - wl_free(end); - } + controls = wl_reverse(controls); + for (wl = controls; wl; wl = wl->wl_next) + cp_evloop(wl->wl_word); + wl_free(controls); } /* linked list dbs is used to store the "save" or .save data (defined in breakp2.c), diff --git a/src/frontend/nutinp.c b/src/frontend/nutinp.c index 4f58f0d31..98b8dfcd6 100644 --- a/src/frontend/nutinp.c +++ b/src/frontend/nutinp.c @@ -166,12 +166,10 @@ inp_nutsource(FILE *fp, bool comfile, char *filename) } /* Now that the deck is loaded, do the commands... */ - if (controls) { - for (end = wl = wl_reverse(controls); wl; - wl = wl->wl_next) - (void) cp_evloop(wl->wl_word); - wl_free(end); - } + controls = wl_reverse(controls); + for (wl = controls; wl; wl = wl->wl_next) + (void) cp_evloop(wl->wl_word); + wl_free(controls); } /* Now reset everything. Pop the control stack, and fix up the IO diff --git a/src/misc/wlist.c b/src/misc/wlist.c index 32c31ec86..df90efe79 100644 --- a/src/misc/wlist.c +++ b/src/misc/wlist.c @@ -155,16 +155,14 @@ wl_append(wordlist *wlist, wordlist *nwl) wordlist * wl_reverse(wordlist *wl) { - wordlist *w, *t; - - for (w = wl; ; w = t) { - t = w->wl_next; - w->wl_next = w->wl_prev; - w->wl_prev = t; - if (t == NULL) - break; + while (wl) { + wordlist *t = wl->wl_next; + wl->wl_next = wl->wl_prev; + wl->wl_prev = t; + wl = t; } - return (w); + + return wl; }