[augeas-devel] [PATCH] Fix bug#144: wrong behavior of iter concat
francis.giraldeau at usherbrooke.ca
francis.giraldeau at usherbrooke.ca
Fri Oct 22 18:09:07 UTC 2010
From: Francis Giraldeau <francis.giraldeau at gmail.com>
This patch adds a new macro to fastforward a tail list, in the case where a
tree added have multiple children.
Also, fix the test_interface.aug module for trivial empty node missing that the
fix revealed.
---
lenses/tests/test_interfaces.aug | 1 +
src/get.c | 1 +
src/list.h | 15 +++++++++++++++
tests/modules/pass_iter_concat.aug | 7 +++++++
4 files changed, 24 insertions(+), 0 deletions(-)
create mode 100644 tests/modules/pass_iter_concat.aug
diff --git a/lenses/tests/test_interfaces.aug b/lenses/tests/test_interfaces.aug
index 0c40296..a768e25 100644
--- a/lenses/tests/test_interfaces.aug
+++ b/lenses/tests/test_interfaces.aug
@@ -47,6 +47,7 @@ mapping eth1
{ "2" = "eth0" }
{ "3" = "#foo" } }
{ "allow-hotplug" { "1" = "eth1" } }
+ {}
{ "iface" = "lo"
{ "family" = "inet"}
{ "method" = "loopback"} {} }
diff --git a/src/get.c b/src/get.c
index 11ea5de..9d420af 100644
--- a/src/get.c
+++ b/src/get.c
@@ -572,6 +572,7 @@ static struct tree *get_quant_star(struct lens *lens, struct state *state) {
t = get_lens(lens->child, state);
list_tail_cons(tree, tail, t);
+ list_update_tail(tree, tail);
start += REG_SIZE(state);
size -= REG_SIZE(state);
diff --git a/src/list.h b/src/list.h
index eb9f84f..cb45435 100644
--- a/src/list.h
+++ b/src/list.h
@@ -125,6 +125,21 @@
} while(0)
/*
+ * Fast forward the tail
+ */
+#define list_update_tail(list, tail) \
+ do { \
+ if ((tail) == NULL) { \
+ for ((tail) = (list); (tail)->next != NULL; \
+ (tail) = (tail)->next); \
+ } else { \
+ while((tail)->next != NULL) { \
+ (tail) = (tail)->next; \
+ } \
+ } \
+ } while (0)
+
+/*
* Local variables:
* indent-tabs-mode: nil
* c-indent-level: 4
diff --git a/tests/modules/pass_iter_concat.aug b/tests/modules/pass_iter_concat.aug
new file mode 100644
index 0000000..00dc4d8
--- /dev/null
+++ b/tests/modules/pass_iter_concat.aug
@@ -0,0 +1,7 @@
+module Pass_iter_concat =
+
+let l1 = [ key "a" . del "x" "x" ]
+let l2 = [ key "b" . del "y" "y" ]
+let l3 = (l1 . l2)*
+
+test l3 get "axbyaxby" = { "a" }{ "b" }{ "a" }{ "b" }
--
1.7.1
More information about the augeas-devel
mailing list