[augeas-devel] [PATCH 4 of 7] Rewrite php.aug on new inifile.aug

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


# HG changeset patch
# User Raphael Pinson <raphink at gmail.com>
# Date 1218728952 -7200
# Node ID b3d373af10fdb0150400ec084c4d51b60031ef65
# Parent  eeabbccba76be48bd0b338d625bf434e795ae77c
Rewrite php.aug on new inifile.aug

diff -r eeabbccba76b -r b3d373af10fd lenses/php.aug
--- a/lenses/php.aug	Thu Aug 14 17:49:02 2008 +0200
+++ b/lenses/php.aug	Thu Aug 14 17:49:12 2008 +0200
@@ -5,32 +5,41 @@ module PHP =
 module PHP =
   autoload xfm
 
-(* PHP is a standard INI file *)
+(************************************************************************
+ * INI File settings
+ *************************************************************************)
 
+let comment  = IniFile.comment IniFile.comment_re IniFile.comment_default
+let sep      = IniFile.sep IniFile.sep_re IniFile.sep_default
 
-(* Importe useful primitives *)
-let comment = IniFile.comment
-let empty   = IniFile.empty
-let eol     = IniFile.eol
 
+(************************************************************************
+ *                        ENTRY
+ *
+ * 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_re = ( /[A-Za-z][A-Za-z0-9\._-]+/ - /#comment/ - /section/ )
+let entry    = IniFile.entry entry_re sep comment
 
-(*
-  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/ )
 
+(************************************************************************
+ *                         TITLE
+ *
+ * We use IniFile.title_label because there can be entries
+ * outside of sections whose labels would conflict with section names
+ *************************************************************************)
+let title   = IniFile.title_label "section" IniFile.record_label_re
+let record  = IniFile.record title entry
 
-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*
+(************************************************************************
+ *                         LENS & FILTER
+ * There can be entries before any section
+ * IniFile.entry includes comment management, so we just pass entry to lns
+ *************************************************************************)
+let lns    = IniFile.lns record entry
 
 let filter = (incl "/etc/php*/*/php.ini")
              . Util.stdexcl




More information about the augeas-devel mailing list