[dovecot-cvs] dovecot/src/lib-settings settings.c,1.5,1.6

cras at procontrol.fi cras at procontrol.fi
Sat Jul 26 23:42:19 EEST 2003


Update of /home/cvs/dovecot/src/lib-settings
In directory danu:/tmp/cvs-serv13393/src/lib-settings

Modified Files:
	settings.c 
Log Message:
Spaces are now stripped from end of line in config file. You can use " or '
quotes if you need them.



Index: settings.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-settings/settings.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- settings.c	10 Jul 2003 03:04:07 -0000	1.5
+++ settings.c	26 Jul 2003 19:42:17 -0000	1.6
@@ -2,6 +2,7 @@
 
 #include "lib.h"
 #include "istream.h"
+#include "strescape.h"
 #include "settings.h"
 
 #include <stdio.h>
@@ -66,6 +67,7 @@
 	struct istream *input;
 	const char *errormsg, *next_section;
 	char *line, *key, *name;
+	size_t len;
 	int fd, linenum, skip, sections, root_section;
 
 	fd = open(path, O_RDONLY);
@@ -99,7 +101,13 @@
 		if (*line == '#' || *line == '\0')
 			continue;
 
-		/* a) "key = value"
+		/* remove whitespace from end of line */
+		len = strlen(line);
+		while (IS_WHITE(line[len-1]))
+			len--;
+		line[len] = '\0';
+
+		/* a) key = value
 		   b) section_type section_name {
 		   c) } */
 		key = line;
@@ -132,6 +140,14 @@
 			*line++ = '\0';
 			while (IS_WHITE(*line)) line++;
 
+			len = strlen(line);
+			if (len > 0 &&
+			    ((*line == '"' && line[len-1] == '"') ||
+			     (*line == '\'' && line[len-1] == '\''))) {
+				line[len-1] = '\0';
+				line = str_unescape(line+1);
+			}
+
 			errormsg = skip ? NULL :
 				callback(key, line, context);
 		} else {
@@ -147,7 +163,7 @@
 					line++;
 			}
 
-			if (*line != '{' || strcspn(line+1, " \t") != 0)
+			if (*line != '{')
 				errormsg = "Missing value";
 			else {
 				sections++;



More information about the dovecot-cvs mailing list