fix wl_reverse() for empty lists
This commit is contained in:
parent
5859f1a61d
commit
a890a55937
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue