[augeas-devel] [PATCH] Complain when nodes in the tree can not be put

David Lutterkort lutter at redhat.com
Wed Oct 1 23:38:15 UTC 2008


3 files changed, 10 insertions(+), 3 deletions(-)
src/put.c                            |    2 +-
tests/modules/pass_put_bad_label.aug |    9 +++++++++
tests/rec-hosts-add.rb               |    2 --


# HG changeset patch
# User David Lutterkort <lutter at redhat.com>
# Date 1222904282 25200
# Node ID 5ee02f496ee45ce60b034ab9088063928c20ef2d
# Parent  fd2d461fd6520a47f51199a0e1576a8d83bb7c2c
Complain when nodes in the tree can not be put

When nodes are added to the tree that do not match the appropriate
key/label lens, we used to silently drop them if the key/label was inside a
repetition inside a concat.

Now, we check when we split the tree for a concat that we have used all the
nodes in the tree that we were supposed to, and complain otherwise.

This also uncovered that the test rec-hosts-add.rb was broken, but still
passed.

diff -r fd2d461fd652 -r 5ee02f496ee4 src/put.c
--- a/src/put.c	Wed Oct 01 16:19:56 2008 -0700
+++ b/src/put.c	Wed Oct 01 16:38:02 2008 -0700
@@ -194,7 +194,7 @@
     if (count == -2) {
         FIXME("Match failed - produce better error");
         abort();
-    } else if (count == -1) {
+    } else if (count == -1 || count != outer->end - outer->start) {
         char *labels = strndup(outer->labels + outer->start,
                                outer->end - outer->start);
         put_error(state, lens,
diff -r fd2d461fd652 -r 5ee02f496ee4 tests/modules/pass_put_bad_label.aug
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/modules/pass_put_bad_label.aug	Wed Oct 01 16:38:02 2008 -0700
@@ -0,0 +1,9 @@
+module Pass_put_bad_label =
+
+  let entry = [ key /[a-z]+/ . del /=/ "=" . store /[0-9]+/ . del "\n" "\n" ]
+
+  let lns = [ key /[A-Z]+/ . del "\n" "\n" . entry* ]
+              
+  test lns put "SECTION\na=1\nz=26\n" after 
+    insa "B" "/SECTION/a";
+    set "/SECTION/B" "2" = *
diff -r fd2d461fd652 -r 5ee02f496ee4 tests/rec-hosts-add.rb
--- a/tests/rec-hosts-add.rb	Wed Oct 01 16:19:56 2008 -0700
+++ b/tests/rec-hosts-add.rb	Wed Oct 01 16:38:02 2008 -0700
@@ -4,8 +4,6 @@
 ins 10000 before /files/etc/hosts/2
 set /files/etc/hosts/10000/ipaddr 192.168.0.1
 set /files/etc/hosts/10000/canonical pigiron.example.com
-clear /files/etc/hosts/10000/aliases
-print
 save
 "
 refresh=true




More information about the augeas-devel mailing list