mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
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: https://origsvn.digium.com/svn/asterisk/trunk@252241 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
10
main/app.c
10
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(®exbuf_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(®exbuf_category, category, REG_EXTENDED | REG_NOSUB)) {
|
||||
if (!ast_strlen_zero(category) && regcomp(®exbuf_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(®exbuf_group);
|
||||
regfree(®exbuf_category);
|
||||
if (!ast_strlen_zero(category)) {
|
||||
regfree(®exbuf_category);
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
Reference in New Issue
Block a user