else if (*cp == '"') {
state = in_attr;
pattr = attrbuf;
+#ifndef JSON_MINIMAL
+ if (end != NULL)
+ *end = cp;
+#endif
} else if (*cp == '}')
break;
else {
break;
case in_attr:
if (pattr == NULL) {
- if (end != NULL)
- *end = cp;
+ /* don't update end here, leave at attribute start */
return JSON_ERR_NULLPTR;
}
if (*cp == '"') {
json_debug_trace((1,
"Unknown attribute name '%s' (attributes begin with '%s').\n",
attrbuf, attrs->attribute));
+ /* don't update end here, leave at attribute start */
return JSON_ERR_BADATTR;
}
state = await_value;
pval = valbuf;
} else if (pattr >= attrbuf + JSON_ATTR_MAX - 1) {
json_debug_trace((1, "Attribute name too long.\n"));
- if (end != NULL)
- *end = cp;
+ /* don't update end here, leave at attribute start */
return JSON_ERR_ATTRLEN;
} else
*pattr++ = *cp;
break;
case in_val_string:
if (pval == NULL) {
- if (end != NULL)
- *end = cp;
+ /* don't update end here, leave at value start */
return JSON_ERR_NULLPTR;
}
if (*cp == '\\')
} else if (pval > valbuf + JSON_VAL_MAX - 1
|| pval > valbuf + maxlen) {
json_debug_trace((1, "String value too long.\n"));
- if (end != NULL)
- *end = cp;
+ /* don't update end here, leave at value start */
return JSON_ERR_STRLONG; /* */
} else
*pval++ = *cp;
break;
case in_val_token:
if (pval == NULL) {
- if (end != NULL)
- *end = cp;
+ /* don't update end here, leave at value start */
return JSON_ERR_NULLPTR;
}
if (isspace((unsigned char) *cp) || *cp == ',' || *cp == '}') {
--cp;
} else if (pval > valbuf + JSON_VAL_MAX - 1) {
json_debug_trace((1, "Token value too long.\n"));
- if (end != NULL)
- *end = cp;
+ /* don't update end here, leave at value start */
return JSON_ERR_TOKLONG;
} else
*pval++ = *cp;
&& cursor->type != t_ignore && cursor->map == 0)) {
json_debug_trace((1,
"Saw quoted value when expecting non-string.\n"));
- if (end != NULL)
- *end = cp;
return JSON_ERR_QNONSTRING;
}
if (!value_quoted
|| cursor->map != 0)) {
json_debug_trace((1,
"Didn't see quoted value when expecting string.\n"));
- if (end != NULL)
- *end = cp;
return JSON_ERR_NONQSTRING;
}
if (cursor->map != 0) {
}
json_debug_trace((1, "Invalid enumerated value string %s.\n",
valbuf));
- if (end != NULL)
- *end = cp;
return JSON_ERR_BADENUM;
foundit:
(void)snprintf(valbuf, sizeof(valbuf), "%d", mp->value);
json_debug_trace((1,
"Required attribute value %s not present.\n",
cursor->dflt.check));
- if (end != NULL)
- *end = cp;
+ /* don't update end here, leave at start of attribute */
return JSON_ERR_CHECKFAIL;
}
break;
substatus =
json_internal_read_object(cp, arr->arr.objects.subtype, arr,
offset, &cp);
- if (substatus != 0)
+ if (substatus != 0) {
+ if (end != NULL)
+ end = &cp;
return substatus;
+ }
break;
case t_integer:
arr->arr.integers.store[offset] = (int)strtol(cp, &ep, 0);