From: Timo Sirainen Date: Wed, 27 Aug 2003 14:35:54 +0000 (+0300) Subject: Support # comments also at the end of setting lines X-Git-Tag: 1.1.alpha1~4363 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6cc8fac7fd9b47e179629a61acef0e8758763803;p=thirdparty%2Fdovecot%2Fcore.git Support # comments also at the end of setting lines --HG-- branch : HEAD --- diff --git a/src/lib-settings/settings.c b/src/lib-settings/settings.c index ded6bc358a..a09ee5d7f7 100644 --- a/src/lib-settings/settings.c +++ b/src/lib-settings/settings.c @@ -66,7 +66,7 @@ int settings_read(const char *path, const char *section, { 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 @@ int settings_read(const char *path, const char *section, 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]))