-
- expression_len = strlen(filter->expression);
- for(i=0;i<expression_len;i++) {
- // debug
-// g_print("%c\n ",filter->expression[i]);
- if(nest_quotes) {
- switch(filter->expression[i]) {
- case '\\' :
- if(filter->expression[i+1] == '\"') {
- i++;
- }
- break;
- case '\"':
- nest_quotes = 0;
- i++;
- break;
- }
- if(a_string_spaces->len != 0) {
- a_field_component = g_string_append(
- a_field_component, a_string_spaces->str);
- a_string_spaces = g_string_set_size(a_string_spaces, 0);
- }
- a_field_component = g_string_append_c(a_field_component,
- filter->expression[i]);
- continue;
- }
-
- switch(filter->expression[i]) {
- /*
- * logical operators
- */
- case '&': /* and */
-
- /* get current tree in tree stack */
- t1 = (LttvFilterTree*)g_ptr_array_index(tree_stack,tree_stack->len-1);
-
- /* get current node at absolute right */
- while(t1->right != LTTV_TREE_IDLE) {
- g_assert(t1->right == LTTV_TREE_NODE);
- t1 = t1->r_child.t;
- }
- t2 = lttv_filter_tree_new();
- t2->node = LTTV_LOGICAL_AND;
- t1->right = LTTV_TREE_NODE;
- t1->r_child.t = t2;
- if(not) { /* add not operator to tree */
- t3 = lttv_filter_tree_new();
- t3->node = LTTV_LOGICAL_NOT;
- t2->left = LTTV_TREE_NODE;
- t2->l_child.t = t3;
- t2 = t3;
- not = 0;
- }
- if(subtree != NULL) { /* append subtree to current tree */
- t2->left = LTTV_TREE_NODE;
- t2->l_child.t = subtree;
- subtree = NULL;
- } else { /* append a simple expression */
- lttv_simple_expression_assign_value(a_simple_expression,g_string_free(a_field_component,FALSE));
- a_field_component = g_string_new("");
- g_string_free(a_string_spaces, TRUE);
- a_string_spaces = g_string_new("");
- t2->left = LTTV_TREE_LEAF;
- t2->l_child.leaf = a_simple_expression;
- a_simple_expression = lttv_simple_expression_new();
- }
- break;
-
- case '|': /* or */
-
- t1 = (LttvFilterTree*)g_ptr_array_index(tree_stack,tree_stack->len-1);
- while(t1->right != LTTV_TREE_IDLE) {
- g_assert(t1->right == LTTV_TREE_NODE);
- t1 = t1->r_child.t;
- }
- t2 = lttv_filter_tree_new();
- t2->node = LTTV_LOGICAL_OR;
- t1->right = LTTV_TREE_NODE;
- t1->r_child.t = t2;
- if(not) { // add not operator to tree
- t3 = lttv_filter_tree_new();
- t3->node = LTTV_LOGICAL_NOT;
- t2->left = LTTV_TREE_NODE;
- t2->l_child.t = t3;
- t2 = t3;
- not = 0;
- }
- if(subtree != NULL) { /* append subtree to current tree */
- t2->left = LTTV_TREE_NODE;
- t2->l_child.t = subtree;
- subtree = NULL;
- } else { /* append a simple expression */
- lttv_simple_expression_assign_value(a_simple_expression,g_string_free(a_field_component,FALSE));
- a_field_component = g_string_new("");
- g_string_free(a_string_spaces, TRUE);
- a_string_spaces = g_string_new("");
- t2->left = LTTV_TREE_LEAF;
- t2->l_child.leaf = a_simple_expression;
- a_simple_expression = lttv_simple_expression_new();
- }
- break;
-
- case '^': /* xor */
-
- t1 = (LttvFilterTree*)g_ptr_array_index(tree_stack,tree_stack->len-1);
- while(t1->right != LTTV_TREE_IDLE) {
- g_assert(t1->right == LTTV_TREE_NODE);
- t1 = t1->r_child.t;
- }
- t2 = lttv_filter_tree_new();
- t2->node = LTTV_LOGICAL_XOR;
- t1->right = LTTV_TREE_NODE;
- t1->r_child.t = t2;
- if(not) { // add not operator to tree
- t3 = lttv_filter_tree_new();
- t3->node = LTTV_LOGICAL_NOT;
- t2->left = LTTV_TREE_NODE;
- t2->l_child.t = t3;
- t2 = t3;
- not = 0;
- }
- if(subtree != NULL) { /* append subtree to current tree */
- t2->left = LTTV_TREE_NODE;
- t2->l_child.t = subtree;
- subtree = NULL;
- } else { /* append a simple expression */
- lttv_simple_expression_assign_value(a_simple_expression,g_string_free(a_field_component,FALSE));
- a_field_component = g_string_new("");
- g_string_free(a_string_spaces, TRUE);
- a_string_spaces = g_string_new("");
- t2->left = LTTV_TREE_LEAF;
- t2->l_child.leaf = a_simple_expression;
- a_simple_expression = lttv_simple_expression_new();
- }
- break;
-
- case '!': /* not, or not equal (math op) */
-
- if(filter->expression[i+1] == '=') { /* != */
- g_ptr_array_add( a_field_path,(gpointer) a_field_component );
- lttv_simple_expression_assign_field(a_field_path,a_simple_expression);
- a_field_component = g_string_new("");
- g_string_free(a_string_spaces, TRUE);
- a_string_spaces = g_string_new("");
- lttv_simple_expression_assign_operator(a_simple_expression,LTTV_FIELD_NE);
- i++;
- } else { /* ! */
- not=1;
- }
- break;
-
- case '(': /* start of parenthesis */
- case '[':
- case '{':
-
- p_nesting++; /* incrementing parenthesis nesting value */
- t1 = lttv_filter_tree_new();
- if(not) { /* add not operator to tree */
- t3 = lttv_filter_tree_new();
- t3->node = LTTV_LOGICAL_NOT;
- t1->right = LTTV_TREE_NODE;
- t1->r_child.t = t3;
- not = 0;
- }
- g_ptr_array_add( tree_stack,(gpointer) t1 );
- break;
-
- case ')': /* end of parenthesis */
- case ']':
- case '}':
-
- p_nesting--; /* decrementing parenthesis nesting value */
- if(p_nesting<0 || tree_stack->len<2) {
- g_warning("Wrong filtering options, the string\n\"%s\"\n\
- is not valid due to parenthesis incorrect use",filter->expression);
- return FALSE;
- }
-
- /* there must at least be the root tree left in the array */
- g_assert(tree_stack->len>0);
-
- t1 = g_ptr_array_index(tree_stack,tree_stack->len-1);
- while(t1->right != LTTV_TREE_IDLE) {
- t1 = t1->r_child.t;
- }
- if(not) { // add not operator to tree
- g_print("ici");
- t3 = lttv_filter_tree_new();
- t3->node = LTTV_LOGICAL_NOT;
- t1->right = LTTV_TREE_NODE;
- t1->r_child.t = t3;
- t1 = t3;
- not = 0;
- }
- if(subtree != NULL) { /* append subtree to current tree */
- t1->right = LTTV_TREE_NODE;
- t1->r_child.t = subtree;
- subtree = g_ptr_array_index(tree_stack,tree_stack->len-1);
- g_ptr_array_remove_index(tree_stack,tree_stack->len-1);
- } else { /* assign subtree as current tree */
- lttv_simple_expression_assign_value(a_simple_expression,g_string_free(a_field_component,FALSE));
- a_field_component = g_string_new("");
- g_string_free(a_string_spaces, TRUE);
- a_string_spaces = g_string_new("");
- t1->right = LTTV_TREE_LEAF;
- t1->r_child.leaf = a_simple_expression;
- a_simple_expression = lttv_simple_expression_new();
- subtree = g_ptr_array_remove_index(tree_stack,tree_stack->len-1);
- }
- break;
-
- /*
- * mathematic operators
- */
- case '<': /* lower, lower or equal */
-
- g_ptr_array_add( a_field_path,(gpointer) a_field_component );
- lttv_simple_expression_assign_field(a_field_path,a_simple_expression);
- a_field_component = g_string_new("");
- g_string_free(a_string_spaces, TRUE);
- a_string_spaces = g_string_new("");
- if(filter->expression[i+1] == '=') { /* <= */
- i++;
- lttv_simple_expression_assign_operator(a_simple_expression,LTTV_FIELD_LE);
- } else lttv_simple_expression_assign_operator(a_simple_expression,LTTV_FIELD_LT);
- break;
-
- case '>': /* higher, higher or equal */
-
- g_ptr_array_add( a_field_path,(gpointer) a_field_component );
- lttv_simple_expression_assign_field(a_field_path,a_simple_expression);
- a_field_component = g_string_new("");
- g_string_free(a_string_spaces, TRUE);
- a_string_spaces = g_string_new("");
- if(filter->expression[i+1] == '=') { /* >= */
- i++;
- lttv_simple_expression_assign_operator(a_simple_expression,LTTV_FIELD_GE);
- } else lttv_simple_expression_assign_operator(a_simple_expression,LTTV_FIELD_GT);
- break;
-
- case '=': /* equal */
-
- g_ptr_array_add( a_field_path,(gpointer) a_field_component );
- lttv_simple_expression_assign_field(a_field_path,a_simple_expression);
- a_field_component = g_string_new("");
- g_string_free(a_string_spaces, TRUE);
- a_string_spaces = g_string_new("");
- lttv_simple_expression_assign_operator(a_simple_expression,LTTV_FIELD_EQ);
- break;
-
- /*
- * Field concatening caracter
- */
- case '.': /* dot */
-
- /*
- * divide field expression into elements
- * in a_field_path array.
- *
- * A dot can also be present in double values
- */
- if(a_simple_expression->field == LTTV_FILTER_UNDEFINED) {
- g_ptr_array_add( a_field_path,(gpointer) a_field_component );
- a_field_component = g_string_new("");
- g_string_free(a_string_spaces, TRUE);
- a_string_spaces = g_string_new("");
- } else {
- /* Operator found, we are in the value field */
- g_string_append_c(a_field_component, filter->expression[i]);
- }
- break;
- case ' ': /* keep spaces that are within a field component */
- if(a_field_component->len == 0) break; /* ignore */
- else
- a_string_spaces = g_string_append_c(a_string_spaces,
- filter->expression[i]);
-
- case '\n': /* ignore */
- break;
- case '\"':
- nest_quotes?(nest_quotes=0):(nest_quotes=1);
- break;
- default: /* concatening current string */
- if(a_string_spaces->len != 0) {
- a_field_component = g_string_append(
- a_field_component, a_string_spaces->str);
- a_string_spaces = g_string_set_size(a_string_spaces, 0);
- }
- a_field_component = g_string_append_c(a_field_component,
- filter->expression[i]);
- }
- }
-
- /*
- * Preliminary check to see
- * if tree was constructed correctly
- */
- if( p_nesting>0 ) {
- g_warning("Wrong filtering options, the string\n\"%s\"\n\
- is not valid due to parenthesis incorrect use",filter->expression);
- return FALSE;
- }
-
- if(tree_stack->len != 1) /* only root tree should remain */
- return FALSE;
-
- /*
- * processing last element of expression
- */
- t1 = g_ptr_array_index(tree_stack,tree_stack->len-1);
- while(t1->right != LTTV_TREE_IDLE) {
- g_assert(t1->right == LTTV_TREE_NODE);
- t1 = t1->r_child.t;
- }
- if(not) { // add not operator to tree
- t3 = lttv_filter_tree_new();
- t3->node = LTTV_LOGICAL_NOT;
- t1->right = LTTV_TREE_NODE;
- t1->r_child.t = t3;
- t1 = t3;
- not = 0;
- }
- if(subtree != NULL) { /* add the subtree */
- t1->right = LTTV_TREE_NODE;
- t1->r_child.t = subtree;
- subtree = NULL;
- } else { /* add a leaf */
- lttv_simple_expression_assign_value(a_simple_expression,g_string_free(a_field_component,FALSE));
- a_field_component = NULL;
- g_string_free(a_string_spaces, TRUE);
- a_string_spaces = NULL;
- t1->right = LTTV_TREE_LEAF;
- t1->r_child.leaf = a_simple_expression;
- a_simple_expression = NULL;
- }
-
-
- /* free the pointer array */
- g_assert(a_field_path->len == 0);
- g_ptr_array_free(a_field_path,TRUE);
-
- /* free the tree stack -- but keep the root tree */
- filter->head = ltt_g_ptr_array_remove_index_slow(tree_stack,0);
- g_ptr_array_free(tree_stack,TRUE);
-
- /* free the field buffer if allocated */
- if(a_field_component != NULL) g_string_free(a_field_component,TRUE);
- if(a_string_spaces != NULL) g_string_free(a_string_spaces, TRUE);
-
- /* free the simple expression buffer if allocated */
- if(a_simple_expression != NULL) lttv_simple_expression_destroy(a_simple_expression);
-
- g_assert(filter->head != NULL); /* tree should exist */
- g_assert(subtree == NULL); /* remaining subtree should be included in main tree */
-
+
+ expression_len = strlen(filter->expression);
+ for(i=0;i<expression_len;i++) {
+ // debug
+// g_print("%c\n ",filter->expression[i]);
+ if(nest_quotes) {
+ switch(filter->expression[i]) {
+ case '\\' :
+ if(filter->expression[i+1] == '\"') {
+ i++;
+ }
+ break;
+ case '\"':
+ nest_quotes = 0;
+ i++;
+ break;
+ }
+ if(a_string_spaces->len != 0) {
+ a_field_component = g_string_append(
+ a_field_component, a_string_spaces->str);
+ a_string_spaces = g_string_set_size(a_string_spaces, 0);
+ }
+ a_field_component = g_string_append_c(a_field_component,
+ filter->expression[i]);
+ continue;
+ }
+
+ switch(filter->expression[i]) {
+ /*
+ * logical operators
+ */
+ case '&': /* and */
+
+ /* get current tree in tree stack */
+ t1 = (LttvFilterTree*)g_ptr_array_index(tree_stack,tree_stack->len-1);
+
+ /* get current node at absolute right */
+ while(t1->right != LTTV_TREE_IDLE) {
+ g_assert(t1->right == LTTV_TREE_NODE);
+ t1 = t1->r_child.t;
+ }
+ t2 = lttv_filter_tree_new();
+ t2->node = LTTV_LOGICAL_AND;
+ t1->right = LTTV_TREE_NODE;
+ t1->r_child.t = t2;
+ if(not) { /* add not operator to tree */
+ t3 = lttv_filter_tree_new();
+ t3->node = LTTV_LOGICAL_NOT;
+ t2->left = LTTV_TREE_NODE;
+ t2->l_child.t = t3;
+ t2 = t3;
+ not = 0;
+ }
+ if(subtree != NULL) { /* append subtree to current tree */
+ t2->left = LTTV_TREE_NODE;
+ t2->l_child.t = subtree;
+ subtree = NULL;
+ } else { /* append a simple expression */
+ lttv_simple_expression_assign_value(a_simple_expression,
+ g_string_free(a_field_component,FALSE));
+ a_field_component = g_string_new("");
+ g_string_free(a_string_spaces, TRUE);
+ a_string_spaces = g_string_new("");
+ t2->left = LTTV_TREE_LEAF;
+ t2->l_child.leaf = a_simple_expression;
+ a_simple_expression = lttv_simple_expression_new();
+ }
+ break;
+
+ case '|': /* or */
+
+ t1 = (LttvFilterTree*)g_ptr_array_index(tree_stack,tree_stack->len-1);
+ while(t1->right != LTTV_TREE_IDLE) {
+ g_assert(t1->right == LTTV_TREE_NODE);
+ t1 = t1->r_child.t;
+ }
+ t2 = lttv_filter_tree_new();
+ t2->node = LTTV_LOGICAL_OR;
+ t1->right = LTTV_TREE_NODE;
+ t1->r_child.t = t2;
+ if(not) { // add not operator to tree
+ t3 = lttv_filter_tree_new();
+ t3->node = LTTV_LOGICAL_NOT;
+ t2->left = LTTV_TREE_NODE;
+ t2->l_child.t = t3;
+ t2 = t3;
+ not = 0;
+ }
+ if(subtree != NULL) { /* append subtree to current tree */
+ t2->left = LTTV_TREE_NODE;
+ t2->l_child.t = subtree;
+ subtree = NULL;
+ } else { /* append a simple expression */
+ lttv_simple_expression_assign_value(a_simple_expression,
+ g_string_free(a_field_component,FALSE));
+ a_field_component = g_string_new("");
+ g_string_free(a_string_spaces, TRUE);
+ a_string_spaces = g_string_new("");
+ t2->left = LTTV_TREE_LEAF;
+ t2->l_child.leaf = a_simple_expression;
+ a_simple_expression = lttv_simple_expression_new();
+ }
+ break;
+
+ case '^': /* xor */
+
+ t1 = (LttvFilterTree*)g_ptr_array_index(tree_stack,tree_stack->len-1);
+ while(t1->right != LTTV_TREE_IDLE) {
+ g_assert(t1->right == LTTV_TREE_NODE);
+ t1 = t1->r_child.t;
+ }
+ t2 = lttv_filter_tree_new();
+ t2->node = LTTV_LOGICAL_XOR;
+ t1->right = LTTV_TREE_NODE;
+ t1->r_child.t = t2;
+ if(not) { // add not operator to tree
+ t3 = lttv_filter_tree_new();
+ t3->node = LTTV_LOGICAL_NOT;
+ t2->left = LTTV_TREE_NODE;
+ t2->l_child.t = t3;
+ t2 = t3;
+ not = 0;
+ }
+ if(subtree != NULL) { /* append subtree to current tree */
+ t2->left = LTTV_TREE_NODE;
+ t2->l_child.t = subtree;
+ subtree = NULL;
+ } else { /* append a simple expression */
+ lttv_simple_expression_assign_value(a_simple_expression,
+ g_string_free(a_field_component,FALSE));
+ a_field_component = g_string_new("");
+ g_string_free(a_string_spaces, TRUE);
+ a_string_spaces = g_string_new("");
+ t2->left = LTTV_TREE_LEAF;
+ t2->l_child.leaf = a_simple_expression;
+ a_simple_expression = lttv_simple_expression_new();
+ }
+ break;
+
+ case '!': /* not, or not equal (math op) */
+
+ if(filter->expression[i+1] == '=') { /* != */
+ g_ptr_array_add( a_field_path,(gpointer) a_field_component );
+ lttv_simple_expression_assign_field(a_field_path,a_simple_expression);
+ a_field_component = g_string_new("");
+ g_string_free(a_string_spaces, TRUE);
+ a_string_spaces = g_string_new("");
+ lttv_simple_expression_assign_operator(a_simple_expression,LTTV_FIELD_NE);
+ i++;
+ } else { /* ! */
+ not=1;
+ }
+ break;
+
+ case '(': /* start of parenthesis */
+ case '[':
+ case '{':
+
+ p_nesting++; /* incrementing parenthesis nesting value */
+ t1 = lttv_filter_tree_new();
+ if(not) { /* add not operator to tree */
+ t3 = lttv_filter_tree_new();
+ t3->node = LTTV_LOGICAL_NOT;
+ t1->right = LTTV_TREE_NODE;
+ t1->r_child.t = t3;
+ not = 0;
+ }
+ g_ptr_array_add( tree_stack,(gpointer) t1 );
+ break;
+
+ case ')': /* end of parenthesis */
+ case ']':
+ case '}':
+
+ p_nesting--; /* decrementing parenthesis nesting value */
+ if(p_nesting<0 || tree_stack->len<2) {
+ g_warning("Wrong filtering options, the string\n\"%s\"\n\
+ is not valid due to parenthesis incorrect use",filter->expression);
+ return FALSE;
+ }
+
+ /* there must at least be the root tree left in the array */
+ g_assert(tree_stack->len>0);
+
+ t1 = g_ptr_array_index(tree_stack,tree_stack->len-1);
+ while(t1->right != LTTV_TREE_IDLE) {
+ t1 = t1->r_child.t;
+ }
+ if(not) { // add not operator to tree
+ g_print("ici");
+ t3 = lttv_filter_tree_new();
+ t3->node = LTTV_LOGICAL_NOT;
+ t1->right = LTTV_TREE_NODE;
+ t1->r_child.t = t3;
+ t1 = t3;
+ not = 0;
+ }
+ if(subtree != NULL) { /* append subtree to current tree */
+ t1->right = LTTV_TREE_NODE;
+ t1->r_child.t = subtree;
+ subtree = g_ptr_array_index(tree_stack,tree_stack->len-1);
+ g_ptr_array_remove_index(tree_stack,tree_stack->len-1);
+ } else { /* assign subtree as current tree */
+ lttv_simple_expression_assign_value(a_simple_expression,
+ g_string_free(a_field_component,FALSE));
+ a_field_component = g_string_new("");
+ g_string_free(a_string_spaces, TRUE);
+ a_string_spaces = g_string_new("");
+ t1->right = LTTV_TREE_LEAF;
+ t1->r_child.leaf = a_simple_expression;
+ a_simple_expression = lttv_simple_expression_new();
+ subtree = g_ptr_array_remove_index(tree_stack,tree_stack->len-1);
+ }
+ break;
+
+ /*
+ * mathematic operators
+ */
+ case '<': /* lower, lower or equal */
+
+ g_ptr_array_add( a_field_path,(gpointer) a_field_component );
+ lttv_simple_expression_assign_field(a_field_path,a_simple_expression);
+ a_field_component = g_string_new("");
+ g_string_free(a_string_spaces, TRUE);
+ a_string_spaces = g_string_new("");
+ if(filter->expression[i+1] == '=') { /* <= */
+ i++;
+ lttv_simple_expression_assign_operator(a_simple_expression,
+ LTTV_FIELD_LE);
+ } else lttv_simple_expression_assign_operator(a_simple_expression,
+ LTTV_FIELD_LT);
+ break;
+
+ case '>': /* higher, higher or equal */
+
+ g_ptr_array_add( a_field_path,(gpointer) a_field_component );
+ lttv_simple_expression_assign_field(a_field_path,a_simple_expression);
+ a_field_component = g_string_new("");
+ g_string_free(a_string_spaces, TRUE);
+ a_string_spaces = g_string_new("");
+ if(filter->expression[i+1] == '=') { /* >= */
+ i++;
+ lttv_simple_expression_assign_operator(a_simple_expression,
+ LTTV_FIELD_GE);
+ } else lttv_simple_expression_assign_operator(a_simple_expression,
+ LTTV_FIELD_GT);
+ break;
+
+ case '=': /* equal */
+
+ g_ptr_array_add( a_field_path,(gpointer) a_field_component );
+ lttv_simple_expression_assign_field(a_field_path,a_simple_expression);
+ a_field_component = g_string_new("");
+ g_string_free(a_string_spaces, TRUE);
+ a_string_spaces = g_string_new("");
+ lttv_simple_expression_assign_operator(a_simple_expression,LTTV_FIELD_EQ);
+ break;
+
+ /*
+ * Field concatening caracter
+ */
+ case '.': /* dot */
+
+ /*
+ * divide field expression into elements
+ * in a_field_path array.
+ *
+ * A dot can also be present in double values
+ */
+ if(a_simple_expression->field == LTTV_FILTER_UNDEFINED) {
+ g_ptr_array_add( a_field_path,(gpointer) a_field_component );
+ a_field_component = g_string_new("");
+ g_string_free(a_string_spaces, TRUE);
+ a_string_spaces = g_string_new("");
+ } else {
+ /* Operator found, we are in the value field */
+ g_string_append_c(a_field_component, filter->expression[i]);
+ }
+ break;
+ case ' ': /* keep spaces that are within a field component */
+ if(a_field_component->len == 0) break; /* ignore */
+ else
+ a_string_spaces = g_string_append_c(a_string_spaces,
+ filter->expression[i]);
+
+ case '\n': /* ignore */
+ break;
+ case '\"':
+ nest_quotes?(nest_quotes=0):(nest_quotes=1);
+ break;
+ default: /* concatening current string */
+ if(a_string_spaces->len != 0) {
+ a_field_component = g_string_append(
+ a_field_component, a_string_spaces->str);
+ a_string_spaces = g_string_set_size(a_string_spaces, 0);
+ }
+ a_field_component = g_string_append_c(a_field_component,
+ filter->expression[i]);
+ }
+ }
+
+ /*
+ * Preliminary check to see
+ * if tree was constructed correctly
+ */
+ if( p_nesting>0 ) {
+ g_warning("Wrong filtering options, the string\n\"%s\"\n\
+ is not valid due to parenthesis incorrect use",filter->expression);
+ return FALSE;
+ }
+
+ if(tree_stack->len != 1) /* only root tree should remain */
+ return FALSE;
+
+ /*
+ * processing last element of expression
+ */
+ t1 = g_ptr_array_index(tree_stack,tree_stack->len-1);
+ while(t1->right != LTTV_TREE_IDLE) {
+ g_assert(t1->right == LTTV_TREE_NODE);
+ t1 = t1->r_child.t;
+ }
+ if(not) { // add not operator to tree
+ t3 = lttv_filter_tree_new();
+ t3->node = LTTV_LOGICAL_NOT;
+ t1->right = LTTV_TREE_NODE;
+ t1->r_child.t = t3;
+ t1 = t3;
+ not = 0;
+ }
+ if(subtree != NULL) { /* add the subtree */
+ t1->right = LTTV_TREE_NODE;
+ t1->r_child.t = subtree;
+ subtree = NULL;
+ } else { /* add a leaf */
+ lttv_simple_expression_assign_value(a_simple_expression,g_string_free(a_field_component,FALSE));
+ a_field_component = NULL;
+ g_string_free(a_string_spaces, TRUE);
+ a_string_spaces = NULL;
+ t1->right = LTTV_TREE_LEAF;
+ t1->r_child.leaf = a_simple_expression;
+ a_simple_expression = NULL;
+ }
+
+
+ /* free the pointer array */
+ g_assert(a_field_path->len == 0);
+ g_ptr_array_free(a_field_path,TRUE);
+
+ /* free the tree stack -- but keep the root tree */
+ filter->head = ltt_g_ptr_array_remove_index_slow(tree_stack,0);
+ g_ptr_array_free(tree_stack,TRUE);
+
+ /* free the field buffer if allocated */
+ if(a_field_component != NULL) g_string_free(a_field_component,TRUE);
+ if(a_string_spaces != NULL) g_string_free(a_string_spaces, TRUE);
+
+ /* free the simple expression buffer if allocated */
+ if(a_simple_expression != NULL) lttv_simple_expression_destroy(a_simple_expression);
+
+ g_assert(filter->head != NULL); /* tree should exist */
+ g_assert(subtree == NULL); /* remaining subtree should be included in main tree */
+