diff options
Diffstat (limited to 'src/common.c')
-rw-r--r-- | src/common.c | 31 |
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; } |