From 8fe335a41010c34a9999b0cdeb7da172d5907636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Obiltschnig?= Date: Sat, 30 Sep 2023 21:48:40 +0200 Subject: [PATCH] merge JSON fixes from 1.12 --- JSON/include/Poco/JSON/Array.h | 2 +- JSON/include/Poco/JSON/Query.h | 2 +- JSON/src/pdjson.c | 2 +- JSON/src/pdjson.h | 18 +++++++++--------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/JSON/include/Poco/JSON/Array.h b/JSON/include/Poco/JSON/Array.h index 32f5443df0..964556419f 100644 --- a/JSON/include/Poco/JSON/Array.h +++ b/JSON/include/Poco/JSON/Array.h @@ -46,7 +46,7 @@ class JSON_API Array /// Array::Ptr arr = result.extract(); /// Object::Ptr object = arr->getObject(0); // object == {\"test\" : 0} /// int i = object->getElement("test"); // i == 0; - /// Object::Ptr subObject = *arr->getObject(1); // subObject == {\"test\" : 0} + /// Object::Ptr subObject = arr->getObject(1); // subObject == {\"test\" : 0} /// Array subArr::Ptr = subObject->getArray("test1"); // subArr == [1, 2, 3] /// i = result = subArr->get(0); // i == 1; /// diff --git a/JSON/include/Poco/JSON/Query.h b/JSON/include/Poco/JSON/Query.h index c639a3d7dd..47cbe0c3c8 100644 --- a/JSON/include/Poco/JSON/Query.h +++ b/JSON/include/Poco/JSON/Query.h @@ -32,7 +32,7 @@ class JSON_API Query { public: Query(const Dynamic::Var& source); - /// Creates a Query/ + /// Creates a Query. /// /// Source must be JSON Object, Array, Object::Ptr, /// Array::Ptr or empty Var. Any other type will trigger throwing of diff --git a/JSON/src/pdjson.c b/JSON/src/pdjson.c index cd56715efc..37055ccced 100644 --- a/JSON/src/pdjson.c +++ b/JSON/src/pdjson.c @@ -555,7 +555,7 @@ read_number(json_stream *json, int c) json_error(json, "unexpected byte '%c' in number", c); return JSON_ERROR; } - } else if (strchr("123456789", c) != NULL) { + } else if (c >= '1' && c <= '9') { c = json->source.peek(&json->source); if (is_digit(c)) { if (read_digits(json) != 0) diff --git a/JSON/src/pdjson.h b/JSON/src/pdjson.h index 32673b71fd..c0262d120b 100644 --- a/JSON/src/pdjson.h +++ b/JSON/src/pdjson.h @@ -9,12 +9,12 @@ extern "C" { #else #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) - #include - #else - #ifndef bool - #define bool int - #define true 1 - #define false 0 + #include +#else + #ifndef bool + #define bool int + #define true 1 + #define false 0 #endif /* bool */ #endif /* __STDC_VERSION__ */ #endif /* __cplusplus */ @@ -33,7 +33,7 @@ struct json_allocator { void (*free)(void *); }; -typedef int (*json_user_io) (void *user); +typedef int (*json_user_io)(void *user); typedef struct json_stream json_stream; typedef struct json_allocator json_allocator; @@ -69,8 +69,8 @@ PDJSON_SYMEXPORT bool json_isspace(int c); /* internal */ struct json_source { - int (*get) (struct json_source *); - int (*peek) (struct json_source *); + int (*get)(struct json_source *); + int (*peek)(struct json_source *); size_t position; union { struct {