Skip to content

Commit

Permalink
Merge pull request #72 from Airblader/bug-71
Browse files Browse the repository at this point in the history
Parse entries with empty value correctly.
  • Loading branch information
Airblader authored Nov 24, 2016
2 parents 38925b3 + 2645838 commit 47fcefd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ int xcb_xrm_entry_parse(const char *_str, xcb_xrm_entry_t **_entry, bool resourc
}
}

if (state.chunk == CS_VALUE) {
if (state.chunk == CS_PRE_VALUE_WHITESPACE || state.chunk == CS_VALUE) {
*value_walk = '\0';
entry->value = strdup(value);
if (entry->value == NULL)
Expand Down
7 changes: 5 additions & 2 deletions tests/tests_match.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ static int test_get_resource(void) {
err |= check_get_resource("First: x\\\ny", "First", "", "xy", false);
err |= check_get_resource("! First: x", "First", "", NULL, false);
err |= check_get_resource("# First: x", "First", "", NULL, false);
err |= check_get_resource("First:", "First", "", "", false);
err |= check_get_resource("First: ", "First", "", "", false);
err |= check_get_resource("First: \t ", "First", "", "", false);
/* Matching among multiple entries */
err |= check_get_resource(
"First: 1\n"
Expand Down Expand Up @@ -204,7 +207,7 @@ static int test_convert(void) {
bool err = false;

err |= check_convert_to_bool(NULL, false, -2);
err |= check_convert_to_bool("", false, -2);
err |= check_convert_to_bool("", false, -1);
err |= check_convert_to_bool("0", false, 0);
err |= check_convert_to_bool("1", true, 0);
err |= check_convert_to_bool("10", true, 0);
Expand All @@ -223,7 +226,7 @@ static int test_convert(void) {
err |= check_convert_to_bool("abc", false, -1);

err |= check_convert_to_long(NULL, LONG_MIN, -2);
err |= check_convert_to_long("", LONG_MIN, -2);
err |= check_convert_to_long("", LONG_MIN, -1);
err |= check_convert_to_long("0", 0, 0);
err |= check_convert_to_long("1", 1, 0);
err |= check_convert_to_long("-1", -1, 0);
Expand Down

0 comments on commit 47fcefd

Please sign in to comment.