]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib:util: codepoint_cmpi: be transitive and case-insensitive
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Sat, 13 Apr 2024 05:53:24 +0000 (17:53 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 7 May 2024 23:25:35 +0000 (23:25 +0000)
the less/greater conparisons were not case-sensitive, which made the whole
function non-transitive.

I think codepoint_cmpi() is currently only used for equality tests, so
nothing will change.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/util/charset/codepoints.c
selftest/knownfail.d/codepoint_cmpi [deleted file]

index 80226278faf4d5b9904778db7fb5d20479f99cfe..a62771801d8137507282e7ff8355d0cfad647882 100644 (file)
@@ -16480,22 +16480,8 @@ _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;
-       }
+       c1 = toupper_m(c1);
+       c2 = toupper_m(c2);
        return NUMERIC_CMP(c1, c2);
 }
 
diff --git a/selftest/knownfail.d/codepoint_cmpi b/selftest/knownfail.d/codepoint_cmpi
deleted file mode 100644 (file)
index 4d0a08f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-^samba4.local.charset.codepoint_cmpi