]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
util:charset:codepoints: codepoint_cmpi warning about non-transitivity
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Thu, 4 Apr 2024 01:56:16 +0000 (14:56 +1300)
committerJule Anger <janger@samba.org>
Mon, 10 Jun 2024 13:25:16 +0000 (13:25 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15625

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit f07ae6990702f8806c0c815454b80a5596b7219a)

lib/util/charset/codepoints.c

index b5220763d40e85fdddc21fb1a7b3f600e96878d8..cc263745b6d964b00ef7247afad3ac29b88354a8 100644 (file)
@@ -16480,6 +16480,18 @@ _PUBLIC_ bool isupper_m(codepoint_t val)
 */
 _PUBLIC_ int codepoint_cmpi(codepoint_t c1, codepoint_t c2)
 {
+       /*
+        * FIXME: this is unsuitable for use in a sort, as the
+        * comparison is intransitive.
+        *
+        * The problem is toupper_m() is only called on equality case,
+        * which has strange effects.
+        *
+        *    Consider {'a', 'A', 'B'}.
+        *     'a' == 'A'
+        *     'a' >  'B'  (lowercase letters come after upper)
+        *     'A' <  'B'
+        */
        if (c1 == c2 ||
            toupper_m(c1) == toupper_m(c2)) {
                return 0;