[augeas-devel] augeas: master - Inittab: parse end-of-line comments into a #comment

David Lutterkort lutter at fedoraproject.org
Mon Oct 26 13:12:20 UTC 2009


Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=3d72cac6633f33d3ac301c8c5cac036105f1c3f3
Commit:        3d72cac6633f33d3ac301c8c5cac036105f1c3f3
Parent:        67d07837f56f7d14756ef4ba8a5cfab6cf4c8bd8
Author:        David Lutterkort <lutter at redhat.com>
AuthorDate:    Fri Oct 23 12:39:12 2009 +0200
Committer:     David Lutterkort <lutter at redhat.com>
CommitterDate: Mon Oct 26 14:09:53 2009 +0100

Inittab: parse end-of-line comments into a #comment

---
 lenses/inittab.aug            |    5 ++++-
 lenses/tests/test_inittab.aug |   16 ++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/lenses/inittab.aug b/lenses/inittab.aug
index 86a0dc8..f7452b5 100644
--- a/lenses/inittab.aug
+++ b/lenses/inittab.aug
@@ -12,10 +12,13 @@ module Inittab =
 
    let record =
      let field (name:string) = [ label name . store value ] in
+     let eolcomment =
+       [ label "#comment" . del /#[ \t]*/ "# "
+           . store /([^ \t\n].*[^ \t\n]|[^ \t\n]?)/ ] in
        [ key id . sep .
            field "runlevels" . sep .
            field "action" . sep .
-           field "process" . eol ]
+           field "process" . eolcomment? . eol ]
 
    let lns = ( comment | record ) *
 
diff --git a/lenses/tests/test_inittab.aug b/lenses/tests/test_inittab.aug
index 61d8d21..9c6c34f 100644
--- a/lenses/tests/test_inittab.aug
+++ b/lenses/tests/test_inittab.aug
@@ -39,6 +39,22 @@ l0:0:wait:/etc/rc.d/rc 0
   test Inittab.lns put simple after set "/id/runlevels" "3" =
     "id:3:initdefault:\n"
 
+  test Inittab.lns get
+    "co:2345:respawn:/usr/bin/command # End of line comment\n" =
+    { "co"
+        { "runlevels" = "2345" }
+        { "action" = "respawn" }
+        { "process" = "/usr/bin/command " }
+        { "#comment" = "End of line comment" } }
+
+  test Inittab.lns get
+    "co:2345:respawn:/usr/bin/blank_comment # \t \n" =
+    { "co"
+        { "runlevels" = "2345" }
+        { "action" = "respawn" }
+        { "process" = "/usr/bin/blank_comment " }
+        { "#comment" = "" } }
+
 (* Local Variables: *)
 (* mode: caml       *)
 (* End:             *)




More information about the augeas-devel mailing list