Index: main/config.c =================================================================== --- main/config.c (revision 109906) +++ main/config.c (working copy) @@ -1042,16 +1042,22 @@ 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, ")"); } for(cmt = cat->sameline; cmt; cmt=cmt->next) @@ -1063,10 +1069,15 @@ 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; }