Make parseini properly handle line continuations.
[matthijs/upstream/backupninja.git] / lib / parseini.in
index 6f56d4228dc3efd1e44ef556bcd46dd14713d262..a6282dc59f4717f94acbcb929ec2f6abfa352bf8 100644 (file)
@@ -1,3 +1,4 @@
+# -*- mode: awk; indent-tabs-mode: nil; -*-
 # 
 # parseini --- parses 'ini' style configuration files.
 #
@@ -8,27 +9,26 @@
 #
 # example ini file:
 # 
-#              fruit = apple
-#              fruit = pear
-#              multiline = this is a multiline \
-#       parameter
+#    fruit = apple
+#    fruit = pear
+#    multiline = this is a multiline \
+#    parameter
 #
-#       # this is a comment
+#    # this is a comment
+#    [colors]  
+#    red = yes
+#    green = no
+#    blue = maybe
 #
-#              [colors]  
-#              red = yes
-#              green = no
-#              blue = maybe
-#              
-#              [ocean] 
-#              fish = red 
-#              fish = blue
+#    [ocean] 
+#    fish = red 
+#    fish = blue
 #       
 # example usage:
-#       > awk -f parseini S=ocean P=fish testfile.ini 
+#    > awk -f parseini S=ocean P=fish testfile.ini 
 # would return: 
-#       red
-#       blue
+#    red
+#    blue
 #
    
 BEGIN { 
@@ -92,7 +92,9 @@ END {
                 if (v ~ /\\$/) { 
                    v = substr(v, 1, length(v)-1) 
                    sub(/[ \r\t]+$/, "", v) 
-                } 
+                } else {
+                                       continueline = 0
+                               }
                 if (v) value[nvalue++] = v 
             } 
             else if (v ~ MATCH) { 
@@ -119,7 +121,7 @@ END {
     for (x = 0; x < nline; ++x) { 
         sub(/^[ \r\t]+/, "", line[x]) 
         sub(/[ \r\t]+$/, "", line[x]) 
-     
+    } 
  
     # output the final result
     for (x = 0; x < nline; ++x)