Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r697221f r47128d9  
    3232  char *rv;
    3333  rv=owl_function_command(cmdbuff);
    34   g_free(rv);
     34  if (rv) g_free(rv);
    3535}
    3636
     
    453453
    454454  if (rv || status) {
    455     g_free(cryptmsg);
     455    if(cryptmsg) g_free(cryptmsg);
    456456    g_free(old_msg);
    457457    owl_function_error("Error in zcrypt, possibly no key found.  Message not sent.");
     
    991991  /* execute the commands in shutdown */
    992992  ret = owl_perlconfig_execute("BarnOwl::Hooks::_shutdown();");
    993   g_free(ret);
     993  if (ret) g_free(ret);
    994994
    995995  /* signal our child process, if any */
     
    18171817          owl_global_get_cols(&g));
    18181818
    1819   if (has_colors()) {
     1819  if (owl_global_get_hascolors(&g)) {
    18201820    owl_fmtext_append_normal(&fm, "Color: Yes\n");
    1821     owl_fmtext_appendf_normal(&fm, "Number of color pairs: %i\n", owl_util_get_colorpairs());
     1821    owl_fmtext_appendf_normal(&fm, "Number of color pairs: %i\n", owl_global_get_colorpairs(&g));
    18221822    owl_fmtext_appendf_normal(&fm, "Can change colors: %s\n", can_change_color() ? "yes" : "no");
    18231823  } else {
     
    22262226    f = fl->data;
    22272227    owl_fmtext_append_normal(&fm, "   ");
    2228     owl_fmtext_append_normal_color(&fm, owl_filter_get_name(f),
    2229                                    owl_filter_get_fgcolor(f),
    2230                                    owl_filter_get_bgcolor(f));
     2228    if (owl_global_get_hascolors(&g)) {
     2229      owl_fmtext_append_normal_color(&fm, owl_filter_get_name(f), owl_filter_get_fgcolor(f), owl_filter_get_bgcolor(f));
     2230    } else {
     2231      owl_fmtext_append_normal(&fm, owl_filter_get_name(f));
     2232    }
    22312233    owl_fmtext_append_normal(&fm, "\n");
    22322234  }
     
    23582360done:
    23592361  g_free(class);
    2360   g_free(instance);
     2362  if (instance) {
     2363    g_free(instance);
     2364  }
    23612365  return(filtname);
    23622366}
     
    25192523
    25202524  filtname = g_strdup_printf("conversation-%s", ccs);
    2521   g_strdelimit(filtname, " ", '-');
     2525  owl_text_tr(filtname, ' ', '-');
    25222526
    25232527  if (owl_global_get_filter(&g, filtname)) {
     
    27812785void owl_function_zpunt(const char *class, const char *inst, const char *recip, int direction)
    27822786{
    2783   GPtrArray *argv;
     2787  GString *buf;
    27842788  char *quoted;
    27852789
    2786   argv = g_ptr_array_new();
     2790  buf = g_string_new("");
    27872791  if (!strcmp(class, "*")) {
    2788     g_ptr_array_add(argv, g_strdup("class"));
    2789     g_ptr_array_add(argv, g_strdup(".*"));
     2792    g_string_append(buf, "class .*");
    27902793  } else {
    27912794    quoted=owl_text_quote(class, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    2792     g_ptr_array_add(argv, g_strdup("class"));
    2793     g_ptr_array_add(argv, g_strdup_printf("^(un)*%s(\\.d)*$", quoted));
     2795    owl_string_appendf_quoted(buf, "class ^(un)*%q(\\.d)*$", quoted);
    27942796    g_free(quoted);
    27952797  }
    27962798  if (!strcmp(inst, "*")) {
    2797     g_ptr_array_add(argv, g_strdup("and"));
    2798     g_ptr_array_add(argv, g_strdup("instance"));
    2799     g_ptr_array_add(argv, g_strdup(".*"));
     2799    g_string_append(buf, " and instance .*");
    28002800  } else {
    28012801    quoted=owl_text_quote(inst, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    2802     g_ptr_array_add(argv, g_strdup("and"));
    2803     g_ptr_array_add(argv, g_strdup("instance"));
    2804     g_ptr_array_add(argv, g_strdup_printf("^(un)*%s(\\.d)*$", quoted));
     2802    owl_string_appendf_quoted(buf, " and instance ^(un)*%q(\\.d)*$", quoted);
    28052803    g_free(quoted);
    28062804  }
    28072805  if (!strcmp(recip, "*")) {
    2808     /* nothing */
     2806    /* g_string_append(buf, ""); */
    28092807  } else {
    28102808    if(!strcmp(recip, "%me%")) {
     
    28122810    }
    28132811    quoted=owl_text_quote(recip, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    2814     g_ptr_array_add(argv, g_strdup("and"));
    2815     g_ptr_array_add(argv, g_strdup("recipient"));
    2816     g_ptr_array_add(argv, g_strdup_printf("^%s$", quoted));
     2812    owl_string_appendf_quoted(buf, " and recipient ^%q$", quoted);
    28172813    g_free(quoted);
    28182814  }
    28192815
    2820   owl_function_punt(argv->len, (const char *const*) argv->pdata, direction);
    2821   g_ptr_array_foreach(argv, (GFunc)g_free, NULL);
    2822   g_ptr_array_free(argv, true);
    2823 }
    2824 
    2825 void owl_function_punt(int argc, const char *const *argv, int direction)
     2816  owl_function_punt(buf->str, direction);
     2817  g_string_free(buf, true);
     2818}
     2819
     2820void owl_function_punt(const char *filter, int direction)
    28262821{
    28272822  owl_filter *f;
     
    28312826
    28322827  /* first, create the filter */
    2833   f = owl_filter_new("punt-filter", argc, argv);
     2828  owl_function_debugmsg("About to filter %s", filter);
     2829  f = owl_filter_new_fromstring("punt-filter", filter);
    28342830  if (f == NULL) {
    28352831    owl_function_error("Error creating filter for zpunt");
     
    28582854  }
    28592855
    2860   if (direction == 0) {
    2861     owl_function_debugmsg("punting");
    2862     /* If we're punting, add the filter to the global punt list */
     2856  owl_function_debugmsg("punting");
     2857  /* If we're punting, add the filter to the global punt list */
     2858  if (direction==0) {
    28632859    owl_list_append_element(fl, f);
    2864   } else if (direction == 1) {
    2865     owl_function_makemsg("No matching punt filter");
    2866  }
     2860  }
    28672861}
    28682862
     
    29652959 
    29662960  if (viewsize==0) {
    2967     owl_function_makemsg("No messages present");
     2961    owl_function_error("No messages present");
    29682962    return;
    29692963  }
     
    29792973  /* bounds check */
    29802974  if (start>=viewsize || start<0) {
    2981     owl_function_makemsg("No further matches found");
     2975    owl_function_error("No further matches found");
    29822976    return;
    29832977  }
     
    30083002  }
    30093003  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    3010   owl_function_makemsg("No matches found");
     3004  owl_function_error("No matches found");
    30113005}
    30123006
Note: See TracChangeset for help on using the changeset viewer.