conf.c: move directive parsing out of _parseconfig
Include directives no longer have to be within a section. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
36f702ba82
commit
8287312c29
@ -841,6 +841,25 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int _parse_directive(const char *file, int linenum,
|
||||||
|
char *key, char *value, struct section_t *section)
|
||||||
|
{
|
||||||
|
if(section->name == NULL) {
|
||||||
|
pm_printf(ALPM_LOG_ERROR, _("config file %s, line %d: All directives must belong to a section.\n"),
|
||||||
|
file, linenum);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(section->parse_options && section->is_options) {
|
||||||
|
/* we are either in options ... */
|
||||||
|
return _parse_options(key, value, file, linenum);
|
||||||
|
} else if(!section->parse_options && !section->is_options) {
|
||||||
|
/* ... or in a repo section */
|
||||||
|
return _parse_repo(key, value, file, linenum, section);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/** The "real" parseconfig. Each "Include" directive will recall this method so
|
/** The "real" parseconfig. Each "Include" directive will recall this method so
|
||||||
* recursion and stack depth are limited to 10 levels. The publicly visible
|
* recursion and stack depth are limited to 10 levels. The publicly visible
|
||||||
* parseconfig calls this with a NULL section argument so we can recall from
|
* parseconfig calls this with a NULL section argument so we can recall from
|
||||||
@ -928,13 +947,6 @@ static int _parseconfig(const char *file, struct section_t *section, int depth)
|
|||||||
ret = 1;
|
ret = 1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
/* For each directive, compare to the camelcase string. */
|
|
||||||
if(section->name == NULL) {
|
|
||||||
pm_printf(ALPM_LOG_ERROR, _("config file %s, line %d: All directives must belong to a section.\n"),
|
|
||||||
file, linenum);
|
|
||||||
ret = 1;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
/* Include is allowed in both options and repo sections */
|
/* Include is allowed in both options and repo sections */
|
||||||
if(strcmp(key, "Include") == 0) {
|
if(strcmp(key, "Include") == 0) {
|
||||||
glob_t globbuf;
|
glob_t globbuf;
|
||||||
@ -976,16 +988,8 @@ static int _parseconfig(const char *file, struct section_t *section, int depth)
|
|||||||
globfree(&globbuf);
|
globfree(&globbuf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(section->parse_options && section->is_options) {
|
if((ret = _parse_directive(file, linenum, key, value, section)) != 0) {
|
||||||
/* we are either in options ... */
|
goto cleanup;
|
||||||
if((ret = _parse_options(key, value, file, linenum)) != 0) {
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
} else if(!section->parse_options && !section->is_options) {
|
|
||||||
/* ... or in a repo section */
|
|
||||||
if((ret = _parse_repo(key, value, file, linenum, section)) != 0) {
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user