* - the exists an other lttv_filter which conflicts with this one
*/
+/*
+ * TODO
+ * - refine switch of expression in multiple uses functions
+ * - add the current simple expression to the tree
+ */
+
#include <lttv/filter.h>
/*
*/
lttv_filter_tree* tree = lttv_filter_tree_new();
lttv_filter_tree* subtree = NULL;
-// lttv_filter_tree* current_tree = NULL;
GPtrArray *tree_stack = g_ptr_array_new();
g_ptr_array_add( tree_stack,(gpointer) tree );
for(i=0;i<strlen(expression);i++) {
// g_print("%s\n",a_field_component->str);
- g_print("%c\n",expression[i]);
+ g_print("%c ",expression[i]);
switch(expression[i]) {
/*
* logical operators
*/
case '&': /* and */
- t1 = g_ptr_array_index(tree_stack,tree_stack->len-1);
+ t1 = (lttv_filter_tree*)g_ptr_array_index(tree_stack,tree_stack->len-1);
while(t1->right != LTTV_TREE_UNDEFINED) t1 = t1->r_child.t;
t2 = lttv_filter_tree_new();
t2->node->type = LTTV_EXPRESSION_OP;
t2->l_child.t = subtree;
subtree = NULL;
t1->right = LTTV_TREE_NODE;
- t1->l_child.t = t2;
+ t1->r_child.t = t2;
} else {
a_simple_expression.value = a_field_component->str;
a_field_component = g_string_new("");
t2->left = LTTV_TREE_LEAF;
t2->l_child.leaf = g_new(lttv_simple_expression,1);
t1->right = LTTV_TREE_NODE;
- t1->l_child.t = t2;
+ t1->r_child.t = t2;
}
break;
g_assert(tree_stack->len>0);
if(subtree != NULL) {
t1 = g_ptr_array_index(tree_stack,tree_stack->len-1);
- /* FIXME ==> SEG FAULT */
while(t1->right != LTTV_TREE_UNDEFINED && t1->right != LTTV_TREE_LEAF) {
g_assert(t1!=NULL && t1->r_child.t != NULL);
t1 = t1->r_child.t;
g_string_append_c(a_field_component,expression[i]);
}
}
-
-
+
+ /* processing last element of expression */
+ g_assert(tree_stack->len==1); /* only root tree should remain */
+ t1 = g_ptr_array_index(tree_stack,tree_stack->len-1);
+ while(t1->right != LTTV_TREE_UNDEFINED) t1 = t1->r_child.t;
+ if(subtree != NULL) { /* add the subtree */
+ t1->right = LTTV_TREE_NODE;
+ t1->l_child.t = subtree;
+ subtree = NULL;
+ } else { /* add a leaf */
+ a_simple_expression.value = a_field_component->str;
+ a_field_component = g_string_new("");
+ t1->right = LTTV_TREE_LEAF;
+ t1->r_child.leaf = g_new(lttv_simple_expression,1);
+ }
+
+ g_assert(tree != NULL);
+ g_assert(subtree == NULL);
if( p_nesting>0 ) {
g_warning("Wrong filtering options, the string\n\"%s\"\n\
is not valid due to parenthesis incorrect use",expression);
return NULL;
}
+
+ return tree;
+
}
/**
/usr/include/glib-2.0/glib/gtypes.h \
/usr/lib/glib-2.0/include/glibconfig.h \
/usr/include/glib-2.0/glib/gmacros.h \
- /usr/lib/gcc/i386-redhat-linux/3.4.2/include/stddef.h \
- /usr/lib/gcc/i386-redhat-linux/3.4.2/include/limits.h \
- /usr/lib/gcc/i386-redhat-linux/3.4.2/include/syslimits.h \
+ /usr/lib/gcc-lib/i486-linux/3.3.5/include/stddef.h \
+ /usr/lib/gcc-lib/i486-linux/3.3.5/include/limits.h \
+ /usr/lib/gcc-lib/i486-linux/3.3.5/include/syslimits.h \
/usr/include/limits.h /usr/include/features.h /usr/include/sys/cdefs.h \
/usr/include/gnu/stubs.h /usr/include/bits/posix1_lim.h \
/usr/include/bits/local_lim.h /usr/include/linux/limits.h \
/usr/include/bits/posix2_lim.h \
- /usr/lib/gcc/i386-redhat-linux/3.4.2/include/float.h \
+ /usr/lib/gcc-lib/i486-linux/3.3.5/include/float.h \
/usr/include/glib-2.0/glib/garray.h \
/usr/include/glib-2.0/glib/gasyncqueue.h \
/usr/include/glib-2.0/glib/gthread.h \
/usr/include/glib-2.0/glib/gstring.h \
/usr/include/glib-2.0/glib/gunicode.h \
/usr/include/glib-2.0/glib/gutils.h \
- /usr/lib/gcc/i386-redhat-linux/3.4.2/include/stdarg.h \
+ /usr/lib/gcc-lib/i486-linux/3.3.5/include/stdarg.h \
/usr/include/glib-2.0/glib/gmarkup.h \
/usr/include/glib-2.0/glib/gmessages.h \
/usr/include/glib-2.0/glib/gnode.h \
/usr/include/atk-1.0/atk/atknoopobjectfactory.h \
/usr/include/atk-1.0/atk/atkobjectfactory.h \
/usr/include/atk-1.0/atk/atkregistry.h \
- /usr/include/atk-1.0/atk/atkobjectfactory.h \
/usr/include/atk-1.0/atk/atkrelation.h \
/usr/include/atk-1.0/atk/atkrelationset.h \
/usr/include/atk-1.0/atk/atkselection.h \
/usr/include/gtk-2.0/gtk/gtktextmark.h \
/usr/include/gtk-2.0/gtk/gtktextview.h \
/usr/include/gtk-2.0/gtk/gtktipsquery.h \
- /usr/include/gtk-2.0/gtk/gtktoggletoolbutton.h \
/usr/include/gtk-2.0/gtk/gtktoolbar.h \
- /usr/include/gtk-2.0/gtk/gtktoolbutton.h \
- /usr/include/gtk-2.0/gtk/gtktoolitem.h \
/usr/include/gtk-2.0/gtk/gtktree.h \
/usr/include/gtk-2.0/gtk/gtktreednd.h \
/usr/include/gtk-2.0/gtk/gtktreeitem.h \
/usr/include/glib-2.0/glib/gmacros.h:
-/usr/lib/gcc/i386-redhat-linux/3.4.2/include/stddef.h:
+/usr/lib/gcc-lib/i486-linux/3.3.5/include/stddef.h:
-/usr/lib/gcc/i386-redhat-linux/3.4.2/include/limits.h:
+/usr/lib/gcc-lib/i486-linux/3.3.5/include/limits.h:
-/usr/lib/gcc/i386-redhat-linux/3.4.2/include/syslimits.h:
+/usr/lib/gcc-lib/i486-linux/3.3.5/include/syslimits.h:
/usr/include/limits.h:
/usr/include/bits/posix2_lim.h:
-/usr/lib/gcc/i386-redhat-linux/3.4.2/include/float.h:
+/usr/lib/gcc-lib/i486-linux/3.3.5/include/float.h:
/usr/include/glib-2.0/glib/garray.h:
/usr/include/glib-2.0/glib/gutils.h:
-/usr/lib/gcc/i386-redhat-linux/3.4.2/include/stdarg.h:
+/usr/lib/gcc-lib/i486-linux/3.3.5/include/stdarg.h:
/usr/include/glib-2.0/glib/gmarkup.h:
/usr/include/atk-1.0/atk/atkregistry.h:
-/usr/include/atk-1.0/atk/atkobjectfactory.h:
-
/usr/include/atk-1.0/atk/atkrelation.h:
/usr/include/atk-1.0/atk/atkrelationset.h:
/usr/include/gtk-2.0/gtk/gtktipsquery.h:
-/usr/include/gtk-2.0/gtk/gtktoggletoolbutton.h:
-
/usr/include/gtk-2.0/gtk/gtktoolbar.h:
-/usr/include/gtk-2.0/gtk/gtktoolbutton.h:
-
-/usr/include/gtk-2.0/gtk/gtktoolitem.h:
-
/usr/include/gtk-2.0/gtk/gtktree.h:
/usr/include/gtk-2.0/gtk/gtktreednd.h: