Skip to content

Commit

Permalink
Add macro '%-x**' containing all occurrences of the flag '-x<arg>' or…
Browse files Browse the repository at this point in the history
… '-x <arg>'.

Flags are added to this macro with the flag and argument
in the original notation and separated from previous by spaces.

Fix #546
  • Loading branch information
rhabacker committed Mar 24, 2023
1 parent 13ee56a commit 1f88268
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 @@ -39,7 +39,8 @@ macros are available:
%** all arguments (including any processed flags)
%# the number of arguments
%{-f} if present at invocation, the flag f itself (including the argument)
%{-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 @@ -859,6 +859,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%s", (*mep)->body, c, fill, oarg);
else if (mep)
rasprintf(&body, "%s -%c", (*mep)->body, c);
else if (oarg)
rasprintf(&body, "-%c%s%s", c, fill, 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 1f88268

Please sign in to comment.