]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Support # comments also at the end of setting lines
authorTimo Sirainen <tss@iki.fi>
Wed, 27 Aug 2003 14:35:54 +0000 (17:35 +0300)
committerTimo Sirainen <tss@iki.fi>
Wed, 27 Aug 2003 14:35:54 +0000 (17:35 +0300)
--HG--
branch : HEAD

src/lib-settings/settings.c

index ded6bc358ab3fc7bdb0d87c67fcf080186e44a8b..a09ee5d7f7a3e74e3289b2aa35a4d8bce409fb77 100644 (file)
@@ -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]))