Drop case insensitive comparisons in the config parsing.
These case insensitive comparisons didn't work in some locales, like tr_TR where upper(i) != I. So a second case sensitive comparison had to be made for each directive. Only keeping case sensitive comparisons make the code cleaner and treat all locales equally. Ref: http://www.archlinux.org/pipermail/pacman-dev/2008-March/011445.html Also fix pactests to use the correct case. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
dae3f9deef
commit
b3e6cf652c
11 changed files with 32 additions and 40 deletions
|
@ -40,6 +40,8 @@ Include = /etc/pacman.d/core
|
||||||
Server = file:///home/pkgs
|
Server = file:///home/pkgs
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
*NOTE*: Each directive must be in CamelCase. If the case isn't respected, the directive
|
||||||
|
won't be recognized. For example. noupgrade or NOUPGRADE will not work.
|
||||||
|
|
||||||
Options
|
Options
|
||||||
-------
|
-------
|
||||||
|
|
|
@ -3,7 +3,7 @@ self.description = "Remove a package in HoldPkg"
|
||||||
p1 = pmpkg("dummy")
|
p1 = pmpkg("dummy")
|
||||||
self.addpkg2db("local", p1)
|
self.addpkg2db("local", p1)
|
||||||
|
|
||||||
self.option["holdpkg"] = ["dummy"]
|
self.option["HoldPkg"] = ["dummy"]
|
||||||
|
|
||||||
self.args = "-R %s" % p1.name
|
self.args = "-R %s" % p1.name
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ sp3.groups = ["grp"]
|
||||||
for p in sp1, sp2, sp3:
|
for p in sp1, sp2, sp3:
|
||||||
self.addpkg2db("sync", p);
|
self.addpkg2db("sync", p);
|
||||||
|
|
||||||
self.option["ignorepkg"] = ["pkg2"]
|
self.option["IgnorePkg"] = ["pkg2"]
|
||||||
|
|
||||||
self.args = "-S grp"
|
self.args = "-S grp"
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ lp2 = pmpkg("pkg2")
|
||||||
for p in lp1, lp2:
|
for p in lp1, lp2:
|
||||||
self.addpkg2db("local", p)
|
self.addpkg2db("local", p)
|
||||||
|
|
||||||
self.option["ignorepkg"] = ["pkg2"]
|
self.option["IgnorePkg"] = ["pkg2"]
|
||||||
|
|
||||||
self.args = "-Su"
|
self.args = "-Su"
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ lp = pmpkg("pkg1")
|
||||||
|
|
||||||
self.addpkg2db("local", lp)
|
self.addpkg2db("local", lp)
|
||||||
|
|
||||||
self.option["ignorepkg"] = ["pkg1"]
|
self.option["IgnorePkg"] = ["pkg1"]
|
||||||
|
|
||||||
self.args = "-Su"
|
self.args = "-Su"
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ lp2 = pmpkg("pkg2")
|
||||||
for p in lp1, lp2:
|
for p in lp1, lp2:
|
||||||
self.addpkg2db("local", p)
|
self.addpkg2db("local", p)
|
||||||
|
|
||||||
self.option["ignoregroup"] = ["grp"]
|
self.option["IgnoreGroup"] = ["grp"]
|
||||||
|
|
||||||
self.args = "-Su"
|
self.args = "-Su"
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ p = pmpkg("dummy", "1.0-2")
|
||||||
p.files = ["etc/dummy.conf"]
|
p.files = ["etc/dummy.conf"]
|
||||||
self.addpkg(p)
|
self.addpkg(p)
|
||||||
|
|
||||||
self.option["noupgrade"] = ["etc/dummy.conf"]
|
self.option["NoUpgrade"] = ["etc/dummy.conf"]
|
||||||
|
|
||||||
self.args = "-U %s" % p.filename()
|
self.args = "-U %s" % p.filename()
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ p.files = ["bin/dummy",
|
||||||
"usr/man/man1/dummy.1"]
|
"usr/man/man1/dummy.1"]
|
||||||
self.addpkg(p)
|
self.addpkg(p)
|
||||||
|
|
||||||
self.option["noextract"] = ["usr/man/man1/dummy.1"]
|
self.option["NoExtract"] = ["usr/man/man1/dummy.1"]
|
||||||
|
|
||||||
self.args = "-U %s" % p.filename()
|
self.args = "-U %s" % p.filename()
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ self.description = "Quick check for using XferCommand"
|
||||||
# this setting forces us to download packages
|
# this setting forces us to download packages
|
||||||
self.cachepkgs = False
|
self.cachepkgs = False
|
||||||
#wget doesn't support file:// urls. curl does
|
#wget doesn't support file:// urls. curl does
|
||||||
self.option['xfercommand'] = ['/usr/bin/curl %u > %o']
|
self.option['XferCommand'] = ['/usr/bin/curl %u > %o']
|
||||||
|
|
||||||
numpkgs = 10
|
numpkgs = 10
|
||||||
pkgnames = []
|
pkgnames = []
|
||||||
|
|
|
@ -181,7 +181,7 @@ def mkcfgfile(filename, root, option, db):
|
||||||
|
|
||||||
# Repositories
|
# Repositories
|
||||||
data.extend(["[%s]\n" \
|
data.extend(["[%s]\n" \
|
||||||
"server = file://%s\n" \
|
"Server = file://%s\n" \
|
||||||
% (value.treename, \
|
% (value.treename, \
|
||||||
os.path.join(root, SYNCREPO, value.treename)) \
|
os.path.join(root, SYNCREPO, value.treename)) \
|
||||||
for key, value in db.iteritems() if key != "local"])
|
for key, value in db.iteritems() if key != "local"])
|
||||||
|
|
|
@ -604,7 +604,7 @@ static int _parseconfig(const char *file, const char *givensection,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* directive */
|
/* directive */
|
||||||
char *key, *upperkey;
|
char *key;
|
||||||
/* strsep modifies the 'line' string: 'key \0 ptr' */
|
/* strsep modifies the 'line' string: 'key \0 ptr' */
|
||||||
key = line;
|
key = line;
|
||||||
ptr = line;
|
ptr = line;
|
||||||
|
@ -617,11 +617,7 @@ static int _parseconfig(const char *file, const char *givensection,
|
||||||
file, linenum);
|
file, linenum);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
/* For each directive, compare to the uppercase and camelcase string.
|
/* For each directive, compare to the camelcase string. */
|
||||||
* This prevents issues with certain locales where characters don't
|
|
||||||
* follow the toupper() rules we may expect, e.g. tr_TR where i != I.
|
|
||||||
*/
|
|
||||||
upperkey = strtoupper(strdup(key));
|
|
||||||
if(section == NULL) {
|
if(section == NULL) {
|
||||||
pm_printf(PM_LOG_ERROR, _("config file %s, line %d: All directives must belong to a section.\n"),
|
pm_printf(PM_LOG_ERROR, _("config file %s, line %d: All directives must belong to a section.\n"),
|
||||||
file, linenum);
|
file, linenum);
|
||||||
|
@ -629,25 +625,25 @@ static int _parseconfig(const char *file, const char *givensection,
|
||||||
}
|
}
|
||||||
if(ptr == NULL && strcmp(section, "options") == 0) {
|
if(ptr == NULL && strcmp(section, "options") == 0) {
|
||||||
/* directives without settings, all in [options] */
|
/* directives without settings, all in [options] */
|
||||||
if(strcmp(key, "NoPassiveFTP") == 0 || strcmp(upperkey, "NOPASSIVEFTP") == 0) {
|
if(strcmp(key, "NoPassiveFTP") == 0) {
|
||||||
alpm_option_set_nopassiveftp(1);
|
alpm_option_set_nopassiveftp(1);
|
||||||
pm_printf(PM_LOG_DEBUG, "config: nopassiveftp\n");
|
pm_printf(PM_LOG_DEBUG, "config: nopassiveftp\n");
|
||||||
} else if(strcmp(key, "UseSyslog") == 0 || strcmp(upperkey, "USESYSLOG") == 0) {
|
} else if(strcmp(key, "UseSyslog") == 0) {
|
||||||
alpm_option_set_usesyslog(1);
|
alpm_option_set_usesyslog(1);
|
||||||
pm_printf(PM_LOG_DEBUG, "config: usesyslog\n");
|
pm_printf(PM_LOG_DEBUG, "config: usesyslog\n");
|
||||||
} else if(strcmp(key, "ILoveCandy") == 0 || strcmp(upperkey, "ILOVECANDY") == 0) {
|
} else if(strcmp(key, "ILoveCandy") == 0) {
|
||||||
config->chomp = 1;
|
config->chomp = 1;
|
||||||
pm_printf(PM_LOG_DEBUG, "config: chomp\n");
|
pm_printf(PM_LOG_DEBUG, "config: chomp\n");
|
||||||
} else if(strcmp(key, "UseColor") == 0 || strcmp(upperkey, "USECOLOR") == 0) {
|
} else if(strcmp(key, "UseColor") == 0) {
|
||||||
config->usecolor = 1;
|
config->usecolor = 1;
|
||||||
pm_printf(PM_LOG_DEBUG, "config: usecolor\n");
|
pm_printf(PM_LOG_DEBUG, "config: usecolor\n");
|
||||||
} else if(strcmp(key, "ShowSize") == 0 || strcmp(upperkey, "SHOWSIZE") == 0) {
|
} else if(strcmp(key, "ShowSize") == 0) {
|
||||||
config->showsize = 1;
|
config->showsize = 1;
|
||||||
pm_printf(PM_LOG_DEBUG, "config: showsize\n");
|
pm_printf(PM_LOG_DEBUG, "config: showsize\n");
|
||||||
} else if(strcmp(key, "UseDelta") == 0 || strcmp(upperkey, "USEDELTA") == 0) {
|
} else if(strcmp(key, "UseDelta") == 0) {
|
||||||
alpm_option_set_usedelta(1);
|
alpm_option_set_usedelta(1);
|
||||||
pm_printf(PM_LOG_DEBUG, "config: usedelta\n");
|
pm_printf(PM_LOG_DEBUG, "config: usedelta\n");
|
||||||
} else if(strcmp(key, "TotalDownload") == 0 || strcmp(upperkey, "TOTALDOWNLOAD") == 0) {
|
} else if(strcmp(key, "TotalDownload") == 0) {
|
||||||
config->totaldownload = 1;
|
config->totaldownload = 1;
|
||||||
pm_printf(PM_LOG_DEBUG, "config: totaldownload\n");
|
pm_printf(PM_LOG_DEBUG, "config: totaldownload\n");
|
||||||
} else {
|
} else {
|
||||||
|
@ -657,51 +653,46 @@ static int _parseconfig(const char *file, const char *givensection,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* directives with settings */
|
/* directives with settings */
|
||||||
if(strcmp(key, "Include") == 0 || strcmp(upperkey, "INCLUDE") == 0) {
|
if(strcmp(key, "Include") == 0) {
|
||||||
pm_printf(PM_LOG_DEBUG, "config: including %s\n", ptr);
|
pm_printf(PM_LOG_DEBUG, "config: including %s\n", ptr);
|
||||||
_parseconfig(ptr, section, db);
|
_parseconfig(ptr, section, db);
|
||||||
/* Ignore include failures... assume non-critical */
|
/* Ignore include failures... assume non-critical */
|
||||||
} else if(strcmp(section, "options") == 0) {
|
} else if(strcmp(section, "options") == 0) {
|
||||||
if(strcmp(key, "NoUpgrade") == 0
|
if(strcmp(key, "NoUpgrade") == 0) {
|
||||||
|| strcmp(upperkey, "NOUPGRADE") == 0) {
|
|
||||||
setrepeatingoption(ptr, "NoUpgrade", alpm_option_add_noupgrade);
|
setrepeatingoption(ptr, "NoUpgrade", alpm_option_add_noupgrade);
|
||||||
} else if(strcmp(key, "NoExtract") == 0
|
} else if(strcmp(key, "NoExtract") == 0) {
|
||||||
|| strcmp(upperkey, "NOEXTRACT") == 0) {
|
|
||||||
setrepeatingoption(ptr, "NoExtract", alpm_option_add_noextract);
|
setrepeatingoption(ptr, "NoExtract", alpm_option_add_noextract);
|
||||||
} else if(strcmp(key, "IgnorePkg") == 0
|
} else if(strcmp(key, "IgnorePkg") == 0) {
|
||||||
|| strcmp(upperkey, "IGNOREPKG") == 0) {
|
|
||||||
setrepeatingoption(ptr, "IgnorePkg", alpm_option_add_ignorepkg);
|
setrepeatingoption(ptr, "IgnorePkg", alpm_option_add_ignorepkg);
|
||||||
} else if(strcmp(key, "IgnoreGroup") == 0
|
} else if(strcmp(key, "IgnoreGroup") == 0) {
|
||||||
|| strcmp(upperkey, "IGNOREGROUP") == 0) {
|
|
||||||
setrepeatingoption(ptr, "IgnoreGroup", alpm_option_add_ignoregrp);
|
setrepeatingoption(ptr, "IgnoreGroup", alpm_option_add_ignoregrp);
|
||||||
} else if(strcmp(key, "HoldPkg") == 0
|
} else if(strcmp(key, "HoldPkg") == 0) {
|
||||||
|| strcmp(upperkey, "HOLDPKG") == 0) {
|
|
||||||
setrepeatingoption(ptr, "HoldPkg", alpm_option_add_holdpkg);
|
setrepeatingoption(ptr, "HoldPkg", alpm_option_add_holdpkg);
|
||||||
} else if(strcmp(key, "DBPath") == 0 || strcmp(upperkey, "DBPATH") == 0) {
|
} else if(strcmp(key, "DBPath") == 0) {
|
||||||
/* don't overwrite a path specified on the command line */
|
/* don't overwrite a path specified on the command line */
|
||||||
if(!config->dbpath) {
|
if(!config->dbpath) {
|
||||||
config->dbpath = strdup(ptr);
|
config->dbpath = strdup(ptr);
|
||||||
pm_printf(PM_LOG_DEBUG, "config: dbpath: %s\n", ptr);
|
pm_printf(PM_LOG_DEBUG, "config: dbpath: %s\n", ptr);
|
||||||
}
|
}
|
||||||
} else if(strcmp(key, "CacheDir") == 0 || strcmp(upperkey, "CACHEDIR") == 0) {
|
} else if(strcmp(key, "CacheDir") == 0) {
|
||||||
if(alpm_option_add_cachedir(ptr) != 0) {
|
if(alpm_option_add_cachedir(ptr) != 0) {
|
||||||
pm_printf(PM_LOG_ERROR, _("problem adding cachedir '%s' (%s)\n"),
|
pm_printf(PM_LOG_ERROR, _("problem adding cachedir '%s' (%s)\n"),
|
||||||
ptr, alpm_strerrorlast());
|
ptr, alpm_strerrorlast());
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
pm_printf(PM_LOG_DEBUG, "config: cachedir: %s\n", ptr);
|
pm_printf(PM_LOG_DEBUG, "config: cachedir: %s\n", ptr);
|
||||||
} else if(strcmp(key, "RootDir") == 0 || strcmp(upperkey, "ROOTDIR") == 0) {
|
} else if(strcmp(key, "RootDir") == 0) {
|
||||||
/* don't overwrite a path specified on the command line */
|
/* don't overwrite a path specified on the command line */
|
||||||
if(!config->rootdir) {
|
if(!config->rootdir) {
|
||||||
config->rootdir = strdup(ptr);
|
config->rootdir = strdup(ptr);
|
||||||
pm_printf(PM_LOG_DEBUG, "config: rootdir: %s\n", ptr);
|
pm_printf(PM_LOG_DEBUG, "config: rootdir: %s\n", ptr);
|
||||||
}
|
}
|
||||||
} else if (strcmp(key, "LogFile") == 0 || strcmp(upperkey, "LOGFILE") == 0) {
|
} else if (strcmp(key, "LogFile") == 0) {
|
||||||
if(!config->logfile) {
|
if(!config->logfile) {
|
||||||
config->logfile = strdup(ptr);
|
config->logfile = strdup(ptr);
|
||||||
pm_printf(PM_LOG_DEBUG, "config: logfile: %s\n", ptr);
|
pm_printf(PM_LOG_DEBUG, "config: logfile: %s\n", ptr);
|
||||||
}
|
}
|
||||||
} else if (strcmp(key, "XferCommand") == 0 || strcmp(upperkey, "XFERCOMMAND") == 0) {
|
} else if (strcmp(key, "XferCommand") == 0) {
|
||||||
alpm_option_set_xfercommand(ptr);
|
alpm_option_set_xfercommand(ptr);
|
||||||
pm_printf(PM_LOG_DEBUG, "config: xfercommand: %s\n", ptr);
|
pm_printf(PM_LOG_DEBUG, "config: xfercommand: %s\n", ptr);
|
||||||
} else {
|
} else {
|
||||||
|
@ -709,7 +700,7 @@ static int _parseconfig(const char *file, const char *givensection,
|
||||||
file, linenum, key);
|
file, linenum, key);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
} else if(strcmp(key, "Server") == 0 || strcmp(upperkey, "SERVER") == 0) {
|
} else if(strcmp(key, "Server") == 0) {
|
||||||
/* let's attempt a replacement for the current repo */
|
/* let's attempt a replacement for the current repo */
|
||||||
char *server = strreplace(ptr, "$repo", section);
|
char *server = strreplace(ptr, "$repo", section);
|
||||||
|
|
||||||
|
@ -725,7 +716,6 @@ static int _parseconfig(const char *file, const char *givensection,
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(upperkey);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
Loading…
Add table
Reference in a new issue