[augeas-devel] [PATCH] Map entries outside of sections inside a ".anon" section

Raphael Pinson raphink at gmail.com
Fri Aug 29 12:03:39 UTC 2008


# HG changeset patch
# User Raphael Pinson <raphink at gmail.com>
# Date 1220011392 -7200
# Node ID 2b020796632f86960f88a3c420e0f743426864c9
# Parent  15b35d21a9a5bc598745825c8fd01aab3fe31262
Map entries outside of sections inside a ".anon" section
Clean regexp for entry key
Remove /.anon/ from record key regexp
Modify test_php.aug according to new mapping policy

diff -r 15b35d21a9a5 -r 2b020796632f lenses/php.aug
--- a/lenses/php.aug	Wed Aug 27 15:58:30 2008 -0700
+++ b/lenses/php.aug	Fri Aug 29 14:03:12 2008 +0200
@@ -11,6 +11,7 @@ module PHP =
 
 let comment  = IniFile.comment IniFile.comment_re IniFile.comment_default
 let sep      = IniFile.sep IniFile.sep_re IniFile.sep_default
+let empty    = IniFile.empty
 
 
 (************************************************************************
@@ -20,7 +21,7 @@ let sep      = IniFile.sep IniFile.sep_r
  * 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_re = ( /[A-Za-z][A-Za-z0-9\._-]+/ )
 let entry    = IniFile.entry entry_re sep comment
 
 
@@ -30,8 +31,10 @@ let entry    = IniFile.entry entry_re se
  * 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       = IniFile.title ( IniFile.record_re - /.anon/ )
+let record      = IniFile.record title entry
+
+let record_anon = [ label ".anon" . ( entry | empty )+ ]
 
 
 (************************************************************************
@@ -39,7 +42,7 @@ let record  = IniFile.record title entry
  * 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 lns    = record_anon? . record*
 
 let filter = (incl "/etc/php*/*/php.ini")
              . Util.stdexcl
diff -r 15b35d21a9a5 -r 2b020796632f lenses/tests/test_php.aug
--- a/lenses/tests/test_php.aug	Wed Aug 27 15:58:30 2008 -0700
+++ b/lenses/tests/test_php.aug	Fri Aug 29 14:03:12 2008 +0200
@@ -17,9 +17,10 @@ sqlite.assoc_case = 0
 
 
    test PHP.lns get conf = 
-      {}
-      { "safe_mode" = "Off" }
-      { "section" = "PHP"
+      { ".anon"
+         {}
+         { "safe_mode" = "Off" } }
+      { "PHP"
          { "#comment" = "Enable the PHP scripting language engine under Apache." }
 	 { "engine"  = "On" }
 	 {}
@@ -28,5 +29,5 @@ sqlite.assoc_case = 0
 	 { "unserialize_callback_func" }
 	 { "date.default_latitude" = "31.7667" }
 	 {} }
-      { "section" = "sqlite"
+      { "sqlite"
          { "sqlite.assoc_case" = "0" } }




More information about the augeas-devel mailing list