json: Move past the end char of a symbol

So that we can put a \0 there and continue parsing the rest of
the string. This allows us to in-place parse_string.
This commit is contained in:
Wim Taymans 2021-03-14 09:28:38 +01:00
parent 762663e74e
commit 2d1f84fd7d

View file

@ -112,7 +112,7 @@ static inline int spa_json_next(struct spa_json * iter, const char **value)
iter->state = __STRUCT;
if (iter->depth > 0)
goto again;
return iter->cur - *value;
return iter->cur++ - *value;
}
continue;
case __STRING:
@ -124,8 +124,7 @@ static inline int spa_json_next(struct spa_json * iter, const char **value)
iter->state = __STRUCT;
if (iter->depth > 0)
continue;
iter->cur++;
return iter->cur - *value;
return ++iter->cur - *value;
case 240 ... 247:
utf8_remain++;
SPA_FALLTHROUGH;
@ -308,7 +307,8 @@ static inline int spa_json_parse_string(const char *val, int len, char *result)
{
const char *p;
if (!spa_json_is_string(val, len)) {
strncpy(result, val, len);
if (result != val)
strncpy(result, val, len);
result += len;
} else {
for (p = val+1; p < val + len; p++) {