Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify builtin and user-defined parametric macro calling syntax #1434

Merged
merged 9 commits into from
Nov 26, 2020
36 changes: 8 additions & 28 deletions rpmio/macro.c
Original file line number Diff line number Diff line change
Expand Up @@ -752,30 +752,14 @@ doDefine(MacroBuf mb, const char * se, int level, int expandbody)
static size_t
doUndefine(MacroBuf mb, rpmMacroEntry me, ARGV_t argv)
{
const char *se = argv[1];
const char *start = se;
const char *s = se;
char *buf = xmalloc(strlen(s) + 1);
char *n = buf, *ne = n;
int c;

COPYNAME(ne, s, c);

/* Move scan over body */
while (iseol(*s))
s++;
se = s;

if (!validName(mb, n, ne - n, "%undefine")) {
const char *n = argv[1];
if (!validName(mb, n, strlen(n), "%undefine")) {
mb->error = 1;
goto exit;
} else {
popMacro(mb->mc, n);
}

popMacro(mb->mc, n);

exit:
_free(buf);
return se - start;
return 0;
}

static size_t doDef(MacroBuf mb, rpmMacroEntry me, ARGV_t argv)
Expand All @@ -792,12 +776,8 @@ static size_t doGlobal(MacroBuf mb, rpmMacroEntry me, ARGV_t argv)

static size_t doDump(MacroBuf mb, rpmMacroEntry me, ARGV_t argv)
{
const char *se = argv[1];
const char *start = se;
rpmDumpMacroTable(mb->mc, NULL);
while (iseol(*se))
se++;
return se - start;
return 0;
}


Expand Down Expand Up @@ -1263,7 +1243,7 @@ static struct builtins_s {
{ "define", doDef, -1, ME_PARSE },
{ "dirname", doFoo, 1, ME_FUNC },
{ "dnl", doDnl, -1, ME_PARSE },
{ "dump", doDump, 0, ME_PARSE },
{ "dump", doDump, 0, ME_FUNC },
{ "echo", doOutput, 1, ME_FUNC },
{ "error", doOutput, 1, ME_FUNC },
{ "exists", doFoo, 1, ME_FUNC },
Expand All @@ -1284,7 +1264,7 @@ static struct builtins_s {
{ "trace", doTrace, 0, ME_FUNC },
{ "u2p", doFoo, 1, ME_FUNC },
{ "uncompress", doUncompress, 1, ME_FUNC },
{ "undefine", doUndefine, 1, ME_PARSE },
{ "undefine", doUndefine, 1, ME_FUNC },
{ "url2path", doFoo, 1, ME_FUNC },
{ "verbose", doVerbose, 0, ME_FUNC },
{ "warn", doOutput, 1, ME_FUNC },
Expand Down