aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2010-03-13 22:21:18 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2010-03-13 22:21:18 +0000
commitc85a8686506e39ab038b347052279d09d4a7437e (patch)
tree71f048eba8323b3dd8ca134014debd241a04e963
parentbe31fb34f7164d84a0b5a89243623e652078c7f2 (diff)
Resolve unit test failure that occurred on Mac OSX.
On Linux (glibc), regcomp() does not return an error for an empty string. However, the version on OSX will return an error. The test for channel group matching by regex now passes on the mac, as well. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@252241 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--main/app.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/main/app.c b/main/app.c
index 7cb7e30b0..0619151d8 100644
--- a/main/app.c
+++ b/main/app.c
@@ -1095,8 +1095,10 @@ int ast_app_group_match_get_count(const char *groupmatch, const char *category)
regex_t regexbuf_category;
int count = 0;
- if (ast_strlen_zero(groupmatch))
+ if (ast_strlen_zero(groupmatch)) {
+ ast_log(LOG_NOTICE, "groupmatch empty\n");
return 0;
+ }
/* if regex compilation fails, return zero matches */
if (regcomp(&regexbuf_group, groupmatch, REG_EXTENDED | REG_NOSUB)) {
@@ -1104,7 +1106,7 @@ int ast_app_group_match_get_count(const char *groupmatch, const char *category)
return 0;
}
- if (regcomp(&regexbuf_category, category, REG_EXTENDED | REG_NOSUB)) {
+ if (!ast_strlen_zero(category) && regcomp(&regexbuf_category, category, REG_EXTENDED | REG_NOSUB)) {
ast_log(LOG_ERROR, "Regex compile failed on: %s\n", category);
return 0;
}
@@ -1118,7 +1120,9 @@ int ast_app_group_match_get_count(const char *groupmatch, const char *category)
AST_RWLIST_UNLOCK(&groups);
regfree(&regexbuf_group);
- regfree(&regexbuf_category);
+ if (!ast_strlen_zero(category)) {
+ regfree(&regexbuf_category);
+ }
return count;
}