[augeas-devel] augeas: master - Interfaces: various bug fixes

David Lutterkort lutter at fedoraproject.org
Thu May 28 23:45:53 UTC 2009


Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=58ac068203c0a7fe9ac24645a5cb887623b836d7
Commit:        58ac068203c0a7fe9ac24645a5cb887623b836d7
Parent:        40fdbcb38780f100f900f3588dd101caf5b41a1c
Author:        Matt Palmer <matt at anchor.net.au>
AuthorDate:    Thu May 28 16:31:40 2009 -0700
Committer:     David Lutterkort <lutter at redhat.com>
CommitterDate: Thu May 28 16:45:09 2009 -0700

Interfaces: various bug fixes

* disallow end-of-line comments
* support generic allow-* stanzas
---
 AUTHORS                          |    1 +
 lenses/interfaces.aug            |   31 ++++++++++++++++---------------
 lenses/tests/test_interfaces.aug |   30 +++++++++++++++++++-----------
 3 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index abd0d9a..d378b0e 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -15,6 +15,7 @@ Contributions by:
   Jim Meyering     <meyering at redhat.com>
   Sean Millichamp  <sean at bruenor.org>
   Joel Nimety      <jnimety at perimeterusa.com>
+  Matt Palmer      <matt at anchor.net.au>
   Alan Pevec       <apevec at redhat.com>
   Raphael Pinson   <raphink at gmail.com>
   Robin Lee Powell <rlpowell at digitalkingdom.org>
diff --git a/lenses/interfaces.aug b/lenses/interfaces.aug
index 98389e8..44b1b03 100644
--- a/lenses/interfaces.aug
+++ b/lenses/interfaces.aug
@@ -17,12 +17,12 @@ let eol        = Util.eol
 (* Define separators *)
 
 (* a line can be extended across multiple lines by making the last  *)
-(*  character a backslash, unless the line is a comment (see below) *)
+(*  character a backslash *)
 let sep_spc    =  del /([ \t]+|[ \t]*\\\\\n[ \t]*)/ " "
 
 (* Define fields *)
