[augeas-devel] [PATCH 4 of 4] Show comments as fields and ignore empty lines and empty comments
Raphael Pinson
raphink at gmail.com
Tue Aug 12 15:34:20 UTC 2008
# HG changeset patch
# User Raphael Pinson <raphink at gmail.com>
# 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")
More information about the augeas-devel
mailing list