]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
accept asterisk N/X/Z/. notation everywhere regexes are expected when they start...
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 12 May 2009 17:10:57 +0000 (17:10 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 12 May 2009 17:10:57 +0000 (17:10 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13287 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_utils.h
src/switch_regex.c
src/switch_utils.c

index 1b965b4a7600bef8e6908be5f46df41241bdc9a0..466bc22541962d9ea79371c359506b714b37809a 100644 (file)
@@ -514,7 +514,7 @@ SWITCH_DECLARE(char *) switch_separate_paren_args(char *str);
 SWITCH_DECLARE(const char *) switch_stristr(const char *instr, const char *str);
 SWITCH_DECLARE(switch_bool_t) switch_is_lan_addr(const char *ip);
 SWITCH_DECLARE(char *) switch_replace_char(char *str, char from, char to, switch_bool_t dup);
-SWITCH_DECLARE(switch_bool_t) switch_ast2regex(char *pat, char *rbuf, size_t len);
+SWITCH_DECLARE(switch_bool_t) switch_ast2regex(const char *pat, char *rbuf, size_t len);
 
 /*!
   \brief Escape a string by prefixing a list of characters with an escape character
index 697ba1cf62bdc03647b324e38cb1d23333331189..aee8f2b9e3ce5b329621fac0db1ab643aaf3a5a6 100644 (file)
@@ -60,11 +60,18 @@ SWITCH_DECLARE(int) switch_regex_perform(const char *field, const char *expressi
        int match_count = 0;
        char *tmp = NULL;
        uint32_t flags = 0;
+       char abuf[256] = "";
 
        if (!(field && expression)) {
                return 0;
        }
 
+       if (*expression == '_') {
+               if (switch_ast2regex(expression + 1, abuf, sizeof(abuf))) {
+                       expression = abuf;
+               }
+       }
+       
        if (*expression == '/') {
                char *opts = NULL;
                tmp = strdup(expression + 1);
index 8b3088f03fdf37fbab83ca2b816b9ff3d2e54a37..5829140098aaec2799d8f875e14e10f3d2c68a59 100644 (file)
@@ -565,9 +565,9 @@ SWITCH_DECLARE(switch_bool_t) switch_is_lan_addr(const char *ip)
                )? SWITCH_FALSE : SWITCH_TRUE;
 }
 
-SWITCH_DECLARE(switch_bool_t) switch_ast2regex(char *pat, char *rbuf, size_t len)
+SWITCH_DECLARE(switch_bool_t) switch_ast2regex(const char *pat, char *rbuf, size_t len)
 {
-       char *p = pat;
+       const char *p = pat;
 
        if (!pat) {
                return SWITCH_FALSE;