From ed5e3b0dc15c6bb9d579ed700d3e26851e9f8781 Mon Sep 17 00:00:00 2001 From: Jan Orel Date: Thu, 13 May 2021 15:45:27 +0200 Subject: [PATCH] M #-: Let oned.aug parse space leading comment (#1209) --- share/augeas/oned.aug | 11 ++++++++--- share/augeas/test_oned.aug | 7 +++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/share/augeas/oned.aug b/share/augeas/oned.aug index 1501f74806..4f19bb7530 100644 --- a/share/augeas/oned.aug +++ b/share/augeas/oned.aug @@ -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 *) diff --git a/share/augeas/test_oned.aug b/share/augeas/test_oned.aug index 6c577eb44f..f264da646d 100644 --- a/share/augeas/test_oned.aug +++ b/share/augeas/test_oned.aug @@ -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