# HG changeset patch
# User Raphael Pinson <[EMAIL PROTECTED]>
# Date 1218555081 -7200
# Node ID 4aba95fd1ecce6a12e81eea290c28953ec10a065
# Parent  3bb078264c922b9e1019d50bf7f74eaa70760b51
Show comments as fields and ignore empty lines and empty comments

diff -r 3bb078264c92 -r 4aba95fd1ecc lenses/hosts.aug
--- a/lenses/hosts.aug  Tue Aug 12 17:28:19 2008 +0200
+++ b/lenses/hosts.aug  Tue Aug 12 17:31:21 2008 +0200
@@ -9,7 +9,9 @@ module Hosts =
   let eol = del /[ \t]*\n/ "\n"
   let indent = del /[ \t]+/ ""
 
-  let comment = [ indent? . del /(#.*|[ \t]*)\n/ "\n" ]
+  let comment = [ indent? . label "comment" . del /#[ \t]*/ "# " . store /([^ 
\t\n].*[^ \t\n]|[^ \t\n])/ . eol ]
+  let empty   = [ del /[ \t]*#?[ \t]*\n/ "" ]
+
   let word = /[^# \n\t]+/
   let record = [ seq "host" . indent? .
                               [ label "ipaddr" . store  word ] . sep_tab .
@@ -17,7 +19,7 @@ module Hosts =
                               [ label "alias" . sep_spc . store word ]*
                  . eol ]
 
-  let lns = ( comment | record ) *
+  let lns = ( empty | comment | record ) *
 
   let xfm = transform lns (incl "/etc/hosts")
 

_______________________________________________
augeas-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/augeas-devel

Reply via email to