[svn-commits] rmudgett: trunk r381118 - /trunk/main/pbx.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sat Feb 9 14:58:57 CST 2013


Author: rmudgett
Date: Sat Feb  9 14:58:53 2013
New Revision: 381118

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=381118
Log:
pbx: Fix regression caused by taking advantage of the function name sort.

Taking advantage of the sorted order of the registered functions container
requires that they are actually inserted in the expected sort order.

* Insert the registered functions into the container in case sensitive
position.  As a result, only the complete_functions() routine needs to
search the entire container because it does a case insensitive search for
convenience.

Caught the unit tests.

Modified:
    trunk/main/pbx.c

Modified: trunk/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/pbx.c?view=diff&rev=381118&r1=381117&r2=381118
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Sat Feb  9 14:58:53 2013
@@ -3814,11 +3814,14 @@
 	wordlen = strlen(word);
 	AST_RWLIST_RDLOCK(&acf_root);
 	AST_RWLIST_TRAVERSE(&acf_root, cur, acflist) {
-		/* case-insensitive for convenience in this 'complete' function */
+		/*
+		 * Do a case-insensitive search for convenience in this
+		 * 'complete' function.
+		 *
+		 * We must search the entire container because the functions are
+		 * sorted and normally found case sensitively.
+		 */
 		cmp = strncasecmp(word, cur->name, wordlen);
-		if (cmp > 0) {
-			continue;
-		}
 		if (!cmp) {
 			/* Found match. */
 			if (++which <= state) {
@@ -3828,8 +3831,6 @@
 			ret = ast_strdup(cur->name);
 			break;
 		}
-		/* Not in container. */
-		break;
 	}
 	AST_RWLIST_UNLOCK(&acf_root);
 
@@ -4066,7 +4067,7 @@
 
 	/* Store in alphabetical order */
 	AST_RWLIST_TRAVERSE_SAFE_BEGIN(&acf_root, cur, acflist) {
-		if (strcasecmp(acf->name, cur->name) < 0) {
+		if (strcmp(acf->name, cur->name) < 0) {
 			AST_RWLIST_INSERT_BEFORE_CURRENT(acf, acflist);
 			break;
 		}




More information about the svn-commits mailing list