Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • filter.c

    rd791cdb rad15610  
    6363static owl_filterelement * owl_filter_parse_primitive_expression(int argc, char **argv, int *next)
    6464{
     65  owl_filterelement *fe, *op;
     66  int i = 0, skip;
     67
    6568  if(!argc) return NULL;
    6669
    67   owl_filterelement * fe = owl_malloc(sizeof(owl_filterelement));
    68   owl_filterelement *op;
    69 
     70  fe = owl_malloc(sizeof(owl_filterelement));
    7071  owl_filterelement_create(fe);
    71   int i = 0, skip;
    7272
    7373  if(!strcasecmp(argv[i], "(")) {
     
    118118{
    119119  int i = 0, skip;
    120   owl_filterelement * op1 = NULL, * op2 = NULL;
     120  owl_filterelement * op1 = NULL, * op2 = NULL, *tmp;
    121121
    122122  op1 = owl_filter_parse_primitive_expression(argc-i, argv+i, &skip);
     
    129129    op2 = owl_filter_parse_primitive_expression(argc-i-1, argv+i+1, &skip);
    130130    if(!op2) goto err;
    131     owl_filterelement * tmp = owl_malloc(sizeof(owl_filterelement));
     131    tmp = owl_malloc(sizeof(owl_filterelement));
    132132    if(!strcasecmp(argv[i], "and")) {
    133133      owl_filterelement_create_and(tmp, op1, op2);
     
    204204int owl_filter_message_match(owl_filter *f, owl_message *m)
    205205{
     206  int ret;
    206207  if(!f->root) return 0;
    207   int ret = owl_filterelement_match(f->root, m);
     208  ret = owl_filterelement_match(f->root, m);
    208209  if(f->polarity) ret = !ret;
    209210  return ret;
     
    283284  int failed = 0;
    284285  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);
    286287    failed = 1;
    287288    goto out;
     
    289290  ok = owl_filter_message_match(&f, m);
    290291  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);
    292293    failed = 1;
    293294  }
     
    295296  owl_filter_free(&f);
    296297  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);
    298299  }
    299300  return failed;
     
    305306
    306307int owl_filter_regtest(void) {
    307   owl_list_create(&(g.filterlist));
    308308  int numfailed=0;
    309309  owl_message m;
     310  owl_filter f1, f2, f3, f4;
     311
     312  owl_list_create(&(g.filterlist));
    310313  owl_message_init(&m);
    311314  owl_message_set_type_zephyr(&m);
     
    345348  TEST_FILTER("true and false or false", 0);
    346349
    347   owl_filter f1, f2, f3, f4;
    348 
    349350  owl_filter_init_fromstring(&f1, "f1", "class owl");
    350351  owl_global_add_filter(&g, &f1);
Note: See TracChangeset for help on using the changeset viewer.