Mercurial > dovecot > core-2.2
changeset 1743:37881cedb70d HEAD
Support # comments also at the end of setting lines
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 27 Aug 2003 17:35:54 +0300 |
parents | 05427d8112ee |
children | 2a0220362d1b |
files | src/lib-settings/settings.c |
diffstat | 1 files changed, 17 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-settings/settings.c Wed Aug 27 01:15:36 2003 +0300 +++ b/src/lib-settings/settings.c Wed Aug 27 17:35:54 2003 +0300 @@ -66,7 +66,7 @@ { struct istream *input; const char *errormsg, *next_section; - char *line, *key, *name; + char *line, *key, *name, *p, quote; size_t len; int fd, linenum, skip, sections, root_section; @@ -101,6 +101,22 @@ if (*line == '#' || *line == '\0') continue; + /* strip away comments. pretty kludgy way really.. */ + for (p = line; *p != '\0'; p++) { + if (*p == '\'' || *p == '"') { + quote = *p; + for (p++; *p != quote && *p != '\0'; p++) { + if (*p == '\\' && p[1] != '\0') + p++; + } + if (*p == '\0') + break; + } else if (*p == '#') { + *p = '\0'; + break; + } + } + /* remove whitespace from end of line */ len = strlen(line); while (IS_WHITE(line[len-1]))