[pacman-dev] Case sensitive options in pacman.conf
Xavier
shiningxc at gmail.com
Tue Mar 11 11:10:29 EDT 2008
Currently, every options in pacman.conf apparently has a fixed case :
RootDir = /
DBPath = /var/lib/pacman/
CacheDir = /var/cache/pacman/pkg/
LogFile = /var/log/pacman.log
HoldPkg = pacman glibc
But in fact, pacman does an insensitive comparisons when parsing the file.
} else if(!strcmp(key, "CACHEDIR")) {
with key = strtoupper("CacheDir")
So you can put cAcHeDiR if you like..
Then we found out this insensitive comparison didn't work in some locales,
like tr_TR one, where for example, upper(i) != I
To work around this, we also added a sensitive comparison :
} else if(strcmp(origkey, "CacheDir") == 0 || strcmp(key, "CACHEDIR") == 0) {
http://projects.archlinux.org/git/?p=pacman.git;a=commitdiff;h=1cd7567ff8af4bcc2813eb0f104fdab8ef0f7c53
So in fact, in tr_TR locale, only case sensitive options will really work (eg
cAcHeDiR won't work).
Why do we make a special case for this locale? I think that having to do
every single comparisons twice during the config file parsing is really ugly,
and more error prone when adding new options.
So I would vote for only allowing case sensitive options in pacman.conf, to
treat all locales equally, and cleaning the code :)
If that's not acceptable, what about adding a new function, to do something
like :
} else if(compare(origkey, "CacheDir", "CACHEDIR") == 0) {
That still isn't ideal but would at least reduce the duplication a bit.
More information about the pacman-dev
mailing list