diff options
author | Steven Schubiger <stsc@refcnt.org> | 2019-09-17 23:14:18 +0200 |
---|---|---|
committer | Steven Schubiger <stsc@refcnt.org> | 2019-09-17 23:14:18 +0200 |
commit | 9082b6aa7b7bd32db92ed1bd8ebe31e836147704 (patch) | |
tree | 1267f3fae5576a73bd969cd77480713e4e1da7ac /colorize.c | |
parent | 69f07b58527f4a75d67443232a34f944a65ae423 (diff) | |
download | colorize-9082b6aa7b7bd32db92ed1bd8ebe31e836147704.tar.gz colorize-9082b6aa7b7bd32db92ed1bd8ebe31e836147704.tar.bz2 |
parse_conf(): minor tweaks
- Parse lines with CRLF endings
- Separate the '#' sign from the option name
Diffstat (limited to 'colorize.c')
-rw-r--r-- | colorize.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -681,9 +681,11 @@ parse_conf (const char *conf_file, struct conf *config) char *p; cnt++; + if ((p = strchr (line, '\r')) && *(p + 1) != '\n') + vfprintf_fail ("%s: CR ending of line %u is not supported, switch to CRLF/LF instead", conf_file, cnt); if (strlen (line) > (sizeof (line) - 2)) vfprintf_fail ("%s: line %u exceeds maximum of %u characters", conf_file, cnt, (unsigned int)(sizeof (line) - 2)); - if ((p = strrchr (line, '\n'))) + if ((p = strpbrk (line, "\n\r"))) *p = '\0'; /* NAME PARSING (start) */ p = line; @@ -696,9 +698,9 @@ parse_conf (const char *conf_file, struct conf *config) opt = p; if (!(assign = strchr (opt, '='))) /* check for = */ { - char *space; - if ((space = strchr (opt, ' '))) - *space = '\0'; + char *s; + if ((s = strpbrk (opt, "# "))) + *s = '\0'; vfprintf_fail (formats[FMT_CONF], conf_file, opt, "not followed by ="); } p = assign; |