-let sto_to_eol = store /([^\\# \t\n].*[^\\ \t\n]|[^\\ \t\n])/
-let sto_to_spc = store /[^\\# \t\n]+/
+let sto_to_eol = store /([^\\ \t\n].*[^\\ \t\n]|[^\\ \t\n])/ . eol
+let sto_to_spc = store /[^\\ \t\n]+/
 
 (* Define comments and empty lines *)
 
@@ -39,12 +39,11 @@ let stanza_param (l:string) = [ sep_spc . label l . sto_to_spc ]
 (* Define reseverved words *)
 let stanza_word = /(iface|auto|allow-[a-z-]+|mapping)/
 
-(* Define additional lines for mluti-line stanzas *)
+(* Define additional lines for multi-line stanzas *)
 let stanza_option = [  del /[ \t]*/ "   "
                      . key  ( /[a-z_-]+/ - stanza_word )
                      . sep_spc
-                     . sto_to_eol
-                     . eol ]
+                     . sto_to_eol ]
 
 (************************************************************************
  *                              AUTO
@@ -52,22 +51,24 @@ let stanza_option = [  del /[ \t]*/ "   "
 
 let array (r:regexp) (t:string) =  del r t . label t . counter t
    . [ sep_spc . seq t . sto_to_spc ]+
-let auto = [ array /(allow-)?auto/ "auto" . (comment|eol) ]
+let auto = [ array /(allow-)?auto/ "auto" . eol ]
 
 (************************************************************************
- *                              HOTPLUG
+ *                              GENERIC ALLOW
  *************************************************************************)
 
-let hotplug = [ stanza_id "allow-hotplug" . (comment|eol) ]
+let allow = [ key ( /allow-[a-z-]+/ - "allow-auto" )
+             . counter "allow_seq"
+             . [ sep_spc . seq "allow_seq" . sto_to_spc ]+
+             . eol ]
 
 (************************************************************************
  *                              MAPPING
  *************************************************************************)
 
 let mapping = [ stanza_id "mapping"
-               . (comment|empty)+
-               . stanza_option
-               . (stanza_option|comment|empty)* ]
+               . eol
+               . (stanza_option|comment|empty)+ ]
 
 (************************************************************************
  *                              IFACE
@@ -76,8 +77,8 @@ let mapping = [ stanza_id "mapping"
 let iface   = [ stanza_id    "iface"
               . stanza_param "family"
               . stanza_param "method"
-              . (comment|empty)+
-              . ( stanza_option . (stanza_option|comment|empty)* )? ]
+              . eol
+              . (stanza_option|comment|empty)* ]
 
 (************************************************************************
  *                              STANZAS
@@ -89,7 +90,7 @@ let iface   = [ stanza_id    "iface"
    come after an auto or hotplug stanza, otherwise they are considered part
    of a iface or mapping block *)
 
-let stanza_single = (auto|hotplug) . (comment|empty)*
+let stanza_single = (auto|allow) . (comment|empty)*
 let stanza_multi  = iface|mapping
 
 (************************************************************************
diff --git a/lenses/tests/test_interfaces.aug b/lenses/tests/test_interfaces.aug
index 62bbd20..9495b4a 100644
--- a/lenses/tests/test_interfaces.aug
+++ b/lenses/tests/test_interfaces.aug
@@ -4,13 +4,13 @@ module Test_interfaces =
 # and how to activate them. For more information, see interfaces(5).
 # The loopback network interface
 
-auto lo eth0 # Take me to the net
+auto lo eth0 #foo
 allow-hotplug eth1
 
 iface lo inet \
  loopback
 
-mapping eth0 # Home sweet home
+mapping eth0
 	script /usr/local/sbin/map-scheme
 map HOME eth0-home
      map \
@@ -20,12 +20,14 @@ iface eth0-home inet static
 
 address 192.168.1.1
      netmask 255.255.255.0
+     bridge_maxwait 0
 #        up flush-mail
+    down Mambo #5
 
 iface eth0-work inet dhcp
 
 allow-auto eth1
-iface eth1 inet dhcp # This is easy
+iface eth1 inet dhcp
 
 mapping eth1
 	# I like mapping ...
@@ -43,13 +45,12 @@ mapping eth1
         { "auto"
             { "1" = "lo" }
             { "2" = "eth0" }
-	    { "#comment" = "Take me to the net" } }
-        { "allow-hotplug" = "eth1" }
+            { "3" = "#foo" } }
+        { "allow-hotplug" { "1" = "eth1" } }
         { "iface" = "lo"
             { "family" = "inet"}
-            { "method" = "loopback"} {} {} }
+            { "method" = "loopback"} {} }
         { "mapping" = "eth0"
-            { "#comment" = "Home sweet home" }
             { "script" = "/usr/local/sbin/map-scheme"}
             { "map" = "HOME eth0-home"}
             { "map" = "WORK eth0-work"} 
@@ -57,25 +58,32 @@ mapping eth1
         { "iface" = "eth0-home"
             { "family" = "inet"}
             { "method" = "static"}
-            {} {}
+            {}
             { "address" = "192.168.1.1" }
             { "netmask" = "255.255.255.0" }
+            { "bridge_maxwait" = "0" }
             { "#comment" = "up flush-mail" }
+            { "down" = "Mambo #5" }
             {} }
         { "iface" = "eth0-work"
             { "family" = "inet"}
             { "method" = "dhcp"}
-            {} {} }
+            {} }
         { "auto"
             { "1" = "eth1" } }
         { "iface" = "eth1"
             { "family" = "inet"}
             { "method" = "dhcp"}
-            { "#comment" = "This is easy" }
 	    {} }
         { "mapping" = "eth1"
-            {}
             { "#comment" = "I like mapping ..." }
             { "#comment" = "... and I like comments" }
             {}
             { "script" = "/usr/local/sbin/map-scheme"} }
+
+test Interfaces.lns put "" after
+	set "/iface[1]" "eth0";
+	set "/iface[1]/family" "inet";
+	set "/iface[1]/method" "dhcp"
+= "iface eth0 inet dhcp\n"
+




More information about the augeas-devel mailing list