From e84a09e48c179ff8fe9fe10b8a09c2f23f83fda9 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Mon, 1 Mar 2010 22:01:57 +0200 Subject: [PATCH] config: Allow key=$var to contain other text after the $var. --HG-- branch : HEAD --- src/config/config-parser.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/config/config-parser.c b/src/config/config-parser.c index 034006f297..c89ec49d90 100644 --- a/src/config/config-parser.c +++ b/src/config/config-parser.c @@ -637,7 +637,7 @@ static int config_write_value(struct parser_context *ctx, const char *key, const char *value, const char **errormsg_r) { - const void *var_value; + const void *var_name, *var_value, *p; enum setting_type var_type; bool dump; @@ -661,18 +661,26 @@ static int config_write_value(struct parser_context *ctx, str_append_c(str, '$'); str_append(str, value); } else { - var_value = config_get_value(ctx, value, &var_type); + p = strchr(value, ' '); + if (p == NULL) + var_name = value; + else + var_name = t_strdup_until(value, p); + + var_value = config_get_value(ctx, var_name, &var_type); if (var_value == NULL) { *errormsg_r = t_strconcat("Unknown variable: $", - value, NULL); + var_name, NULL); return -1; } if (!config_export_type(str, var_value, NULL, var_type, TRUE, &dump)) { *errormsg_r = t_strconcat("Invalid variable: $", - value, NULL); + var_name, NULL); return -1; } + if (p != NULL) + str_append(str, p); } break; default: -- 2.47.3