commit: 74b75c453354a10af3c499aac15d3a2ae0e1c7ee Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> AuthorDate: Sun Dec 19 09:51:16 2021 +0000 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> CommitDate: Sun Dec 19 09:51:16 2021 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=74b75c45
qlist: fix matching of USE-flags Thanks to Michael Yagliyan for finding this bug and proposing the fix. We cannot perform merge-sort if the comparison in use is different between sorting and processing afterwards. Use case-sensitive sort everywhere, for it is cheaper, matches Portage and is safer/more correct/inline with PMS. This does change the default output ordering of the flags though. Added a test that ensures capital USE-flag is now matched correctly. Bug: https://bugs.gentoo.org/829579 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> qlist.c | 5 +++-- tests/qlist/dotest | 3 +++ tests/qlist/root/sys-fs/mtools-4.0.13/IUSE | 1 + tests/qlist/root/sys-fs/mtools-4.0.13/USE | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/qlist.c b/qlist.c index 48f7707..318ae3d 100644 --- a/qlist.c +++ b/qlist.c @@ -64,8 +64,9 @@ static const char * const qlist_opts_help[] = { static int cmpstringp(const void *p1, const void *p2) { - /* case insensitive comparator */ - return strcasecmp(*((char * const *)p1), *((char * const *)p2)); + /* PMS 3.1.4: USE-flag names may contain any of the characters + * [A-Za-z0-9+_@-]. */ + return strcmp(*((char * const *)p1), *((char * const *)p2)); } /* diff --git a/tests/qlist/dotest b/tests/qlist/dotest index 0bb031b..509a20d 100755 --- a/tests/qlist/dotest +++ b/tests/qlist/dotest @@ -70,6 +70,9 @@ test 15 1 "qlist -ICv lajsdflkjasdflkjasdfljasdf" # match test w/out sub-SLOT test 16 0 "qlist -ICSS virtual/sub-2:1" +# check USE retrieval +test 17 0 "qlist -IUv mtools" + cleantmpdir end diff --git a/tests/qlist/root/sys-fs/mtools-4.0.13/IUSE b/tests/qlist/root/sys-fs/mtools-4.0.13/IUSE new file mode 100644 index 0000000..a834dce --- /dev/null +++ b/tests/qlist/root/sys-fs/mtools-4.0.13/IUSE @@ -0,0 +1 @@ +X static-libs abi_x86_32 abi_x86_64 diff --git a/tests/qlist/root/sys-fs/mtools-4.0.13/USE b/tests/qlist/root/sys-fs/mtools-4.0.13/USE new file mode 100644 index 0000000..c91abd8 --- /dev/null +++ b/tests/qlist/root/sys-fs/mtools-4.0.13/USE @@ -0,0 +1 @@ +abi_x86_64 elibc_SunOS kernel_SunOS prefix X
