1
0
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:
Jan Orel 2021-05-13 15:45:27 +02:00 committed by GitHub
parent 3c66d2788d
commit ed5e3b0dc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -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 *)

View File

@ -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