aboutsummaryrefslogtreecommitdiff
path: root/src/common.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2014-07-15 23:12:28 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2014-07-16 00:54:23 +0200
commitc4199467296eb21488258f29f7029891d918b585 (patch)
tree9236f399e97ba418d1b87ff9d646ce0da1c0e20d /src/common.c
parent2921eed702d994352c5afccc31e32bd3f1682b6b (diff)
downloadxK-c4199467296eb21488258f29f7029891d918b585.tar.gz
xK-c4199467296eb21488258f29f7029891d918b585.tar.xz
xK-c4199467296eb21488258f29f7029891d918b585.zip
Cleanup
No functional changes.
Diffstat (limited to 'src/common.c')
-rw-r--r--src/common.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/src/common.c b/src/common.c
index 6bef268..e20c79d 100644
--- a/src/common.c
+++ b/src/common.c
@@ -1551,17 +1551,11 @@ regex_compile (const char *regex, int flags, struct error **e)
if (!err)
return re;
- struct str desc;
- str_init (&desc);
-
- size_t required = regerror (err, re, NULL, 0);
- str_ensure_space (&desc, required);
- desc.len += regerror (err, re,
- desc.str + desc.len, desc.alloc - desc.len) - 1;
+ char buf[regerror (err, re, NULL, 0)];
+ regerror (err, re, buf, sizeof buf);
free (re);
- error_set (e, "%s: %s", "failed to compile regular expression", desc.str);
- str_free (&desc);
+ error_set (e, "%s: %s", "failed to compile regular expression", buf);
return NULL;
}
@@ -1799,17 +1793,7 @@ read_config_file (struct str_map *config, struct error **e)
start++;
char *end = strchr (start, '=');
- if (!end)
- {
- if (*start)
- {
- error_set (e, "line %u in config: %s",
- line_no, "malformed input");
- errors = true;
- break;
- }
- }
- else
+ if (end)
{
char *value = end + 1;
do
@@ -1818,11 +1802,16 @@ read_config_file (struct str_map *config, struct error **e)
str_map_set (config, start, xstrdup (value));
}
+ else if (*start)
+ {
+ error_set (e, "line %u in config: %s", line_no, "malformed input");
+ errors = true;
+ break;
+ }
}
str_free (&line);
fclose (fp);
-
return !errors;
}