mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
json: handle comments when stripping
Or else everything becomes part of the first comment.
This commit is contained in:
parent
0be2959f11
commit
78e2e2c27b
1 changed files with 17 additions and 7 deletions
|
|
@ -287,19 +287,29 @@ 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)) {
|
||||||
bool skip = false;
|
bool skip = false, comment = false;
|
||||||
for (p = val; p < val + len; p++) {
|
for (p = val; p < val + len; p++) {
|
||||||
switch (*p) {
|
switch (*p) {
|
||||||
case '\n': case '\r': case '\b': case '\t': case '\f':
|
case '#':
|
||||||
|
comment = true;
|
||||||
|
break;
|
||||||
|
case '\n': case '\r':
|
||||||
|
comment = false;
|
||||||
|
break;
|
||||||
|
case '\b': case '\t': case '\f':
|
||||||
break;
|
break;
|
||||||
case ' ':
|
case ' ':
|
||||||
if (!skip)
|
if (!comment) {
|
||||||
*result++ = *p;
|
if (!skip)
|
||||||
skip = true;
|
*result++ = *p;
|
||||||
|
skip = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
*result++ = *p;
|
if (!comment) {
|
||||||
skip = false;
|
*result++ = *p;
|
||||||
|
skip = false;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue