dovecot-1.0: If section opening fails, show the line where the l...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Jul 18 06:27:03 EEST 2007
details: http://hg.dovecot.org/dovecot-1.0/rev/0630d47a2c1d
changeset: 5352:0630d47a2c1d
user: Timo Sirainen <tss at iki.fi>
date: Wed Jul 18 06:26:55 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 60ec3834ee46 -r 0630d47a2c1d src/lib-settings/settings.c
--- a/src/lib-settings/settings.c Tue Jul 17 23:58:57 2007 +0300
+++ b/src/lib-settings/settings.c Wed Jul 18 06:26:55 2007 +0300
@@ -7,6 +7,8 @@
#include <stdio.h>
#include <fcntl.h>
+
+#define SECTION_ERRORMSG "%s (section changed at line %d)"
static const char *get_bool(const char *value, bool *result)
{
@@ -67,7 +69,7 @@ bool settings_read(const char *path, con
const char *errormsg, *next_section;
char *line, *key, *name, *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) {
@@ -182,6 +184,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) {
@@ -205,6 +208,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 {
@@ -224,6 +233,7 @@ bool settings_read(const char *path, con
break;
}
}
+ last_section_line = linenum;
sections--;
}
}
More information about the dovecot-cvs
mailing list