dovecot: Support continuing lines with \

dovecot at dovecot.org dovecot at dovecot.org
Wed Jul 25 09:04:07 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/5ec02199ff4a
changeset: 6145:5ec02199ff4a
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jul 25 08:59:58 2007 +0300
description:
Support continuing lines with \

diffstat:

1 file changed, 16 insertions(+), 1 deletion(-)
src/lib-settings/settings.c |   17 ++++++++++++++++-

diffs (54 lines):

diff -r d779b7220e23 -r 5ec02199ff4a src/lib-settings/settings.c
--- a/src/lib-settings/settings.c	Wed Jul 25 08:45:11 2007 +0300
+++ b/src/lib-settings/settings.c	Wed Jul 25 08:59:58 2007 +0300
@@ -1,6 +1,7 @@
-/* Copyright (C) 2002 Timo Sirainen */
+/* Copyright (C) 2002-2007 Timo Sirainen */
 
 #include "lib.h"
+#include "str.h"
 #include "istream.h"
 #include "strescape.h"
 #include "settings.h"
@@ -71,6 +72,7 @@ bool settings_read(const char *path, con
 	struct istream *input;
 	const char *errormsg, *next_section, *name;
 	char *line, *key, *p, quote;
+	string_t *full_line;
 	size_t len;
 	int fd, linenum, last_section_line = 0, skip, sections, root_section;
 
@@ -90,6 +92,7 @@ bool settings_read(const char *path, con
 		next_section = t_strcut(section, '/');
 	}
 
+	full_line = t_str_new(512);
 	linenum = 0; sections = 0; root_section = 0; errormsg = NULL;
 	input = i_stream_create_file(fd, 2048, TRUE);
 	for (;;) {
@@ -139,6 +142,17 @@ bool settings_read(const char *path, con
 		while (IS_WHITE(line[len-1]))
 			len--;
 		line[len] = '\0';
+
+		if (len > 0 && line[len-1] == '\\') {
+			/* continues in next line */
+			line[len-1] = '\0';
+			str_append(full_line, line);
+			continue;
+		}
+		if (str_len(full_line) > 0) {
+			str_append(full_line, line);
+			line = str_c_modifiable(full_line);
+		}
 
 		/* a) key = value
 		   b) section_type [section_name] {
@@ -246,6 +260,7 @@ bool settings_read(const char *path, con
 				path, linenum, errormsg);
 			break;
 		}
+		str_truncate(full_line, 0);
 	}
 
 	i_stream_destroy(&input);


More information about the dovecot-cvs mailing list