tweaks: reshuffle some conditions, to straighten the logic

master
Benno Schulenberg 2020-06-29 12:39:46 +02:00
parent f9b1306adf
commit 3344571227
1 changed files with 14 additions and 17 deletions

View File

@ -287,19 +287,17 @@ void load_history(void)
char *histname = concatenate(statedir, SEARCH_HISTORY);
FILE *histfile = fopen(histname, "rb");
if (histfile == NULL) {
/* If reading an existing file failed, don't save history when we quit. */
if (errno != ENOENT) {
jot_error(N_("Error reading %s: %s"), histname, strerror(errno));
UNSET(HISTORYLOG);
}
free(histname);
return;
/* If reading an existing file failed, don't save history when we quit. */
if (histfile == NULL && errno != ENOENT) {
jot_error(N_("Error reading %s: %s"), histname, strerror(errno));
UNSET(HISTORYLOG);
}
free(histname);
if (histfile == NULL)
return;
linestruct **history = &search_history;
char *line = NULL;
size_t buf_len = 0;
@ -383,16 +381,15 @@ void load_poshistory(void)
{
FILE *histfile = fopen(poshistname, "rb");
if (histfile == NULL) {
/* If reading an existing file failed, don't save history when we quit. */
if (errno != ENOENT) {
jot_error(N_("Error reading %s: %s"), poshistname, strerror(errno));
UNSET(POSITIONLOG);
}
return;
/* If reading an existing file failed, don't save history when we quit. */
if (histfile == NULL && errno != ENOENT) {
jot_error(N_("Error reading %s: %s"), poshistname, strerror(errno));
UNSET(POSITIONLOG);
}
if (histfile == NULL)
return;
char *line = NULL, *lineptr, *xptr;
size_t buf_len = 0;
ssize_t read, count = 0;