[augeas-devel] [PATCH] Fix empty comments in INI file

raphink at gmail.com raphink at gmail.com
Fri Jul 25 08:54:22 UTC 2008


# HG changeset patch
# User Raphael Pinson <raphink at gmail.com>
# Date 1216976039 -7200
# Node ID 5f1e98d571c58345b81a247b42cc8a5d5fe07136
# Parent  26d9cf6f08a155818cab92eb1275a932a017d19b
Fix empty comments in INI file

diff -r 26d9cf6f08a1 -r 5f1e98d571c5 lenses/inifile.aug
--- a/lenses/inifile.aug	Thu Jul 24 17:04:47 2008 +0200
+++ b/lenses/inifile.aug	Fri Jul 25 10:53:59 2008 +0200
@@ -10,15 +10,15 @@ module IniFile  =
     let eol                = del /[ \t]*\n/ "\n"
     let value_sep          = del /[ \t]*=/ " = "
     let value_sepwithcolon = del /[ \t]*(=|:)/ " = "
-    let value_to_eol       = store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
+    let value_to_eol       = del /[ \t]*/ " " . store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
     let value_to_comment   = del /[ \t]*/ "" . store /[^;# \t\n]+/
 
 
     (* Define comment and empty strings *)
     (* Some implementations of INI file allow "#" as a comment sign *)
-    let comment_generic (pattern:regexp) = [ label "comment" . del pattern "; " .  value_to_eol . eol ]
-    let comment = comment_generic /[ \t]*(#|;)[ \t]*/
-    let comment_nosharp = comment_generic /[ \t]*;[ \t]*/
+    let comment_generic (pattern:regexp) = [ label "comment" . del pattern "; " .  value_to_eol? . eol ]
+    let comment = comment_generic /[ \t]*(#|;)/
+    let comment_nosharp = comment_generic /[ \t]*;/
 
     let empty  = [ del /[ \t]*\n/ "" ]
 




More information about the augeas-devel mailing list