Skip to content

Commit 1ff86c4

Browse files
committed
create history file if it doesn't exist
When history is enabled but there is no history file, w3m logs an error message. Change that behavior to create a history file if it doesn't exists.
1 parent ee66aab commit 1ff86c4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

history.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,13 @@ saveHistory(Hist *hist, size_t size)
9090
return;
9191

9292
histf = rcFile(HISTORY_FILE);
93-
if (stat(histf, &st) == -1)
94-
goto fail;
93+
if (stat(histf, &st) == -1) {
94+
FILE *touchHist = fopen(histf, "w");
95+
if (touchHist == NULL)
96+
goto fail;
97+
if (fclose(touchHist) != 0)
98+
goto fail;
99+
}
95100
if (hist->mtime != (long long)st.st_mtime) {
96101
fhist = newHist();
97102
if (loadHistory(fhist) || mergeHistory(fhist, hist))

0 commit comments

Comments
 (0)