[augeas-devel] augeas: master - Require quotes around strings in xorg.conf

David Lutterkort lutter at fedoraproject.org
Tue Aug 4 22:37:24 UTC 2009


Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=97609ef4168b407406f9548de92850a322dd1030
Commit:        97609ef4168b407406f9548de92850a322dd1030
Parent:        c16de9613982d8401c69a34ef79a56a09c6cea33
Author:        Matthew Booth <mbooth at redhat.com>
AuthorDate:    Fri Jul 31 09:22:21 2009 +0100
Committer:     David Lutterkort <lutter at redhat.com>
CommitterDate: Tue Aug 4 15:25:19 2009 -0700

Require quotes around strings in xorg.conf

man xorg.conf appears to support this:
           String      a string enclosed in double quote marks (")

This change means that explicitly parsed values will remove quotes in the
get directory and insert them in the put direction.

Currently, only the following entries are explicitly parsed:
* Option
* Screen
* InputDevice
* Driver
* SubSection
* Identifier
* VideoRam
* DefaultDepth
* Device
* All entries in the Display Subsection

The lens will also accept any other entry name not in this list. However,
as it does not know what types to expect, it stores a bare string. This
will include quote marks.
---
 lenses/tests/test_xorg.aug |   34 +++++++++++++++++-----------------
 lenses/xorg.aug            |   44 +++++++++++++++-----------------------------
 2 files changed, 32 insertions(+), 46 deletions(-)

diff --git a/lenses/tests/test_xorg.aug b/lenses/tests/test_xorg.aug
index 9284f2b..4fd937f 100644
--- a/lenses/tests/test_xorg.aug
+++ b/lenses/tests/test_xorg.aug
@@ -42,30 +42,30 @@ EndSection
      { "#comment" = "xorg.conf" }
      { }
      { "ServerLayout"
-        { "Identifier" = "\"single head configuration\"" }
-        { "Screen"     = "\"Screen0\""
+        { "Identifier" = "single head configuration" }
+        { "Screen"     = "Screen0"
            { "num"      = "0" }
            { "position" = "0 0" } }
-        { "InputDevice" = "\"Generic Keyboard\""
-           { "option"   = "\"CoreKeyboard\"" } } }
+        { "InputDevice" = "Generic Keyboard"
+           { "option"   = "CoreKeyboard" } } }
      { }
      { "InputDevice"
-        { "Identifier" = "\"Generic Keyboard\"" }
+        { "Identifier" = "Generic Keyboard" }
         { "#comment"   = "that's a driver" }
-        { "Driver"     = "\"kbd\"" }
-        { "Option"     = "\"XkbOptions\""
-             { "value"  = "\"lv3:ralt_switch\"" } } }
+        { "Driver"     = "kbd" }
+        { "Option"     = "XkbOptions"
+             { "value"  = "lv3:ralt_switch" } } }
      { }
      { "Device"
-        { "Identifier" = "\"Configured Video Device\"" }
-        { "Option"     = "\"MonitorLayout\""
-             { "value"  = "\"LVDS,VGA\"" } }
+        { "Identifier" = "Configured Video Device" }
+        { "Option"     = "MonitorLayout"
+             { "value"  = "LVDS,VGA" } }
         { "VideoRam"   = "229376" }
-        { "Option"     = "\"NoAccel\"" } }
+        { "Option"     = "NoAccel" } }
      { }
      { "Screen"
-        { "Identifier" = "\"Screen0\"" }
-        { "Device"     = "\"Configured Video Device\"" }
+        { "Identifier" = "Screen0" }
+        { "Device"     = "Configured Video Device" }
         { "DefaultDepth" = "24" }
         { "Display"
            { "ViewPort"
@@ -73,6 +73,6 @@ EndSection
               { "y" = "0" } }
            { "Depth"    = "24" }
            { "Modes"
-              { "mode" = "\"1280x1024\"" }
-              { "mode" = "\"1280x960\"" }
-              { "mode" = "\"1280x800\"" } } } }
+              { "mode" = "1280x1024" }
+              { "mode" = "1280x960" }
+              { "mode" = "1280x800" } } } }
diff --git a/lenses/xorg.aug b/lenses/xorg.aug
index ea30f25..c99bc81 100644
--- a/lenses/xorg.aug
+++ b/lenses/xorg.aug
@@ -21,14 +21,6 @@ About: Lens Usage
     * Get the identifier of the devices with a "Clone" option:
       > match "/files/etc/X11/xorg.conf/Device[Option = 'Clone']/Identifier"
 
