mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	json: remove obsolete # comment handling
Comments are handled by the parser now. Keys and values starting with # are intentional now.
This commit is contained in:
		
							parent
							
								
									826f52344f
								
							
						
					
					
						commit
						77a4ae380e
					
				
					 5 changed files with 4 additions and 17 deletions
				
			
		| 
						 | 
					@ -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)
 | 
								if ((len = spa_json_next(&it[0], &value)) <= 0)
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (key[0] == '#')
 | 
					 | 
				
			||||||
				continue;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			str = pw_properties_get(props, key);
 | 
								str = pw_properties_get(props, key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (spa_json_is_null(value, len)) {
 | 
								if (spa_json_is_null(value, len)) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2343,9 +2343,7 @@ again:
 | 
				
			||||||
	while (spa_json_get_string(&it[1], key, sizeof(key)-1) > 0) {
 | 
						while (spa_json_get_string(&it[1], key, sizeof(key)-1) > 0) {
 | 
				
			||||||
		bool add = false;
 | 
							bool add = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (key[0] == '#') {
 | 
							if (pw_properties_get(impl->modules, key) != NULL) {
 | 
				
			||||||
			add = false;
 | 
					 | 
				
			||||||
		} else if (pw_properties_get(impl->modules, key) != NULL) {
 | 
					 | 
				
			||||||
			add = true;
 | 
								add = true;
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			snprintf(check_path, sizeof(check_path),
 | 
								snprintf(check_path, sizeof(check_path),
 | 
				
			||||||
| 
						 | 
					@ -2357,8 +2355,6 @@ again:
 | 
				
			||||||
				continue;
 | 
									continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			while (spa_json_get_string(&it[2], value, sizeof(value)-1) > 0) {
 | 
								while (spa_json_get_string(&it[2], value, sizeof(value)-1) > 0) {
 | 
				
			||||||
				if (value[0] == '#')
 | 
					 | 
				
			||||||
					continue;
 | 
					 | 
				
			||||||
				pw_properties_set(impl->modules, value, "true");
 | 
									pw_properties_set(impl->modules, value, "true");
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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) {
 | 
						while (spa_json_get_string(&it[1], key, sizeof(key)-1) > 0) {
 | 
				
			||||||
		const char *val;
 | 
							if (spa_json_get_string(&it[1], value, sizeof(value)-1) > 0) {
 | 
				
			||||||
		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) {
 | 
					 | 
				
			||||||
			pw_context_add_spa_lib(context, key, value);
 | 
								pw_context_add_spa_lib(context, key, value);
 | 
				
			||||||
			count++;
 | 
								count++;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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)
 | 
							if ((len = spa_json_next(&it[1], &value)) <= 0)
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (key[0] == '#')
 | 
					 | 
				
			||||||
			continue;
 | 
					 | 
				
			||||||
		if (spa_json_is_null(value, len))
 | 
							if (spa_json_is_null(value, len))
 | 
				
			||||||
			val = NULL;
 | 
								val = NULL;
 | 
				
			||||||
		else {
 | 
							else {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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");
 | 
						props = pw_properties_new_string("foo=bar bar=baz \"#ignore\"=ignore him=too empty=\"\" =gg");
 | 
				
			||||||
	spa_assert(props != NULL);
 | 
						spa_assert(props != NULL);
 | 
				
			||||||
	spa_assert(props->flags == 0);
 | 
						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, "foo"), "bar"));
 | 
				
			||||||
	spa_assert(spa_streq(pw_properties_get(props, "bar"), "baz"));
 | 
						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, "him"), "too"));
 | 
				
			||||||
	spa_assert(spa_streq(pw_properties_get(props, "empty"), ""));
 | 
						spa_assert(spa_streq(pw_properties_get(props, "empty"), ""));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue