Skip to content

Commit

Permalink
create history file if it doesn't exists
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
femnad committed Jul 30, 2023
1 parent ee66aab commit 297eb5f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions history.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,13 @@ saveHistory(Hist *hist, size_t size)
return;

histf = rcFile(HISTORY_FILE);
if (stat(histf, &st) == -1)
goto fail;
if (stat(histf, &st) == -1) {
FILE *touchHist = fopen(histf, "w");
if (touchHist == NULL)
goto fail;
if (fclose(touchHist) != 0)
goto fail;
}
if (hist->mtime != (long long)st.st_mtime) {
fhist = newHist();
if (loadHistory(fhist) || mergeHistory(fhist, hist))
Expand Down

0 comments on commit 297eb5f

Please sign in to comment.