summaryrefslogtreecommitdiff
path: root/src/commit2.c
diff options
context:
space:
mode:
authorMichael Larson <slioch@slioch.vyatta.com>2010-02-15 09:40:48 -0800
committerMichael Larson <slioch@slioch.vyatta.com>2010-02-15 09:40:48 -0800
commit8ddf8669aa70830ce271e4837e41173e1fd069f8 (patch)
tree77d71848907228d197a649fd683909fb117e54bd /src/commit2.c
parent3b38a06aff94a1be2540a7f30e8ed1246b3a4af5 (diff)
downloadvyatta-cfg-8ddf8669aa70830ce271e4837e41173e1fd069f8.tar.gz
vyatta-cfg-8ddf8669aa70830ce271e4837e41173e1fd069f8.zip
fixed problem with sibling environment variable flag. Also added
designition for single entry (FIRSTLAST).
Diffstat (limited to 'src/commit2.c')
-rw-r--r--src/commit2.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/commit2.c b/src/commit2.c
index 788ef09..3143e51 100644
--- a/src/commit2.c
+++ b/src/commit2.c
@@ -447,15 +447,29 @@ process_func(GNode *node, gpointer data)
//set location env
setenv(ENV_DATA_PATH,d->_path,1);
- //do last sibling check
- GNode *n = g_node_last_sibling(node);
- if (n == node) {
- setenv(ENV_SIBLING_POSITION,"LAST",1);
+ //do first/last/only sibling check, restrict to nodes with operations defined
+ GNode *n_last_op = NULL;
+ GNode *n_first_op = NULL;
+
+ GNode *sib = g_node_first_sibling(node);
+ while (sib != NULL) {
+ if (!IS_NOOP(((struct VyattaNode*)(sib->data))->_data._operation)) {
+ if (n_first_op == NULL) {
+ n_first_op = sib;
+ }
+ n_last_op = sib;
+ }
+ sib = sib->next;
}
- n = g_node_first_sibling(node);
- if (n == node) {
+ if (n_last_op != NULL && n_first_op != NULL && node == n_first_op && node == n_last_op) {
+ setenv(ENV_SIBLING_POSITION,"FIRSTLAST",1);
+ }
+ else if (n_first_op != NULL && node == n_first_op) {
setenv(ENV_SIBLING_POSITION,"FIRST",1);
}
+ else if (n_last_op != NULL && node == n_last_op) {
+ setenv(ENV_SIBLING_POSITION,"LAST",1);
+ }
//do not set for promoted actions
if (!IS_ACTIVE(d->_operation)) {