Further simplify rpmInitMacros()
- Use argvSplit() for splitting the macro path to components instead of manual pointer-parsery. - If URL's are to be supported or accepted at all (previous code attempted to skip them), ':' is a very poor delimiter character.
This commit is contained in:
parent
e336146a9e
commit
9ae911eefe
|
@ -1511,45 +1511,32 @@ exit:
|
||||||
void
|
void
|
||||||
rpmInitMacros(rpmMacroContext mc, const char * macrofiles)
|
rpmInitMacros(rpmMacroContext mc, const char * macrofiles)
|
||||||
{
|
{
|
||||||
char *mfiles, *m, *me;
|
ARGV_t pattern, globs = NULL;
|
||||||
|
|
||||||
if (macrofiles == NULL)
|
if (macrofiles == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mfiles = xstrdup(macrofiles);
|
argvSplit(&globs, macrofiles, ":");
|
||||||
for (m = mfiles; m && *m != '\0'; m = me) {
|
for (pattern = globs; *pattern; pattern++) {
|
||||||
ARGV_t av = NULL;
|
ARGV_t path, files = NULL;
|
||||||
int ac = 0;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (me = m; (me = strchr(me, ':')) != NULL; me++) {
|
|
||||||
/* Skip over URI's. */
|
|
||||||
if (!(me[1] == '/' && me[2] == '/'))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (me && *me == ':')
|
|
||||||
*me++ = '\0';
|
|
||||||
else
|
|
||||||
me = m + strlen(m);
|
|
||||||
|
|
||||||
/* Glob expand the macro file path element, expanding ~ to $HOME. */
|
/* Glob expand the macro file path element, expanding ~ to $HOME. */
|
||||||
i = rpmGlob(m, &ac, &av);
|
if (rpmGlob(*pattern, NULL, &files) != 0) {
|
||||||
if (i != 0)
|
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* Read macros from each file. */
|
/* Read macros from each file. */
|
||||||
for (i = 0; i < ac; i++) {
|
for (path = files; *path; path++) {
|
||||||
if (rpmFileHasSuffix(av[i], ".rpmnew") ||
|
if (rpmFileHasSuffix(*path, ".rpmnew") ||
|
||||||
rpmFileHasSuffix(av[i], ".rpmsave") ||
|
rpmFileHasSuffix(*path, ".rpmsave") ||
|
||||||
rpmFileHasSuffix(av[i], ".rpmorig")) {
|
rpmFileHasSuffix(*path, ".rpmorig")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
(void) rpmLoadMacroFile(mc, av[i]);
|
(void) rpmLoadMacroFile(mc, *path);
|
||||||
}
|
}
|
||||||
argvFree(av);
|
argvFree(files);
|
||||||
}
|
}
|
||||||
mfiles = _free(mfiles);
|
argvFree(globs);
|
||||||
|
|
||||||
/* Reload cmdline macros */
|
/* Reload cmdline macros */
|
||||||
rpmLoadMacros(rpmCLIMacroContext, RMIL_CMDLINE);
|
rpmLoadMacros(rpmCLIMacroContext, RMIL_CMDLINE);
|
||||||
|
|
Loading…
Reference in New Issue