dovecot-2.0: lib-settings: Fixed setting "strlist/key=value" whe...

dovecot at dovecot.org dovecot at dovecot.org
Tue Feb 22 15:02:28 EET 2011


details:   http://hg.dovecot.org/dovecot-2.0/rev/bc77e80947c0
changeset: 12618:bc77e80947c0
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Feb 22 15:00:37 2011 +0200
description:
lib-settings: Fixed setting "strlist/key=value" when strlist hadn't been initialized yet.
This happened when using -O parameter.

diffstat:

 src/lib-settings/settings-parser.c |  29 +++++++++++++++++++++++++----
 1 files changed, 25 insertions(+), 4 deletions(-)

diffs (53 lines):

diff -r be78b9fd88e7 -r bc77e80947c0 src/lib-settings/settings-parser.c
--- a/src/lib-settings/settings-parser.c	Tue Feb 22 13:57:20 2011 +0200
+++ b/src/lib-settings/settings-parser.c	Tue Feb 22 15:00:37 2011 +0200
@@ -66,6 +66,9 @@
 	.parent_offset = (size_t)-1
 };
 
+static int settings_parse_keyvalue(struct setting_parser_context *ctx,
+				   const char *key, const char *value);
+
 static void
 setting_parser_copy_defaults(struct setting_parser_context *ctx, 
 			     const struct setting_parser_info *info,
@@ -657,7 +660,7 @@
 {
 	const struct setting_define *def;
 	struct setting_link *link;
-	const char *end;
+	const char *end, *parent_key;
 	unsigned int i;
 
 	/* try to find from roots */
@@ -679,9 +682,27 @@
 	if (end == NULL)
 		return FALSE;
 
-	link = hash_table_lookup(ctx->links, t_strdup_until(key, end));
-	if (link == NULL)
-		return FALSE;
+	parent_key = t_strdup_until(key, end);
+	link = hash_table_lookup(ctx->links, parent_key);
+	if (link == NULL) {
+		/* maybe this is the first strlist value */
+		unsigned int parent_n = 0;
+		const struct setting_define *parent_def;
+		struct setting_link *parent_link;
+
+		if (!settings_find_key_nth(ctx, parent_key, &parent_n,
+					   &parent_def, &parent_link))
+			return FALSE;
+		if (parent_def->type != SET_STRLIST)
+			return FALSE;
+
+		/* setting parent_key=0 adds it to links list */
+		if (settings_parse_keyvalue(ctx, parent_key, "0") <= 0)
+			return FALSE;
+
+		link = hash_table_lookup(ctx->links, parent_key);
+		i_assert(link != NULL);
+	}
 
 	*link_r = link;
 	if (link->info == &strlist_info) {


More information about the dovecot-cvs mailing list