[common] option: trim whitespace from option names and values

This commit is contained in:
Geoffrey McRae 2019-05-21 12:34:41 +10:00
parent ce9b94e93d
commit 51ca08719e
2 changed files with 8 additions and 1 deletions

View File

@ -1 +1 @@
a12-195-g7cc0f7cb99+1
a12-196-gce9b94e93d+1

View File

@ -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;