settings: Allow empty strings in section key

This commit is contained in:
Tobias Brunner
2014-02-12 14:34:32 +01:00
parent 9f9a6b0681
commit 25ee33ba65
2 changed files with 33 additions and 23 deletions
@@ -77,6 +77,8 @@ END_TEARDOWN
START_TEST(test_get_str) START_TEST(test_get_str)
{ {
verify_string("val1", "main.key1"); verify_string("val1", "main.key1");
verify_string("val1", "main..key1");
verify_string("val1", ".main.key1");
verify_string("with spaces", "main.key2"); verify_string("with spaces", "main.key2");
verify_string("value", "main.sub1.key"); verify_string("value", "main.sub1.key");
verify_string("value2", "main.sub1.key2"); verify_string("value2", "main.sub1.key2");
+11 -3
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2010 Tobias Brunner * Copyright (C) 2010-2014 Tobias Brunner
* Copyright (C) 2008 Martin Willi * Copyright (C) 2008 Martin Willi
* Hochschule fuer Technik Rapperswil * Hochschule fuer Technik Rapperswil
* *
@@ -251,7 +251,11 @@ static section_t *find_section_buffered(section_t *section,
{ {
return NULL; return NULL;
} }
if (section->sections->find_first(section->sections, if (!strlen(buf))
{
found = section;
}
else if (section->sections->find_first(section->sections,
(linked_list_match_t)section_find, (linked_list_match_t)section_find,
(void**)&found, buf) != SUCCESS) (void**)&found, buf) != SUCCESS)
{ {
@@ -336,7 +340,11 @@ static kv_t *find_value_buffered(section_t *section, char *start, char *key,
{ {
return NULL; return NULL;
} }
if (section->sections->find_first(section->sections, if (!strlen(buf))
{
found = section;
}
else if (section->sections->find_first(section->sections,
(linked_list_match_t)section_find, (linked_list_match_t)section_find,
(void**)&found, buf) != SUCCESS) (void**)&found, buf) != SUCCESS)
{ {