Skip to content

Commit

Permalink
Use basename (3) for the %basename macro
Browse files Browse the repository at this point in the history
  • Loading branch information
ffesti committed Mar 7, 2024
1 parent 77d02b7 commit eb2d628
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 1 addition & 4 deletions rpmio/macro.c
Original file line number Diff line number Diff line change
Expand Up @@ -1301,10 +1301,7 @@ static void doFoo(rpmMacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)

if (rstreq("basename", me->name)) {
buf = xstrdup(argv[1]);
if ((b = strrchr(buf, '/')) == NULL)
b = buf;
else
b++;
b = basename(buf);
} else if (rstreq("dirname", me->name)) {
buf = xstrdup(argv[1]);
b = dirname(buf);
Expand Down
10 changes: 10 additions & 0 deletions tests/rpmmacro.at
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,11 @@ runroot rpm --eval "%dirname /foo"
runroot rpm --eval "%dirname /foo/"
runroot rpm --eval "%dirname /foo/foobar"
runroot rpm --eval "%dirname /foo/foobar/"
runroot rpm --eval "%basename /foo/foobar"
runroot rpm --eval "%basename /foo/foobar/"
runroot rpm --eval "%basename /"
runroot rpm --eval "%basename foobar/"
runroot rpm --eval "%basename foobar"
runroot rpm --define '%xxx /hello/%%%%/world' --eval '%{dirname:%xxx}'
runroot rpm --eval "%{uncompress}"
runroot rpm --eval "%{uncompress:}"
Expand Down Expand Up @@ -403,6 +408,11 @@ runroot rpm --eval "%verbose foo"
/
/foo
/foo
foobar
foobar
/
foobar
foobar
/hello/%%

bar
Expand Down

0 comments on commit eb2d628

Please sign in to comment.