summaryrefslogtreecommitdiff
path: root/src/history.c
diff options
context:
space:
mode:
authorPhil Jones <philj56@gmail.com>2022-06-23 13:59:23 +0100
committerPhil Jones <philj56@gmail.com>2022-06-23 13:59:23 +0100
commitc57d9a2a65725dce8632bea6e539517f6b5e8f7d (patch)
treec18011302444bebaa9d3ca56549d22ca70507469 /src/history.c
parent8ee3f74a3267ded3444c6f68b0551af0ba09d943 (diff)
Add tofi-run symlink.
Invoking 'tofi' now acts like dmenu, expecting newline-separated options on stdin. Also fix history file handling and add an option to disable it.
Diffstat (limited to 'src/history.c')
-rw-r--r--src/history.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/history.c b/src/history.c
index 4438b5d..99edf79 100644
--- a/src/history.c
+++ b/src/history.c
@@ -66,11 +66,14 @@ struct history history_load()
return vec;
}
+ errno = 0;
if (fseek(histfile, 0, SEEK_END) != 0) {
log_error("Error seeking in history file: %s.\n", strerror(errno));
fclose(histfile);
return vec;
}
+
+ errno = 0;
size_t len = ftell(histfile);
if (fseek(histfile, 0, SEEK_SET) != 0) {
log_error("Error seeking in history file: %s.\n", strerror(errno));
@@ -78,8 +81,9 @@ struct history history_load()
return vec;
}
+ errno = 0;
char *buf = xmalloc(len);
- if (fread(buf, 1, len, histfile) != 0) {
+ if (fread(buf, 1, len, histfile) != len) {
log_error("Error reading history file: %s.\n", strerror(errno));
fclose(histfile);
return vec;