[augeas-devel] augeas: master - Xinetd: map comments using Util.comment

David Lutterkort lutter at fedoraproject.org
Wed Apr 8 19:54:57 UTC 2009


Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=d03812392263cf095c67c868f369cd8be067e2d6
Commit:        d03812392263cf095c67c868f369cd8be067e2d6
Parent:        3b0d8f588ae757767ca465e0ca599e198cd234e3
Author:        Raphael Pinson <raphink at gmail.com>
AuthorDate:    Wed Apr 8 12:18:28 2009 -0700
Committer:     David Lutterkort <lutter at redhat.com>
CommitterDate: Wed Apr 8 12:18:28 2009 -0700

Xinetd: map comments using Util.comment

---
 lenses/tests/test_xinetd.aug |   14 +++++++++-----
 lenses/xinetd.aug            |    9 +++++----
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/lenses/tests/test_xinetd.aug b/lenses/tests/test_xinetd.aug
index 62b68c2..c49496b 100644
--- a/lenses/tests/test_xinetd.aug
+++ b/lenses/tests/test_xinetd.aug
@@ -3,9 +3,9 @@ module Test_xinetd =
 let eol_ws = "defaults \t \n{\n  enabled = cvs echo  \n}\n\n"
 
 let cvs = "# default: off
-# description: The CVS service can record the history of your source \
-#              files. CVS stores all the versions of a file in a single \
-#              file in a clever way that only stores the differences \
+# description: The CVS service can record the history of your source
+#              files. CVS stores all the versions of a file in a single
+#              file in a clever way that only stores the differences
 #              between versions.
 service cvspserver
 {
@@ -40,7 +40,11 @@ test Xinetd.lns put eol_ws after rm "/defaults/enabled/value[last()]" =
   "defaults \t \n{\n  enabled = cvs  \n}\n\n"
 
 test Xinetd.lns get cvs =
-  {} {} {} {} {}
+  { "#comment" = "default: off" }
+  { "#comment" = "description: The CVS service can record the history of your source" }
+  { "#comment" = "files. CVS stores all the versions of a file in a single" }
+  { "#comment" = "file in a clever way that only stores the differences" }
+  { "#comment" = "between versions." }
   { "cvspserver"
       { "disable" = "yes" }
       { "port" = "2401" }
@@ -55,7 +59,7 @@ test Xinetd.lns get cvs =
           { "value" = "-f" }
           { "value" = "--allow-root=/var/cvs" }
           { "value" = "pserver" } }
-      {}
+      { "#comment" = "bind                    = 127.0.0.1" }
       { "log_on_failure" { "add" } { "value" = "HOST" } } }
 
 (* Switch the '+=' to a simple '=' *)
diff --git a/lenses/xinetd.aug b/lenses/xinetd.aug
index 51c1936..bd75005 100644
--- a/lenses/xinetd.aug
+++ b/lenses/xinetd.aug
@@ -17,7 +17,8 @@
 module Xinetd =
   autoload xfm
 
-  let comment = [ del /[ \t]*(#.*|[ \t]*)\n/ "#\n" ]
+  let comment = Util.comment
+  let empty   = Util.empty
 
   let name = key /[^ \t\n\/+-=]+/
   let bol_spc = del /[ \t]*/ "\t"
@@ -86,7 +87,7 @@ module Xinetd =
    *       would simply be prohibitively large. 
    *)
   let body (attr:lens) = Util.del_str "\n{\n"
-                       . (comment|attr)*
+                       . (empty|comment|attr)*
                        . del /[ \t]*}[ \t]*\n/ "}\n"
 
   (* View: includes
@@ -101,12 +102,12 @@ module Xinetd =
                      . Util.del_ws_spc . store /[^ \t\n]+/ . eol ]
 
   let service = 
-     let key_re = /[^ \t\n\/]+/ - /include|includedir|defaults/ in
+     let key_re = /[^# \t\n\/]+/ - /include|includedir|defaults/ in
      [ del /service[ \t]+/ "service " . key key_re . body service_attr ]
 
   let defaults = [ key "defaults" . del /[ \t]*/ "" . body default_attr ]
 
-  let lns = ( comment | includes | defaults | service )*
+  let lns = ( empty | comment | includes | defaults | service )*
 
   let filter = incl "/etc/xinetd.d/*"
              . incl "/etc/xinetd.conf"




More information about the augeas-devel mailing list