Changes in filter.c [d791cdb:ad15610]
Legend:
- Unmodified
- Added
- Removed
-
filter.c
rd791cdb rad15610 63 63 static owl_filterelement * owl_filter_parse_primitive_expression(int argc, char **argv, int *next) 64 64 { 65 owl_filterelement *fe, *op; 66 int i = 0, skip; 67 65 68 if(!argc) return NULL; 66 69 67 owl_filterelement * fe = owl_malloc(sizeof(owl_filterelement)); 68 owl_filterelement *op; 69 70 fe = owl_malloc(sizeof(owl_filterelement)); 70 71 owl_filterelement_create(fe); 71 int i = 0, skip;72 72 73 73 if(!strcasecmp(argv[i], "(")) { … … 118 118 { 119 119 int i = 0, skip; 120 owl_filterelement * op1 = NULL, * op2 = NULL ;120 owl_filterelement * op1 = NULL, * op2 = NULL, *tmp; 121 121 122 122 op1 = owl_filter_parse_primitive_expression(argc-i, argv+i, &skip); … … 129 129 op2 = owl_filter_parse_primitive_expression(argc-i-1, argv+i+1, &skip); 130 130 if(!op2) goto err; 131 owl_filterelement *tmp = owl_malloc(sizeof(owl_filterelement));131 tmp = owl_malloc(sizeof(owl_filterelement)); 132 132 if(!strcasecmp(argv[i], "and")) { 133 133 owl_filterelement_create_and(tmp, op1, op2); … … 204 204 int owl_filter_message_match(owl_filter *f, owl_message *m) 205 205 { 206 int ret; 206 207 if(!f->root) return 0; 207 intret = owl_filterelement_match(f->root, m);208 ret = owl_filterelement_match(f->root, m); 208 209 if(f->polarity) ret = !ret; 209 210 return ret; … … 283 284 int failed = 0; 284 285 if(owl_filter_init_fromstring(&f, "test-filter", filt)) { 285 printf(" \tFAIL:parse %s\n", filt);286 printf("not ok can't parse %s\n", filt); 286 287 failed = 1; 287 288 goto out; … … 289 290 ok = owl_filter_message_match(&f, m); 290 291 if((shouldmatch && !ok) || (!shouldmatch && ok)) { 291 printf(" \tFAIL:match %s (got %d, expected %d)\n", filt, ok, shouldmatch);292 printf("not ok match %s (got %d, expected %d)\n", filt, ok, shouldmatch); 292 293 failed = 1; 293 294 } … … 295 296 owl_filter_free(&f); 296 297 if(!failed) { 297 printf(" \tok :%s %s\n", shouldmatch ? "matches" : "doesn't match", filt);298 printf("ok %s %s\n", shouldmatch ? "matches" : "doesn't match", filt); 298 299 } 299 300 return failed; … … 305 306 306 307 int owl_filter_regtest(void) { 307 owl_list_create(&(g.filterlist));308 308 int numfailed=0; 309 309 owl_message m; 310 owl_filter f1, f2, f3, f4; 311 312 owl_list_create(&(g.filterlist)); 310 313 owl_message_init(&m); 311 314 owl_message_set_type_zephyr(&m); … … 345 348 TEST_FILTER("true and false or false", 0); 346 349 347 owl_filter f1, f2, f3, f4;348 349 350 owl_filter_init_fromstring(&f1, "f1", "class owl"); 350 351 owl_global_add_filter(&g, &f1);
Note: See TracChangeset
for help on using the changeset viewer.