From: Timo Sirainen Date: Thu, 4 Nov 2010 15:47:37 +0000 (+0000) Subject: config parser: Log an error about missing '}'. X-Git-Tag: 2.0.7~17 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1618629fd55e914c8d2e28fc01b8264613f00a99;p=thirdparty%2Fdovecot%2Fcore.git config parser: Log an error about missing '}'. --- diff --git a/src/config/config-parser-private.h b/src/config/config-parser-private.h index 49849e4c6b..fca68e1f6a 100644 --- a/src/config/config-parser-private.h +++ b/src/config/config-parser-private.h @@ -23,6 +23,9 @@ struct config_section_stack { /* root=NULL-terminated list of parsers */ struct config_module_parser *parsers; unsigned int pathlen; + + const char *open_path; + unsigned int open_linenum; }; struct input_stack { diff --git a/src/config/config-parser.c b/src/config/config-parser.c index bd007adeb4..706e1e398a 100644 --- a/src/config/config-parser.c +++ b/src/config/config-parser.c @@ -165,6 +165,9 @@ config_add_new_section(struct config_parser_context *ctx) section->prev = ctx->cur_section; section->filter = ctx->cur_section->filter; section->parsers = ctx->cur_section->parsers; + + section->open_path = p_strdup(ctx->pool, ctx->cur_input->path); + section->open_linenum = ctx->cur_input->linenum; return section; } @@ -312,6 +315,14 @@ config_all_parsers_check(struct config_parser_context *ctx, pool_t tmp_pool; int ret = 0; + if (ctx->cur_section->prev != NULL) { + *error_r = t_strdup_printf( + "Missing '}' (section started at %s:%u)", + ctx->cur_section->open_path, + ctx->cur_section->open_linenum); + return -1; + } + tmp_pool = pool_alloconly_create("config parsers check", 1024*32); parsers = array_get(&ctx->all_parsers, &count); i_assert(count > 0 && parsers[count-1] == NULL);