dovecot: If section opening fails, show the line where the last ...

dovecot at dovecot.org dovecot at dovecot.org
Wed Jul 18 06:27:00 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/dab02b1fc89d
changeset: 6063:dab02b1fc89d
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jul 18 06:26:56 2007 +0300
description:
If section opening fails, show the line where the last section was opened or
closed.

diffstat:

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

diffs (50 lines):

diff -r 8341db7a1698 -r dab02b1fc89d src/lib-settings/settings.c
--- a/src/lib-settings/settings.c	Wed Jul 18 06:17:47 2007 +0300
+++ b/src/lib-settings/settings.c	Wed Jul 18 06:26:56 2007 +0300
@@ -7,6 +7,8 @@
 
 #include <stdio.h>
 #include <fcntl.h>
+
+#define SECTION_ERRORMSG "%s (section changed at line %d)"
 
 settings_section_callback_t *null_settings_section_callback = NULL;
 
@@ -70,7 +72,7 @@ bool settings_read(const char *path, con
 	const char *errormsg, *next_section, *name;
 	char *line, *key, *p, quote;
 	size_t len;
-	int fd, linenum, skip, sections, root_section;
+	int fd, linenum, last_section_line = 0, skip, sections, root_section;
 
 	fd = open(path, O_RDONLY);
 	if (fd < 0) {
@@ -185,6 +187,7 @@ bool settings_read(const char *path, con
 			if (*line != '{')
 				errormsg = "Expecting '='";
 			else {
+				last_section_line = linenum;
 				sections++;
 				if (next_section != NULL &&
 				    strcmp(next_section, name) == 0) {
@@ -208,6 +211,12 @@ bool settings_read(const char *path, con
 						!sect_callback(key, name,
 							       context,
 							       &errormsg);
+					if (errormsg != NULL &&
+					    last_section_line != 0) {
+						errormsg = t_strdup_printf(
+							SECTION_ERRORMSG,
+							errormsg, linenum);
+					}
 				}
 			}
 		} else {
@@ -227,6 +236,7 @@ bool settings_read(const char *path, con
 						break;
 					}
 				}
+				last_section_line = linenum;
 				sections--;
 			}
 		}


More information about the dovecot-cvs mailing list