mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-11 04:58:16 +03:00
M #-: Let oned.aug parse space leading comment (#1209)
This commit is contained in:
parent
3c66d2788d
commit
ed5e3b0dc1
@ -1,9 +1,10 @@
|
||||
module Oned =
|
||||
autoload xfm
|
||||
|
||||
(* Version: 1.4 *)
|
||||
(* Version: 1.5 *)
|
||||
|
||||
(* Change log: *)
|
||||
(* 1.5: Allow space before comment *)
|
||||
(* 1.4: Allow space after section *)
|
||||
(* 1.3: Allow escaped quotes in values *)
|
||||
(* 1.2: Include /etc/one/monitord.conf *)
|
||||
@ -30,8 +31,12 @@ let re_section_value_str = /[^ \t\n"#,]+/
|
||||
|
||||
(* Store either after-value comment or full-line comment *)
|
||||
let comment = [ label "#comment" . store /#[^\n]*/ ]
|
||||
let comment_eol = comment . eol
|
||||
|
||||
(* Comment with leading space *)
|
||||
let space_comment = [ label "#comment" . store /[ \t][ \t]*#[^\n]*/ ]
|
||||
|
||||
let comment_eol = comment . eol
|
||||
let space_comment_eol = space_comment . eol
|
||||
|
||||
(* Simple words *)
|
||||
let name = key /[A-Za-z_0-9]+/
|
||||
@ -66,7 +71,7 @@ let section = opt_space
|
||||
let empty_line = [ del /[ \t]*\n/ "\n" ]
|
||||
|
||||
(* Main lens *)
|
||||
let lns = ( top_level_line | comment_eol | section | empty_line )*
|
||||
let lns = ( top_level_line | comment_eol | space_comment_eol | section | empty_line )*
|
||||
|
||||
|
||||
(* Variable: filter *)
|
||||
|
@ -39,6 +39,13 @@ LOG = [
|
||||
|
||||
test Oned.lns get
|
||||
"A=1
|
||||
# comment
|
||||
# comment with leading space
|
||||
# comment with leading tab
|
||||
" =?
|
||||
|
||||
test Oned.lns get
|
||||
"A=1
|
||||
A=1
|
||||
B=2 # comment
|
||||
# abc
|
||||
|
Loading…
x
Reference in New Issue
Block a user