diff --git a/main/config.c b/main/config.c index 2740640a55..00cc0d8367 100644 --- a/main/config.c +++ b/main/config.c @@ -1042,15 +1042,21 @@ int config_text_file_save(const char *configfile, const struct ast_config *cfg, if (!cat->precomments) fprintf(f,"\n"); fprintf(f, "[%s]", cat->name); - if (cat->ignored) - fprintf(f, "(!)"); - if (!AST_LIST_EMPTY(&cat->template_instances)) { - struct ast_category_template_instance *x; + if (cat->ignored || !AST_LIST_EMPTY(&cat->template_instances)) { fprintf(f, "("); - AST_LIST_TRAVERSE(&cat->template_instances, x, next) { - fprintf(f,"%s",x->name); - if (x != AST_LIST_LAST(&cat->template_instances)) - fprintf(f,","); + if (cat->ignored) { + fprintf(f, "!"); + } + if (cat->ignored && !AST_LIST_EMPTY(&cat->template_instances)) { + fprintf(f, ","); + } + if (!AST_LIST_EMPTY(&cat->template_instances)) { + struct ast_category_template_instance *x; + AST_LIST_TRAVERSE(&cat->template_instances, x, next) { + fprintf(f,"%s",x->name); + if (x != AST_LIST_LAST(&cat->template_instances)) + fprintf(f,","); + } } fprintf(f, ")"); } @@ -1063,10 +1069,15 @@ int config_text_file_save(const char *configfile, const struct ast_config *cfg, var = cat->root; while(var) { struct ast_category_template_instance *x; + struct ast_variable *v2; int found = 0; AST_LIST_TRAVERSE(&cat->template_instances, x, next) { - const char *pvalue = ast_variable_retrieve(cfg, x->name, var->name); - if (pvalue && !strcmp(pvalue, var->value)) { + + for (v2 = x->inst->root; v2; v2 = v2->next) { + if (!strcasecmp(var->name, v2->name)) + break; + } + if (v2 && v2->value && !strcmp(v2->value, var->value)) { found = 1; break; }