FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 03-16-2011, 11:09 PM
Dan McGee
 
Default Warn but don't error for unknown pacman.conf directives

This makes all the pacman developers' jobs harder as we have to switch
files whenever running multiple pacman versions and are using newly
introduced options. Instead of erroring out, print warnings and continue
on.

This patch also fixes a const-correctness issue. We immediately cast a
'const char *' to a 'char *' in setrepeatingoption(), which is just
plain wrong as we manipulate the underlying string. Fix the types and
remove the now unnecessary variable.

Finally, a few messages change here for consistency and clarity and
because we continue parsing rather than bailing out on a problem.

Signed-off-by: Dan McGee <dan@archlinux.org>
---

For maint. Requested by Xavier, +1 from Allan.

-Dan

src/pacman/pacman.c | 50 ++++++++++++++++++++++++--------------------------
1 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 984bd1b..a520338 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -817,21 +817,20 @@ static void option_add_cleanmethod(const char *value) {
* @param option the string (friendly) name of the option, used for messages
* @param optionfunc a function pointer to an alpm_option_add_* function
*/
-static void setrepeatingoption(const char *ptr, const char *option,
+static void setrepeatingoption(char *ptr, const char *option,
void (*optionfunc)(const char*))
{
- char *p = (char*)ptr;
char *q;

- while((q = strchr(p, ' '))) {
+ while((q = strchr(ptr, ' '))) {
*q = '';
- (*optionfunc)(p);
- pm_printf(PM_LOG_DEBUG, "config: %s: %s
", option, p);
- p = q;
- p++;
+ (*optionfunc)(ptr);
+ pm_printf(PM_LOG_DEBUG, "config: %s: %s
", option, ptr);
+ ptr = q;
+ ptr++;
}
- (*optionfunc)(p);
- pm_printf(PM_LOG_DEBUG, "config: %s: %s
", option, p);
+ (*optionfunc)(ptr);
+ pm_printf(PM_LOG_DEBUG, "config: %s: %s
", option, ptr);
}

static char *get_filename(const char *url) {
@@ -954,7 +953,8 @@ cleanup:
return(ret);
}

-static int _parse_options(char *key, char *value)
+static int _parse_options(const char *key, char *value,
+ const char *file, int linenum)
{
if(value == NULL) {
/* options without settings */
@@ -976,8 +976,9 @@ static int _parse_options(char *key, char *value)
} else if(strcmp(key, "CheckSpace") == 0) {
alpm_option_set_checkspace(1);
} else {
- pm_printf(PM_LOG_ERROR, _("directive '%s' without value not recognized
"), key);
- return(1);
+ pm_printf(PM_LOG_WARNING,
+ _("config file %s, line %d: directive '%s' in section '%s' not recognized.
"),
+ file, linenum, key, "options");
}
} else {
/* options with settings */
@@ -1028,8 +1029,10 @@ static int _parse_options(char *key, char *value)
} else if (strcmp(key, "CleanMethod") == 0) {
setrepeatingoption(value, "CleanMethod", option_add_cleanmethod);
} else {
- pm_printf(PM_LOG_ERROR, _("directive '%s' with a value not recognized
"), key);
- return(1);
+
+ pm_printf(PM_LOG_WARNING,
+ _("config file %s, line %d: directive '%s' in section '%s' not recognized.
"),
+ file, linenum, key, "options");
}

}
@@ -1163,7 +1166,7 @@ static int _parseconfig(const char *file, const char *givensection,
/* Include is allowed in both options and repo sections */
if(strcmp(key, "Include") == 0) {
if(value == NULL) {
- pm_printf(PM_LOG_ERROR, _("config file %s, line %d: directive %s needs a value
"),
+ pm_printf(PM_LOG_ERROR, _("config file %s, line %d: directive '%s' needs a value
"),
file, linenum, key);
ret = 1;
goto cleanup;
@@ -1175,12 +1178,12 @@ static int _parseconfig(const char *file, const char *givensection,
switch(globret) {
case GLOB_NOSPACE:
pm_printf(PM_LOG_DEBUG,
- "config file %s, line %d: include globing out of space
",
+ "config file %s, line %d: include globbing out of space
",
file, linenum);
break;
case GLOB_ABORTED:
pm_printf(PM_LOG_DEBUG,
- "config file %s, line %d: include globing read error for %s
",
+ "config file %s, line %d: include globbing read error for %s
",
file, linenum, value);
break;
case GLOB_NOMATCH:
@@ -1201,18 +1204,14 @@ static int _parseconfig(const char *file, const char *givensection,
}
if(strcmp(section, "options") == 0) {
/* we are either in options ... */
- if((ret = _parse_options(key, value)) != 0) {
- pm_printf(PM_LOG_ERROR, _("config file %s, line %d: problem in options section
"),
- file, linenum);
- ret = 1;
+ if((ret = _parse_options(key, value, file, linenum)) != 0) {
goto cleanup;
}
- continue;
} else {
/* ... or in a repo section */
if(strcmp(key, "Server") == 0) {
if(value == NULL) {
- pm_printf(PM_LOG_ERROR, _("config file %s, line %d: directive %s needs a value
"),
+ pm_printf(PM_LOG_ERROR, _("config file %s, line %d: directive '%s' needs a value
"),
file, linenum, key);
ret = 1;
goto cleanup;
@@ -1222,10 +1221,9 @@ static int _parseconfig(const char *file, const char *givensection,
goto cleanup;
}
} else {
- pm_printf(PM_LOG_ERROR, _("config file %s, line %d: directive '%s' in repository section '%s' not recognized.
"),
+ pm_printf(PM_LOG_WARNING,
+ _("config file %s, line %d: directive '%s' in section '%s' not recognized.
"),
file, linenum, key, section);
- ret = 1;
- goto cleanup;
}
}

--
1.7.4.1
 

Thread Tools




All times are GMT. The time now is 08:24 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org