1

I recently assembled a lens in Augeas and now it's not functioning quite as desired.

My file contains a few references with the following syntax:

Value1 = KEY 32 OR\
   KEY 33 OR\
   ....

How do I represent the backslash newline combination and treat it as part of the same value?

EDIT - I'm running version .10.0

...
  let comment  = IniFile.comment IniFile.comment_re IniFile.comment_default
  let sep      = IniFile.sep IniFile.sep_re IniFile.sep_default
  let empty    = IniFile.empty

  let setting   = IniFile.entry_re
  let title   =  IniFile.indented_title_label "target" IniFile.record_label_re
  let entry    = [ key IniFile.entry_re . sep . IniFile.sto_to_comment . (comment|IniFile.eol) ] |
                 [ key IniFile.entry_re . store // . (comment|IniFile.eol) ] |
                 [ key /\![A-Za-z][A-Za-z0-9\._-]+/ . del / / " " . store /\/[A-Za-z0-9\.\/_-]+/ . (comment|IniFile.eol) ] |
                 comment

  let record    = IniFile.record title entry
  let record_anon = [ label ".anon" . ( entry | empty )+ ]

  let lns       = record_anon | record*

...

Tim Brigham
  • 15,545
  • 10
  • 75
  • 115
  • Can you post your lens code, too? – raphink Oct 15 '12 at 17:54
  • Are you sure your file is really an IniFile? IniFiles usually don't use a `\` for multiline values, just a newline with an indented line. – raphink Oct 15 '12 at 19:55
  • @ℝaphink - It isn't perfect but it was easier than creating any additional primitives. – Tim Brigham Oct 15 '12 at 20:20
  • I mean, do you really have sections in your file, or is it more of a [`Simplevars`](http://git.fedorahosted.org/cgit/augeas.git/tree/lenses/tests/test_simplevars.aug) kind of file with continuated lines? – raphink Oct 15 '12 at 20:43
  • @ℝaphink -There are sections included. Most of my files have sections, a few use the anon entries. – Tim Brigham Oct 15 '12 at 21:22
  • In that case, you will need to create a new kind of entry, similar to what is used in `Sudoers` or `Shellvars`, to support these continuated lines. – raphink Oct 16 '12 at 05:46

1 Answers1

2

Your lens is not written for multiline entries. If you want to support multiline entries, you need to use IniFile.entry_multiline:

let entry_multiline (kw:regexp) (sep:lens) (comment:lens)
                       = [ key kw . sep . sto_multiline? . (comment|eol) ] | comment

However, this definition doesn't recognize \ as a line continuation symbol because I've never seen an IniFile use it to this day. While \ is commonly used as a line continuation symbol for various key/value formats, IniFiles usually simply use indentation to determine if a line is a continuation of the previous one.

As a note, I don't think your definition of lns is really what you intend it to be:

let lns       = record_anon | record*

means, "one record_anon, followed by zero, one or more records", while I guess you probably mean "zero, one or more record_anon, followed by zero, one or more records", which is:

let lns       = record_anon* . record*
raphink
  • 11,987
  • 6
  • 37
  • 48