|
|
4b6aa8 |
From 3fc1e286151e12b3229750da7a550b8f799a35bc Mon Sep 17 00:00:00 2001
|
|
|
4b6aa8 |
From: Julius Milan <jmilan@redhat.com>
|
|
|
4b6aa8 |
Date: Wed, 22 Mar 2017 14:10:04 +0100
|
|
|
4b6aa8 |
Subject: [PATCH] augeas: trim spaces on eol, around value separator
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
Resolves abrt/libreport#474
|
|
|
4b6aa8 |
Related to rhbz#1435256
|
|
|
4b6aa8 |
---
|
|
|
4b6aa8 |
augeas/libreport.aug | 19 ++++++++++++-------
|
|
|
4b6aa8 |
augeas/test_libreport.aug | 20 ++++++++++++++++++++
|
|
|
4b6aa8 |
2 files changed, 32 insertions(+), 7 deletions(-)
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
diff --git a/augeas/libreport.aug b/augeas/libreport.aug
|
|
|
4b6aa8 |
index 7125be2..76b3bcc 100644
|
|
|
4b6aa8 |
--- a/augeas/libreport.aug
|
|
|
4b6aa8 |
+++ b/augeas/libreport.aug
|
|
|
4b6aa8 |
@@ -2,19 +2,24 @@ module Libreport =
|
|
|
4b6aa8 |
autoload xfm
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
(* Define useful primitives *)
|
|
|
4b6aa8 |
- let value_sep = del / ?= ?/ " = "
|
|
|
4b6aa8 |
- let value_to_eol = store /([^ \t\n].*[^ \t\n]|[^ \t\n]?)/
|
|
|
4b6aa8 |
- let eol = del /\n/ "\n"
|
|
|
4b6aa8 |
- let ident = /[a-zA-Z][a-zA-Z_]+/
|
|
|
4b6aa8 |
+ let val_sep = del /[ \t]*=[ \t]*/ " = "
|
|
|
4b6aa8 |
+ let val = store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
|
|
|
4b6aa8 |
+ let eol = del /\n/ "\n"
|
|
|
4b6aa8 |
+ let whitespace_eol = del /[ \t]*\n/ "\n"
|
|
|
4b6aa8 |
+ let ident = /[a-zA-Z][a-zA-Z_]+/
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
(* Define comment *)
|
|
|
4b6aa8 |
- let comment = [ label "#comment" . del /#[ \t]*/ "# " . value_to_eol . eol ]
|
|
|
4b6aa8 |
+ let commented_line = [ label "#comment" . del /#[ \t]*/ "# " . val . eol ]
|
|
|
4b6aa8 |
+ let empty_comment = [ label "#comment" . value "" . del /#[ \t]*/ "# " . eol ]
|
|
|
4b6aa8 |
+ let comment = commented_line | empty_comment
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
(* Define empty *)
|
|
|
4b6aa8 |
- let empty = [ del /[ \t]*\n/ "\n" ]
|
|
|
4b6aa8 |
+ let empty = [ del /[ \t]*\n/ "\n" ]
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
(* Define option *)
|
|
|
4b6aa8 |
- let option = [ del /[ \t]*/ "" . key ident . value_sep . value_to_eol . eol ]
|
|
|
4b6aa8 |
+ let option_val = [ del /[ \t]*/ "" . key ident . val_sep . val . whitespace_eol ]
|
|
|
4b6aa8 |
+ let option_no_val = [ value "" . del /[ \t]*/ "" . key ident . val_sep . eol ]
|
|
|
4b6aa8 |
+ let option = option_val | option_no_val
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
(* Define lens *)
|
|
|
4b6aa8 |
let lns = ( comment | empty | option )*
|
|
|
4b6aa8 |
diff --git a/augeas/test_libreport.aug b/augeas/test_libreport.aug
|
|
|
4b6aa8 |
index 116e97c..3dfbfa6 100644
|
|
|
4b6aa8 |
--- a/augeas/test_libreport.aug
|
|
|
4b6aa8 |
+++ b/augeas/test_libreport.aug
|
|
|
4b6aa8 |
@@ -16,6 +16,8 @@ Password =
|
|
|
4b6aa8 |
# bugs in selinux-policy component.
|
|
|
4b6aa8 |
# (If you need to add more, the syntax is: \"component[,component...]\")
|
|
|
4b6aa8 |
#
|
|
|
4b6aa8 |
+#
|
|
|
4b6aa8 |
+#
|
|
|
4b6aa8 |
DontMatchComponents = selinux-policy
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
# for more info about these settings see: https://github.com/abrt/abrt/wiki/FAQ#creating-private-bugzilla-tickets
|
|
|
4b6aa8 |
@@ -25,6 +27,14 @@ PrivateGroups=private
|
|
|
4b6aa8 |
Whitespace_two=start
|
|
|
4b6aa8 |
Whitespace_three =start
|
|
|
4b6aa8 |
Whitespace_four= start
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+AssignmentWhitespace_a =what
|
|
|
4b6aa8 |
+ AssignmentWhitespace_b = an
|
|
|
4b6aa8 |
+AssignmentWhitespace_c= original
|
|
|
4b6aa8 |
+ AssignmentWhitespace_d = idea
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+EOLWhitespace_a = nice
|
|
|
4b6aa8 |
+EOLWhitespace_b = nice
|
|
|
4b6aa8 |
"
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
test Libreport.lns get conf =
|
|
|
4b6aa8 |
@@ -44,6 +54,8 @@ PrivateGroups=private
|
|
|
4b6aa8 |
{ "#comment" = "bugs in selinux-policy component." }
|
|
|
4b6aa8 |
{ "#comment" = "(If you need to add more, the syntax is: \"component[,component...]\")" }
|
|
|
4b6aa8 |
{ "#comment" = "" }
|
|
|
4b6aa8 |
+ { "#comment" = "" }
|
|
|
4b6aa8 |
+ { "#comment" = "" }
|
|
|
4b6aa8 |
{ "DontMatchComponents" = "selinux-policy" }
|
|
|
4b6aa8 |
{}
|
|
|
4b6aa8 |
{ "#comment" = "for more info about these settings see: https://github.com/abrt/abrt/wiki/FAQ#creating-private-bugzilla-tickets" }
|
|
|
4b6aa8 |
@@ -53,3 +65,11 @@ PrivateGroups=private
|
|
|
4b6aa8 |
{ "Whitespace_two" = "start" }
|
|
|
4b6aa8 |
{ "Whitespace_three" = "start" }
|
|
|
4b6aa8 |
{ "Whitespace_four" = "start" }
|
|
|
4b6aa8 |
+ {}
|
|
|
4b6aa8 |
+ { "AssignmentWhitespace_a" = "what" }
|
|
|
4b6aa8 |
+ { "AssignmentWhitespace_b" = "an" }
|
|
|
4b6aa8 |
+ { "AssignmentWhitespace_c" = "original" }
|
|
|
4b6aa8 |
+ { "AssignmentWhitespace_d" = "idea" }
|
|
|
4b6aa8 |
+ {}
|
|
|
4b6aa8 |
+ { "EOLWhitespace_a" = "nice" }
|
|
|
4b6aa8 |
+ { "EOLWhitespace_b" = "nice" }
|
|
|
4b6aa8 |
--
|
|
|
4b6aa8 |
1.8.3.1
|
|
|
4b6aa8 |
|