summaryrefslogtreecommitdiffstats
path: root/src/corelib/text
Commit message (Collapse)AuthorAgeFilesLines
* Fix int/qsizetype mismatches in qstring.hMarc Mutz2022-05-171-7/+6
| | | | | | | | | | | | | | | | | [ChangeLog][QtCore][QString] Fixed result truncation mod INT_MAX in fromStdSstring(), fromStdU16string(), fromStdU32string(), and fromStdWstring(). [ChangeLog][QtCore][QAnyStringView] Fixed result truncation mod INT_MAX in asLatin1StringView(). [ChangeLog][QtCore][QUtf8StringView] Fixed result truncation mod INT_MAX in toString(). Pick-to: 6.3 6.2 Change-Id: I944c561018a6ab4581ad6b1d71ec1ba1accba4a4 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QString: don't use utf16() just to create a u16stringMarc Mutz2022-05-161-1/+1
| | | | | | | | | | | | QString::utf16() will detach from QStringLiterals in order to ensure NUL-termination, we don't need the returned pointer NUL-terminated, because we pass the length explicitly to the u16string ctor, so just use data(). Task-number: QTBUG-98763 Pick-to: 6.3 Change-Id: If883901a41480f469162ff4ed5bef927a3bf060a Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-1669-2582/+170
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Remove remnants of the old Intel C++ compilerThiago Macieira2022-05-113-3/+3
| | | | | | | | | | | | | We don't support it any more. I don't think it has ever properly compiled Qt 6 (and it's no longer working for me against GCC 12's libstdc++ headers). If you report a bug against it, Intel support's first question is if you can try instead the new Clang/LLVM-based oneAPI C++ compiler. So we support only that one, which identifies itself as Q_CC_CLANG. Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eb57a092c8439e Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Use Q_CC_{GNU,MSVC}_ONLY when comparing to particular versionsMarc Mutz2022-05-062-2/+2
| | | | | | | | | | | | | | | | | This prevents false-negatives and false-positives, as e.g. Clang 10.0.0 masks as GCC 4.2, so Q_CC_GNU is 402 on that compiler. Depending on the test (Q_CC_GNU > NNN or Q_CC_GNU < NNN), the result of the test is almost random. Q_CC_<comp>_ONLY makes sure we match only GCC or MSVC, not bycatch such as Clang or ICC. Pick-to: 6.3 6.2 5.15 Change-Id: I4c550a11ecf85fc9a2216b330b69bd03d45b47e0 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QRegularExpression: eradicate QT_STRINGVIEW_LEVELMarc Mutz2022-05-032-19/+0
| | | | | | | | | | It's not used and not useful. Task-number: QTBUG-100861 Pick-to: 6.3 6.2 Change-Id: Ie28d07474ee8fae96b569632d835dbb0ffd0e48f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Deprecate _qs and _qba literal operators in favor of _s and _baSona Kurazyan2022-05-024-0/+16
| | | | | | | | | | [ChangeLog][QtCore] Deprecated _qs and _qba literal operators for QString and QByteArray in favor of _s and _ba in the Qt::Literals::StringLiterals namespace. Task-number: QTBUG-101408 Change-Id: I26aee0055e3b4c1860de6eda8e0eb857c5b3e11a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace remaining uses of deprecated _qs with _sSona Kurazyan2022-05-021-1/+1
| | | | | | Task-number: QTBUG-101408 Change-Id: I1fda67c07e948af5017f0b99b67f8c20d7052033 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Implement support for '0b' prefix in toInt() etcMarc Mutz2022-04-283-57/+120
| | | | | | | | | | | | | | | | | | | | [ChangeLog][QtCore][QByteArray/QByteArrayView/QLatin1String/QString/QStringView] The string-to-integer conversion functions (toInt() etc) now support the 0b prefix for binary literals. That means that base = 0 will recognize 0b to mean base = 2 and an explicit base = 2 argument will make toInt() (etc) skip an optional 0b. [ChangeLog][QtCore][Important Behavior Changes] Due to the newly-introduced support for 0b (binary) prefixes in integer parsing, some strings that were previously rejected as invalid now parse as valid. E.g., Qt 6.3 with autodetected bases would have tried to parse "0b1" as an octal value and fail, whereas 6.4 will parse it as the binary literal and return 1. Fixes: QTBUG-85002 Change-Id: Id4eff72d63619080e5afece4d059b6ffd52f28c8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix qlocale_unix's handling of uiLanguages to take script into accountEdward Welbourne2022-04-271-8/+9
| | | | | | | | | | | | | | | Some languages have, in the same territory, locales for more than one script. In such cases, since we ignored the script, we got the one that is used by default, instead of the one actually asked for. Take the script into account. Added TODO comment in test listing the known examples of this; manually tested before and after the fix to verify the prior code was indeed getting it wrong and now does do it right. Change-Id: Iaf9201d6992bc39e6e9346ef8b7c69d418db7253 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Return more specific entries before less in QLocale::uiLanguages()Edward Welbourne2022-04-271-12/+17
| | | | | | | | | | | | | | | | | | The documentation overtly listed entries in this order but the code gave less specific entries before more specific (and the tests verified the same). This is now reversed. [ChangeLog][QtCore][QLocale] uiLanguages() now prefers more specific locale names over less specific ones, matching its own documentation, except where the system backend supplies them in some other order. This means a translation with the expected script and/or territory as well as language will be used in preference to a generic one for just the language, rather than only as a fall-back when the more generic one is missing. Fixes: QTBUG-102796 Change-Id: I3c7b3627afb51246df5a6ad0230e23b60af78071 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix unused variables in qtbaseAndrei Golubev2022-04-252-10/+0
| | | | | | | | | | | | | | | | | | | | | | | clang compiler recently got smarter and detects "pseudo used variable" patterns where we declare a variable and only use it in self-increments, self-decrements and other similar expressions Errors: qtbase/src/corelib/text/qlocale.cpp:3898:9: error: variable 'group_cnt' set but not used [-Werror,-Wunused-but-set-variable] int group_cnt = 0; // counts number of group chars ^ qtbase/src/corelib/text/qunicodetools.cpp:1372:21: error: variable 'uc' set but not used [-Werror,-Wunused-but-set-variable] const char16_t *uc = text + from; ^ and more of the kind Remove the ones that have no usage, mark others with [[maybe_unused]] Pick-to: 6.3 6.2 Change-Id: Ib2d0722110e3da8c39e29ec78c0ec290d064c970 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Exploit the new macro varargs form of Q_GLOBAL_STATICEdward Welbourne2022-04-221-2/+2
| | | | | | | | Convert various uses of Q_GLOBAL_STATIC_WITH_ARGS() to the less verbose form the recent reworking makes possible. Change-Id: I57820660b5d00d39bf54b5a08cb921ebaec57c7c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace uses of _qs with _s in sources and examplesSona Kurazyan2022-04-192-2/+2
| | | | | | Task-number: QTBUG-101408 Change-Id: I48360ba3b23965cd3d90ac243c100a0656a4cde8 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QtCore: stop using QLatin1Char constructor for creating char literalsSona Kurazyan2022-04-111-16/+16
| | | | | | | | Required for porting away from QLatin1Char/QLatin1String in scope of QTBUG-98434. Change-Id: Ibe32a11699f67df2aa80505ba2944f33e5e823e0 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Update CLDR-derived data to newly-released v41Ievgenii Meshcheriakov2022-04-082-2271/+2291
| | | | | | | Fixes: QTBUG-101214 Change-Id: I42f3e76d03b4759d3cda9ab81856d0b6d7506d8e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Add literal operators for QString/QByteArray to StringLiterals namespaceSona Kurazyan2022-04-074-8/+76
| | | | | | | | | | | | [ChangeLog][QtCore] Added literal operators for _s and _ba for QString and QByteArray respectively in the Qt::Literals::StringLiterals namespace. Task-number: QTBUG-101408 Change-Id: I5cd4e7f36f614ea805cfecc27b91c5d981cd3794 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Rest of QtBase: sweep Q_DECLARE_METATYPE → QT_DECL_METATYPE_EXTERNMarc Mutz2022-04-072-4/+14
| | | | | | | | | | | | | | | | It's one of our best tools to improve compile times. In some places, we can't do the change, yet, because there's no .cpp file for the header file. Also mark Q_DECLARE_METATYPE macros that are in the wrong place. We shouldn't have Q_D_M markup for public classes in .cpp or _p.h files. Fixes: QTBUG-102206 Change-Id: Iec0a39e4745571b24d07dacc87593321967c10e3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QByteArray/QVarLengthArray: add missing resize(n, v) overloadsMarc Mutz2022-04-062-0/+26
| | | | | | | | | | | | | | | | | | QList and QString had them, so add them to QByteArray and QVarLengthArray, too. In the QVLA case, we need to jump though a hoop or two to avoid having to duplicate all the reallocation logic. Nothing a few template tricks cannot solve. [ChangeLog][QtCore][QByteArray] Added resize(n, ch) overload. [ChangeLog][QtCore][QVarLengthArray] Added resize(n, v) overload. Fixes: QTBUG-102270 Change-Id: I0d281ae5b574f440f682e4a62427b434dcf5b687 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* We do in fact support 'F' format for floating-point valuesEdward Welbourne2022-04-011-10/+12
| | | | | | | | | | | | | | Update docs and add tests. [ChangeLog][QtCore] Documented existing support for 'F' format when converting floating-point numbers to strings in QLocale::toString(), hence equally for QString's floating-point formatting. Previously it was supported but the documentation neglected to mention it; it only differs from 'f' for infinities and NaN. Change-Id: Ic946c0f7b9e86fdf512daa3124bea57fc664b34b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QBAV/QSV: remove a historical noteGiuseppe D'Angelo2022-04-012-8/+0
| | | | | | | | | Both QByteArray and QString can contain more than 2^32 elements on 64 bits platforms, so the warning does not apply any more. Change-Id: I4604c1fe225922a0df7e78135eeb5a1e2b84fea3 Pick-to: 6.2 6.3 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Allow brace initialization for some of QLatin1StringView constructorsSona Kurazyan2022-04-012-19/+19
| | | | | | | | | | | | | | | Removed "explicit" keyword from constructors taking (const char *, qsizetype) and (const char *, const char *). Switched to using brace initialization for creating QLatin1StringView in QtCore. [ChangeLog][QtCore][QLatin1StringView] The (const char *, qsizetype) and (const char *, const char *) constructors are no longer explicit. Change-Id: I4f6760692e4df60fe4231e86a25f6ea03cd1bf82 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Apply Q_CONSTINIT across the codebaseMarc Mutz2022-03-293-8/+8
| | | | | | | | | Still not complete. Just grepping for static and thread_local. Task-number: QTBUG-100486 Change-Id: I90ca14e8db3a95590ecde5f89924cf6fcc9755a3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Short live Q_CONSTINIT!Marc Mutz2022-03-261-1/+1
| | | | | | | | | | | | | | | | | | It expands to the first available of - constinit (C++20) - [[clang::require_constant_initialization]] (Clang) - __constinit (GCC >= 10) Use it around the code (on and near static QBasicAtomic; this patch makes no attempt to find all statics in qtbase). [ChangeLog][QtCore][QtGlobal] Added macro Q_CONSTINIT. Fixes: QTBUG-100484 Change-Id: I11e0363a7acb3464476859d12ec7f94319d82be7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QtCore: Replace remaining uses of QLatin1String with QLatin1StringViewSona Kurazyan2022-03-2616-75/+75
| | | | | | | Task-number: QTBUG-98434 Change-Id: Ib7c5fc0aaca6ef33b93c7486e99502c555bf20bc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QtCore: replace QLatin1String/QLatin1Char with _L1/u'' where applicableSona Kurazyan2022-03-257-106/+118
| | | | | | | | | | | As a drive-by, did also minor refactorings/improvements. Task-number: QTBUG-98434 Change-Id: I81964176ae2f07ea63674c96f47f9c6aa046854f Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
* Fix char/uchar comparison warning in toPercentEncodingEdward Welbourne2022-03-251-1/+1
| | | | | | | This amends commit 5291dc7dcfa489354d3f880468902debf755d9cd Change-Id: Icdd9562f74a4de0323ba8fef558958af41eeb5a1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use QLatin1StringView in QString/QLatin1String APIs and docsSona Kurazyan2022-03-237-440/+454
| | | | | | | | | | | | | | | - Replaced QLatin1String with QLatin1StringView in QString/QLatin1String APIs and docs (except for QLatin1String class declaration and ctor names). - Made the docs look like QLatin1StringView is "The Real Thing". [ChangeLog][QtCore] Made QLatin1StringView the recommended name for referring to a Latin-1 string view (instead of QLatin1String). Task-number: QTBUG-98434 Change-Id: I6d9a85cc956c6da0c910ad7d23be7956e4bd94ac Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QAnyStringView: constexpr detect 8-bit ASCII as Latin 1Øystein Heskestad2022-03-211-7/+45
| | | | | | | | | | This has performance benefits when doing comparisons. The check is only performed at compile time. Task-number: QTBUG-101014 Change-Id: I55694b045fe5e75d9671d0a3a70c80d998cf98c8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix build on macOS without warning after QString::count deprecationVolker Hilsheimer2022-03-201-2/+2
| | | | | | Pick-to: 6.3 Change-Id: Ie043289c258fadbfafaf4a88b9695f0e65699de8 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Add QLatin1StringView as an alias for QLatin1StringSona Kurazyan2022-03-192-0/+37
| | | | | | | | | | | | | | And switch to using QLatin1StringView for bootstrap builds and Qt 7. [ChangeLog][QtCore] Added QLatin1StringView as an alias for QLatin1String. Task-number: QTBUG-98434 Change-Id: Iefb860b63eb05ef4755b2e26de265e6e6e4420b3 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Add QByteArray::percentDecoded() as an instance methodEdward Welbourne2022-03-182-16/+31
| | | | | | | | | | | | | Percent-decoding was previously only present as a static method taking a QBA parameter; it might as well be an instance method of that parameter. Change most QBA tests to use it rather the static method. [ChangeLog][QtCore][QByteArray] percentDecoded() is now available as an instance method of the byte array to be decoded, equivalent to the static QByteArray::fromPercentEncoding(). Change-Id: I982101c44bdac5cc4041e85598d52ac101d38fa1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Get rid of QByteArray::nulTerminated()Edward Welbourne2022-03-182-22/+1
| | | | | | | | | | | It is private and was not called by anything inline, even in 5.15, so can safely be removed without causing binary incompatibilities, now that it is no longer used even out-of-line. Task-number: QTBUG-74286 Change-Id: Iaec3877079746bd9ba7d1a39efbfb2711e7c00a5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Tidy up QByteArray::toPercentEncoding()Edward Welbourne2022-03-181-10/+5
| | | | | | | | | | | | | | | | After inlining the local static void to which it used to delegate most of the work, the main loop can access *this and we have no need for yet another copy of it or the variables to iterate it. We can also access the result array directly, rather than via a (poorly-named) pointer. It turns out that wrapping QBA in QBAV each time we call a lambda on it costs enough to cause a 50% slowdown, so change the lambda to now take the const refs we have. (Constructing the views only once is as good, for reference.) Change-Id: I81c5996d91415d8a933de714177a89462555ff03 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Core: Do not depend on transitive includesFabian Kosmale2022-03-172-0/+2
| | | | | Change-Id: I2c71188a4d27692a2d6ef1aa447b329627214b17 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Add QStringView::localeAwareCompare()Sona Kurazyan2022-03-173-0/+19
| | | | | | | | | | | | | | QString already has a localeAwareCompare(QStringView, QStringView) static method. Use it in QStringView::localeAwareCompare(QStringView). [ChangeLog][QtCore][QStringView] Added QStringView::localeAwareCompare(). Task-number: QTBUG-98431 Change-Id: Iec3865a5439d9fb653cc1150da21042186bdee98 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QString/QByteArray: = default the move ctorsMarc Mutz2022-03-162-2/+2
| | | | | | | | | | | | | Instead of relying on implicit construction of the d-pointer and then swapping that with other.d (using overly-generic qSwap(), no less), simply let the compiler do The Right Thing™ via QArrayDataPointer's move constructor. Pick-to: 6.3 6.2 Task-number: QTBUG-97601 Change-Id: I3be30f99f6fb0e17d3550edbe64cbe80880e604a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QString: reorganize the {starts,ends}With implementationsThiago Macieira2022-03-151-77/+44
| | | | | | | | | | | Same as the previous commit, one of the reasons it was done like this was because of git blame. The qt_{starts,ends}_with functions that are shared between QtPrivate:: and QString:: are getting inlined so there's no code benefit. Pick-to: 6.3 Change-Id: Ib42b3adc93bf4d43bd55fffd16c19a8ed3c94483 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QStringTokenizer::toContainer(): allow more types of target containersMarc Mutz2022-03-151-1/+1
| | | | | | | | | | | | | | | | | | | The previous constraint called for the value_type of the container to exactly match the value_type of the tokenizer, which means toContainer() could only ever work on containers of views. But there is value in allowing QStringList, even though it works only on QL1S needles (QStringView -> QString isn't implicit). But users may have other types that for better or worse implicitly convert from views, so we shouldn't over-constrain the function. [ChangeLog][QtCore][QStringTokenizer] toContainer() now works on containers whose value_type can be constructed from the tokenizer's value_type. It no longer requires an exact match. Fixes: QTBUG-101702 Change-Id: Ie384cd1c4b51eaa57675f2a014141ceec8651c81 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* De-pessimize Windows version of QSystemLocalePrivate::measurementSystem()Marc Mutz2022-03-151-3/+1
| | | | | | | | Don't create a QString from a wchar_t array to check that the array contains "1\0". Just do character-by-character comparison. Change-Id: I7e5c2348c24af6a9b046c91423a52f756ceb9eb9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Restore C++20-deprecated mixed-enum bitwise operatorsMarc Mutz2022-03-151-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | C++20 deprecated arithmetic on enum types. For enums used on QFlags<>, these operators have always been user-defined, but when the two enums are of different type, such as QFrame::Shape and QFrame::Shadow, the deprecation warning pops up. We have in the past fixed these in our headers by manual casts, but that doesn't help our users when our API requires them to OR together enums of different type. Until we can rework these APIs to use a variadic QFlags type, we need to fix it in an SC and BC way, which is what this patch sets out to do. The idea is simply to mark pairs of enums that are designed to be ORed together and replace the deprecated built-in bitwise operators with user-defined ones in C++20. To ensure SC and BC, we pass an explicit result type and use that to check, in C++17 builds, that it matches the decltype of the result of the built-in operator. This patch is the first in a series of similar patches. It introduces said markup macro and applies it to all enum pairs that create warnings on (my) Linux GCC 11.3 and Clang 10.0.0 builds. It is expected that more such markups are needed, for other modules, and for symmetry. Even with this patch, there is one mixed-enum warning left, in qxcbwindow.cpp. This appears to be a genuine bug (cf. QTBUG-101306), so this patch doesn't mark the enums involved in it as designed to be used together. This patch also unearthed that QT_TYPESAFE_FLAGS, possibly unsurprisingly so, breaks several mixed bitwise flags-enum operations (QTBUG-101344). Pick-to: 6.3 6.2 5.15 Task-number: QTBUG-99948 Change-Id: I86ec11c1e4d31dfa81e2c3aad031b2aa113503eb Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Correct character semantics documentation in QByteArray(View)Edward Welbourne2022-03-142-3/+9
| | | | | | | | | | | QByteArray's list of case-implicating functions included three that don't implicate case and omitted one that does. QByteArrayView lacked any mention of the liminal nature of these and other methods that presume any particular semantics to character data. Pick-to: 6.2 6.3 Change-Id: I928ef2274704584f8a137c0a4a7aa3c3da57718e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Inline q_toPercentEncoding() in QByteArray::toPercentEncoding()Edward Welbourne2022-03-141-39/+32
| | | | | | | | The latter didn't do much aside from call the former, which was private with no other callers. This prepares the way for som tidy-up. Change-Id: Iff741662365553e719a9c8b1253aff11de96455f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Eliminate the last place that QBA::nulTerminated() is neededEdward Welbourne2022-03-141-17/+10
| | | | | | | | | | | | By simply forwarding two QByteArray values (as views, since that suffices) we can retain knowledge of their sizes and thus avoid the need to null-terminate in order to forward to a hand-rolled strchr() that depended on that. Using QBAV::contains() turns out to be quite expensive, so use memchr() to implement a more efficient check. In the process, turn a pointlessly repeated check into an assertion. Change-Id: I316623206e1cf315a59d54cf574649d6acbb5c43 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Avoid possible allocation by amending a conditionEdward Welbourne2022-03-141-21/+10
| | | | | | | | | | | QBA::toPercentEncoding() duplicated a condition to decide whether it should include a percent-replacement character in its always-encode list (which might allocate memory), where simply pretesting each character against the percent achieves the same effect more cheaply. Change-Id: Ic87a977713207d74b07ee6b811b0ead3b6945ef6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Prevent exclusion of percent character from percent-encodingEdward Welbourne2022-03-141-4/+5
| | | | | | | | | | | | | | | | | | | | | | When a percent-replacement present in the exclude list would, normally, not have been encoded, it was encoded regardless, as otherwise round-tripping fails. However, when percent or its replacement would normally have been encoded, its presence in the exclude list lead to it not being encoded, which duly breaks round-tripping. It also violates https://datatracker.ietf.org/doc/html/rfc3986#section-2.4 [ChangeLog][Incompatible behavior change][QByteArray] When converting to percent-encoding, it was possible to exclude the percent character (or its replacement, unless this is one of the characters not normally encoded) from conversion. Doing so would violate RFC 3986 Section 2.4 and break round-tripping of any string that contains the percent character. The percent character, or its replacement, is now always encoded, even if mentioned in the exclude list, as the documentation has always claimed. Change-Id: I885ce33e05dc6877f1b3700fb0870fa30556a5aa Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Deprecate {QString, QByteArray}::count()Sona Kurazyan2022-03-124-5/+14
| | | | | | | | | | | | And remove their uses. [ChangeLog][QtCore][Deprecation Notice] Deprecated QString::count() and QByteArray::count() that take no parameters, to avoid confusion with the algorithm overloads of the same name. They can be replaced by size() or length() methods. Change-Id: I6541e3235ab58cf750d89568d66d3b1d9bbd4a04 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use qstringfwd.h when forward declaring string classesSona Kurazyan2022-03-123-9/+2
| | | | | | Task-number: QTBUG-98434 Change-Id: I37b70a1b7bc164fa7dc9cb702827297ca66a6fdc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Extract Header qstringfwd.hMarc Mutz2022-03-113-34/+87
| | | | | | | | | | | | | | | | ... from qstringalgorithms.h and qutf8stringview.h, in order to centralize the declaration of the string classes, much like qcontainerfwd.h does for Qt containers. [ChangeLog][QtCore] Added header qstringfwd.h containing forward-declarations of all Qt string classes. Task-number: QTBUG-98434 Change-Id: I4cf1ede9fe6c286230f4c7e7abe379da28ce5d15 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove two unused functions from qbytearray.cppEdward Welbourne2022-03-091-11/+0
| | | | | | | | | | The q_toPercentEncoding() overload without percent parameter and the q_normalizePercentEncoding() function are nowhere used. Although they were extern symbols, they were not declared in a header. Thei names mark them as Qt-internal. So removal should be safe. Change-Id: If6cece20796a80d98a9af4e764443f3ab8c555c9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>