summaryrefslogtreecommitdiffstats
path: root/src/corelib/text
Commit message (Collapse)AuthorAgeFilesLines
...
* Rework QByteArrayView comparison helpersIvan Solovev2024-03-184-14/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit fb50ab700600cbcdf21e5d06321f357eae4303bb replaced relational operators in QByteArrayView with comparison helper macros. That commit had to implement the helper methods as static members instead of hidden friends, because otherwise it broke the construction of QByteArrayView from QLatin1StringView. The reason for that is the conditional noexcept on the relational operators. The noexcept(noexcept(comparesEqual)) check inside the class declaration expands before the class is complete, and as a result discards the QByteArrayView constructor, which is restricted by the QtPrivate::IsContainerCompatibleWithQByteArrayView trait. Back then I could not find a proper solution, so just decided to declare the helper functions for QByteArrayView as private static members. Such approach has two drawbacks: - all new helper functions for QBAV vs other type T relational operators should also be static member functions, because the compiler always prefers member functions over friend functions, even if the argument types do not match. - QBAV helper functions cannot be used in generic code. Also, qCompareThreeWay() would not work for QBAV. To fix the issue this patch explicitly adds a QByteArrayView(QLatin1StringView) constructor which is not restricted by any trait. To keep the constructor constexpr, we have to move the actual definition into qlatin1stringview.h header file. Integrity compiler also complains about QByteArrayView(QUtf8StringView) constructors, so the same approach is used to enable them. This allows to convert all the private static member helpers in QByteArrayView to hidden friends. The extended tests will be added in a follow-up commit, because they require some more changes. Amends fb50ab700600cbcdf21e5d06321f357eae4303bb and a08bafc9205d0b67f71a1896ad84272eeb294374. This patch removes some exported methods and adds new ones, but it is not BiC, because the aforementioned patches are only merged into dev branch at this point. Task-number: QTBUG-108805 Change-Id: Iee6526a71d859c4fcb2e95bf20fe84ddead6dfb0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Bootstrap: remove the UTF-16 and UTF-32 codecsThiago Macieira2024-03-134-3/+20
| | | | | | | | | | | | | | | | | | | | | | | | | Unlike most of everything else in the Bootstrap lib, this is code that couldn't be eliminated by the linker because they were referenced in one static array. Maybe an exceptionally smart whole-program analysis could do it, but GCC and Clang LTO modes don't do that now. I removed the code that performed detection from HTML and from data too. I could have left the detection of UTF-8 and "other" but this code wasn't necessary. In particular, QTextStream couldn't benefit from it because it already defaults to UTF-8, so the detection code would never determine anything different from the input. Drive-by removed QStringConverter::availableCodecs() too because it was in the middle of functions #ifdef'ed out to. This reduced the size of release-mode moc text data bss dec hex filename 1079858 5440 640 1085938 1091f2 original/moc 1074386 5200 640 1080226 107ba2 updated/moc -5472 -240 0 -5712 difference Change-Id: I01ec3c774d9943adb903fffd17b7f114c42874ac Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* Bootstrap: remove qnumeric.cpp by using qnumeric_p.hThiago Macieira2024-03-133-18/+14
| | | | | | | | | That is, use the inline functions that refer to <numeric_limits> and <cmath> directly, instead of the out-of-line wrappers. Someone should verify if the hacks for QNX's <math.h> are still required. Change-Id: I01ec3c774d9943adb903fffd17b7ee560b4b71b9 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* Use canonical capitalization of Unicode-3.0 SPDX tagKai Köhne2024-03-131-2/+2
| | | | | | | | | | | | | | | | | | | | The SPDX database lists the license as 'Unicode-3.0', and 'Unicode License v3'. Now, the SPDX standard actually says that License identifiers (including license exception identifiers) used in SPDX documents or source code files should be matched in a case- insensitive manner. But the website at https://spdx.org/licenses/ doesn't treat it this way, so the link we generate out of the identifier actually gives a 404. So it's just easier to use the 'original' capitalization. Amends 063026cc503 Pick-to: 6.5 6.6 6.7 Change-Id: I826077a914721b7b9499ad62c08fdf20be94e88d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Bootstrap: remove QDataStreamThiago Macieira2024-03-132-2/+2
| | | | | | | | | | | It was only used by the cmake_automoc_parser so it would write a 64-bit in big-endian format. So bypass QDataStream and write it native endianness. Change-Id: I01ec3c774d9943adb903fffd17b79c78e56db4cf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* QString/QByteArray: add explicit constructors for Q{String,ByteArray}ViewThiago Macieira2024-03-122-2/+4
| | | | | | | | | | | | | | | | | | | std::string has them too, see constructor 10 in [1]. There, they are StringViewLike, something we may want to do here too, which would also lower the precedence of the constructor in the overload resolution. This will be needed for the non-const heterogeneous QHash::operator[]. [ChangeLog][QtCore][QByteArray] Added a constructor to create a QByteArray from QByteArrayView. [ChangeLog][QtCore][QString] Added a constructor to create a QString from QStringView. [1] https://en.cppreference.com/w/cpp/string/basic_string/basic_string Change-Id: I6818d78a57394e37857bfffd17b9ab03bd0253e6 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qstringalgorithms: include <iterator> in favor of <string.h>Dennis Oberst2024-03-121-2/+1
| | | | | | | | | | | | The switch from <string> to <string.h> dropped the definition of std::size. Include <iterator> since <string.h> is no longer used to pull in std::size. Amends: dc2ae08e02730ab795445bc047221aa56914f723. Pick-to: 6.7 Change-Id: Ib742538eb5d21c77fcae7ee9abb6d5329bbcfd63 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QtPrivate::equalStrings(): enforce matching size where applicableThiago Macieira2024-03-061-7/+15
| | | | | | | | | | | | | | | | Commit 8a7b74f6e71d6b8264f365148bf5a04db4038617 added these functions and already placed the checking for the size in the inline code. Aside from the operators==, the only other place that calls equalStrings() directly is QAnyStringView::equal() and that also checks the size for the non-UTF-8 string views do match. Unfortunately, the size checking for UTF-8 was only added in 52e0a91fbc187ca09d3ea6279e8bdce982edc586. This reverts commit e0eb93d9a2b104ac8d7596c419d1f13dc9db9b1b ("QLatin1StringView: delegate operator== to QByteArrayView") because that would compare the sizes again. Change-Id: I83dda2d36c904517b3c0fffd17b38e422b5e2c25 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Revert "QStringView: simplify the constructor from QString"Marc Mutz2024-03-062-8/+10
| | | | | | | | | | | | | | | This reverts commit 7d18ad49a37440835bb38bd77bc4e0991387ada0. Reason for revert: This changes the constructor from being a template to being a normal function, so changes overload resolution. The commit message gave no indication on why this is safe. Since it's just a nice to have, revert instead of running the risk of breaking code. Pick-to: 6.7 Change-Id: Icd506e7221bb50c99f276f6a43c15403ec0be7a9 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Replace some QString::fromUtf16() with QStringView::toString()Thiago Macieira2024-03-042-3/+6
| | | | | | | | | | | | | | The QStringView counterpart is somewhat faster because it doesn't go through the UTF-16 codec in QUtf16::convertToUnicode(), which tries to detect the BOM. I've included QString::fromWCharArray in this because: a) it's used extensively in Windows code b) wide chars in memory probably don't have BOMs anyway Change-Id: I01ec3c774d9943adb903fffd17b815be4d2ab8ba Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* Move QLocaleData::convertDoubleToFloat to qnumeric_p.hThiago Macieira2024-03-041-16/+7
| | | | | | | So others can use it too. Change-Id: I01ec3c774d9943adb903fffd17b86236d06a948c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Remove qbytearray_p.hGiuseppe D'Angelo2024-03-041-28/+0
| | | | | | | It's unused now. Change-Id: I948650abdbcc0dc0f7925c56e326762ba66e8ee9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLocal8Bit::convertToUnicode[win]: rewrite remainingChars handling as recursiveMårten Nordheim2024-03-021-52/+62
| | | | | | | | | | | | | Then we will automatically handle invalid leading characters instead of throwing away the whole sequence when it cannot be converted. Added a test that was failing before. Drive-by change: add a comment explaining why we have the stack allocated buffer. Task-number: QTBUG-118834 Change-Id: I647a58f2ba95e2e7ed4ea6a964d99ecc0c91fad3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Rename qIsConstantEvaluated() to q20::is_constant_evaluated()Marc Mutz2024-03-023-15/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | We should really try to avoid another almost-std-compatible-but-not-quite idiom. When qIsConstantEvaluated() was added, the rationale was given that this cannot be q20, because we can't implement it in all compilers. But we can: returning false is a perfectly legal implementation, and makes most users actually simpler because the #ifdef'ery can be dropped. There are only two users that still require the macro, because either they do different fallbacks depending on whether the implementation is trivial, or because they direct expected test outcomes. The INTEGRITY compiler complains "calling __has_builtin() in a constant expression", which we currently don't understand. To unblock this patch, and therefore the 6.7 release, hard-code INTEGRITY to return false. Amends 95e6fac0a5a1eee3aa23e4da0a93c6c25e32fb98. Pick-to: 6.7 Change-Id: If6cae902ff434f2ccceb6057cb053b7f304a604c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QAnyStringView: use new comparison helper macrosIvan Solovev2024-03-022-23/+21
| | | | | | | | | | | Also extend unit-test to use new test helper functions. Remove the now-redundant test for three-way comparison, because it is covered by the test helper functions. Task-number: QTBUG-117661 Change-Id: I242b560c281245e04e34353c80000a20998fc677 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QUtf8StringView: use more comparison helper macrosIvan Solovev2024-03-021-19/+11
| | | | | | | | Convert the last relational operators to using the macros. Task-number: QTBUG-117661 Change-Id: I5c4c890527d1a3c9500e98f47881d2e17b101ca9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QByteArray: use comparison helper macrosIvan Solovev2024-03-023-103/+118
| | | | | | | | | | | | | | | | | | Replace the existing friend relational operators with the macros. Add the previously-missing relational opertors with QChar and char16_t. This allows to remove the last dummy relational operators and the macros to generate them in tst_qstringapisymmetry. Because of a bug in libstdc++[0], we have to explicitly keep the QBA vs QBA relational operators even in C++20 mode. This problem is specific to QByteArray, because it is convertible to const void *. [0]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114153 Task-number: QTBUG-117661 Change-Id: Iac7f81cd3274331b7c7695a51803321b511361c0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Q(Latin1)Char: use comparison helper macrosIvan Solovev2024-03-023-47/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | Replace the existing friend relational operators with the macros. Add the previously-missing QChar vs `const char *` relational operators. These require out-of-line helper methods, because we need to interpret the `const char *` array as utf-8. The `const char *` relational operators cause ambiguities when comparing QChar with 0 (previously it was only handled by the nullptr_t overloads). As we have it in several places in our tests, I'd assume that the users can also do it. To resolve the ambiguities, mark the new relational operators as Q_WEAK_OVERLOADs. This allows to remove the dummy QChar vs `const char *` relational operators from tst_qstringapisymmetry, but at the same time requires that we introduce new dummy operators for QByteArray vs char16_t comparison. These will be fixed in a follow-up patch. For QLatin1Char - convert to uchar before doing the comparison, to match the behavior of QLatin1StringView and QChar. Extend QChar's unit tests. Task-number: QTBUG-117661 Change-Id: I9213fe05a5efdb96d48688f07bec9519f9887a77 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QByteArrayView vs QChar and vs char16_t relational operatorsIvan Solovev2024-03-022-0/+36
| | | | | | | | | This allows to remove the dummy relational operators from tst_qstringapisymmetry. Task-number: QTBUG-108805 Change-Id: I7cb3154d6fcb571cafab6b318806f74bc8300448 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLatin1StringView: consistently use comparison helper macrosIvan Solovev2024-03-022-112/+103
| | | | | | | | | | | Replace all friend relational operators with comparison helper macros. This allows to enable operator<=>() in C++20 builds. Use new \compares and \compareswith qdoc commands in the documentation. Task-number: QTBUG-117661 Change-Id: I0445d7af3c2d692c810e15e83041de2a19f946a9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add missing QUtf8StringView relational operatorsIvan Solovev2024-03-023-0/+51
| | | | | | | | | | | | Add QU8SV vs QSV, QU8SV vs QChar, and QU8SV vs char16_t relational operators. This allows to get rid of the dummy relational operators in tst_qstringapisymmetry. Task-number: QTBUG-117661 Change-Id: If95d7418efd13c505ed0e3bef748b86ff55e623a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QString: use comparison helper macros - missing string views [3/3]Ivan Solovev2024-03-022-1/+21
| | | | | | | | | | | | | | | | | | | | | The comparison with QStringView works as is, there is no need to add explicit operators. Add the missing relational operators with QUtf8StringView. Once it is added, comparison of QString with u8"string literal" becomes ambiguous, so explicitly add operators for `const char8_t*` as well. This also makes the comparison with u8 string literals faster, because it now uses a view instead of constructing a QString. Adding QUtf8StringView overloads also makes comparison with `const char *` ambiguous if QT_RESTRICTED_CAST_FROM_ASCII is defined. To fix that, mark the overload as Q_WEAK_OVERLOAD. Luckily, we can just use the third Attributes parameter of the macro for that. Provide more unit-tests to cover the new relational operators. Task-number: QTBUG-117661 Change-Id: I60d1f4ad7ea607472deeb5c250e62f2bb7019268 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QString: use comparison helper macros - comparison with byte arrays [2/3]Ivan Solovev2024-03-024-165/+187
| | | | | | | | | | | | | | | | | | Use the comparison helper macros to replace the member relational operators for comparison with QByteArray and const char *. As QString and QByteArray are exported, we cannot simply remove the inline methods, so wrap them into QT_CORE_REMOVED_SINCE. Add relational operators with QByteArrayView. Provide more unit-tests for the comparison with the byte array types. This enables operator<=> for QString vs byte arrays in C++20 builds. Task-number: QTBUG-117661 Change-Id: I305343e1b6c5d78b10f2976573db4e904ba6b44b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QString: use comparison helper macros - trivial changes [1/3]Ivan Solovev2024-03-022-104/+75
| | | | | | | | | | | | | Replace the hidden friend relational operators with hidden friend helper functions and comparison helper macros. Provide more unit-tests for the updated types. This enables operator<=> in C++20 builds. Task-number: QTBUG-117661 Change-Id: I17329cd6422f272a435fc1da241203581eef7fbb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Bring back QASV::detects_US_ASCII_at_compile_timeIvan Solovev2024-03-011-0/+8
| | | | | | | | | | | | | | Even though undocumented, it's public API, doesn't hurt to carry along, and improves compiler coverage in the test, so let's not remove it. Found in 6.7 API review Amends 95e6fac0a5a1eee3aa23e4da0a93c6c25e32fb98. Pick-to: 6.7 Change-Id: Ia935036a69e0e678f22ac86b48a2c1c5e8c46733 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QByteArrayView: make conversion to string_view constexprMarc Mutz2024-03-011-1/+1
| | | | | | | | | | | | | | Both QByteArrayView and std::string_view are Literal Types, so the conversion between them should be constexpr. Amends 96d67da420697cee10bdc537a1a592f6f22e2b8f. Found in API-review. Pick-to: 6.7 Change-Id: Ic513ce32aa2a743ca890dc05a683a62c0f3a7d50 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* Fix -Wimplicit-fallthrough for clangTim Blechmann2024-03-011-0/+1
| | | | | | | | | | | | | | | | | | | Clang's `-Wimplicit-fallthrough` warnings are a little stricter than gcc's interpretation: switch (i) { case 0: foo(); case 4: break; } While gcc accepts the implicit fallthrough, if the following statement is a trivial `break`, clang will warn about it. Pick-to: 6.7 Change-Id: I38e0817f1bc034fbb552aeac21de1516edcbcbb0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QString/QByteArray: add slice() methodsAhmad Samir2024-02-294-14/+93
| | | | | | | | | [ChangeLog][QtCore][QString/QByteArray] Added slice() methods that work like sliced(), but modify the string/byte-array they are called on. Task-number: QTBUG-99218 Change-Id: I3075562983ef123d9aa022a2304c7e774cf2ea42 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Containers: add max_size()Giuseppe D'Angelo2024-02-275-5/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | One more method for STL compatibility. This one is particularly subtle as it's required by the `reservable-container` concept: https://eel.is/c++draft/ranges#range.utility.conv.general-3 Without this concept, ranges::to won't reserve() before copying the elements (out of a sized range which isn't a common_range). Implementation notes: there were already a couple of constants denoting the maximum QByteArray and QString size. Centralize that implementation in QTypedArrayData, so that QList can use it too. The maximum allocation size (private constant) needs a even more central place so that even QVLA can use it. Lacking anything better, I've put it in qcontainerfwd.h. Since our containers aren't allocator-aware, I can make max_size() a static member, and replace the existing constants throughout the rest of qtbase. (I can't kill them yet as they're used by other submodules.) [ChangeLog][QtCore][QList] Added max_size(). [ChangeLog][QtCore][QString] Added max_size(). [ChangeLog][QtCore][QByteArray] Added max_size(). [ChangeLog][QtCore][QVarLengthArray] Added max_size(). Change-Id: I176142e31b998f4f787c96333894b8f6653eb70d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QStringView: stop instantiating std::char_traits<QChar> and <uchar>Thiago Macieira2024-02-261-18/+36
| | | | | | | | | | | It's deprecated and will be removed with LLVM 19. Amends b1ee49b46533d39f7fabda68d0bd08a1ab130a27. Pick-to: 6.7 Change-Id: I5dd50a1a7ca5424d9e7afffd17ad07b3ab3fc18a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QLocal8Bit::convertToUnicode[win]: Fix order of growth and saturateMårten Nordheim2024-02-231-1/+1
| | | | | | | | | | | | | | The order was wrong so we could have ended up saturating a 0 before we grew to 1. Since this has never been in a release it is of no concern, and it was already an edge-case anyway. Amends 1090d5dd4ae5be898d4566314eda43b0283709d9 Pick-to: 6.7 6.6 6.5 Change-Id: I4b70f9018c3049697495a58313af148f8366c8bb Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Change license in files to avoid LGPL and non-LGPL license mixLucie Gérard2024-02-201-1/+1
| | | | | | | | | | | | | | | | | | | | According to QUIP-18 [1], all module files should be LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only or LicenseRef-Qt-Commercial OR GPL-3.0-only LGPD and non-LGPL licenses should not be mixed in a given directory. The files in this patch are the only ones in their directory with non-LGPL license. The license is changed to that of the other module files in the same directory. [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: Id58248a6f60438e01e77e9448f07e3057d173260 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* QStringView: use new comparison helper macrosIvan Solovev2024-02-202-25/+20
| | | | | | | | | | Replace the friend relational operators for QSV vs QSV and QSV vs QChar comparison. Task-number: QTBUG-117661 Change-Id: I547f69dac67c27b04864e56b383e75e213a17bfe Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Simplify QLatin1StringView vs byte array relational operatorsIvan Solovev2024-02-203-114/+54
| | | | | | | | | | | | | | | | | | | | | | | | Now when QLatin1StringView implements relational operators with QByteArrayView in terms of new comparison helper macros and helper methods taking QByteArrayView, we can easily re-use these helper methods to provide comparison with QByteArray and const char *. QLatin1StringView already provided almost all of these operations, partly as hidden friend functions, partly as inline methods. Since the class is not exported, and the methods were inline, we can just remove all of them and replace them with the comparison helper macros. This should speed up the relational operators, because they do not construct string objects using QString::fromUtf8() anymore, but use QUtf8StringView instead. This also adds the previously missing QByteArray vs QLatin1StringView relational operators. Task-number: QTBUG-117661 Change-Id: I17a9185127ae130dab9409c6340a58f5d39f5a10 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QStringView vs byte array relational operatorsIvan Solovev2024-02-202-0/+40
| | | | | | | | | | | | | | | | | | | | ... by using the new comparison helper macors. Note that by providing helper functions for QByteArrayView, we can support all three types: QByteArray, QByteArrayView, and const char *. Use the regular QT_NO_CAST_FROM_ASCII and QT_RESTRICTED_CAST_FROM_ASCII guards to disable the operators if the cast from ASCII is forbidden. Also use QT_ASCII_CAST_WARN on each operator. This allows to enable related tests in tst_qstringapisymmetry. Task-number: QTBUG-117661 Task-number: QTBUG-108805 Change-Id: I0d77c30245d8b5ac4b8cfd98d650c1885aca2005 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QByteArrayView vs const char * relational operatorsIvan Solovev2024-02-202-19/+28
| | | | | | | | | | | | | | | | | | | | | | ... by using the new comparison helper macros. Also, convert the existing QByteArrayView relational operators to use these macros. An attempt to define the helper functions comparesEqual() and compareThreeWay() as hidden friends leads to compilation errors, because the QByteArrayView(QLatin1StringView) constructor gets somehow disabled. Apparently, it cannot satisfy the QtPrivate::IsContainerCompatibleWithQByteArrayView trait anymore. I could not find a reason for that, so I just defined the helper functions as static inline private members of QByteArrayView. This fixes the issue. This allows to enable related tests in tst_qstringapisymmetry. Task-number: QTBUG-108805 Change-Id: I35a69e99db8c61531ec726dab5b242b857f69e85 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QByteArray vs QByteArrayView relational operatorsIvan Solovev2024-02-201-0/+11
| | | | | | | | | | ... by using the new comparison helper macors. This allows to enable related tests in tst_qstringapisymmetry. Task-number: QTBUG-108805 Change-Id: I2cef8f4a25889b74a921fea47995d59c3a49d368 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QUtf8StringView vs byte array relational operatorsIvan Solovev2024-02-202-1/+59
| | | | | | | | | | | | | | | | | | | | | | | ... by using the new comparison helper macros. First the relational operators between QU8SV and QBAV where added, and this resulted in the ambiguities when comparing QU8SV vs QBA. So, the relational operators between QU8SV and QBA are also added in the same commit. This, in turn, resulted in ambiguities when comparing QU8SV and const char *, so add these relational operators as well. Use the regular QT_NO_CAST_FROM_ASCII and QT_RESTRICTED_CAST_FROM_ASCII guards to disable the operators if the cast from ASCII is forbidden. Also use QT_ASCII_CAST_WARN on each operator. This allows to enable related tests in tst_qstringapisymmetry. Task-number: QTBUG-117661 Task-number: QTBUG-108805 Change-Id: If7919496fdf4519fd2a9398397a39210aadba077 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QLatin1StringView vs QByteArrayView relational operatorsIvan Solovev2024-02-202-0/+27
| | | | | | | | | | | | | | ... by using the new comparison helper macros. The operators are marked as QT_ASCII_CAST_WARN, like the pre-existing relational operators with QByteArray and const char *. This allows to enable related tests in tst_qstringapisymmetry. Task-number: QTBUG-117661 Task-number: QTBUG-108805 Change-Id: Ic9bcddffc25585edb7375c3e651d49d040a60454 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* PCRE2: upgrade to 10.43Giuseppe D'Angelo2024-02-191-1/+2
| | | | | | | | | | | | Apart from some source code reshuffling, 10.43's JIT has dropped its support for ARMv5. [ChangeLog][Third-Party Code] PCRE2 was updated to version 10.43. Pick-to: 6.7 6.6 6.5 Change-Id: I7909f0a9358f38282f5eaeacd2eb10529b47e63c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* Add QUtf8StringView vs QLatin1StringView relational operatorsIvan Solovev2024-02-162-0/+22
| | | | | | | | | | | | | | | ... by using the new comparison helper macros. This allows to remove dummy comparison operators from tst_qstringapisymmetry. This is also a pre-requisite for a follow-up commit that introduces relational operators between QLatin1StringView and QByteArrayView. Task-number: QTBUG-117661 Task-number: QTBUG-108805 Change-Id: I5837b457a777fddff1071bc252982e68d004fa94 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QByteArray/QString: add resizeForOverwriteGiuseppe D'Angelo2024-02-164-0/+35
| | | | | | | | | | | | | | | For these classes it's not really a new feature, but exposing the current resize() behavior (which does uninitialized resizes) under a proper name. Changing the existing behavior for resize() is a behavioral break that we can only likely afford in Qt 7. [ChangeLog][QtCore][QString] Added resizeForOverwrite(). [ChangeLog][QtCore][QByteArray] Added resizeForOverwrite(). Change-Id: I15b3104aee2bc29d23e91d97b0e64f87612d0099 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLocal8Bit::convertFromUnicode[win]: limit fprintf to !NDEBUGMårten Nordheim2024-02-161-0/+2
| | | | | | | | | Because there is no other way to stop it from printing the output. Pick-to: 6.7 6.6 6.5 Change-Id: Ie6dcb393351f50691366849ba85d60e2e186f9fb Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Fix QDoc warnings for overloadsPaul Wicking2024-02-142-0/+3
| | | | | Change-Id: I9a77b6ea0026748c7f97f73b327118f7a9212d52 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QLocal8Bit::convert{To,From}Unicode[win]: use more of stateMårten Nordheim2024-02-141-5/+26
| | | | | | | | | | | | | | | Like other backends we should increment the invalid character count when we output a replacement character. And we should also output the NULL character if requested! The downside here is that convertFromUnicode doesn't even have the ability to do so. So instead I added a comment explaining why it is not handled there. Task-number: QTBUG-118318 Pick-to: 6.7 6.6 6.5 Change-Id: I57ba631aa59454e77007ab353277b7e8c2b5526a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Disable NSUserDefaults initialization workaround on iOSTor Arne Vestbø2024-02-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | | Core Foundation would fail to pick up defaults from command line arguments, as the logic to read the command line arguments was in the Foundation class NSUserDefaults. As a workaround, we initialized NSUserDefaults as early as we could, so that we could use Core Foundation elsewhere in Qt. As NSUserDefaults is considered a potential privacy risk, and needs explicit declaration of use for iOS in the privacy manifest, we disable the workaround for iOS. This should be okey, as the original issue does not seem to manifest on iOS 17, and was only a problem in practice when using command line arguments to debug things. The issue is also seemingly gone from macOS 14.3, but we keep the workaround in for now, just in case. Task-number: QTBUG-114319 Pick-to: 6.7 Change-Id: I2c698353673f797756a877a49cfbd8a37367c31e Reviewed-by: Doris Verria <doris.verria@qt.io>
* QLocal8Bit::convertFromUnicode[win]: support more than 2Gi inputMårten Nordheim2024-02-121-8/+47
| | | | | | | | | | | | | | | | As we did for convertToUnicode. To support more than 2Gi input, we need to handle the input in chunks because of the `int` parameter in the Windows API. Testing also revealed some corner cases we also need to handle, which is mostly happening when there is an incomplete surrogate pair at the end of the current input window. The test takes between 3 (plain MinGW) and 8 (MSVC with ASAN) seconds to run on my machine. Pick-to: 6.7 6.6 6.5 Fixes: QTBUG-105105 Change-Id: I4fb0420b88ca41dfa8b561a35c6d96659bd81468 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QLocal8Bit::convertFromUnicode[win]: Pre 2Gi changesMårten Nordheim2024-02-121-20/+29
| | | | | | | | | | | | | As we did for convertToUnicode, we do some smaller changes, like increasing indentation, and switching to using pointers and calculating the input-size in this commit, so that the real changes in the next commit are (hopefully) easier to read. Pick-to: 6.7 6.6 6.5 Task-number: QTBUG-105105 Change-Id: I3bf1a487f63a3e24efd7a945152647dd8fc0aca8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QLocal8Bit::convertToUnicode[win]: support more than 2Gi inputMårten Nordheim2024-02-121-18/+50
| | | | | | | | | | | | | | | | | | | | | To properly support more than 2Gi input we have to support being asked to resize more than once. Previously we would only have to resize the one time because we went from our 4K stack buffer to the final size heap buffer. But now, since our input size can only be specified in int, we have to deal with looping over the input and resizing the buffer as needed. We also have to deal with trailing data at the end of our sliding window potentially causing issues for the encoding. So we try to shrink our window when it causes issues, or store the trailing data for the next call. The >2Gi test takes about 6-8 seconds on my machine. Pick-to: 6.7 6.6 6.5 Task-number: QTBUG-105105 Change-Id: I9a44b8f379bf2c2c58183f961544ed2f4c8c7215 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QLocal8Bit::convertToUnicode[win]: split out buffer growingMårten Nordheim2024-02-121-8/+27
| | | | | | | | | | | | | | | | | | We will need to potentially grow the buffer before appending anything to it, because if we pass in 0 as a size then the MultiByteToWideChar just returns the size we would need. If we didn't intend to do so then we would increment our output buffers even though nothing is written. And when appending single characters (like the replacement character for an invalid sequence) we need to grow the buffer as well. We'll need this all in the next commit. Pick-to: 6.7 6.6 6.5 Task-number: QTBUG-105105 Change-Id: I94b9a0f7d18a725da01a47398163e6d0f704eefc Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>