Don't second-guess strcoll()

It's defective on Android, but no worse so than the fall-back we were
using; and we can't remember why we had that fall-back anyway.

Task-number: QTBUG-63518
Change-Id: I28e9b5c7cc64963c9e3941eb1bad85aced280a9b
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Edward Welbourne 2020-07-30 16:30:00 +02:00
parent 2d5dcd1b9f
commit 2d6705575c

View File

@ -1655,9 +1655,7 @@ inline char qToLower(char ch)
localeAwareCompare() compares according the "Order for sorted localeAwareCompare() compares according the "Order for sorted
lists" setting in the International preferences panel. On other lists" setting in the International preferences panel. On other
Unix-like systems without ICU, the comparison falls back to the Unix-like systems without ICU, the comparison falls back to the
system library's \c strcoll(), falling back when it considers system library's \c strcoll(),
strings equal to QString's (locale-unaware) comparison, described
above,
\section1 Converting Between encoded strings data and QString \section1 Converting Between encoded strings data and QString
@ -5931,11 +5929,8 @@ int QString::localeAwareCompare_helper(const QChar *data1, qsizetype length1,
CFRelease(otherString); CFRelease(otherString);
return result; return result;
# elif defined(Q_OS_UNIX) # elif defined(Q_OS_UNIX)
// declared in <string.h> // declared in <string.h> (no better than qt_compare_strings() on Android, sadly)
int delta = strcoll(lhs.toLocal8Bit().constData(), rhs.toLocal8Bit().constData()); return strcoll(lhs.toLocal8Bit().constData(), rhs.toLocal8Bit().constData());
if (delta == 0)
delta = qt_compare_strings(lhs, rhs, Qt::CaseSensitive);
return delta;
# else # else
# error "This case shouldn't happen" # error "This case shouldn't happen"
return qt_compare_strings(lhs, rhs, Qt::CaseSensitive); return qt_compare_strings(lhs, rhs, Qt::CaseSensitive);