From 77a4ae380e4c53dd62179df3c480214522d48ac3 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 10 Jun 2021 17:59:53 +0200 Subject: [PATCH] json: remove obsolete # comment handling Comments are handled by the parser now. Keys and values starting with # are intentional now. --- src/examples/media-session/match-rules.c | 3 --- src/examples/media-session/media-session.c | 6 +----- src/pipewire/conf.c | 7 +------ src/pipewire/properties.c | 2 -- src/tests/test-properties.c | 3 ++- 5 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/examples/media-session/match-rules.c b/src/examples/media-session/match-rules.c index dda9774db..9dd79f691 100644 --- a/src/examples/media-session/match-rules.c +++ b/src/examples/media-session/match-rules.c @@ -53,9 +53,6 @@ static bool find_match(struct spa_json *arr, struct pw_properties *props) if ((len = spa_json_next(&it[0], &value)) <= 0) break; - if (key[0] == '#') - continue; - str = pw_properties_get(props, key); if (spa_json_is_null(value, len)) { diff --git a/src/examples/media-session/media-session.c b/src/examples/media-session/media-session.c index a94511dee..944d65a18 100644 --- a/src/examples/media-session/media-session.c +++ b/src/examples/media-session/media-session.c @@ -2343,9 +2343,7 @@ again: while (spa_json_get_string(&it[1], key, sizeof(key)-1) > 0) { bool add = false; - if (key[0] == '#') { - add = false; - } else if (pw_properties_get(impl->modules, key) != NULL) { + if (pw_properties_get(impl->modules, key) != NULL) { add = true; } else { snprintf(check_path, sizeof(check_path), @@ -2357,8 +2355,6 @@ again: continue; while (spa_json_get_string(&it[2], value, sizeof(value)-1) > 0) { - if (value[0] == '#') - continue; pw_properties_set(impl->modules, value, "true"); } } diff --git a/src/pipewire/conf.c b/src/pipewire/conf.c index c19b956b8..063f665e2 100644 --- a/src/pipewire/conf.c +++ b/src/pipewire/conf.c @@ -300,12 +300,7 @@ static int parse_spa_libs(struct pw_context *context, char *str) } while (spa_json_get_string(&it[1], key, sizeof(key)-1) > 0) { - const char *val; - if (key[0] == '#') { - if (spa_json_next(&it[1], &val) <= 0) - break; - } - else if (spa_json_get_string(&it[1], value, sizeof(value)-1) > 0) { + if (spa_json_get_string(&it[1], value, sizeof(value)-1) > 0) { pw_context_add_spa_lib(context, key, value); count++; } diff --git a/src/pipewire/properties.c b/src/pipewire/properties.c index b435d2525..ae993a32b 100644 --- a/src/pipewire/properties.c +++ b/src/pipewire/properties.c @@ -173,8 +173,6 @@ int pw_properties_update_string(struct pw_properties *props, const char *str, si if ((len = spa_json_next(&it[1], &value)) <= 0) break; - if (key[0] == '#') - continue; if (spa_json_is_null(value, len)) val = NULL; else { diff --git a/src/tests/test-properties.c b/src/tests/test-properties.c index e9e19118f..fc61531f2 100644 --- a/src/tests/test-properties.c +++ b/src/tests/test-properties.c @@ -216,10 +216,11 @@ static void test_new_string(void) props = pw_properties_new_string("foo=bar bar=baz \"#ignore\"=ignore him=too empty=\"\" =gg"); spa_assert(props != NULL); spa_assert(props->flags == 0); - spa_assert(props->dict.n_items == 4); + spa_assert(props->dict.n_items == 5); spa_assert(spa_streq(pw_properties_get(props, "foo"), "bar")); spa_assert(spa_streq(pw_properties_get(props, "bar"), "baz")); + spa_assert(spa_streq(pw_properties_get(props, "#ignore"), "ignore")); spa_assert(spa_streq(pw_properties_get(props, "him"), "too")); spa_assert(spa_streq(pw_properties_get(props, "empty"), ""));