From 8ddf8669aa70830ce271e4837e41173e1fd069f8 Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Mon, 15 Feb 2010 09:40:48 -0800 Subject: fixed problem with sibling environment variable flag. Also added designition for single entry (FIRSTLAST). --- src/commit2.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'src/commit2.c') 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)) { -- cgit v1.2.3