From 08ec67bc62242503f77d9503fdbf820c9c12d856 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Wed, 26 Mar 2008 13:32:30 +0000 Subject: patch: add support for -R. ~ +110 byte. By Pascal Bellard fbsplash: new applet by Michele Sanges cnt_history; hi > 0;) { - hi--; - free(state->history[hi]); - } + /* NB: do not trash old history if file can't be opened */ fp = fopen(fromfile, "r"); if (fp) { + /* clean up old history */ + for (hi = state->cnt_history; hi > 0;) { + hi--; + free(state->history[hi]); + } + for (hi = 0; hi < MAX_HISTORY;) { char *hl = xmalloc_getline(fp); int l; @@ -982,8 +984,8 @@ static void load_history(const char *fromfile) state->history[hi++] = hl; } fclose(fp); + state->cur_history = state->cnt_history = hi; } - state->cur_history = state->cnt_history = hi; } /* state->flags is already checked to be nonzero */ -- cgit v1.2.3