From 7c0b1e288cd0814c89278b100fb8efb3b284c87f Mon Sep 17 00:00:00 2001 From: LRFLEW Date: Mon, 25 Jan 2016 02:12:27 -0700 Subject: [PATCH] Fixed minor issues with handling whitespace in config.ini --- src/config.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/config.c b/src/config.c index 3b9d6d8836..ecffde2464 100644 --- a/src/config.c +++ b/src/config.c @@ -597,8 +597,8 @@ bool config_get_section(const utf8string line, const utf8 **sectionName, int *se bool config_get_property_name_value(const utf8string line, utf8 **propertyName, int *propertyNameSize, utf8 **value, int *valueSize) { - utf8 *ch; - int c, lastC; + utf8 *ch, *clast; + int c; bool quotes; ch = line; @@ -607,8 +607,10 @@ bool config_get_property_name_value(const utf8string line, utf8 **propertyName, if (*ch == 0) return false; *propertyName = ch; + bool equals = false; while ((c = utf8_get_next(ch, (const utf8**)&ch)) != 0) { if (isspace(c) || c == '=') { + if (c == '=') equals = true; *propertyNameSize = ch - *propertyName - 1; break; } else if (c == '#') { @@ -618,9 +620,11 @@ bool config_get_property_name_value(const utf8string line, utf8 **propertyName, if (*ch == 0) return false; utf8_skip_whitespace(&ch); - if (*ch != '=') return false; - ch++; - utf8_skip_whitespace(&ch); + if (!equals) { + if (*ch != '=') return false; + ch++; + utf8_skip_whitespace(&ch); + } if (*ch == 0) return false; if (*ch == '"') { @@ -631,13 +635,15 @@ bool config_get_property_name_value(const utf8string line, utf8 **propertyName, } *value = ch; + clast = ch; while ((c = utf8_get_next(ch, (const utf8**)&ch)) != 0) { - if (isspace(c) || c == '#') { - if (!quotes) break; + if (!quotes) { + if (c == '#') break; + if (c != ' ') clast = ch; } - lastC = c; } - *valueSize = ch - *value - 1; + if (!quotes) *valueSize = clast - *value; + else *valueSize = ch - *value - 1; if (quotes) (*valueSize)--; return true; }