Changes in / [b848e30:f1c845b]


Ignore:
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    r3b8a563 r697221f  
    281281  OWLCMD_ARGS("punt", owl_command_punt, OWL_CTX_ANY,
    282282              "suppress an arbitrary filter",
    283               "punt <filter-text>",
    284               "punt <filter-text (multiple words)>\n"
     283              "punt <filter-name>\n"
     284              "punt <filter-text (multiple words)>",
    285285              "The punt command will suppress messages to the specified\n"
    286286              "filter\n\n"
     
    289289  OWLCMD_ARGS("unpunt", owl_command_unpunt, OWL_CTX_ANY,
    290290              "remove an entry from the punt list",
    291               "unpunt <filter-text>\n"
    292               "unpunt <filter-text>\n"
    293               "unpunt <number>\n",
     291              "unpunt <number>\n"
     292              "unpunt <filter-name>\n"
     293              "unpunt <filter-text (multiple words)>",
    294294              "The unpunt command will remove an entry from the puntlist.\n"
    295               "The first two forms correspond to the first two forms of the :punt\n"
    296               "command. The latter allows you to remove a specific entry from the\n"
     295              "The last two forms correspond to the two forms of the :punt\n"
     296              "command. The first allows you to remove a specific entry from\n"
    297297              "the list (see :show zpunts)\n\n"
    298298              "SEE ALSO:  punt, zpunt, zunpunt, show zpunts\n"),
     
    24642464  owl_list * fl;
    24652465  owl_filter * f;
    2466   char * text;
    24672466  int i;
    24682467
     
    24802479        return;
    24812480      } else {
    2482         owl_function_error("No such filter number: %d", i+1);
     2481        owl_function_makemsg("No such filter number: %d.", i+1);
    24832482      }
    24842483    }
    2485     text = owl_string_build_quoted("filter %q", argv[1]);
    2486     owl_function_punt(text, unpunt);
    2487     g_free(text);
     2484    const char *filter[] = {"filter", argv[1]};
     2485    owl_function_punt(2, filter, unpunt);
    24882486  } else {
    2489     owl_function_punt(skiptokens(buff, 1), unpunt);
     2487    /* Pass in argv[1]..argv[argc-1]. */
     2488    owl_function_punt(argc - 1, argv + 1, unpunt);
    24902489  }
    24912490}
  • functions.c

    r47128d9 r697221f  
    27812781void owl_function_zpunt(const char *class, const char *inst, const char *recip, int direction)
    27822782{
    2783   GString *buf;
     2783  GPtrArray *argv;
    27842784  char *quoted;
    27852785
    2786   buf = g_string_new("");
     2786  argv = g_ptr_array_new();
    27872787  if (!strcmp(class, "*")) {
    2788     g_string_append(buf, "class .*");
     2788    g_ptr_array_add(argv, g_strdup("class"));
     2789    g_ptr_array_add(argv, g_strdup(".*"));
    27892790  } else {
    27902791    quoted=owl_text_quote(class, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    2791     owl_string_appendf_quoted(buf, "class ^(un)*%q(\\.d)*$", quoted);
     2792    g_ptr_array_add(argv, g_strdup("class"));
     2793    g_ptr_array_add(argv, g_strdup_printf("^(un)*%s(\\.d)*$", quoted));
    27922794    g_free(quoted);
    27932795  }
    27942796  if (!strcmp(inst, "*")) {
    2795     g_string_append(buf, " and instance .*");
     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(".*"));
    27962800  } else {
    27972801    quoted=owl_text_quote(inst, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    2798     owl_string_appendf_quoted(buf, " and instance ^(un)*%q(\\.d)*$", quoted);
     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));
    27992805    g_free(quoted);
    28002806  }
    28012807  if (!strcmp(recip, "*")) {
    2802     /* g_string_append(buf, ""); */
     2808    /* nothing */
    28032809  } else {
    28042810    if(!strcmp(recip, "%me%")) {
     
    28062812    }
    28072813    quoted=owl_text_quote(recip, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    2808     owl_string_appendf_quoted(buf, " and recipient ^%q$", quoted);
     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));
    28092817    g_free(quoted);
    28102818  }
    28112819
    2812   owl_function_punt(buf->str, direction);
    2813   g_string_free(buf, true);
    2814 }
    2815 
    2816 void owl_function_punt(const char *filter, int direction)
     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
     2825void owl_function_punt(int argc, const char *const *argv, int direction)
    28172826{
    28182827  owl_filter *f;
     
    28222831
    28232832  /* first, create the filter */
    2824   owl_function_debugmsg("About to filter %s", filter);
    2825   f = owl_filter_new_fromstring("punt-filter", filter);
     2833  f = owl_filter_new("punt-filter", argc, argv);
    28262834  if (f == NULL) {
    28272835    owl_function_error("Error creating filter for zpunt");
     
    28502858  }
    28512859
    2852   owl_function_debugmsg("punting");
    2853   /* If we're punting, add the filter to the global punt list */
    2854   if (direction==0) {
     2860  if (direction == 0) {
     2861    owl_function_debugmsg("punting");
     2862    /* If we're punting, add the filter to the global punt list */
    28552863    owl_list_append_element(fl, f);
    2856   }
     2864  } else if (direction == 1) {
     2865    owl_function_makemsg("No matching punt filter");
     2866 }
    28572867}
    28582868
Note: See TracChangeset for help on using the changeset viewer.