[common] option: trim whitespace from option names and values
This commit is contained in:
1 parent
ce9b94e93d
commit
51ca08719e
2 files changed
+8
-1
No files matched your search
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user