diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2008-04-19 16:42:56 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2008-04-19 16:42:56 +0300 |
commit | 9ae911eefedf9618202b6a76d670914119784464 (patch) | |
tree | 65be934cdfbf7712e5cb6e8e18c4a9a42760a076 /rpmio | |
parent | e336146a9ed6b28016e0dff68ea6979c3c9e5866 (diff) | |
download | rpm-9ae911eefedf9618202b6a76d670914119784464.tar.gz rpm-9ae911eefedf9618202b6a76d670914119784464.tar.bz2 rpm-9ae911eefedf9618202b6a76d670914119784464.zip |
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.
Diffstat (limited to 'rpmio')
-rw-r--r-- | rpmio/macro.c | 41 |
1 files changed, 14 insertions, 27 deletions
diff --git a/rpmio/macro.c b/rpmio/macro.c index 52f62b62d..8b3ba59b1 100644 --- a/rpmio/macro.c +++ b/rpmio/macro.c @@ -1511,45 +1511,32 @@ exit: void rpmInitMacros(rpmMacroContext mc, const char * macrofiles) { - char *mfiles, *m, *me; + ARGV_t pattern, globs = NULL; if (macrofiles == NULL) return; - mfiles = xstrdup(macrofiles); - for (m = mfiles; m && *m != '\0'; m = me) { - ARGV_t av = 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); - + argvSplit(&globs, macrofiles, ":"); + for (pattern = globs; *pattern; pattern++) { + ARGV_t path, files = NULL; + /* Glob expand the macro file path element, expanding ~ to $HOME. */ - i = rpmGlob(m, &ac, &av); - if (i != 0) + if (rpmGlob(*pattern, NULL, &files) != 0) { continue; + } /* Read macros from each file. */ - for (i = 0; i < ac; i++) { - if (rpmFileHasSuffix(av[i], ".rpmnew") || - rpmFileHasSuffix(av[i], ".rpmsave") || - rpmFileHasSuffix(av[i], ".rpmorig")) { + for (path = files; *path; path++) { + if (rpmFileHasSuffix(*path, ".rpmnew") || + rpmFileHasSuffix(*path, ".rpmsave") || + rpmFileHasSuffix(*path, ".rpmorig")) { continue; } - (void) rpmLoadMacroFile(mc, av[i]); + (void) rpmLoadMacroFile(mc, *path); } - argvFree(av); + argvFree(files); } - mfiles = _free(mfiles); + argvFree(globs); /* Reload cmdline macros */ rpmLoadMacros(rpmCLIMacroContext, RMIL_CMDLINE); |