diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/global/qnumeric.h | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qmetaobjectbuilder.cpp | 2 | ||||
-rw-r--r-- | src/corelib/text/qchar.cpp | 20 | ||||
-rw-r--r-- | src/corelib/tools/qcryptographichash.cpp | 38 | ||||
-rw-r--r-- | src/widgets/doc/src/external-resources.qdoc | 2 |
5 files changed, 43 insertions, 21 deletions
diff --git a/src/corelib/global/qnumeric.h b/src/corelib/global/qnumeric.h index 723a462bae1..6caf3510f8a 100644 --- a/src/corelib/global/qnumeric.h +++ b/src/corelib/global/qnumeric.h @@ -27,6 +27,8 @@ # include <QtCore/qstdlibdetection.h> # if defined(Q_CC_GNU_ONLY) && (defined(Q_STL_LIBCPP) || Q_CC_GNU_ONLY < 1500) // broken - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121811 +# elif defined(Q_OS_FREEBSD) && __FreeBSD_version <= 1500000 +// broken - https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=290299 # else # include <stdckdint.h> # endif diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp index a2719f97da7..6065bf2baea 100644 --- a/src/corelib/kernel/qmetaobjectbuilder.cpp +++ b/src/corelib/kernel/qmetaobjectbuilder.cpp @@ -1339,7 +1339,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, [[maybe_unused]] int flags = prop.flags; - if (isBuiltinType(prop.type)) + if (!isBuiltinType(prop.type)) flags |= EnumOrFlag; if constexpr (mode == Construct) { diff --git a/src/corelib/text/qchar.cpp b/src/corelib/text/qchar.cpp index 167ba9e84d0..6be19473b85 100644 --- a/src/corelib/text/qchar.cpp +++ b/src/corelib/text/qchar.cpp @@ -1999,26 +1999,34 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, qs qsizetype pos = from; while (pos < l) { qsizetype p2 = pos+1; - char32_t u1 = s.at(pos).unicode(); - if (QChar::isHighSurrogate(u1)) { + char32_t u1; + if (const char16_t hi = s.at(pos).unicode(); QChar::isHighSurrogate(hi)) { const char16_t low = s.at(p2).unicode(); if (QChar::isLowSurrogate(low)) { - u1 = QChar::surrogateToUcs4(u1, low); + u1 = QChar::surrogateToUcs4(hi, low); if (p2 >= l) break; ++p2; + } else { + u1 = hi; } + } else { + u1 = hi; } ushort c1 = 0; advance: - char32_t u2 = s.at(p2).unicode(); - if (QChar::isHighSurrogate(u2) && p2 < l) { + char32_t u2; + if (const char16_t hi = s.at(p2).unicode(); QChar::isHighSurrogate(hi) && p2 < l) { const char16_t low = s.at(p2+1).unicode(); if (QChar::isLowSurrogate(low)) { - u2 = QChar::surrogateToUcs4(u2, low); + u2 = QChar::surrogateToUcs4(hi, low); ++p2; + } else { + u2 = hi; } + } else { + u2 = hi; } ushort c2 = 0; diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp index fea5bdfa906..092ff46b084 100644 --- a/src/corelib/tools/qcryptographichash.cpp +++ b/src/corelib/tools/qcryptographichash.cpp @@ -235,6 +235,8 @@ public: // when not called from the static hash() function, this function needs to be // called with finalizeMutex held (finalize() will do that): void finalizeUnchecked() noexcept; + QSpan<uchar> finalizeUnchecked(QSpan<uchar> buffer) noexcept; + // END functions that need to be called with finalizeMutex held QByteArrayView resultView() const noexcept { return result.toByteArrayView(); } static bool supportsAlgorithm(QCryptographicHash::Algorithm method); @@ -268,7 +270,7 @@ public: explicit EVP(QCryptographicHash::Algorithm method); void reset() noexcept; - void finalizeUnchecked(HashResult &result) noexcept; + void finalizeUnchecked(QSpan<uchar> buffer) noexcept; }; #endif @@ -281,7 +283,7 @@ public: void reset(QCryptographicHash::Algorithm method) noexcept; void addData(QCryptographicHash::Algorithm method, QByteArrayView data) noexcept; - void finalizeUnchecked(QCryptographicHash::Algorithm method, HashResult &result) noexcept; + void finalizeUnchecked(QCryptographicHash::Algorithm method, QSpan<uchar> buffer) noexcept; Sha1State sha1Context; #ifdef USING_OPENSSL30 @@ -297,7 +299,7 @@ public: SHA3Context sha3Context; enum class Sha3Variant { Sha3, Keccak }; - static void sha3Finish(SHA3Context &ctx, HashResult &result, Sha3Variant sha3Variant); + static void sha3Finish(SHA3Context &ctx, QSpan<uchar> result, Sha3Variant sha3Variant); blake2b_state blake2bContext; blake2s_state blake2sContext; } state; @@ -308,7 +310,7 @@ public: const QCryptographicHash::Algorithm method; }; -void QCryptographicHashPrivate::State::sha3Finish(SHA3Context &ctx, HashResult &result, +void QCryptographicHashPrivate::State::sha3Finish(SHA3Context &ctx, QSpan<uchar> result, Sha3Variant sha3Variant) { /* @@ -981,9 +983,23 @@ void QCryptographicHashPrivate::finalizeUnchecked() noexcept state.finalizeUnchecked(method, result); } +/*! + \internal + + Must be called with finalizeMutex held, except when called from the static + hash() function, where no sharing can take place. +*/ +QSpan<uchar> QCryptographicHashPrivate::finalizeUnchecked(QSpan<uchar> buffer) noexcept +{ + buffer = buffer.first(hashLengthInternal(method)); + state.finalizeUnchecked(method, buffer); + Q_ASSERT(result.size() == 0); // internal buffer wasn't used + return buffer; +} + #ifdef USING_OPENSSL30 void QCryptographicHashPrivate::State::finalizeUnchecked(QCryptographicHash::Algorithm method, - HashResult &result) noexcept + QSpan<uchar> result) noexcept { switch (method) { case QCryptographicHash::Keccak_224: @@ -1030,7 +1046,7 @@ void QCryptographicHashPrivate::State::finalizeUnchecked(QCryptographicHash::Alg } } -void QCryptographicHashPrivate::EVP::finalizeUnchecked(HashResult &result) noexcept +void QCryptographicHashPrivate::EVP::finalizeUnchecked(QSpan<uchar> result) noexcept { if (!initializationFailed) { EVP_MD_CTX_ptr copy = EVP_MD_CTX_ptr(EVP_MD_CTX_new()); @@ -1043,7 +1059,7 @@ void QCryptographicHashPrivate::EVP::finalizeUnchecked(HashResult &result) noexc #else // USING_OPENSSL30 void QCryptographicHashPrivate::State::finalizeUnchecked(QCryptographicHash::Algorithm method, - HashResult &result) noexcept + QSpan<uchar> result) noexcept { switch (method) { case QCryptographicHash::Sha1: { @@ -1166,12 +1182,8 @@ QByteArrayView QCryptographicHash::hashInto(QSpan<std::byte> buffer, QCryptographicHashPrivate hash(method); for (QByteArrayView part : data) hash.addData(part); - hash.finalizeUnchecked(); // no mutex needed: no-one but us has access to 'hash' - auto result = hash.resultView(); - Q_ASSERT(buffer.size() >= result.size()); - // ### optimize: have the method directly write into `buffer` - memcpy(buffer.data(), result.data(), result.size()); - return buffer.first(result.size()); + auto span = QSpan{reinterpret_cast<uchar *>(buffer.data()), buffer.size()}; + return hash.finalizeUnchecked(span); // no mutex needed: no-one but us has access to 'hash' } /*! diff --git a/src/widgets/doc/src/external-resources.qdoc b/src/widgets/doc/src/external-resources.qdoc index 17459b6a5bc..96117546a29 100644 --- a/src/widgets/doc/src/external-resources.qdoc +++ b/src/widgets/doc/src/external-resources.qdoc @@ -8,7 +8,7 @@ */ /*! - \externalpage http://www.nvg.ntnu.no/sinclair/computers/zxspectrum/zxspectrum.htm + \externalpage https://rk.nvg.ntnu.no/sinclair/computers/zxspectrum/zxspectrum.htm \title Sinclair Spectrum */ /*! |