mirror of
https://github.com/troglobit/finit.git
synced 2026-11-06 15:51:03 +00:00
fgetval(): handle extra separators betwee key and value
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
70c2939596
commit
3d9cbaf040
1 file changed
+10
-3
+10
-3
@@ -132,9 +132,16 @@ static inline char *fgetval(char *line, const char *key, char *sep)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr = strsep(&str, sep);
|
/*
|
||||||
if (!ptr)
|
* Check if we should strip optional separator, e.g.,
|
||||||
goto fail;
|
* 'foo = bar' => '= bar' should be stripped to 'bar'
|
||||||
|
*/
|
||||||
|
while (str && strchr(sep, str[0])) {
|
||||||
|
ptr = strsep(&str, sep);
|
||||||
|
if (!ptr)
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
ptr = str;
|
||||||
|
|
||||||
if (*ptr == '"' || *ptr == '\'') {
|
if (*ptr == '"' || *ptr == '\'') {
|
||||||
char *end = &ptr[strlen(ptr) - 1];
|
char *end = &ptr[strlen(ptr) - 1];
|
||||||
|
|||||||
Reference in new issue
Block a user