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 */
|
/* Now that the deck is loaded, do the commands, if there are any */
|
||||||
if (controls) {
|
controls = wl_reverse(controls);
|
||||||
for (end = wl = wl_reverse(controls); wl; wl = wl->wl_next)
|
for (wl = controls; wl; wl = wl->wl_next)
|
||||||
cp_evloop(wl->wl_word);
|
cp_evloop(wl->wl_word);
|
||||||
wl_free(end);
|
wl_free(controls);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* linked list dbs is used to store the "save" or .save data (defined in breakp2.c),
|
/* 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... */
|
/* Now that the deck is loaded, do the commands... */
|
||||||
if (controls) {
|
controls = wl_reverse(controls);
|
||||||
for (end = wl = wl_reverse(controls); wl;
|
for (wl = controls; wl; wl = wl->wl_next)
|
||||||
wl = wl->wl_next)
|
(void) cp_evloop(wl->wl_word);
|
||||||
(void) cp_evloop(wl->wl_word);
|
wl_free(controls);
|
||||||
wl_free(end);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now reset everything. Pop the control stack, and fix up the IO
|
/* Now reset everything. Pop the control stack, and fix up the IO
|
||||||
|
|
|
||||||
|
|
@ -155,16 +155,14 @@ wl_append(wordlist *wlist, wordlist *nwl)
|
||||||
wordlist *
|
wordlist *
|
||||||
wl_reverse(wordlist *wl)
|
wl_reverse(wordlist *wl)
|
||||||
{
|
{
|
||||||
wordlist *w, *t;
|
while (wl) {
|
||||||
|
wordlist *t = wl->wl_next;
|
||||||
for (w = wl; ; w = t) {
|
wl->wl_next = wl->wl_prev;
|
||||||
t = w->wl_next;
|
wl->wl_prev = t;
|
||||||
w->wl_next = w->wl_prev;
|
wl = t;
|
||||||
w->wl_prev = t;
|
|
||||||
if (t == NULL)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return (w);
|
|
||||||
|
return wl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue