diff --git a/main/config.c b/main/config.c index 9c96327b0e..119821c939 100644 --- a/main/config.c +++ b/main/config.c @@ -1525,7 +1525,10 @@ static void insert_leading_blank_lines(FILE *fp, struct inclfile *fi, struct ast stored in the precomments, but not printed back out. I did have to make sure that comments following the ;! header comments were not also deleted in the process */ - for (i=fi->lineno;ilineno < 0) { /* insertions can mess up the line numbering and produce negative numbers that mess things up */ + return; + } + for (i=fi->lineno; ilineno = lineno+1; /* Advance the file lineno */ @@ -1609,7 +1612,7 @@ int config_text_file_save(const char *configfile, const struct ast_config *cfg, } } } - + insert_leading_blank_lines(f, fi, cat->precomments, cat->lineno); /* Dump section with any appropriate comment */ for (cmt = cat->precomments; cmt; cmt=cmt->next) { @@ -1623,8 +1626,6 @@ int config_text_file_save(const char *configfile, const struct ast_config *cfg, if (cmtp) fprintf(f,"%s", cmtp); } - if (!cat->precomments) - fprintf(f,"\n"); fprintf(f, "[%s]", cat->name); if (cat->ignored || !AST_LIST_EMPTY(&cat->template_instances)) { fprintf(f, "(");