QtMiscUtils: add missing toAsciiUpper(), use it in moc
... to make moc code locale-independent. The C toupper function is locale-dependent. Given the right locale (Türkiye, e.g.), toupper('i') is either - İ (LATIN CAPITAL LETTER I WITH DOT ABOVE; if representable) or - i (unchanged; if it isn't) Both results are wrong for the present use-case. Fix by adding QtMiscTools::toAsciiUpper(), complementing existing toAsciiLower(), and using that. It's private API, but moc.h, despite the name, is not a public header. Pick-to: 6.5 6.4 6.2 5.15 Task-number: QTBUG-109235 Change-Id: Iaf071ba2113b672aa0aed3da6a4e1d47fb659365 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
5a0dcda171
commit
b8c2a0c18a
@ -54,6 +54,11 @@ constexpr inline char toAsciiLower(char ch) noexcept
|
|||||||
return (ch >= 'A' && ch <= 'Z') ? ch - 'A' + 'a' : ch;
|
return (ch >= 'A' && ch <= 'Z') ? ch - 'A' + 'a' : ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr inline char toAsciiUpper(char ch) noexcept
|
||||||
|
{
|
||||||
|
return (ch >= 'a' && ch <= 'z') ? ch - 'a' + 'A' : ch;
|
||||||
|
}
|
||||||
|
|
||||||
constexpr inline int caseCompareAscii(char lhs, char rhs) noexcept
|
constexpr inline int caseCompareAscii(char lhs, char rhs) noexcept
|
||||||
{
|
{
|
||||||
const char lhsLower = QtMiscUtils::toAsciiLower(lhs);
|
const char lhsLower = QtMiscUtils::toAsciiLower(lhs);
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
#include <qjsonobject.h>
|
#include <qjsonobject.h>
|
||||||
#include <qversionnumber.h>
|
#include <qversionnumber.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
|
||||||
|
#include <private/qtools_p.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -102,7 +103,7 @@ struct PropertyDef
|
|||||||
{
|
{
|
||||||
bool stdCppSet() const {
|
bool stdCppSet() const {
|
||||||
QByteArray s("set");
|
QByteArray s("set");
|
||||||
s += toupper(name[0]);
|
s += QtMiscUtils::toAsciiUpper(name[0]);
|
||||||
s += name.mid(1);
|
s += name.mid(1);
|
||||||
return (s == write);
|
return (s == write);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user