[augeas-devel] [PATCH 1 of 7] Adapt php.aug to support entries outside of sections and still map sections as labels (Fix #9)

Raphael Pinson raphink at gmail.com
Thu Aug 14 15:52:03 UTC 2008


# HG changeset patch
# User Raphael Pinson <raphink at gmail.com>
# Date 1218700651 -7200
# Node ID 9dfd488a44716a108971f084228d36dd1d682476
# Parent  495c005f666b22c0bcd550e1733077908053d7d4
Adapt php.aug to support entries outside of sections and still map sections as labels (Fix #9)

diff -r 495c005f666b -r 9dfd488a4471 lenses/php.aug
--- a/lenses/php.aug	Wed Aug 13 18:53:43 2008 +0200
+++ b/lenses/php.aug	Thu Aug 14 09:57:31 2008 +0200
@@ -7,10 +7,30 @@ module PHP =
 
 (* PHP is a standard INI file *)
 
-let entry  = IniFile.entry /[a-z][a-z0-9\._-]+/
 
-let record = IniFile.record "section" entry
-let lns    = IniFile.lns record
+(* Importe useful primitives *)
+let comment = IniFile.comment
+let empty   = IniFile.empty
+let eol     = IniFile.eol
+
+
+(*
+  We have to remove the keyword "section" from possible entry keywords 
+  otherwise it would lead to an ambiguity with the "section" label
+  since PHP allows entries outside of sections.
+*)
+let entry  = IniFile.entry ( /[a-z][a-z0-9\._-]+/ - /section/ )
+
+
+let title_label
+           = label "section"
+             .Util.del_str "[" . store /[^]]+/
+             . Util.del_str "]". eol
+
+let record = [ title_label
+             . (entry | comment | empty)* ]
+
+let lns    = ( IniFile.comment | IniFile.empty | entry )* . record*
 
 let filter = (incl "/etc/php*/*/php.ini")
              . Util.stdexcl
diff -r 495c005f666b -r 9dfd488a4471 lenses/tests/test_php.aug
--- a/lenses/tests/test_php.aug	Wed Aug 13 18:53:43 2008 +0200
+++ b/lenses/tests/test_php.aug	Thu Aug 14 09:57:31 2008 +0200
@@ -1,6 +1,8 @@ module Test_php =
 module Test_php =
 
-   let conf = "[PHP]
+   let conf = "
+safe_mode = Off  
+[PHP]
 ; Enable the PHP scripting language engine under Apache.
 engine = On
 
@@ -15,6 +17,8 @@ sqlite.assoc_case = 0
 
 
    test PHP.lns get conf = 
+      {}
+      { "safe_mode" = "Off" }
       { "section" = "PHP"
          { "#comment" = "Enable the PHP scripting language engine under Apache." }
 	 { "engine"  = "On" }




More information about the augeas-devel mailing list