1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

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 <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Douglas Bagnall 2024-04-13 17:53:24 +12:00 committed by Andrew Bartlett
parent 310d59c7cc
commit 13af2cb021
2 changed files with 2 additions and 17 deletions

View 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);
}

View File

@ -1 +0,0 @@
^samba4.local.charset.codepoint_cmpi