Xdg config dir#130
Conversation
pmatilai
left a comment
There was a problem hiding this comment.
We can't read both ~/.popt and the XDG version, it needs to be one or the other.
I'd suggest first determining the path (based on file existence), preferring XDG if it exists, and then have exactly one poptReadConfig() call to process it. Also, magic "+20" on buffer sizes doesn't cut it. Calculate the string size and then +1 for the trailing zero.
poptReadConfigFile reads an optional config file, ie. it returns success even if that config file does not exist. This behavior is exported and can not be changed. But sometimes, eg. with ~/.config/popt and ~/.popt, we need to know whether a config file exists in order to read just one. Add poptReadConfigFileInternal to allow that. It basically is the guts of the old poptReadConfigFile. And make poptReadConfigFile a very thin wrapper around poptReadConfigFileInternal.
Look for per-user alias specification in the ${XDG_CONFIG_HOME}/popt
file. Still look in the traditional ${HOME}/.popt file but only if the
file in the new XDG base directory doesn't exists.
As per the XDG spec, if ${XDG_CONFIG_HOME} is not set, default to
~/.config/popt.
Fixes: rpm-software-management#129
|
Let's see whether this addresses your review. Please note that poptReadConfigFile being exported (being API) complicated things quite a bit. This series should not alter that API. Fingers crossed!
Being lazy, I only copied the approach used in master. Anyhow, manipulating strings in C is fun (for specific values of fun). Fingers crossed again! |
This is an attempt at fixing issue #129. I've tried to keep it as simple as possible.
Note that this small series will make popt check both XDG_CONFIG_HOME/popt and ~/.popt. It is explained is some detail in the commit description, comments and in popt.3.
Speaking about popt.3: I gave up on understanding the groff, nroff, troff or whatever formatting stuff. It renders OK on my machine, but that might be just dumb luck.