changeset 9862:864693ced870 HEAD

config: When we detect a conflict, log where in config it came from.
author Timo Sirainen <tss@iki.fi>
date Thu, 03 Sep 2009 17:33:40 -0400
parents 717688db5e82
children 3e20e23154e0
files src/config/config-filter.c src/config/config-filter.h src/config/config-parser.c
diffstat 3 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/config/config-filter.c	Thu Sep 03 17:33:05 2009 -0400
+++ b/src/config/config-filter.c	Thu Sep 03 17:33:40 2009 -0400
@@ -149,8 +149,9 @@
 		if (settings_parser_apply_changes(dest[i].parser,
 						  src->parsers[i].parser, pool,
 						  error_r) < 0) {
-			*error_r = t_strdup_printf("Conflict in setting %s",
-						   *error_r);
+			*error_r = t_strdup_printf("Conflict in setting %s "
+				"found from filter at %s", *error_r,
+				src->file_and_line);
 			return -1;
 		}
 	}
--- a/src/config/config-filter.h	Thu Sep 03 17:33:05 2009 -0400
+++ b/src/config/config-filter.h	Thu Sep 03 17:33:40 2009 -0400
@@ -11,6 +11,7 @@
 
 struct config_filter_parser {
 	struct config_filter filter;
+	const char *file_and_line;
 	/* NULL-terminated array of parsers */
 	struct config_module_parser *parsers;
 };
--- a/src/config/config-parser.c	Thu Sep 03 17:33:05 2009 -0400
+++ b/src/config/config-parser.c	Thu Sep 03 17:33:40 2009 -0400
@@ -166,6 +166,9 @@
 
 	parser = p_new(ctx->pool, struct config_filter_parser, 1);
 	parser->filter = cur_section->filter;
+	parser->file_and_line =
+		p_strdup_printf(ctx->pool, "%s:%d",
+				ctx->cur_input->path, ctx->cur_input->linenum);
 	parser->parsers = cur_section->prev == NULL ? ctx->root_parsers :
 		config_module_parsers_init(ctx->pool);
 	array_append(&ctx->all_parsers, &parser, 1);
@@ -573,14 +576,14 @@
 					     settings_parser_flags);
 	}
 
+	memset(&root, 0, sizeof(root));
+	root.path = path;
+	ctx.cur_input = &root;
+
 	p_array_init(&ctx.all_parsers, ctx.pool, 128);
 	ctx.cur_section = p_new(ctx.pool, struct config_section_stack, 1);
 	config_add_new_parser(&ctx);
 
-	memset(&root, 0, sizeof(root));
-	root.path = path;
-	ctx.cur_input = &root;
-
 	str = t_str_new(256);
 	full_line = t_str_new(512);
 	errormsg = NULL;