From c2c2339bf770f9efcce5fb12200dd2da49b38c92 Mon Sep 17 00:00:00 2001
From: David Lutterkort <lutter@redhat.com>
Date: Thu, 11 Aug 2011 11:39:08 -0700
Subject: [PATCH] Fix uses of Spacevars as a utility module

  - add Build.key_ws_value to do the same as Spacevars.entry
  - expand uses of (Spacevars.lns l) into the more explicit (comment|empty|l)*

This fixes test breakage introduced by commit 4840c7ab
---
 lenses/build.aug     | 14 ++++++++++++++
 lenses/slapd.aug     |  9 ++++++---
 lenses/spacevars.aug |  8 +-------
 lenses/squid.aug     |  6 ++++--
 4 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/lenses/build.aug b/lenses/build.aug
index 693a6118..e3dfa01f 100644
--- a/lenses/build.aug
+++ b/lenses/build.aug
@@ -130,6 +130,20 @@ let key_value_line_comment (kw:regexp) (sep:lens) (sto:lens) (comment:lens) =
 let key_value (kw: regexp) (sep:lens) (sto:lens) =
                                    [ key kw . sep . sto ]
 
+(************************************************************************
+ * View: key_ws_value
+ *
+ *   Store a key/value pair where key and value are separated by whitespace
+ *   and the value goes to the end of the line. Leading and trailing
+ *   whitespace is stripped from the value. The end of line is consumed by
+ *   this lens
+ *
+ *   Parameters:
+ *     kw:regexp - the pattern to match as key
+ ************************************************************************)
+let key_ws_value (kw:regexp) =
+  key_value_line kw Util.del_ws_spc (store Rx.space_in)
+
 (************************************************************************
  * View: flag
  *   A simple flag subnode, consisting of a single key
diff --git a/lenses/slapd.aug b/lenses/slapd.aug
index 246dfa1d..afe074b1 100644
--- a/lenses/slapd.aug
+++ b/lenses/slapd.aug
@@ -20,6 +20,9 @@ let sto_to_eol  = store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
 let sto_to_spc  = store /[^\\# \t\n]+/
 let sto_to_by   = store (/[^\\# \t\n]+/ - "by")
 
+let comment     = Util.comment
+let empty       = Util.empty
+
 (************************************************************************
  *                           ACCESS TO
  *************************************************************************)
@@ -97,7 +100,7 @@ let global_re   = "allow"
                 | "TLSCRLCheck"
                 | "backend"
 
-let global     = Spacevars.entry global_re
+let global     = Build.key_ws_value global_re
 
 (************************************************************************
  *                             DATABASE
@@ -141,13 +144,13 @@ let database    = [ key "database"
                   . spc
                   . sto_to_eol
                   . eol
-                  . Spacevars.lns (Spacevars.entry database_re|access) ]
+                  . (comment|empty|Build.key_ws_value database_re|access)* ]
 
 (************************************************************************
  *                              LENS
  *************************************************************************)
 
-let lns         = Spacevars.lns (global|access) . (database)*
+let lns         = (comment|empty|global|access)* . (database)*
 
 let filter      = incl "/etc/ldap/slapd.conf"
                 . incl "/etc/openldap/slapd.conf"
diff --git a/lenses/spacevars.aug b/lenses/spacevars.aug
index 46950864..ea0f5a30 100644
--- a/lenses/spacevars.aug
+++ b/lenses/spacevars.aug
@@ -14,21 +14,15 @@ module Spacevars =
  *                           USEFUL PRIMITIVES
  *************************************************************************)
 
-let eol     = Util.eol
-let spc     = Util.del_ws_spc
 let comment = Util.comment
 let empty   = Util.empty
 
-let sto_to_eol = store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
-
 (************************************************************************
  *                               ENTRIES
  *************************************************************************)
 
 
-let entry =
-  let kw = /[A-Za-z0-9\._-]+(\[[0-9]+\])?/ in
-  [ key kw . spc . sto_to_eol . eol ]
+let entry = Build.key_ws_value /[A-Za-z0-9\._-]+(\[[0-9]+\])?/
 
 (************************************************************************
  *                                LENS
diff --git a/lenses/squid.aug b/lenses/squid.aug
index 40291b86..29cef36b 100644
--- a/lenses/squid.aug
+++ b/lenses/squid.aug
@@ -20,6 +20,7 @@ let word        =  /[A-Za-z0-9!_.-]+(\[[0-9]+\])?/
 let sto_to_spc  = store /[^# \t\n]+/
 
 let comment     = Util.comment
+let empty       = Util.empty
 let comment_or_eol = Util.comment_or_eol
 let value (kw:string)
                 = [ spc . label kw . sto_to_spc ]
@@ -339,7 +340,8 @@ let entry_re =    "accept_filter"
                 | "zph_option"
                 | "zph_parent"
                 | "zph_sibling"
-let entry       = indent . Spacevars.entry entry_re
+
+let entry       = indent . (Build.key_ws_value entry_re)
 
 (************************************************************************
  *                                AUTH
@@ -422,7 +424,7 @@ let extension_methods = indent . [ key "extension_methods" . spc
  *                               LENS
  *************************************************************************)
 
-let lns         = Spacevars.lns (entry|auth|acl|http_access|refresh_pattern|extension_methods)
+let lns         = (comment|empty|entry|auth|acl|http_access|refresh_pattern|extension_methods)*
 
 let filter      = Util.stdexcl
                 . incl "/etc/squid/squid.conf"
-- 
2.16.3

