[PATCH] allow multiline in config

Alexander Malysh <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hi,

please find attached patch that allows multilines in bash styli in the
config file. E.g.:

option = very long \
jsdgfjshf

in order to have \ at the end:
option = not long \\

Comments and votes please.
 
-- 
Thanks,
Alex
cfg-multiline.patch (text/x-diff, 1.8 KB)
Index: gwlib/cfg.c
===================================================================
RCS file: /home/cvs/gateway/gwlib/cfg.c,v
retrieving revision 1.30
diff -a -u -p -r1.30 cfg.c
--- gwlib/cfg.c	11 Feb 2005 15:35:48 -0000	1.30
+++ gwlib/cfg.c	3 Jun 2006 14:10:48 -0000
@@ -316,7 +316,7 @@ static List *expand_file(Octstr *file, i
     List *lines; 
     List *expand; 
     long lineno; 
-    CfgLoc *loc; 
+    CfgLoc *loc = NULL; 
  
     os = octstr_read_file(octstr_get_cstr(file)); 
     if (os == NULL) 
@@ -326,15 +326,29 @@ static List *expand_file(Octstr *file, i
     lineno = 0; 
     expand = gwlist_create(); 
               
-    while ((line = gwlist_extract_first(lines)) != NULL) { 
-        ++lineno; 
-        loc = cfgloc_create(file); 
-        loc->line_no = lineno; 
-        loc->line = line; 
-        if (forward) 
-            gwlist_append(expand, loc); 
-        else 
-            gwlist_insert(expand, 0, loc); 
+    while ((line = gwlist_extract_first(lines)) != NULL) {
+    	if (loc == NULL) {
+            ++lineno; 
+            loc = cfgloc_create(file); 
+            loc->line_no = lineno;
+            loc->line = octstr_create("");
+            if (forward) 
+                gwlist_append(expand, loc); 
+            else 
+                gwlist_insert(expand, 0, loc);
+        }
+        /* check for escape and then add to existing loc */
+        if (octstr_get_char(line, octstr_len(line) - 1) == '\\') {
+            octstr_delete(line, octstr_len(line) - 1, 1);
+            octstr_append(loc->line, line); 
+            /* check for second escape */
+            if (octstr_get_char(line, octstr_len(line) - 1) == '\\')
+                loc = NULL;
+        } else {
+            octstr_append(loc->line, line);
+            loc = NULL;
+        }
+        octstr_destroy(line);
     } 
     
     /*
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.