-About: Quotes in values
-  In this file, values may or may not be quoted (with double quotes) unless
-they contain spaces or tabulations. For this reason, the quotes are
-included in the parsed values when present. New values with no spaces will
-not have quotes by default, unless you type the quotes yourself around
-them. New values with spaces will not be accepted unless they are
-explicitely surrounded by double qutoes.
-
 About: Configuration files
   This lens applies to /etc/X11/xorg.conf. See <filter>.
 *)
@@ -75,24 +67,14 @@ let sep_dquote  = Util.del_str "\""
  * This is a list of all patterns which have specific handlers, and should
  * therefore not be matched by the generic handler
  *)
-let entries_re  = /([oO]ption|[sS]creen|[iI]nput[dD]evice|[dD]river|[sS]ub[sS]ection|[dD]isplay|[iI]dentifier|[vV]ideo[rR]am|[dD]efault[dD]epth)/
+let entries_re  = /([oO]ption|[sS]creen|[iI]nput[dD]evice|[dD]river|[sS]ub[sS]ection|[dD]isplay|[iI]dentifier|[vV]ideo[rR]am|[dD]efault[dD]epth|[dD]evice)/
 
 (* Variable: generic_entry_re *)
 let generic_entry_re = /[^# \t\n\/]+/ - entries_re
 
-
-(*
- * Variable: unquoted_word
- *   Words without spaces may have quotes or not
- *   the quotes are then part of the value
- *)
-let unquoted_word = /[^" \t\n]+/                   (* " relax Emacs *)
-
-(* Variable: quoted_word *)
-let quoted_word = /"[^"\n]+"/                     (* " relax Emacs *)
-
-(* Variable: word_all *)
-let word_all = unquoted_word | quoted_word
+(* Variable: quoted_string_val *)
+let quoted_string_val = del "\"" "\"" . store /[^"\n]+/ . del "\"" "\""
+                                              (* " relax, emacs *)
 
 (* Variable: int *)
 let int = /[0-9]+/
@@ -135,7 +117,7 @@ let entry_xy (canon:string) (re:regexp) =
  *)
 let entry_str (canon:string) (re:regexp) =
         [ indent . del re canon . label canon
-          . sep_spc . store quoted_word . eol ]
+          . sep_spc . quoted_string_val . eol ]
 
 (* View: entry_generic
  * An entry without a specific handler. Store everything after the keyword,
@@ -146,8 +128,8 @@ let entry_generic  = [ indent . key generic_entry_re
 
 (* View: option *)
 let option = [ indent . del /[oO]ption/ "Option" . label "Option" . sep_spc
-               . store quoted_word
-               . [ label "value" . sep_spc . store quoted_word ]*
+               . quoted_string_val
+               . [ label "value" . sep_spc . quoted_string_val ]*
                . eol ]
 
 (* View: screen
@@ -155,14 +137,14 @@ let option = [ indent . del /[oO]ption/ "Option" . label "Option" . sep_spc
  *)
 let screen = [ indent . del /[sS]creen/ "Screen" . label "Screen" . sep_spc
                . [ label "num" . store int . sep_spc ]?
-               . store quoted_word . sep_spc
+               . quoted_string_val . sep_spc
                . [ label "position" . store to_eol ]
                . eol ]
 
 (* View: input_device *)
 let input_device = [ indent . del /[iI]nput[dD]evice/ "InputDevice"
-                     . label "InputDevice" . sep_spc . store quoted_word
-                     . [ label "option" . sep_spc . store quoted_word ]*
+                     . label "InputDevice" . sep_spc . quoted_string_val
+                     . [ label "option" . sep_spc . quoted_string_val ]*
                      . eol ]
 
 (* View: driver *)
@@ -177,6 +159,9 @@ let videoram = entry_int "VideoRam" /[vV]ideo[rR]am/
 (* View: default_depth *)
 let default_depth = entry_int "DefaultDepth" /[dD]efault[dD]epth/
 
+(* View: device *)
+let device = entry_str "Device" /[dD]evice/
+
 (************************************************************************
  * Group:                          DISPLAY SUBSECTION
  *************************************************************************)
@@ -184,7 +169,7 @@ let default_depth = entry_int "DefaultDepth" /[dD]efault[dD]epth/
 
 (* View: display_modes *)
 let display_modes = [ indent . del /[mM]odes/ "Modes" . label "Modes"
-                      . [ label "mode" . sep_spc . store quoted_word ]+
+                      . [ label "mode" . sep_spc . quoted_string_val ]+
                       . eol ]
 
 (*************************************************************************
@@ -274,6 +259,7 @@ let section_entry = option |
                     identifier |
                     videoram |
                     default_depth |
+                    device |
                     entry_generic |
                     empty | comment
 




More information about the augeas-devel mailing list