w3m
w3m copied to clipboard
Set `rc_dir` based on `W3M_DIR` environment variable.
By default, w3m puts all of its data in the ~/.w3m/
directory (creating it as necessary). This was not configurable in any way.
This commit addresses this problem. When the W3M_DIR
environment variable is set, w3m will use its contents to store its data files instead. The default location is unchanged.
This PR should resolve issue #130. Sorry for the delay :)
Thanks for the feedback @rkta -- I've made the changes you suggested (+ some minor fixes).
I had a closer look and found another more serious issue.
PATH_MAX is problematic, but I'm ok with its use here. Though the strncpy(component, dir, sizeof(component)); needs an error check.
And I would squash those commits, but that's not on me to decide. Otherwise LGTM.
Thanks!
Thanks for catching the strncpy
bug -- the latest push should fix it. I've updated to a proper malloc
style implementation to address the former reservation.
I was under the impression that squashing (if desired) happens when merging -- I can squash them now no problem though.
With this changes we don't need limits.h anymore, do we?
Fixed. I appreciate your patience.
One more thing:
rc.c: In function ‘init_rc’: rc.c:1353:17: warning: unused variable ‘st’ [-Wunused-variable] 1353 | struct stat st; | ^~
Sorry for being that late.
Fixed.
I hope this will be merged eventually. It's a useful feature.
On Wed, Jun 01, 2022 at 04:59:13AM -0700, N-R-K wrote:
@N-R-K commented on this pull request.
- n = strlen(dir);
- if (n == 0)
- return -1;
- if ((dircpy = malloc(n + 1)) == NULL)
- return -1;
- strcpy(dircpy, dir);
Any reason for not using
strdup(3)
?
Or even better 'Strnew_charp()' - and then replace the above 'strlen' call and 'if' with:
if (*n = '\0') return -1;
@rkta The syscall below needs a const char *
, so I'd have to break encapsulation anyways (and I thought the Str getters and indexing would overcomplicate the function). do_mkdir
got away with standard C, so I followed :)
Is there a reason you'd prefer that construct?
On Thu, Jun 02, 2022 at 06:16:55PM -0700, yashlala wrote:
@rkta The syscall below needs a
const char *
, so I'd have to break encapsulation anyways (+ I thought the Str getters and indexing would overcomplicate the function).do_mkdir
got away with standard C, so I followed :)
Instead of: if ((dircpy = malloc(n + 1)) == NULL) return -1; strcpy(dircpy, dir);
you can do: dircpy = Strnew_charp(dir)->ptr;
and you don't need to care about malloc() and free(). Strnew_charp() will exit(1) if malloc() fails and garbage collect the memory if it's not used anymore.
Is there a reason you'd prefer that construct?
I'd say it's the common pattern used in the code base, but it's not really that important.
Huh. I'm amazed the garbage collector can differentiate C pointer data from integer data to that degree of confidence.
I've made the change you suggested. Please let me know if there's anything else I should do before it's merged.
Hi @N-R-K ; Github is telling me that you need to review this before the patch can be merged into main, so I'm reaching out again. If there's anything I need to do before it's ready for upstream, I'm happy to do so.
Github is telling me that you need to review this before the patch can be merged into main
Huh, I think that's just some generic UI thing. I'm not the maintainer of this project (@tats is) nor am I in any position to decide what gets merged to master.
Alright then. @tats -- unless you have suggestions, I think this PR is finalized and ready to merge.
Any update?
I plan to merge this, though still XDG-non-compliant.
Merged, thanks for your contribution.