Changeset 01dcae5 for filter.c


Ignore:
Timestamp:
Mar 29, 2009, 2:43:40 PM (15 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
owl
Children:
395b32e
Parents:
3674002
Message:
sprintf fixes for owl_filter_print, owl_function_printallvars, owl_function_show_filter
        owl_function_show_zpunts, owl_function_zpunt
adopt ^(un)*%s(\\.d) style regex for punting
File:
1 edited

Legend:

Unmodified
Added
Removed
  • filter.c

    rfa00c5c r01dcae5  
    476476}
    477477
    478 void owl_filter_print(owl_filter *f, char *out)
     478char *owl_filter_print(owl_filter *f)
    479479{
    480480  int i, j;
    481481  owl_filterelement *fe;
    482   char *tmp;
    483 
    484   strcpy(out, owl_filter_get_name(f));
    485   strcat(out, ": ");
     482  GString *out = g_string_new("");
    486483
    487484  if (f->color!=OWL_COLOR_DEFAULT) {
    488     strcat(out, "-c ");
    489     strcat(out, owl_util_color_to_string(f->color));
    490     strcat(out, " ");
     485    g_string_append(out, "-c ");
     486    if (f->color < 8) {
     487      g_string_append(out, owl_util_color_to_string(f->color));
     488    } else {
     489      g_string_append_printf(out, "%i",f->color);
     490    }
     491    g_string_append(out, " ");
    491492  }
    492493
     
    494495  for (i=0; i<j; i++) {
    495496    fe=owl_list_get_element(&(f->fes), i);
    496     tmp=owl_filterelement_to_string(fe);
    497     strcat(out, tmp);
    498     owl_free(tmp);
    499   }
    500   strcat(out, "\n");
     497    g_string_append(out, owl_filterelement_to_string(fe));
     498  }
     499
     500  return g_string_free(out, 0);
    501501}
    502502
     
    504504int owl_filter_equiv(owl_filter *a, owl_filter *b)
    505505{
    506   char buff[LINE], buff2[LINE];
    507 
    508   owl_filter_print(a, buff);
    509   owl_filter_print(b, buff2);
    510 
    511   if (!strcmp(buff, buff2)) return(1);
    512   return(0);
     506  char *buffa, *buffb;
     507  int ret;
     508
     509  buffa = owl_filter_print(a);
     510  buffb = owl_filter_print(b);
     511
     512  ret = !strcmp(buffa, buffb);
     513  ret = ret && !strcmp(owl_filter_get_name(a),
     514                       owl_filter_get_name(b));
     515
     516  owl_free(buffa);
     517  owl_free(buffb);
     518
     519  return ret;
    513520}
    514521
Note: See TracChangeset for help on using the changeset viewer.