diff options
author | Benjamin Cohen <bencoh@notk.org> | 2012-10-21 12:51:01 +0200 |
---|---|---|
committer | Benjamin Cohen <bencoh@notk.org> | 2012-10-21 12:51:01 +0200 |
commit | f49a112911e625f2ab4ceaa5b23d7ae10d38def3 (patch) | |
tree | c489fd81a2c20dd06b30134a02f1d46f46d5ef1c | |
parent | 919aa42cdc36470c0e447b72fb2d3f305e90c2e1 (diff) |
-rw-r--r-- | config_load.c | 2 | ||||
-rw-r--r-- | util.c | 20 | ||||
-rw-r--r-- | util.h | 1 |
3 files changed, 20 insertions, 3 deletions
diff --git a/config_load.c b/config_load.c index bcebd92..6ae0e3a 100644 --- a/config_load.c +++ b/config_load.c @@ -1001,7 +1001,7 @@ static RcLoadStatus config_load (ParserState *ps) if (*ps->statement == '\0') continue; - string_rtrim (ps->statement); + string_rtrim_space (ps->statement); result = process_statement (ps); } @@ -55,9 +55,9 @@ void string_rtrim (char *str) char *end = 0; while (str && *str) { - if (end && !isspace (*str)) { + if (end && !(isspace (*str) && *str != ' ')) { end = 0; - } else if (!end && isspace (*str)) { + } else if (!end && (isspace (*str) && *str != ' ')) { end = str; } @@ -68,4 +68,20 @@ void string_rtrim (char *str) *end = '\0'; } +void string_rtrim_space (char *str) +{ + char *end = 0; + while (str && *str) { + if (end && !isspace (*str)) { + end = 0; + } else if (!end && isspace (*str)) { + end = str; + } + + ++str; + } + + if (end) + *end = '\0'; +} @@ -26,6 +26,7 @@ int num_digits (unsigned long value); int extract_number (char **cp); void string_rtrim (char *str); +void string_rtrim_space (char *str); |