summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization/qjsonparser.cpp
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2023-01-17 20:54:52 +0200
committerAhmad Samir <a.samirh78@gmail.com>2023-02-07 20:04:11 +0200
commit498f3452285aa44580e1d03baeec126d475f8401 (patch)
tree6307934b58045f6b6761023f769844d87cdc63ca /src/corelib/serialization/qjsonparser.cpp
parent9a8b9473d5f0fd4639193481ba9b344d91f3f00a (diff)
QtMiscUtils: add some more character helpers
isHexDigit, isOctalDigit, isAsciiDigit, isAsciiLower, isAsciiUpper, isAsciiLetterOrNumber. This de-duplicates some code through out. Rename two local lambdas that were called "isAsciiLetterOrNumber" to not conflict with the method in QtMiscUtils. Change-Id: I5b631f95b9f109136d19515f7e20b8e2fbca3d43 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/serialization/qjsonparser.cpp')
-rw-r--r--src/corelib/serialization/qjsonparser.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/corelib/serialization/qjsonparser.cpp b/src/corelib/serialization/qjsonparser.cpp
index b11ae3a9d2..d39d766d75 100644
--- a/src/corelib/serialization/qjsonparser.cpp
+++ b/src/corelib/serialization/qjsonparser.cpp
@@ -11,6 +11,7 @@
#include "private/qstringconverter_p.h"
#include "private/qcborvalue_p.h"
#include "private/qnumeric_p.h"
+#include <private/qtools_p.h>
//#define PARSER_DEBUG
#ifdef PARSER_DEBUG
@@ -28,6 +29,8 @@ static const int nestingLimit = 1024;
QT_BEGIN_NAMESPACE
+using namespace QtMiscUtils;
+
// error strings for the JSON parser
#define JSONERR_OK QT_TRANSLATE_NOOP("QJsonParseError", "no error occurred")
#define JSONERR_UNTERM_OBJ QT_TRANSLATE_NOOP("QJsonParseError", "unterminated object")
@@ -693,14 +696,14 @@ bool Parser::parseNumber()
if (json < end && *json == '0') {
++json;
} else {
- while (json < end && *json >= '0' && *json <= '9')
+ while (json < end && isAsciiDigit(*json))
++json;
}
// frac = decimal-point 1*DIGIT
if (json < end && *json == '.') {
++json;
- while (json < end && *json >= '0' && *json <= '9') {
+ while (json < end && isAsciiDigit(*json)) {
isInt = isInt && *json == '0';
++json;
}
@@ -712,7 +715,7 @@ bool Parser::parseNumber()
++json;
if (json < end && (*json == '-' || *json == '+'))
++json;
- while (json < end && *json >= '0' && *json <= '9')
+ while (json < end && isAsciiDigit(*json))
++json;
}