aboutsummaryrefslogtreecommitdiffstats
path: root/main/config.c
diff options
context:
space:
mode:
authormurf <murf@f38db490-d61c-443f-a65b-d21fe96a405b>2007-09-11 22:37:20 +0000
committermurf <murf@f38db490-d61c-443f-a65b-d21fe96a405b>2007-09-11 22:37:20 +0000
commit4d7d64c096963446029501683f31cf1a5ca87eff (patch)
treea4df544cd3a1ba20ed815cdfdd974168b9403c37 /main/config.c
parente4953f8f1057f73b3e6b42a3ba87f40631eade99 (diff)
This solves an unreported solaris compile problem (missing -lnsl -lsocket).
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@82268 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/config.c')
-rw-r--r--main/config.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/main/config.c b/main/config.c
index ac9c87818..e8d13a5b2 100644
--- a/main/config.c
+++ b/main/config.c
@@ -1160,6 +1160,12 @@ static struct ast_config *config_text_file_load(const char *database, const char
else
process_buf = buf;
+ if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS) && comment_buffer && comment_buffer[0] && (ast_strlen_zero(buf) || strlen(buf) == strspn(buf," \t\n\r"))) {
+ /* blank line? really? Can we add it to an existing comment and maybe preserve inter- and post- comment spacing? */
+ CB_ADD(&comment_buffer, &comment_buffer_size, "\n"); /* add a newline to the comment buffer */
+ continue; /* go get a new line, then */
+ }
+
while ((comment_p = strchr(new_buf, COMMENT_META))) {
if ((comment_p > new_buf) && (*(comment_p-1) == '\\')) {
/* Escaped semicolons aren't comments. */
@@ -1228,10 +1234,14 @@ static struct ast_config *config_text_file_load(const char *database, const char
/* end of file-- anything in a comment buffer? */
if (last_cat) {
if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS) && comment_buffer && comment_buffer[0] ) {
+ CB_ADD(&comment_buffer, &comment_buffer_size, lline_buffer); /* add the current lline buffer to the comment buffer */
+ lline_buffer[0] = 0; /* erase the lline buffer */
last_cat->trailing = ALLOC_COMMENT(comment_buffer);
}
} else if (last_var) {
if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS) && comment_buffer && comment_buffer[0] ) {
+ CB_ADD(&comment_buffer, &comment_buffer_size, lline_buffer); /* add the current lline buffer to the comment buffer */
+ lline_buffer[0] = 0; /* erase the lline buffer */
last_var->trailing = ALLOC_COMMENT(comment_buffer);
}
} else {
@@ -1323,6 +1333,27 @@ static void set_fn(char *fn, int fn_size, const char *file, const char *configfi
snprintf(fn, fn_size, "%s/%s", ast_config_AST_CONFIG_DIR, file);
}
+static int count_linefeeds(char *str)
+{
+ int count = 0;
+ while (*str) {
+ if (*str =='\n')
+ count++;
+ }
+ return count;
+}
+
+static int count_linefeeds_in_comments(struct ast_comment *x)
+{
+ int count = 0;
+ while (x)
+ {
+ count += count_linefeeds(x->cmt);
+ x = x->next;
+ }
+ return count;
+}
+
int config_text_file_save(const char *configfile, const struct ast_config *cfg, const char *generator)
{
FILE *f;