dovecot-2.0: config: Added support for "key=$key stuff"

dovecot at dovecot.org dovecot at dovecot.org
Fri Mar 19 20:40:28 EET 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/513c43179ca9
changeset: 10955:513c43179ca9
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Mar 19 20:39:45 2010 +0200
description:
config: Added support for "key=$key stuff"

diffstat:

 src/config/config-parser.c |  17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diffs (45 lines):

diff -r bcd43231f723 -r 513c43179ca9 src/config/config-parser.c
--- a/src/config/config-parser.c	Fri Mar 19 17:51:28 2010 +0200
+++ b/src/config/config-parser.c	Fri Mar 19 20:39:45 2010 +0200
@@ -583,12 +583,19 @@
 
 static const void *
 config_get_value(struct config_parser_context *ctx, const char *key,
-		 enum setting_type *type_r)
+		 bool expand_parent, enum setting_type *type_r)
 {
+	struct config_section_stack *section;
 	struct config_module_parser *l;
 	const void *value;
 
-	for (l = ctx->cur_section->parsers; l->root != NULL; l++) {
+	section = ctx->cur_section;
+	if (expand_parent && ctx->cur_section->prev != NULL) {
+		/* for: key = $key stuff */
+		section = section->prev;
+	}
+
+	for (l = section->parsers; l->root != NULL; l++) {
 		value = settings_parse_get_value(l->parser, key, type_r);
 		if (value != NULL)
 			return value;
@@ -604,7 +611,7 @@
 	const void *var_name, *var_value, *p;
 	enum setting_type var_type;
 	const char *error;
-	bool dump;
+	bool dump, expand_parent;
 
 	switch (type) {
 	case CONFIG_LINE_TYPE_KEYVALUE:
@@ -633,7 +640,9 @@
 			else
 				var_name = t_strdup_until(value, p);
 
-			var_value = config_get_value(ctx, var_name, &var_type);
+			expand_parent = strcmp(key, var_name) == 0;
+			var_value = config_get_value(ctx, var_name,
+						     expand_parent, &var_type);
 			if (var_value == NULL) {
 				ctx->error = p_strconcat(ctx->pool,
 							 "Unknown variable: $",


More information about the dovecot-cvs mailing list