Skip to content

Commit

Permalink
Add macro '-x**' containing all occurrences of the flag '-x'.
Browse files Browse the repository at this point in the history
The flags and arguments added to this macro are separated by spaces.

For example, if the macro argument is '-Dxxx', '-D yyy' and
'-D aaa=bbb', the body of the generated macro %{-D**} will
consist of: '-D xxx -D yyy -D aaa=bbb'.

Fix rpm-software-management#546
  • Loading branch information
rhabacker committed Mar 23, 2023
1 parent 528a43a commit 8b9dbee
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/manual/macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ macros are available:
%* all arguments (unlike shell, not including any processed flags)
%# the number of arguments
%{-f} if present at invocation, the flag f itself
%{-f*} if present at invocation, the argument to flag f
%{-f*} if present at invocation, the argument to the last occurence of flag f
%{-f**} if present at invocation, all occurrences of flag f (flag and argument, space separated) (rpm >= 4.18)
%1, %2 the arguments themselves (after getopt(3) processing)
```

Expand Down
15 changes: 15 additions & 0 deletions rpmio/macro.c
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,21 @@ static int mbopt(int c, const char *oarg, int oint, void *data)
pushMacro(mb->mc, name, NULL, oarg, mb->level, ME_AUTO | ME_LITERAL);
free(name);
}

rasprintf(&name, "-%c**", c);
rpmMacroEntry *mep = findEntry(mb->mc, name, 0, NULL);
if (mep && oarg)
rasprintf(&body, "%s -%c %s", (*mep)->body, c, oarg);
else if (mep)
rasprintf(&body, "%s -%c", (*mep)->body, c);
else if (oarg)
rasprintf(&body, "-%c %s", c, oarg);
else
rasprintf(&body, "-%c", c);
pushMacro(mb->mc, name, NULL, body, mb->level, ME_AUTO | ME_LITERAL);
free(name);
free(body);

return 0;
}

Expand Down

0 comments on commit 8b9dbee

Please sign in to comment.