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;
|
||||
if (!spa_json_is_string(val, len)) {
|
||||
bool skip = false;
|
||||
bool skip = false, comment = false;
|
||||
for (p = val; p < val + len; 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;
|
||||
case ' ':
|
||||
if (!skip)
|
||||
*result++ = *p;
|
||||
skip = true;
|
||||
if (!comment) {
|
||||
if (!skip)
|
||||
*result++ = *p;
|
||||
skip = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
*result++ = *p;
|
||||
skip = false;
|
||||
if (!comment) {
|
||||
*result++ = *p;
|
||||
skip = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue