[asterisk-commits] russell: trunk r252241 - /trunk/main/app.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Mar 13 16:21:21 CST 2010


Author: russell
Date: Sat Mar 13 16:21:18 2010
New Revision: 252241

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=252241
Log:
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.

Modified:
    trunk/main/app.c

Modified: trunk/main/app.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/app.c?view=diff&rev=252241&r1=252240&r2=252241
==============================================================================
--- trunk/main/app.c (original)
+++ trunk/main/app.c Sat Mar 13 16:21:18 2010
@@ -1095,8 +1095,10 @@
 	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 @@
 		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 @@
 	AST_RWLIST_UNLOCK(&groups);
 
 	regfree(&regexbuf_group);
-	regfree(&regexbuf_category);
+	if (!ast_strlen_zero(category)) {
+		regfree(&regexbuf_category);
+	}
 
 	return count;
 }




More information about the asterisk-commits mailing list