[augeas-devel] [PATCH] Add mysql.aug and associated test

David Lutterkort lutter at redhat.com
Wed Sep 3 21:28:44 UTC 2008


On Wed, 2008-09-03 at 22:06 +0200, Raphaël Pinson wrote:

> Unfortunately, I believe that mysql.aug supports both empty key/value
> pairs (i.e. 'field = \n') and flags (i.e. 'field\n').
...
> I still don't really see how to fix that though, except by making two
> separated lenses for entries and flags, which forces me to indicate
> the names of the values for each kind, so they don't overlap on put.

The problem comes from using del twice. Your lens is roughly
        (del /[ \t]*=/ "=" . (del /[ \t]*/ "" . store /[a-z]+/)?)?

i.e., you use one del for the '=' sign and another for the whitespace
before the store. If you write this as

        (del /[ \t]*=[ \t]*/ . store /[a-z]*/)?
        
all the cases should be covered. Attached is a test that shows that.

David


        


-------------- next part --------------
module Td =

let val = (del /[ \t]*=[ \t]*/ "=" . store /[a-z]*/)?
let lns = [ key /[a-z]+/ . val ]

test lns get "key=value" = { "key" = "value" }

test lns get "noval=  " = { "noval" = "" }

test lns get "flag" = { "flag" }

test lns put "flag" after set "flag" "value" = "flag=value"
test lns put "noval =  " after set "noval" "value" = "noval =  value"







More information about the augeas-devel mailing list