w3m
w3m copied to clipboard
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.
On Sun, Jul 30, 2023 at 05:53:47AM -0700, Cihan Demirci wrote:
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.
Oops... :-)
Thanks for this fix!
Two remarks:
- The indentation is off.
- We can simplify this:
--- a/history.c
+++ b/history.c
@@ -90,9 +90,7 @@ saveHistory(Hist *hist, size_t size)
return;
histf = rcFile(HISTORY_FILE);
- if (stat(histf, &st) == -1)
- goto fail;
- if (hist->mtime != (long long)st.st_mtime) {
+ if (!stat(histf, &st) && hist->mtime != (long long)st.st_mtime) {
fhist = newHist();
if (loadHistory(fhist) || mergeHistory(fhist, hist))
disp_err_message("Can't merge history", FALSE);
On Sun, Jul 30, 2023 at 05:53:47AM -0700, Cihan Demirci wrote: 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. Oops... :-) Thanks for this fix! Two remarks: 1. The indentation is off. 2. We can simplify this:
--- a/history.c +++ b/history.c @@ -90,9 +90,7 @@ saveHistory(Hist *hist, size_t size) return; histf = rcFile(HISTORY_FILE); - if (stat(histf, &st) == -1) - goto fail; - if (hist->mtime != (long long)st.st_mtime) { + if (!stat(histf, &st) && hist->mtime != (long long)st.st_mtime) { fhist = newHist(); if (loadHistory(fhist) || mergeHistory(fhist, hist)) disp_err_message("Can't merge history", FALSE);
I see, instead of explicitly creating an empty history, this leverages the newHist()
with the modified conditional, thanks!
I hope the indentation issue went away since this patch only adds one line now (and removes three).
LGTM, Thanks!