Changeset 78f6c35


Ignore:
Timestamp:
May 24, 2011, 9:36:28 PM (13 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.8, release-1.9
Children:
697221f
Parents:
2d415cc
git-author:
David Benjamin <davidben@mit.edu> (04/04/11 01:27:16)
git-committer:
David Benjamin <davidben@mit.edu> (05/24/11 21:36:28)
Message:
Don't use skiptokens in punt/unpunt

There was no need for it. This cuts down on one of the more nasty usages
of skiptokens in command parsing.
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    r2d415cc r78f6c35  
    24642464  owl_list * fl;
    24652465  owl_filter * f;
    2466   char * text;
    24672466  int i;
    24682467
     
    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

    rf97c1a6 r78f6c35  
    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");
Note: See TracChangeset for help on using the changeset viewer.