From 51ca08719e20011ee1d98331d874420516524b30 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Tue, 21 May 2019 12:34:41 +1000 Subject: [PATCH] [common] option: trim whitespace from option names and values --- VERSION | 2 +- common/src/option.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 7699cc25..bd2e69cc 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -a12-195-g7cc0f7cb99+1 \ No newline at end of file +a12-196-gce9b94e93d+1 \ No newline at end of file diff --git a/common/src/option.c b/common/src/option.c index cef3ed0f..c00633ee 100644 --- a/common/src/option.c +++ b/common/src/option.c @@ -458,6 +458,9 @@ bool option_load(const char * filename) goto exit; } + //rtrim + while(nameLen > 1 && (name[nameLen-1] == ' ' || name[nameLen-1] == '\t')) + --nameLen; name[nameLen] = '\0'; expectValue = true; @@ -480,6 +483,10 @@ bool option_load(const char * filename) } line = false; + //ltrim + if (*len == 0 && (c == ' ' || c == '\t')) + break; + if (*len % 32 == 0) *p = realloc(*p, *len + 32 + 1); (*p)[(*len)++] = c;