diff options
| author | Marc Mutz <marc.mutz@qt.io> | 2025-08-19 14:45:11 +0200 |
|---|---|---|
| committer | Marc Mutz <marc.mutz@qt.io> | 2025-08-29 00:03:40 +0000 |
| commit | 8d6349670146cc6dd0b225577831ee30a4d11be5 (patch) | |
| tree | 86bcd8d7908d6c7b0494628cda541b8a4d704f55 /src/corelib/serialization/qjsonparser.cpp | |
| parent | d07a0559f84c60eac7acecad37c1fe4ebba06d8c (diff) | |
Use QUtf8Functions::nextUcs4FromUtf8() in the JSON parser
Can't say this makes the function much simpler, and I didn't find a
Coverity issue about this use, but be consistent and use the new
function here, too. Besides, if we port Parser to qchar8_t, then it
will be simpler, and we might be able to remove the scanUtf8 function
completely.
Pick-to: 6.10 6.9 6.8
Change-Id: Ib6fa7aac14b942b4002163dccc77513a71378ea1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/serialization/qjsonparser.cpp')
| -rw-r--r-- | src/corelib/serialization/qjsonparser.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/corelib/serialization/qjsonparser.cpp b/src/corelib/serialization/qjsonparser.cpp index 77a1bda0f05..df266a76c79 100644 --- a/src/corelib/serialization/qjsonparser.cpp +++ b/src/corelib/serialization/qjsonparser.cpp @@ -785,13 +785,13 @@ static inline bool scanEscapeSequence(const char *&json, const char *end, char32 static inline bool scanUtf8Char(const char *&json, const char *end, char32_t *result) { - const auto *usrc = reinterpret_cast<const uchar *>(json); - const auto *uend = reinterpret_cast<const uchar *>(end); - const uchar b = *usrc++; - qsizetype res = QUtf8Functions::fromUtf8<QUtf8BaseTraits>(b, result, usrc, uend); - if (res < 0) + auto usrc = reinterpret_cast<const qchar8_t*>(json); + const auto uend = reinterpret_cast<const qchar8_t*>(end); + constexpr char32_t Invalid = ~U'\0'; + const char32_t ch = QUtf8Functions::nextUcs4FromUtf8(usrc, uend, Invalid); + if (ch == Invalid) return false; - + *result = ch; json = reinterpret_cast<const char *>(usrc); return true; } |
