Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create history file if it doesn't exist #276

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

femnad
Copy link

@femnad femnad commented Jul 30, 2023

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.

@femnad femnad changed the title create history file if it doesn't exists create history file if it doesn't exist Jul 30, 2023
@rkta
Copy link
Contributor

rkta commented Aug 1, 2023 via email

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.
@femnad
Copy link
Author

femnad commented Aug 1, 2023

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).

@rkta
Copy link
Contributor

rkta commented Aug 1, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants