Convert %{trace} to work via the macro lookup table

%trace differs from the others as it doesn't take any arguments,
it just silently eats any passed. Not that it really matters here.
No functional changes.
This commit is contained in:
Panu Matilainen 2019-01-15 15:39:18 +02:00
parent 672c9e378b
commit 93cda82b22
1 changed files with 13 additions and 11 deletions

View File

@ -139,6 +139,8 @@ static void doLua(MacroBuf mb, int chkexist, int negate,
const char * f, size_t fn, const char * g, size_t gn);
static void doOutput(MacroBuf mb, int chkexist, int negate,
const char * f, size_t fn, const char * g, size_t gn);
static void doTrace(MacroBuf mb, int chkexist, int negate,
const char * f, size_t fn, const char * g, size_t gn);
/* =============================================================== */
@ -505,7 +507,7 @@ static struct builtins_s {
{ STR_AND_LEN("quote"), doFoo },
{ STR_AND_LEN("shrink"), doFoo },
{ STR_AND_LEN("suffix"), doFoo },
{ STR_AND_LEN("trace"), NULL },
{ STR_AND_LEN("trace"), doTrace },
{ STR_AND_LEN("u2p"), doFoo },
{ STR_AND_LEN("uncompress"),doFoo },
{ STR_AND_LEN("undefine"), NULL },
@ -1136,6 +1138,16 @@ static void doLoad(MacroBuf mb, int chkexist, int negate,
free(arg);
}
static void doTrace(MacroBuf mb, int chkexist, int negate,
const char * f, size_t fn, const char * g, size_t gn)
{
mb->expand_trace = mb->macro_trace = (negate ? 0 : mb->depth);
if (mb->depth == 1) {
print_macro_trace = mb->macro_trace;
print_expand_trace = mb->expand_trace;
}
}
/**
* The main macro recursion loop.
* @param mb macro expansion state
@ -1337,16 +1349,6 @@ expandMacro(MacroBuf mb, const char *src, size_t slen)
continue;
}
if (STREQ("trace", f, fn)) {
mb->expand_trace = mb->macro_trace = (negate ? 0 : mb->depth);
if (mb->depth == 1) {
print_macro_trace = mb->macro_trace;
print_expand_trace = mb->expand_trace;
}
s = se;
continue;
}
if (STREQ("dump", f, fn)) {
rpmDumpMacroTable(mb->mc, NULL);
while (iseol(*se))