[augeas-devel] [PATCH 2 of 2] Test that putting into an empty string works

David Lutterkort dlutter at redhat.com
Wed Jul 9 17:38:01 UTC 2008


2 files changed, 21 insertions(+)
src/builtin.c                    |   13 +++++++++++++
tests/modules/pass_empty_put.aug |    8 ++++++++


# HG changeset patch
# User David Lutterkort <dlutter at redhat.com>
# Date 1215625029 25200
# Node ID 6a27483c0c44486e565220c4b8a9ceef1d71cc00
# Parent  fde82628a659edb0d30fb4b095ba31e3d9bca8a2
Test that putting into an empty string works

diff -r fde82628a659 -r 6a27483c0c44 src/builtin.c
--- a/src/builtin.c	Wed Jul 09 10:09:10 2008 -0700
+++ b/src/builtin.c	Wed Jul 09 10:37:09 2008 -0700
@@ -168,11 +168,24 @@
     assert(path->tag == V_STRING);
     assert(val->tag == V_STRING);
     assert(tree->tag == V_TREE);
+
+    struct tree *fake = NULL;
+
+    if (tree->tree == NULL) {
+        fake = make_tree(NULL, NULL, NULL);
+        tree->tree = fake;
+    }
+
     if (tree_set(tree->tree, path->string->str, val->string->str) == NULL) {
         return make_exn_value(ref(info),
                               "Tree set of %s to '%s' failed",
                               path->string->str, val->string->str);
     }
+    if (fake != NULL) {
+        list_remove(fake, tree->tree);
+        free_tree(fake);
+    }
+
     return ref(tree);
 }
 
diff -r fde82628a659 -r 6a27483c0c44 tests/modules/pass_empty_put.aug
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/modules/pass_empty_put.aug	Wed Jul 09 10:37:09 2008 -0700
@@ -0,0 +1,8 @@
+module Pass_empty_put =
+
+  let eol = del "\n" "\n"
+  let lns = [ key /[a-z]+/ . del /[ \t]+/ " " . store /[a-z]+/ . eol ]*
+
+  test lns put "" after
+    set "entry" "value"
+  = "entry value\n"




More information about the augeas-devel mailing list