aboutsummaryrefslogtreecommitdiffstats
path: root/main/config.c
diff options
context:
space:
mode:
authormurf <murf@f38db490-d61c-443f-a65b-d21fe96a405b>2008-11-18 18:10:34 +0000
committermurf <murf@f38db490-d61c-443f-a65b-d21fe96a405b>2008-11-18 18:10:34 +0000
commit5d87508a97a076a8b0b05f08515dcc0e94ae6409 (patch)
treebbc151e0ac5a3f11304e7a562169469051919b8a /main/config.c
parent4546c1078b97f9b913e367a41c7193b973debb4a (diff)
Merged revisions 157302 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r157302 | murf | 2008-11-18 11:07:55 -0700 (Tue, 18 Nov 2008) | 18 lines (closes issue #13420) Reported by: alex70 Patches: 13420.13539.patch uploaded by murf (license 17) Tested by: murf, awk This fixes two problems: a spurious linefeed insertion probably left over from pre-precomment times. Only generated when category had no previous comments. The other problem: Insertions could get the line-numbering out of whack and generate negative line numbers, causing chunks of line numbers to be emitted, on the scale of the number of lines up to that point in the file. In such cases, abort the looping, and all is well. ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@157303 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/config.c')
-rw-r--r--main/config.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/main/config.c b/main/config.c
index 9c96327b0..119821c93 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;i<lineno - precomment_lines; i++) {
+ if (lineno - precomment_lines - fi->lineno < 0) { /* insertions can mess up the line numbering and produce negative numbers that mess things up */
+ return;
+ }
+ for (i=fi->lineno; i<lineno - precomment_lines; i++) {
fprintf(fp,"\n");
}
fi->lineno = 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, "(");