[augeas-devel] [PATCH 1 of 4] Handle blank lines in /etc/hosts

David Lutterkort dlutter at redhat.com
Sat May 31 00:41:05 UTC 2008


2 files changed, 12 insertions(+), 1 deletion(-)
lenses/hosts.aug            |    2 +-
lenses/tests/test_hosts.aug |   11 +++++++++++


# HG changeset patch
# User David Lutterkort <dlutter at redhat.com>
# Date 1212189989 25200
# Node ID fed370da34a7911d7245023f2ddb30ddee3c01cc
# Parent  a6fd47392396fee1dda045d364411ee5991a1713
Handle blank lines in /etc/hosts

diff -r a6fd47392396 -r fed370da34a7 lenses/hosts.aug
--- a/lenses/hosts.aug	Thu May 29 16:38:53 2008 -0700
+++ b/lenses/hosts.aug	Fri May 30 16:26:29 2008 -0700
@@ -8,7 +8,7 @@
 
   let eol = Util.del_str "\n"
 
-  let comment = [ del /#.*\n/ "# " ]
+  let comment = [ del /(#.*|[ \t]*)\n/ "\n" ]
   let word = /[^# \n\t]+/
   let record = [ seq "host" . [ label "ipaddr" . store  word ] . sep_tab .
                               [ label "canonical" . store word ] .
diff -r a6fd47392396 -r fed370da34a7 lenses/tests/test_hosts.aug
--- a/lenses/tests/test_hosts.aug	Thu May 29 16:38:53 2008 -0700
+++ b/lenses/tests/test_hosts.aug	Fri May 30 16:26:29 2008 -0700
@@ -41,6 +41,17 @@
       rm "1/canonical"
     = *
 
+  (* Make sure blank lines get through *)
+  test Hosts.lns get "127.0.0.1\tlocalhost\n \n\n
+127.0.1.1\tetch.example.com\tetch\n" = 
+    { "1" { "ipaddr" = "127.0.0.1" }
+          { "canonical" = "localhost" } }
+    {} {} {}
+    { "2" { "ipaddr" = "127.0.1.1" }
+          { "canonical" = "etch.example.com" } 
+          { "alias" = "etch" } }
+
+
 (* Local Variables: *)
 (* mode: caml *)
 (* End: *)




More information about the augeas-devel mailing list