From: Douglas Bagnall Date: Sat, 13 Apr 2024 05:53:24 +0000 (+1200) Subject: lib:util: codepoint_cmpi: be transitive and case-insensitive X-Git-Tag: tdb-1.4.11~824 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13af2cb02171c0f10133813746e2f938ae2e304d;p=thirdparty%2Fsamba.git lib:util: codepoint_cmpi: be transitive and case-insensitive 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 Reviewed-by: Andrew Bartlett --- diff --git a/lib/util/charset/codepoints.c b/lib/util/charset/codepoints.c index 80226278faf..a62771801d8 100644 --- a/lib/util/charset/codepoints.c +++ b/lib/util/charset/codepoints.c @@ -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 index 4d0a08fedb4..00000000000 --- a/selftest/knownfail.d/codepoint_cmpi +++ /dev/null @@ -1 +0,0 @@ -^samba4.local.charset.codepoint_cmpi