Correct qcollator_posix.cpp's check against system locale
The check was made against the default locale but the code calls the system functions (wcscoll, wcsxfrm, wcscmp) for locale-specific collation, so should be comparing to the system locale's collation locale (i.e. LC_COLLATE). Also correct the Android-only check in tst_QCollator::compare() which duplicated the check but neglected the C locale, which is also supported (via QString::compare). Pick-to: 6.2 Change-Id: I48c3237dd6825e2070272ab88d95bdb8cbb9fc37 Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
48856934ec
commit
25d807f629
@ -1,6 +1,7 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 Aleix Pol Gonzalez <aleixpol@kde.org>
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Copyright (C) 2013 Aleix Pol Gonzalez <aleixpol@kde.org>
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
@ -49,8 +50,10 @@ QT_BEGIN_NAMESPACE
|
||||
void QCollatorPrivate::init()
|
||||
{
|
||||
if (!isC()) {
|
||||
if (locale != QLocale())
|
||||
qWarning("Only C and default locale supported with the posix collation implementation");
|
||||
if (locale != QLocale::system().collation()) {
|
||||
qWarning("Only the C and system collation locales are supported "
|
||||
"with the POSIX collation implementation");
|
||||
}
|
||||
if (caseSensitivity != Qt::CaseSensitive)
|
||||
qWarning("Case insensitive sorting unsupported in the posix collation implementation");
|
||||
}
|
||||
|
@ -282,8 +282,8 @@ void tst_QCollator::compare()
|
||||
};
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
if (collator.locale() != QLocale())
|
||||
QSKIP("Posix implementation of collation only supports default locale");
|
||||
if (collator.locale() != QLocale::c() && collator.locale() != QLocale::system().collation())
|
||||
QSKIP("POSIX implementation of collation only supports C and system collation locales");
|
||||
#endif
|
||||
|
||||
if (numericMode)
|
||||
|
Loading…
x
Reference in New Issue
Block a user