Changeset 9d4c398 for functions.c


Ignore:
Timestamp:
Jan 20, 2011, 7:59:38 PM (13 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.8, release-1.9
Children:
42115bf9
Parents:
a5f477c
git-author:
David Benjamin <davidben@mit.edu> (01/03/11 03:09:14)
git-committer:
David Benjamin <davidben@mit.edu> (01/20/11 19:59:38)
Message:
Reimplement owl_function_zpunt using proper quoting

[nelhage@nelhage.com: Use owl_string_build_quoted]
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    ra5f477c r9d4c398  
    27852785void owl_function_zpunt(const char *class, const char *inst, const char *recip, int direction)
    27862786{
    2787   char *puntexpr, *classexpr, *instexpr, *recipexpr;
     2787  GString *buf;
    27882788  char *quoted;
    27892789
     2790  buf = g_string_new("");
    27902791  if (!strcmp(class, "*")) {
    2791     classexpr = owl_sprintf("class .*");
     2792    g_string_append(buf, "class .*");
    27922793  } else {
    27932794    quoted=owl_text_quote(class, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    2794     owl_text_tr(quoted, ' ', '.');
    2795     owl_text_tr(quoted, '\'', '.');
    2796     owl_text_tr(quoted, '"', '.');
    2797     classexpr = owl_sprintf("class ^(un)*%s(\\.d)*$", quoted);
     2795    owl_string_appendf_quoted(buf, "class ^(un)*%q(\\.d)*$", quoted);
    27982796    owl_free(quoted);
    27992797  }
    28002798  if (!strcmp(inst, "*")) {
    2801     instexpr = owl_sprintf(" and instance .*");
     2799    g_string_append(buf, " and instance .*");
    28022800  } else {
    28032801    quoted=owl_text_quote(inst, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    2804     owl_text_tr(quoted, ' ', '.');
    2805     owl_text_tr(quoted, '\'', '.');
    2806     owl_text_tr(quoted, '"', '.');
    2807     instexpr = owl_sprintf(" and instance ^(un)*%s(\\.d)*$", quoted);
     2802    owl_string_appendf_quoted(buf, " and instance ^(un)*%q(\\.d)*$", quoted);
    28082803    owl_free(quoted);
    28092804  }
    28102805  if (!strcmp(recip, "*")) {
    2811     recipexpr = owl_sprintf("");
     2806    /* g_string_append(buf, ""); */
    28122807  } else {
    28132808    if(!strcmp(recip, "%me%")) {
     
    28152810    }
    28162811    quoted=owl_text_quote(recip, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    2817     owl_text_tr(quoted, ' ', '.');
    2818     owl_text_tr(quoted, '\'', '.');
    2819     owl_text_tr(quoted, '"', '.');
    2820     recipexpr = owl_sprintf(" and recipient ^%s$", quoted);
     2812    owl_string_appendf_quoted(buf, " and recipient ^%q$", quoted);
    28212813    owl_free(quoted);
    28222814  }
    28232815
    2824   puntexpr = owl_sprintf("%s %s %s", classexpr, instexpr, recipexpr);
    2825   owl_function_punt(puntexpr, direction);
    2826   owl_free(puntexpr);
    2827   owl_free(classexpr);
    2828   owl_free(instexpr);
    2829   owl_free(recipexpr);
     2816  owl_function_punt(buf->str, direction);
     2817  g_string_free(buf, true);
    28302818}
    28312819
Note: See TracChangeset for help on using the changeset viewer.