From bef6bf3b706aca0181d14f9871529d2feba25630 Mon Sep 17 00:00:00 2001 From: Nat! Date: Sat, 21 Dec 2019 19:52:21 +0100 Subject: [PATCH] Update jsmn.h Fix numbers and other primitives not being incrementally parsed correctly in non-strict mode. This does not fix incremental parses of root primitives (outside of a container). But it's better than before. --- jsmn.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/jsmn.h b/jsmn.h index cb27ca11..3d1509f5 100644 --- a/jsmn.h +++ b/jsmn.h @@ -163,11 +163,14 @@ static int jsmn_parse_primitive(jsmn_parser *parser, const char *js, return JSMN_ERROR_INVAL; } } -#ifdef JSMN_STRICT - /* In strict mode primitive must be followed by a comma/object/array */ - parser->pos = start; - return JSMN_ERROR_PART; +#ifndef JSMN_STRICT + if( parser->toksuper != -1) // if we are "inside" we may not be done yet #endif + /* In strict mode primitive must be followed by a comma/object/array */ + { + parser->pos = start; + return JSMN_ERROR_PART; + } found: if (tokens == NULL) {