summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qstring.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/5.10' into devLiang Qi2017-11-051-70/+49
|\ | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/minimum-linux.S src/network/access/qhttpthreaddelegate.cpp src/widgets/kernel/qwidgetwindow.cpp Change-Id: Id2e817e85f85c68f5482c9a12912d35590f9d5f8
| * Mark the previously public qstringalgorithms.h functions privateThiago Macieira2017-10-291-70/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Discussed during Qt Contributor Summit 2017. We concluded that we don't want to make these functions public, as they do not follow Qt coding style API. Specifically, qStartsWith(a, b) is not easily understood which argument is the needle and which argument is the haystack (same problem memcpy() has). Compare that to a.startsWith(b) which can clearly be read in English as a subject-verb-object sentence. This commit removes the unit tests that called compare(). Discussed-on: http://lists.qt-project.org/pipermail/development/2017-October/031060.html Change-Id: Icaa86fc7b54d4b368c0efffd14ee6205eb9043fb Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Merge remote-tracking branch 'origin/5.10' into devLiang Qi2017-10-171-10/+19
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/network/fortuneclient/client.cpp examples/network/fortuneserver/server.cpp src/platformsupport/platformcompositor/qopenglcompositorbackingstore_p.h src/plugins/platforms/cocoa/qcocoabackingstore.h src/plugins/platforms/cocoa/qcocoaintegration.h src/plugins/platforms/cocoa/qcocoascreen.h src/plugins/platforms/ios/qiosbackingstore.h src/plugins/sqldrivers/oci/qsql_oci.cpp src/widgets/kernel/qwidgetwindow.cpp Change-Id: Ia6dd2c52d4a691b671cf9a2ffca70deccece8f10
| * Improve qustrlen further by avoiding the alignment prologueThiago Macieira2017-09-261-10/+19
| | | | | | | | | | | | | | | | | | | | | | This avoids looping prior to the main 16-byte loop, by performing one load that may include bytes prior to the start of the string. This is guaranteed not to fault, since str points to a valid character, but it may cause Valgrind to print warnings. Change-Id: I6e9274c1e7444ad48c81fffd14dcae854bba24b2 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.10' into devLiang Qi2017-09-261-0/+38
|\| | | | | | | | | | | | | | | | | | | | | Conflicts: src/gui/kernel/qguiapplication.cpp src/platformsupport/input/libinput/qlibinputpointer.cpp src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h src/plugins/platforms/cocoa/qcocoawindow.h src/testlib/qtestsystem.h Change-Id: I5975ffb3261c2dd82fe02ec4e57df7c0950226c5
| * QStringView: De-inline the length calculation so we can use SSE2Thiago Macieira2017-09-131-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Performance is more important in this case than the theoretical benefit of constexpr. This commit implements the SSE2 search for 16-bit null and it might be possible to implement the equivalent for AArch64 (investigation required). It also adds a fallback to wcslen() for systems where wchar_t is short (non-x86 Windows or 32-bit x86 build with -no-sse2). We can re-add the constexpr loop once the C++ language has a way of overloading constexpr and non-constexpr. GCC has a non-standard way to do that with __builtin_constant_p, which is also implemented in this commit, but note that the inline function is still not constexpr. Change-Id: I6e9274c1e7444ad48c81fffd14dcaacafda5ebdc Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Replace Q_NULLPTR with nullptr where possibleKevin Funk2017-09-191-3/+3
|/ | | | | | | | | | | | | Remaining uses of Q_NULLPTR are in: src/corelib/global/qcompilerdetection.h (definition and documentation of Q_NULLPTR) tests/manual/qcursor/qcursorhighdpi/main.cpp (a test executable compilable both under Qt4 and Qt5) Change-Id: If6b074d91486e9b784138f4514f5c6d072acda9a Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-06-071-30/+25
|\ | | | | | | | | | | | | Conflicts: src/widgets/widgets/qmenu.cpp Change-Id: I6d3baf56eb24501cddb129a3cb6b958ccc25a308
| * QStringLiteral/QByteArrayLiteral: fix/add documentationGiuseppe D'Angelo2017-06-011-30/+25
| | | | | | | | | | | | | | | | | | Various editorial fixes. Also, in 5.9 QStringLiteral does not fall back to fromUtf8 any longer, but guarantees a compile-time construction. Change-Id: Ida4698cf8e32a6e3de97b2c16b997fc9630c9db9 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | QStringView/QLatin1String: add trimmed()Marc Mutz2017-05-161-0/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... using the same qt_trimmed(), qTrimmed(), Q..::trimmed() split we've been using for all other out-of-line string-view member functions to avoid forcing string-view objects onto the stack for the passing of 'this'. In the test, had to fix nullness not being propagated from a QByteArray to the QLatin1String constructed from it. Probably worth fixing in QLatin1String(QByteArray), too. [ChangeLog][QtCore] Added qTrimmed() free functions. [ChangeLog][QtCore][QLatin1String] Added trimmed() function. Change-Id: I73c18ef87e203f30f7552c10dd5c84223bcfae0e Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | QLatin1String: add constructor from pointer pairMarc Mutz2017-05-161-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | This is often more natural than (ptr, len), and I need it in the implementation of QLatin1String::trimmed(). [ChangeLog][QtCore][QLatin1String] Added a constructor taking two pointers, complementing the constructor that takes a pointer and a length. Change-Id: I0606fa0e3f820af1c3c1e261a340e5a941443e4f Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | QLatin1String: add startsWith()/endsWith()Marc Mutz2017-04-281-0/+40
| | | | | | | | | | | | | | | | | | [ChangeLog][QtCore][QLatin1String] Added startsWith(), endsWith(). Change-Id: I7f75a5a1f0409f4b9d3e41b73f4fb5d137572b09 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | QString/Ref: add startsWith/endsWith(QStringView) overloadsMarc Mutz2017-04-281-0/+46
| | | | | | | | | | | | | | | | | | | | [ChangeLog][QtCore][QString/QStringRef] Added startsWith(), endsWith() overloads taking QStringView. Change-Id: Ice6332492d19fd7477d5ac43ecbf6b70175b23ca Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Long live qStartsWith()/qEndsWith()!Marc Mutz2017-04-281-0/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Following the established pattern of implementing non-mutating string algorithms as free functions over views with a public qFoo() and a static qt_foo() split, add qStartsWith() and qEndsWith(), calling the existing qt_{starts,ends}_with_impl() templates. [ChangeLog][QtCore][QStringAlgorithms] Added qStartsWith(), qEndsWith(). Change-Id: Ic95c2a9c13883a99f1a96319083fb249f20de5f1 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Martin Smith <martin.smith@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QStringRef: fix trimmed() returning null strings on empty inputMarc Mutz2017-04-271-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The QString API symmetry test strikes again, showing that this is inconsistent with both QString and QByteArray, which both return empty for empty inputs. The fix actually makes the implementation simpler. Extend the QStringRef test to cover null inputs, too. I can't merge the trimmed() test in the API symmetry test until everything is actually consistent. [ChangeLog][QtCore][QStringRef] trimmed() now returns an empty string-ref for an empty input. Before, it would return a null one. Change-Id: I6b35c5f498053c4e15a4a9dd465bc696258e7393 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
* | Port internal qt_starts/ends_with to QStringViewMarc Mutz2017-04-261-102/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... and add a version taking a QChar needle. Back the implementation with a template function. Mark the slightly surprising behavior that null.startsWith(empty) == false but null.startsWith(null) == true even though empty == null, for review come Qt 6. Saves 0.5KiB in text size on optimized GCC 7.0 Linux AMD64 builds. Change-Id: I2576472d22ccf22ec89911eaed25188f9f7b654f Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | QString: add internal qt_compare_strings(QL1S, QSV)Marc Mutz2017-04-261-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | ... and adapt qCompareString(QLatin1String, QStringView) to call it instead of performing the negation itself. This function will be needed for QLatin1String::startsWith(QStringView). Change-Id: I8f19dfe0c5274a80c88b43d05f9efda8a91eac46 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | QLatin1String: fix qt_compare_strings(QLatin1String, QLatin1String) for null ↵Marc Mutz2017-04-261-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | strings qstrcmp sorts null strings before empty ones, while the Qt string classes consider them equal. The qt_compare_strings() overload for QLatin1String was using qstrcmp(), but is supposed to implement the semantics that Qt string classes use, so we need to add an extra check. Was uncovered by tests for QLatin1String::startsWith(), but added a new test for qCompareStrings() now, which is a bit more complicated than desired, due to the lack of QUtf8String. Change-Id: I0493c4491df928a68861a1bc7f0962f1c870a416 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Docs: Fix some warningsFriedemann Kleint2017-04-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qtbase/src/corelib/tools/qbytearray.cpp:3043: warning: Can't link to '.' qtbase/src/corelib/tools/qstring.cpp:4522: warning: Can't link to '.' qtbase/src/corelib/tools/qstring.cpp:10331: warning: Can't link to '.' qtbase/src/network/access/qhstspolicy.cpp:105: warning: Undocumented parameter 'flags' in QHstsPolicy::QHstsPolicy() qtbase/src/network/access/qhstspolicy.cpp:105: warning: No such parameter 'includeSubDomains' in QHstsPolicy::QHstsPolicy() qtbase/src/network/access/qnetworkaccessmanager.cpp:732: warning: Undocumented parameter 'knownHosts' in QNetworkAccessManager::addStrictTransportSecurityHosts() qtbase/src/network/access/qnetworkreply.cpp:307: warning: Can't link to 'QNetworkRequest::UserVerifiedRedirectsPolicy' qtbase/src/gui/painting/qpagedpaintdevice.cpp:246: warning: No such enum item 'PdfFormat_1_4' in QPagedPaintDevice::PdfVersion qtbase/src/gui/painting/qpagedpaintdevice.cpp:246: warning: Undocumented enum item 'PdfVersion_1_4' in QPagedPaintDevice::PdfVersion qtbase/src/gui/painting/qpagedpaintdevice.cpp:246: warning: Undocumented enum item 'PdfVersion_A1b' in QPagedPaintDevice::PdfVersion qtbase/src/gui/painting/qpagedpaintdevice.cpp:246: warning: No such enum item 'PdfFormat_A1b' in QPagedPaintDevice::PdfVersion qtbase/src/widgets/kernel/qopenglwidget.cpp:1076: warning: Undocumented parameter 'texFormat' in QOpenGLWidget::setTextureFormat() qtbase/src/corelib/tools/qversionnumber.cpp:460: warning: Command '\snippet (//! [3-latin1-1])' failed at end of file 'qversionnumber/main.cpp' Change-Id: Icc163dd8d94cee7e0858040bf8241a3c1f1d221d Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* | Use qToStringViewIgnoringNull() where applicableMarc Mutz2017-04-191-1/+1
| | | | | | | | | | | | | | | | | | Saves just over ¼KiB in QtCore text size on optimized GCC 6.1 Linux AMD64 builds, iow: qToStringViewIgnoringNull() saves ~40B per use. Change-Id: I3278306d5ce594e8ccd0f58b8f8d0319637d1b2b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | QLatin1String: add chopped(), chop(), and truncate()Marc Mutz2017-04-181-4/+44
| | | | | | | | | | | | | | | | | | | | [ChangeLog][QtCore][QLatin1String] Added chopped(), chop(), truncate(). Change-Id: I69b31aae560e94a120d7e8a36e06ea957ccd2003 Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | QByteArray, QString, QStringRef: Add chopped()Marc Mutz2017-04-181-6/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have two functions to get a substring without doing some calculations involving size(): - mid(p): mid(p, size() - p) - right(n) : mid(size() - n, n) (left does not involve size(), so isn't in that set). What was missing was a name for - f(n): mid(0, size() - n) As an action, it's called chop(), so call the transformation version chopped(). I made chopped(n), n < 0 or n > size(), undefined, because QString(Ref) ::left() is broken[1], while the QByteArray implementation is not. This is the only way to get consistent behavior among the three classes. I's also the correct thing to do. [1] instead of returning the empty string for negative indexes, it returns the whole string. [ChangeLog][QtCore][QString/QStringRef/QByteArray] Added chopped(n), a const version of chop(n). Change-Id: I6c2c5b16e0060fa924ced5860f21f2d0f23bd023 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
* | Array-backed containers: add shrink_to_fit for STL compatibilityGiuseppe D'Angelo2017-04-121-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Side note: QHash has squeeze(), but there's no shrink_to_fit on std::unordered_map. [ChangeLog][QtCore][QByteArray] Added shrink_to_fit(). [ChangeLog][QtCore][QString] Added shrink_to_fit(). [ChangeLog][QtCore][QVarLengthArray] Added shrink_to_fit(). [ChangeLog][QtCore][QVector] Added shrink_to_fit(). Change-Id: Ifd7d28c9bed70727be6308f0191a188201784f61 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | Add front()/back() to QString, QStringRef, QByteArray and QLatin1StringMarc Mutz2017-04-071-0/+120
| | | | | | | | | | | | | | | | | | | | | | These STL-compatibility functions are present on our generic containers, but not on the string classes. [ChangeLog][QtCore][QString/QStringRef/QByteArray/QLatin1String] Added front() and back() for STL compatibility. Change-Id: I536019396b319abd1e2daf9c64ebab4e7a35b334 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Add qConvertTo{Utf8,Latin1,Local8Bit,Ucs4}() and corresponding QStringView ↵Marc Mutz2017-04-071-39/+123
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | methods Like the qt_compare_strings()/qCompareStrings() split, distinguish between the internal and exported functions. Because of the circular dependency between qstring.h and qvector.h, the inline toUcs4() function has to be in qvector.h. At some point, we need to refactor the headers so qvector.h is lower in the dependency chain than qstring.h. It's not the first time this bites. Change-Id: Ief9f3bd92c83cdd1f31c51c700f42e146916eefd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QString: add QStringView/QLatin1String overload of (non-multi) arg()Marc Mutz2017-04-061-12/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Use the new overload directly in QXmlStream*. Saves 129B in QtCore text size on optimized GCC 6.1 Linux AMD64 builds, even though we added two more functions. [ChangeLog][QtCore][QString] Added arg(QStringView), arg(QLatin1String) overloads. Change-Id: Idf7236dcab763824593f34182e4e0b16b5ed4321 Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | Use (new) QStringIterator(QStringView) to avoid castsMarc Mutz2017-04-051-1/+1
| | | | | | | | | | | | | | | | | | This is the only one in QtBase that casts to be able to use QStringIterator. Amends d40dcee642c69784f771aae86531ae65b458f1a5. Change-Id: I709e0285717e8d17feab9ab0020c8d0aed0dbe36 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* | Long live qCompareStrings()!Marc Mutz2017-03-291-10/+115
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These free functions are designed to solve the problem that we currently have QString::compare(QString, QString), but we have no QString::compare(QStringRef, QString), even though we have QString::compare(QStringRef). A compare(QString, QStringRef) only exists in QStringRef. This makes writing generic code tedious and error prone. Notably absent are comparisons involving char* and QByteArray. These will be added when we add QUtf8String, the UTF-8 counterpart to QLatin1String. Change-Id: I2dd7c4b1a1e0883ef0091396ee8c190012f4efba Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | QLocalePrivate: port number parsing to QStringViewMarc Mutz2017-03-291-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | This ports all functions in qlocale_p.h to QStringView that can be ported with the QStringView features we already have. Prerequisite for QStringView::to<Integer>(), and QLocale::to<Integer>(QStringView). Change-Id: I52112dc199cdf3a8545e722399b1c9cceaf797e1 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
* | QString: clean up internal string comparison functionsMarc Mutz2017-03-281-123/+102
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | String comparison drew on a large number of internal functions such as qMemEquals, ucstr{n,}{i,}cmp, and QString::compare_helper, all with wildly different calling conventions. E.g. ucstrncmp took its arguments as QChar*, while ucstricmp required ushort*. A complete cleanup of these functions is left for another patch. This patch, as a first step, centralizes calls to these functions. Introduce two helpers, qt_compare_strings(QStringView, QStringView, cs) and qt_compare_strings(QStringView, QLatin1String, cs) and replace all uses of said lower-level functions with calls to these two functions. I'm using QStringView instead of the more traditional (QChar*,int) pairs, since we get two major benefits: 1. The onus of checking for valid arguments is put on the callers (creating QStringViews with negative sizes is UB), allowing these functions to be noexcept, even though the implementation still calls functions taking (ptr, size) or (ptr, ptr) tuples. Duly add a few asserts where we construct QStringViews from (ptr, size) pairs passed in through exported API. 2. Since QStringView can be constructed from both ushort* and QChar*, we no longer have to cast at the call sites. Much of the simplification of the code is due to reduced casts. The Windows 64-bit ABI stipulates that no values greater than the register width can be passed in registers (no register pairing as with all other ABIs), but a) that is their problem, b) it does not seem to matter within a TU, c) MS is known to introduce new calling conventions all the time (like __vectorcall in MSVC2013), so maybe they will introduce a __faststructcall at some point and d) giving up on the above-mentioned two benefits for an unknown runtime cost means we're falling prey to premature optimization. As a consequence of the cleanup, qMemEquals() and ucstrnicmp(ushort*, ushort*, int) can already be removed. Port the ucstr{i,}cmp() functions to QChar/char to avoid casting in their only callers, qt_compare_strings(). Port ucstrcmp from int to size_t indices to avoid MSVC warnings when passing QStringView::size() to them. Change-Id: I4a8add0fc773dc0e1225a3b9a1c1248341a1720f Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-03-201-19/+5
|\| | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qfilesystemengine_win.cpp src/gui/text/qdistancefield.cpp src/plugins/platforms/xcb/qxcbconnection.h Change-Id: I1be4a6f440ccb7599991159e3cb9de60990e4b1e
| * QString: de-deplicate code of leftRef, rightRef, midRefAnton Kudryavtsev2017-03-181-19/+3
| | | | | | | | | | | | | | | | Re-use methods of QStringRef. Change-Id: I5ff719c08c54246e9cafd4f9aa0823ff6df8433b Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * Deprecate QString::nullMarc Mutz2017-03-121-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's a Qt 3 compatibility vehicle, and as such inherits the now-alien property to distinguish empty and null strings. Particularly worrisome is the following asymmetry: QString("") == QString::null // false QString("") == QString(QString::null) // true Instead of fixing this behavior, recognize that people might use it as a weird way to call isNull(), albeit one that once was idiomatic, and simply deprecate everything that deals with QString::null. [ChangeLog][QtCore][QString] QString::null is now deprecated. When used to construct a QString, use QString() instead. When used to compare to a QString, replace with QString::isNull(). Change-Id: I9f7e84a92522c75666da15f49324c500ae93af42 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
* | ucstricmp: compare null and empty strings equalMarc Mutz2017-03-081-9/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For consistency with ucstrcmp(), which does the same. Before, the two overloads would sort null before empty strings. This behavior was removed in Qt 3.0, IIRC- This does not yet change anything, as all callers seem to work around the problem by handling null strings before calling this function (directly or indirectly). We would have seen a failure crop up if it wasn't so. As soon as we use these functions to compare QStringViews, however, the functions need to deal correctly with a nullptr lhs and/or rhs, so fix them. Change-Id: Ie4e417aade993213169b96b5e7351850c52ae733 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QLatin1String: add iteratorsMarc Mutz2017-03-071-0/+161
| | | | | | | | | | | | | | | | | | [ChangeLog][QtCore][QLatin1String] Added iterators, {c,}{r,}{begin,end}(). Change-Id: I0222a3ff44f2aa827c737e2fa3cfbb8aad69b5a7 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QString: make ucstrncmp() work for more than 2Gi charactersMarc Mutz2017-03-061-8/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Required for implementing upcoming QStringView's member functions such as compare(), indexOf(), endsWith(), ... Most implementations of the function body just add the length to the begin pointer to obtain an end pointer and then either no longer use the length, or decrease it in lock-step with increasing the begin pointer. The only exception is MIPS DSP's qt_ucstrncmp_mips_dsp_asm(), which gets the length passed in as an uint, implicitly converted from the int parameter, proving that calling the function with negative length was always undefined behavior, and therefore using an unsigned type does not introduce incompatibilites. I don't stand a snowball's chance in hell to fix the assembler routine, but since the code is only included for MIPS32, we don't need to do anything except be paranoid, add a static_assert that uint is the same size as size_t, and keep calling the old code. Dropped Q_COMPILER_LAMBDA in some places. We require lambdas since 5.7. Also hold lambdas by value, not by reference. This stuff is supposedly completely inlined, anyway, so there's no reason to make the code more complicated with magic lifetime extension of temporaries bound to references. Change-Id: I0c7bdc47648b873992b51b2e9d47d808390320ea Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QString: make UnrollTailLoop work with non-int indicesMarc Mutz2017-03-061-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | The extension of ucstrncmp to size_t will introduce the first user of this loop unrolling construct with size_t indices. Instead of choosing between int and size_t, make the index type a new template argument to facilitate a step-by-step transition from int to size_t users. Change-Id: I9d8fa7aaefa572130403bd19e11f52c58dff0a4d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-02-171-3/+9
|\| | | | | | | | | | | | | Conflicts: qmake/Makefile.unix Change-Id: Ia18e391198222eef34ffa2df6f683e052058d032
| * QString(Ref): make toLatin1()/toLocal8Bit() null handling consistentMarc Mutz2017-02-151-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Systematic testing in tst_QStringApiSymmetry revealed a bug in QStringRef::toLatin1(): a null input did not result in a null output, but an empty one. This is fixed, for consistency with QString::toLatin1(), and QString(Ref)::toUtf8(), which behaved correctly already. The same bug was found in QString(Ref)::toLocal8Bit(), which is particularly hideous, as it's documented to fall back to toLatin1(), which preserves null inputs. Fixed, too. [ChangeLog][QtCore][QString] toLocal8Bit() now preserves nullness of the input QString (outputs null QByteArray). [ChangeLog][QtCore][QStringRef] toLocal8Bit() and toLatin1() now preserve nullness of the input QStringRef (output null QByteArrays). Change-Id: I7026211922c287e03d07e89edbad2987aa646e51 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-02-101-5/+5
|\| | | | | | | | | | | | | Conflicts: src/widgets/widgets/qmainwindowlayout_p.h Change-Id: Id406a67606b885052ed405b0fbc8eea7d9d03224
| * Merge remote-tracking branch 'origin/5.8' into 5.9Liang Qi2017-02-081-5/+5
| |\ | | | | | | | | | | | | | | | | | | | | | Conflicts: configure.json mkspecs/win32-icc/qmake.conf Change-Id: Ibf40546b024d644c7d9ed490bee15b82597f4d3f
| | * Fix libs build with msvc on Chinese locale on WindowsLiang Qi2017-02-011-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Chinese locale means Code Page 936 here. It's also related with removing C4819 warnings. And it's also following Conventions in Qt source code: All code is ascii only (7-bit characters only, run man ascii if unsure) See also http://wiki.qt.io/Coding_Conventions Task-number: QTBUG-56155 Task-number: QTBUG-58161 Change-Id: I37fa7a0e6a82a16eaf80e1cc99be801099ab87de Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: jian liang <jianliang79@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| | * Doc: Normalize \since usageTopi Reinio2017-01-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Although it's permitted to specify the project name together with a version number for \since, it's unnecessary for Qt classes and functions. This change also normalizes the version formatting: '<major>.<minor>' Change-Id: Ie5a43662077d13c31e241bcde8a7a2849d27d330 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* | | QLatin1String: add missing isNull(), isEmpty()Marc Mutz2017-02-091-0/+18
|/ / | | | | | | | | | | | | | | | | | | All Qt string containers have them, so tst_qstringapisymmetry pointed out their absence. [ChangeLog][QtCore][QLatin1String] Added isEmpty(), isNull(). Change-Id: I5ed27ed036c29a7d0f041910fce6c27d9270dd26 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | Merge remote-tracking branch 'origin/5.8' into devLiang Qi2017-01-301-1/+1
|\| | | | | | | | | | | | | | | | | | | | | Conflicts: examples/network/network-chat/peermanager.cpp src/widgets/util/qsystemtrayicon.cpp src/widgets/util/qsystemtrayicon_qpa.cpp src/widgets/util/qsystemtrayicon_win.cpp src/widgets/util/qsystemtrayicon_x11.cpp Change-Id: I1c026df83818c0ccaf956980370e7522960627db
| * Doc: updated QString::fromRawData documentation to QRegularExpressionSamuel Gaist2017-01-231-1/+1
| | | | | | | | | | | | | | | | QString::fromRawData code sample still shows the use of QRegExp. This patch updates it for QRegularExpression and cleans the code. Change-Id: Iff0f736cdbdd7d35c65fde1496ce9f838a8f5c6d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Fix QString comparison on Aarch64Erik Verbruggen2017-01-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | There was an off-by-one error in the while loop for aarch64: we start counting at 0 for the first position, so the last valid input position is "a+7", not 8. This wasn't covered by the tests, nor was the SSE2 version, so now there are also tests for both versions. Change-Id: I7eb8c5708e6179f45ea56885b0e66e1a37969c1d Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Aarch64: vectorize findCharErik Verbruggen2016-12-141-1/+14
| | | | | | | | | | | | | | | | | | | | The "algorithm" is the same as the one for x86. Also added a comment to qt_from_latin1 to indicate that manual vectorization doesn't bring anything useful. Change-Id: I6130cbd83c14c22b1bd15d726b26dbc83068b1a6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.8' into devLiang Qi2016-12-131-54/+56
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: configure qmake/Makefile.unix.macos qmake/Makefile.unix.win32 qmake/generators/win32/msvc_vcproj.cpp src/3rdparty/pcre/qt_attribution.json src/corelib/io/qsettings.cpp src/corelib/kernel/qdeadlinetimer.cpp src/platformsupport/kmsconvenience/qkmsdevice.cpp src/platformsupport/kmsconvenience/qkmsdevice_p.h src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h tests/manual/qstorageinfo/printvolumes.cpp tools/configure/configureapp.cpp Change-Id: Ibaabcc8e965c44926f9fb018466e8b132b8df49e
| * Properly use QT_CONFIG macro to check for ICULars Knoll2016-11-291-2/+2
| | | | | | | | | | | | | | And remove the QT_USE_ICU define. Change-Id: I8134ee18af7c90ed7070926ca31b3a57b3ec37dd Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>