From c684db06c58969023152648ac1531c3d97c320ef Mon Sep 17 00:00:00 2001 From: siboud Date: Fri, 1 Apr 2005 22:20:44 +0000 Subject: [PATCH] filter text module: - added file input function git-svn-id: http://ltt.polymtl.ca/svn@913 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/lttv/lttv/filter.c | 12 ++++----- .../poly/lttv/modules/text/textFilter.c | 25 +++++++++++++++---- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/ltt/branches/poly/lttv/lttv/filter.c b/ltt/branches/poly/lttv/lttv/filter.c index 7f31c53d..dcb3350e 100644 --- a/ltt/branches/poly/lttv/lttv/filter.c +++ b/ltt/branches/poly/lttv/lttv/filter.c @@ -397,7 +397,7 @@ gboolean lttv_simple_expression_assign_operator(LttvSimpleExpression* se, LttvEx */ gboolean lttv_simple_expression_assign_value(LttvSimpleExpression* se, char* value) { - g_print("se->value:%s\n",value); +// g_print("se->value:%s\n",value); switch(se->field) { /* @@ -1036,8 +1036,8 @@ lttv_filter_update(LttvFilter* filter) { * 3. pop the tree value from the tree stack */ - g_print("expression: %s\n",filter->expression); - g_print("strlen(expression): %i\n",strlen(filter->expression)); +// g_print("expression: %s\n",filter->expression); +// g_print("strlen(expression): %i\n",strlen(filter->expression)); for(i=0;iexpression);i++) { // debug g_print("%c ",filter->expression[i]); @@ -1186,14 +1186,12 @@ lttv_filter_update(LttvFilter* filter) { //a_simple_expression->value = g_string_free(a_field_component,FALSE); a_field_component = g_string_new(""); t1 = g_ptr_array_index(tree_stack,tree_stack->len-1); - g_print("here\n"); while(t1->right != LTTV_TREE_IDLE) { g_print("while right:%i %p->child:%p\n",t1->right,t1,t1->r_child.t); g_assert(t1->right == LTTV_TREE_NODE); g_assert(t1->r_child.t != NULL); t1 = t1->r_child.t; } - g_print("here2\n"); t1->right = LTTV_TREE_LEAF; t1->r_child.leaf = a_simple_expression; a_simple_expression = lttv_simple_expression_new(); @@ -1257,8 +1255,8 @@ lttv_filter_update(LttvFilter* filter) { } } - g_print("subtree:%p, tree:%p, t1:%p, t2:%p\n",subtree,tree,t1,t2); - g_print("stack size: %i\n",tree_stack->len); +// g_print("subtree:%p, tree:%p, t1:%p, t2:%p\n",subtree,tree,t1,t2); +// g_print("stack size: %i\n",tree_stack->len); /* * Preliminary check to see diff --git a/ltt/branches/poly/lttv/modules/text/textFilter.c b/ltt/branches/poly/lttv/modules/text/textFilter.c index f8a2ea45..8f7a7d81 100644 --- a/ltt/branches/poly/lttv/modules/text/textFilter.c +++ b/ltt/branches/poly/lttv/modules/text/textFilter.c @@ -57,8 +57,6 @@ static LttvHooks *before_traceset, *event_hook; -static FILE *a_file; - /** * filters the file input from user * @param hook_data the hook data @@ -77,7 +75,9 @@ void filter_analyze_file(void *hook_data) { * and/or command line string. From these sources, an * option string is rebuilded and sent to the filter core */ - GString* a_file_content = g_string_new(""); + +/* OLD CODE + * GString* a_file_content = g_string_new(""); a_file = fopen(a_file_name, "r"); if(a_file == NULL) { g_warning("file %s does not exist", a_file_name); @@ -92,14 +92,27 @@ void filter_analyze_file(void *hook_data) { g_string_append(a_file_content,line); } free(line); + + fclose(a_file); +*/ + + if(!g_file_test(a_file_name,G_FILE_TEST_EXISTS)) { + g_warning("file %s does not exist", a_file_name); + return; + } + + char* a_file_content = NULL; + + g_file_get_contents(a_file_name,&a_file_content,NULL,NULL); g_assert(lttv_iattribute_find_by_path(attributes, "filter/expression", LTTV_POINTER, &value)); if(((GString*)*(value.v_pointer))->len != 0) g_string_append_c((GString*)*(value.v_pointer),'&'); - g_string_append((GString*)*(value.v_pointer),a_file_content->str); + g_string_append_c((GString*)*(value.v_pointer),'('); + g_string_append((GString*)*(value.v_pointer),a_file_content); + g_string_append_c((GString*)*(value.v_pointer),')'); - fclose(a_file); } /** @@ -134,7 +147,9 @@ void filter_analyze_string(void *hook_data) { LTTV_POINTER, &value)); if(((GString*)*(value.v_pointer))->len != 0) g_string_append_c((GString*)*(value.v_pointer),'&'); + g_string_append_c((GString*)*(value.v_pointer),'('); g_string_append((GString*)*(value.v_pointer),a_string); + g_string_append_c((GString*)*(value.v_pointer),')'); // LttvFilter* filter = lttv_filter_new(); // lttv_filter_append_expression(filter,a_string); -- 2.34.1