Skip to content

Commit

Permalink
Raise an error when passing arguments to non-parametric macros
Browse files Browse the repository at this point in the history
  • Loading branch information
pmatilai committed Feb 28, 2024
1 parent ebece0f commit 010f090
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rpmio/macro.c
Original file line number Diff line number Diff line change
Expand Up @@ -1722,6 +1722,11 @@ expandMacro(rpmMacroBuf mb, const char *src, size_t slen)
if (me->opts == NULL && !(me->flags & ME_FUNC)) {
/* Simple non-parametric macro */
doMacro(mb, me, NULL, NULL);
if (g) {
rpmMacroBufErr(mb, 1,
_("unexpected argument to non-parametric macro %%%s\n"),
me->name);
}
s = se;
continue;
}
Expand Down
14 changes: 14 additions & 0 deletions tests/rpmmacro.at
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,20 @@ runroot rpm \
0
0
])

RPMTEST_CHECK([
runroot rpm \
--define 'zzz xxx' \
--eval '%zzz' \
--eval '%{zzz}' \
--eval '%{zzz:}' \
],
[1],
[xxx
xxx
],
[error: unexpected argument to non-parametric macro %zzz
])
RPMTEST_CLEANUP

AT_SETUP([string functions])
Expand Down

0 comments on commit 010f090

Please sign in to comment.