summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-01-18 01:00:07 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-01-18 01:00:08 +0100
commit3e9f8b5249282324c615941af97f1ebf8a85991f (patch)
treef1a4b0a92abe0f0f238516f03b5d216e7912b643 /src/corelib
parent800dda19a611339863aa5cfe6da13bc235d68e68 (diff)
parent9c172af7d5d8696a692fb2e040be11eae99a4b0c (diff)
Merge remote-tracking branch 'origin/5.14' into 5.15
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/doc/qtcore.qdocconf2
-rw-r--r--src/corelib/doc/src/qtcore-index.qdoc2
-rw-r--r--src/corelib/global/qendian.cpp1
-rw-r--r--src/corelib/text/qlocale_win.cpp97
-rw-r--r--src/corelib/text/qregularexpression.cpp8
-rw-r--r--src/corelib/time/qcalendar.cpp2
-rw-r--r--src/corelib/time/qtimezone.cpp2
7 files changed, 72 insertions, 42 deletions
diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf
index 15b1925e51..2b9adabc3a 100644
--- a/src/corelib/doc/qtcore.qdocconf
+++ b/src/corelib/doc/qtcore.qdocconf
@@ -26,7 +26,7 @@ qhp.QtCore.subprojects.classes.sortPages = true
tagfile = ../../../doc/qtcore/qtcore.tags
-depends += activeqt qtdbus qtgui qtwidgets qtnetwork qtdoc qtmacextras qtquick qtlinguist qtdesigner qtconcurrent qtxml qmake qtwinextras qtqml
+depends += activeqt qtdbus qtgui qtwidgets qtnetwork qtdoc qtmacextras qtquick qtlinguist qtdesigner qtconcurrent qtxml qmake qtwinextras qtqml qtcmake
headerdirs += ..
diff --git a/src/corelib/doc/src/qtcore-index.qdoc b/src/corelib/doc/src/qtcore-index.qdoc
index 29fc25f69d..5838d13914 100644
--- a/src/corelib/doc/src/qtcore-index.qdoc
+++ b/src/corelib/doc/src/qtcore-index.qdoc
@@ -56,7 +56,7 @@
\include module-use.qdocinc using qt module
\quotefile overview/using-qt-core.cmake
- See also the \l[QtDoc]{Build with CMake} overview.
+ See also the \l{Build with CMake} overview.
\section2 Building with qmake
diff --git a/src/corelib/global/qendian.cpp b/src/corelib/global/qendian.cpp
index 98dc6a9a4b..eb08b2f848 100644
--- a/src/corelib/global/qendian.cpp
+++ b/src/corelib/global/qendian.cpp
@@ -192,7 +192,6 @@ QT_BEGIN_NAMESPACE
an in-place swap (if necessary). If they are not the same, the memory
regions must not overlap.
- \sa qFromLittleEndian()
\sa qToBigEndian()
\sa qToLittleEndian()
*/
diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp
index 79ea67f966..4b4152c519 100644
--- a/src/corelib/text/qlocale_win.cpp
+++ b/src/corelib/text/qlocale_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Copyright (C) 2016 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
@@ -106,11 +106,11 @@ struct QSystemLocalePrivate
{
QSystemLocalePrivate();
- QChar zeroDigit();
- QChar decimalPoint();
- QChar groupSeparator();
- QChar negativeSign();
- QChar positiveSign();
+ QString zeroDigit();
+ QString decimalPoint();
+ QString groupSeparator();
+ QString negativeSign();
+ QString positiveSign();
QVariant dateFormat(QLocale::FormatType);
QVariant timeFormat(QLocale::FormatType);
QVariant dateTimeFormat(QLocale::FormatType);
@@ -147,12 +147,11 @@ private:
WCHAR lcName[LOCALE_NAME_MAX_LENGTH];
#endif
SubstitutionType substitutionType;
- QChar zero;
+ QString zero; // cached value for zeroDigit()
int getLocaleInfo(LCTYPE type, LPWSTR data, int size);
QString getLocaleInfo(LCTYPE type, int maxlen = 0);
int getLocaleInfo_int(LCTYPE type, int maxlen = 0);
- QChar getLocaleInfo_qchar(LCTYPE type);
int getCurrencyFormat(DWORD flags, LPCWSTR value, const CURRENCYFMTW *format, LPWSTR data, int size);
int getDateFormat(DWORD flags, const SYSTEMTIME * date, LPCWSTR format, LPWSTR data, int size);
@@ -236,12 +235,6 @@ int QSystemLocalePrivate::getLocaleInfo_int(LCTYPE type, int maxlen)
return ok ? v : 0;
}
-QChar QSystemLocalePrivate::getLocaleInfo_qchar(LCTYPE type)
-{
- QString str = getLocaleInfo(type);
- return str.isEmpty() ? QChar() : str.at(0);
-}
-
QSystemLocalePrivate::SubstitutionType QSystemLocalePrivate::substitution()
{
if (substitutionType == SUnknown) {
@@ -257,13 +250,12 @@ QSystemLocalePrivate::SubstitutionType QSystemLocalePrivate::substitution()
else if (buf[0] == '2')
substitutionType = QSystemLocalePrivate::SAlways;
else {
- wchar_t digits[11];
+ wchar_t digits[11]; // See zeroDigit() for why 11.
if (!getLocaleInfo(LOCALE_SNATIVEDIGITS, digits, 11)) {
substitutionType = QSystemLocalePrivate::SNever;
return substitutionType;
}
- const wchar_t zero = digits[0];
- if (buf[0] == zero + 2)
+ if (buf[0] == digits[0] + 2)
substitutionType = QSystemLocalePrivate::SAlways;
else
substitutionType = QSystemLocalePrivate::SNever;
@@ -274,40 +266,75 @@ QSystemLocalePrivate::SubstitutionType QSystemLocalePrivate::substitution()
QString &QSystemLocalePrivate::substituteDigits(QString &string)
{
- ushort zero = zeroDigit().unicode();
- ushort *qch = reinterpret_cast<ushort *>(string.data());
- for (ushort *end = qch + string.size(); qch != end; ++qch) {
- if (*qch >= '0' && *qch <= '9')
- *qch = zero + (*qch - '0');
+ zeroDigit(); // Ensure zero is set.
+ switch (zero.size()) {
+ case 1: {
+ const ushort offset = zero.at(0).unicode() - '0';
+ if (!offset) // Nothing to do
+ break;
+ Q_ASSERT(offset > 9);
+ ushort *const qch = reinterpret_cast<ushort *>(string.data());
+ for (int i = 0, stop = string.size(); i < stop; ++i) {
+ ushort &ch = qch[i];
+ if (ch >= '0' && ch <= '9')
+ ch += offset;
+ }
+ break;
+ }
+ case 2: {
+ // Surrogate pair (high, low):
+ uint digit = QChar::surrogateToUcs4(zero.at(0), zero.at(1));
+ for (int i = 0; i < 10; i++) {
+ const QChar s[2] = { QChar::highSurrogate(digit + i), QChar::lowSurrogate(digit + i) };
+ string.replace(QString(QLatin1Char('0' + i)), QString(s, 2));
+ }
+ break;
+ }
+ default:
+ Q_ASSERT(!"Expected zero digit to be a single UCS2 code-point or a surrogate pair");
+ case 0: // Apparently this locale info was not available.
+ break;
}
return string;
}
-QChar QSystemLocalePrivate::zeroDigit()
+QString QSystemLocalePrivate::zeroDigit()
{
- if (zero.isNull())
- zero = getLocaleInfo_qchar(LOCALE_SNATIVEDIGITS);
+ if (zero.isEmpty()) {
+ /* Ten digits plus a terminator.
+
+ https://docs.microsoft.com/en-us/windows/win32/intl/locale-snative-constants
+ "Native equivalents of ASCII 0 through 9. The maximum number of
+ characters allowed for this string is eleven, including a terminating
+ null character."
+ */
+ wchar_t digits[11];
+ if (getLocaleInfo(LOCALE_SNATIVEDIGITS, digits, 11)) {
+ // assert all(digits[i] == i + digits[0] for i in range(1, 10)), assumed above
+ zero = QString::fromWCharArray(digits, 1);
+ }
+ }
return zero;
}
-QChar QSystemLocalePrivate::decimalPoint()
+QString QSystemLocalePrivate::decimalPoint()
{
- return getLocaleInfo_qchar(LOCALE_SDECIMAL);
+ return getLocaleInfo(LOCALE_SDECIMAL);
}
-QChar QSystemLocalePrivate::groupSeparator()
+QString QSystemLocalePrivate::groupSeparator()
{
- return getLocaleInfo_qchar(LOCALE_STHOUSAND);
+ return getLocaleInfo(LOCALE_STHOUSAND);
}
-QChar QSystemLocalePrivate::negativeSign()
+QString QSystemLocalePrivate::negativeSign()
{
- return getLocaleInfo_qchar(LOCALE_SNEGATIVESIGN);
+ return getLocaleInfo(LOCALE_SNEGATIVESIGN);
}
-QChar QSystemLocalePrivate::positiveSign()
+QString QSystemLocalePrivate::positiveSign()
{
- return getLocaleInfo_qchar(LOCALE_SPOSITIVESIGN);
+ return getLocaleInfo(LOCALE_SPOSITIVESIGN);
}
QVariant QSystemLocalePrivate::dateFormat(QLocale::FormatType type)
@@ -677,7 +704,7 @@ void QSystemLocalePrivate::update()
GetUserDefaultLocaleName(lcName, LOCALE_NAME_MAX_LENGTH);
#endif
substitutionType = SUnknown;
- zero = QChar();
+ zero.resize(0);
}
QString QSystemLocalePrivate::winToQtFormat(QStringView sys_fmt)
@@ -749,7 +776,7 @@ QLocale QSystemLocale::fallbackUiLocale() const
return QLocale(QString::fromLatin1(getWinLocaleName()));
}
-QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const
+QVariant QSystemLocale::query(QueryType type, QVariant in) const
{
QSystemLocalePrivate *d = systemLocalePrivate();
switch(type) {
diff --git a/src/corelib/text/qregularexpression.cpp b/src/corelib/text/qregularexpression.cpp
index a3a4921690..d74b759aa9 100644
--- a/src/corelib/text/qregularexpression.cpp
+++ b/src/corelib/text/qregularexpression.cpp
@@ -1915,6 +1915,10 @@ QString QRegularExpression::wildcardToRegularExpression(const QString &pattern)
\snippet code/src_corelib_tools_qregularexpression.cpp 31
+ The returned regular expression is already fully anchored. In other
+ words, there is no need of calling anchoredPattern() again on the
+ result.
+
\warning Unlike QRegExp, this implementation follows closely the definition
of wildcard for glob patterns:
\table
@@ -1941,12 +1945,12 @@ QString QRegularExpression::wildcardToRegularExpression(const QString &pattern)
\note The backslash (\\) character is \e not an escape char in this context.
In order to match one of the special characters, place it in square brackets
- (for example, "[?]").
+ (for example, \c{[?]}).
More information about the implementation can be found in:
\list
\li \l {https://en.wikipedia.org/wiki/Glob_(programming)} {The Wikipedia Glob article}
- \li \c man 7 glob
+ \li \c {man 7 glob}
\endlist
\sa escape()
diff --git a/src/corelib/time/qcalendar.cpp b/src/corelib/time/qcalendar.cpp
index 6a4623ce92..9d485f181e 100644
--- a/src/corelib/time/qcalendar.cpp
+++ b/src/corelib/time/qcalendar.cpp
@@ -723,7 +723,7 @@ QCalendar::QCalendar(QLatin1String name)
QCalendar::QCalendar(QStringView name)
: d(QCalendarBackend::fromName(name)) {}
-/*
+/*!
\fn bool QCalendar::isValid() const
Returns true if this is a valid calendar object.
diff --git a/src/corelib/time/qtimezone.cpp b/src/corelib/time/qtimezone.cpp
index 3d2078087b..87d8ea75f1 100644
--- a/src/corelib/time/qtimezone.cpp
+++ b/src/corelib/time/qtimezone.cpp
@@ -217,7 +217,7 @@ Q_GLOBAL_STATIC(QTimeZoneSingleton, global_tz);
This class includes data obtained from the CLDR data files under the terms
of the Unicode Data Files and Software License. See
- \l{Unicode Common Locale Data Repository (CLDR)} for details.
+ \l{unicode-cldr}{Unicode Common Locale Data Repository (CLDR)} for details.
\sa QDateTime
*/