mirror of
https://github.com/troglobit/finit.git
synced 2026-10-20 11:19:35 +00:00
util: new function unquote()
Refactor to reduce code duplication Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
4 files changed
+26
-28
No files matched your search
+3
-12
@@ -89,18 +89,9 @@ static void cgset(const char *path, char *ctrl, char *prop)
|
||||
*val++ = 0;
|
||||
|
||||
/* unquote value, if quoted */
|
||||
if (val[0] == '"' || val[0] == '\'') {
|
||||
char q = val[0];
|
||||
char *end;
|
||||
|
||||
end = strchr(&val[1], q);
|
||||
if (!end) {
|
||||
errx(1, "Syntax error, unterminated quote in %s/%s.%s=%s", path, ctrl, prop, val);
|
||||
return;
|
||||
}
|
||||
|
||||
val++;
|
||||
*end = 0;
|
||||
if (unquote(&val, NULL)) {
|
||||
errx(1, "Syntax error, unterminated quote in %s/%s.%s=%s", path, ctrl, prop, val);
|
||||
return;
|
||||
}
|
||||
|
||||
/* disallow sneaky relative paths */
|
||||
|
||||
Reference in new issue
Block a user