mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-19 07:00:10 -05:00
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:
parent
762663e74e
commit
2d1f84fd7d
1 changed files with 4 additions and 4 deletions
|
|
@ -112,7 +112,7 @@ static inline int spa_json_next(struct spa_json * iter, const char **value)
|
||||||
iter->state = __STRUCT;
|
iter->state = __STRUCT;
|
||||||
if (iter->depth > 0)
|
if (iter->depth > 0)
|
||||||
goto again;
|
goto again;
|
||||||
return iter->cur - *value;
|
return iter->cur++ - *value;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
case __STRING:
|
case __STRING:
|
||||||
|
|
@ -124,8 +124,7 @@ static inline int spa_json_next(struct spa_json * iter, const char **value)
|
||||||
iter->state = __STRUCT;
|
iter->state = __STRUCT;
|
||||||
if (iter->depth > 0)
|
if (iter->depth > 0)
|
||||||
continue;
|
continue;
|
||||||
iter->cur++;
|
return ++iter->cur - *value;
|
||||||
return iter->cur - *value;
|
|
||||||
case 240 ... 247:
|
case 240 ... 247:
|
||||||
utf8_remain++;
|
utf8_remain++;
|
||||||
SPA_FALLTHROUGH;
|
SPA_FALLTHROUGH;
|
||||||
|
|
@ -308,7 +307,8 @@ static inline int spa_json_parse_string(const char *val, int len, char *result)
|
||||||
{
|
{
|
||||||
const char *p;
|
const char *p;
|
||||||
if (!spa_json_is_string(val, len)) {
|
if (!spa_json_is_string(val, len)) {
|
||||||
strncpy(result, val, len);
|
if (result != val)
|
||||||
|
strncpy(result, val, len);
|
||||||
result += len;
|
result += len;
|
||||||
} else {
|
} else {
|
||||||
for (p = val+1; p < val + len; p++) {
|
for (p = val+1; p < val + len; p++) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue