[svn-commits] mmichelson: branch mmichelson/npm_fixes r180857 - /team/mmichelson/npm_fixes/...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Mar 10 14:12:01 CDT 2009


Author: mmichelson
Date: Tue Mar 10 14:11:57 2009
New Revision: 180857

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=180857
Log:
Only apply pattern matching logic to extensions which are patterns.


Modified:
    team/mmichelson/npm_fixes/main/pbx.c

Modified: team/mmichelson/npm_fixes/main/pbx.c
URL: http://svn.digium.com/svn-view/asterisk/team/mmichelson/npm_fixes/main/pbx.c?view=diff&rev=180857&r1=180856&r2=180857
==============================================================================
--- team/mmichelson/npm_fixes/main/pbx.c (original)
+++ team/mmichelson/npm_fixes/main/pbx.c Tue Mar 10 14:11:57 2009
@@ -1626,116 +1626,118 @@
 		ast_log(LOG_NOTICE,"new_find_extension called with %s on (sub)tree NULL action=%s\n", str, action2str(action));
 #endif
 	for (p=tree; p; p=p->alt_char) {
-		if (p->x[0] == 'N') {
-			if (p->x[1] == 0 && *str >= '2' && *str <= '9' ) {
-#define NEW_MATCHER_CHK_MATCH	       \
-				if (p->exten && !(*(str+1))) { /* if a shorter pattern matches along the way, might as well report it */             \
-					if (action == E_MATCH || action == E_SPAWN || action == E_FINDLABEL) { /* if in CANMATCH/MATCHMORE, don't let matches get in the way */   \
-						update_scoreboard(score, length+1, spec+p->specificity, p->exten,0,callerid, p->deleted, p);                 \
-						if (!p->deleted) {                                                                                           \
-							if (action == E_FINDLABEL) {                                                                             \
-								if (ast_hashtab_lookup(score->exten->peer_label_table, &pattern)) {                                  \
-									ast_debug(4, "Found label in preferred extension\n");                                            \
-									return;                                                                                          \
-								}                                                                                                    \
-							} else {                                                                                                 \
-								ast_debug(4,"returning an exact match-- first found-- %s\n", p->exten->exten);                       \
-								return; /* the first match, by definition, will be the best, because of the sorted tree */           \
-							}                                                                                                        \
-						}                                                                                                            \
-					}                                                                                                                \
+		if (p->is_pattern) {
+			if (p->x[0] == 'N') {
+				if (p->x[1] == 0 && *str >= '2' && *str <= '9' ) {
+#define	NEW_MATCHER_CHK_MATCH	       \
+					if (p->exten && !(*(str+1))) { /* if a shorter pattern matches along the way, might as well report it */             \
+						if (action == E_MATCH || action == E_SPAWN || action == E_FINDLABEL) { /* if in CANMATCH/MATCHMORE, don't let matches get in the way */   \
+							update_scoreboard(score, length+1, spec+p->specificity, p->exten,0,callerid, p->deleted, p);                 \
+							if (!p->deleted) {                                                                                           \
+								if (action == E_FINDLABEL) {                                                                             \
+									if (ast_hashtab_lookup(score->exten->peer_label_table, &pattern)) {                                  \
+										ast_debug(4, "Found label in preferred extension\n");                                            \
+										return;                                                                                          \
+									}                                                                                                    \
+								} else {                                                                                                 \
+									ast_debug(4,"returning an exact match-- first found-- %s\n", p->exten->exten);                       \
+									return; /* the first match, by definition, will be the best, because of the sorted tree */           \
+								}                                                                                                        \
+							}                                                                                                            \
+						}                                                                                                                \
+					}
+					
+#define	NEW_MATCHER_RECURSE	           \
+					if (p->next_char && ( *(str+1) || (p->next_char->x[0] == '/' && p->next_char->x[1] == 0)                 \
+        	                                       || p->next_char->x[0] == '!')) {                                          \
+						if (*(str+1) || p->next_char->x[0] == '!') {                                                         \
+							new_find_extension(str+1, score, p->next_char, length+1, spec+p->specificity, callerid, label, action); \
+							if (score->exten)  {                                                                             \
+						        ast_debug(4,"returning an exact match-- %s\n", score->exten->exten);                         \
+								return; /* the first match is all we need */                                                 \
+							}												                                                 \
+						} else {                                                                                             \
+							new_find_extension("/", score, p->next_char, length+1, spec+p->specificity, callerid, label, action);	 \
+							if (score->exten || ((action == E_CANMATCH || action == E_MATCHMORE) && score->canmatch)) {      \
+						        ast_debug(4,"returning a (can/more) match--- %s\n", score->exten ? score->exten->exten :     \
+        	                               "NULL");                                                                        \
+								return; /* the first match is all we need */                                                 \
+							}												                                                 \
+						}                                                                                                    \
+					} else if (p->next_char && !*(str+1)) {                                                                  \
+						score->canmatch = 1;                                                                                 \
+						score->canmatch_exten = get_canmatch_exten(p);                                                       \
+						if (action == E_CANMATCH || action == E_MATCHMORE) {                                                 \
+					        ast_debug(4,"returning a canmatch/matchmore--- str=%s\n", str);                                  \
+							return;                                                                                          \
+						}												                                                     \
+					}
+					
+					NEW_MATCHER_CHK_MATCH;
+					NEW_MATCHER_RECURSE;
 				}
-				
-#define NEW_MATCHER_RECURSE	           \
-				if (p->next_char && ( *(str+1) || (p->next_char->x[0] == '/' && p->next_char->x[1] == 0)                 \
-                                               || p->next_char->x[0] == '!')) {                                          \
-					if (*(str+1) || p->next_char->x[0] == '!') {                                                         \
-						new_find_extension(str+1, score, p->next_char, length+1, spec+p->specificity, callerid, label, action); \
-						if (score->exten)  {                                                                             \
-					        ast_debug(4,"returning an exact match-- %s\n", score->exten->exten);                         \
-							return; /* the first match is all we need */                                                 \
-						}												                                                 \
-					} else {                                                                                             \
-						new_find_extension("/", score, p->next_char, length+1, spec+p->specificity, callerid, label, action);	 \
-						if (score->exten || ((action == E_CANMATCH || action == E_MATCHMORE) && score->canmatch)) {      \
-					        ast_debug(4,"returning a (can/more) match--- %s\n", score->exten ? score->exten->exten :     \
-                                       "NULL");                                                                        \
-							return; /* the first match is all we need */                                                 \
-						}												                                                 \
-					}                                                                                                    \
-				} else if (p->next_char && !*(str+1)) {                                                                  \
-					score->canmatch = 1;                                                                                 \
-					score->canmatch_exten = get_canmatch_exten(p);                                                       \
-					if (action == E_CANMATCH || action == E_MATCHMORE) {                                                 \
-				        ast_debug(4,"returning a canmatch/matchmore--- str=%s\n", str);                                  \
-						return;                                                                                          \
-					}												                                                     \
+			} else if (p->x[0] == 'Z') {
+				if (p->x[1] == 0 && *str >= '1' && *str <= '9' ) {
+					NEW_MATCHER_CHK_MATCH;
+					NEW_MATCHER_RECURSE;
 				}
-				
-				NEW_MATCHER_CHK_MATCH;
-				NEW_MATCHER_RECURSE;
-			}
-		} else if (p->x[0] == 'Z') {
-			if (p->x[1] == 0 && *str >= '1' && *str <= '9' ) {
-				NEW_MATCHER_CHK_MATCH;
-				NEW_MATCHER_RECURSE;
-			}
-		} else if (p->x[0] == 'X') { 
-			if (p->x[1] == 0 && *str >= '0' && *str <= '9' ) {
-				NEW_MATCHER_CHK_MATCH;
-				NEW_MATCHER_RECURSE;
-			}
-		} else if (p->x[0] == '.' && p->x[1] == 0) {
-			/* how many chars will the . match against? */
-			int i = 0;
-			const char *str2 = str;
-			while (*str2 && *str2 != '/') {
-				str2++;
-				i++;
-			}
-			if (p->exten && *str2 != '/') {
-				update_scoreboard(score, length+i, spec+(i*p->specificity), p->exten, '.', callerid, p->deleted, p);
-				if (score->exten) {
-					ast_debug(4,"return because scoreboard has a match with '/'--- %s\n", score->exten->exten);
-					return; /* the first match is all we need */
+			} else if (p->x[0] == 'X') { 
+				if (p->x[1] == 0 && *str >= '0' && *str <= '9' ) {
+					NEW_MATCHER_CHK_MATCH;
+					NEW_MATCHER_RECURSE;
 				}
-			}
-			if (p->next_char && p->next_char->x[0] == '/' && p->next_char->x[1] == 0) {
-				new_find_extension("/", score, p->next_char, length+i, spec+(p->specificity*i), callerid, label, action);
-				if (score->exten || ((action == E_CANMATCH || action == E_MATCHMORE) && score->canmatch)) {
-					ast_debug(4,"return because scoreboard has exact match OR CANMATCH/MATCHMORE & canmatch set--- %s\n", score->exten ? score->exten->exten : "NULL");
-					return; /* the first match is all we need */
+			} else if (p->x[0] == '.' && p->x[1] == 0) {
+				/* how many chars will the . match against? */
+				int i = 0;
+				const char *str2 = str;
+				while (*str2 && *str2 != '/') {
+					str2++;
+					i++;
 				}
-			}
-		} else if (p->x[0] == '!' && p->x[1] == 0) {
-			/* how many chars will the . match against? */
-			int i = 1;
-			const char *str2 = str;
-			while (*str2 && *str2 != '/') {
-				str2++;
-				i++;
-			}
-			if (p->exten && *str2 != '/') {
-				update_scoreboard(score, length+1, spec+(p->specificity*i), p->exten, '!', callerid, p->deleted, p);
-				if (score->exten) {
-					ast_debug(4,"return because scoreboard has a '!' match--- %s\n", score->exten->exten);
-					return; /* the first match is all we need */
+				if (p->exten && *str2 != '/') {
+					update_scoreboard(score, length+i, spec+(i*p->specificity), p->exten, '.', callerid, p->deleted, p);
+					if (score->exten) {
+						ast_debug(4,"return because scoreboard has a match with '/'--- %s\n", score->exten->exten);
+						return; /* the first match is all we need */
+					}
 				}
-			}
-			if (p->next_char && p->next_char->x[0] == '/' && p->next_char->x[1] == 0) {
-				new_find_extension("/", score, p->next_char, length+i, spec+(p->specificity*i), callerid, label, action);
-				if (score->exten || ((action == E_CANMATCH || action == E_MATCHMORE) && score->canmatch)) {
-					ast_debug(4,"return because scoreboard has exact match OR CANMATCH/MATCHMORE & canmatch set with '/' and '!'--- %s\n", score->exten ? score->exten->exten : "NULL");
-					return; /* the first match is all we need */
+				if (p->next_char && p->next_char->x[0] == '/' && p->next_char->x[1] == 0) {
+					new_find_extension("/", score, p->next_char, length+i, spec+(p->specificity*i), callerid, label, action);
+					if (score->exten || ((action == E_CANMATCH || action == E_MATCHMORE) && score->canmatch)) {
+						ast_debug(4,"return because scoreboard has exact match OR CANMATCH/MATCHMORE & canmatch set--- %s\n", score->exten ? score->exten->exten : "NULL");
+						return; /* the first match is all we need */
+					}
 				}
-			}
-		} else if (p->x[0] == '/' && p->x[1] == 0) {
-			/* the pattern in the tree includes the cid match! */
-			if (p->next_char && callerid && *callerid) {
-				new_find_extension(callerid, score, p->next_char, length+1, spec, callerid, label, action);
-				if (score->exten || ((action == E_CANMATCH || action == E_MATCHMORE) && score->canmatch)) {
-					ast_debug(4,"return because scoreboard has exact match OR CANMATCH/MATCHMORE & canmatch set with '/'--- %s\n", score->exten ? score->exten->exten : "NULL");
-					return; /* the first match is all we need */
+			} else if (p->x[0] == '!' && p->x[1] == 0) {
+				/* how many chars will the . match against? */
+				int i = 1;
+				const char *str2 = str;
+				while (*str2 && *str2 != '/') {
+					str2++;
+					i++;
+				}
+				if (p->exten && *str2 != '/') {
+					update_scoreboard(score, length+1, spec+(p->specificity*i), p->exten, '!', callerid, p->deleted, p);
+					if (score->exten) {
+						ast_debug(4,"return because scoreboard has a '!' match--- %s\n", score->exten->exten);
+						return; /* the first match is all we need */
+					}
+				}
+				if (p->next_char && p->next_char->x[0] == '/' && p->next_char->x[1] == 0) {
+					new_find_extension("/", score, p->next_char, length+i, spec+(p->specificity*i), callerid, label, action);
+					if (score->exten || ((action == E_CANMATCH || action == E_MATCHMORE) && score->canmatch)) {
+						ast_debug(4,"return because scoreboard has exact match OR CANMATCH/MATCHMORE & canmatch set with '/' and '!'--- %s\n", score->exten ? score->exten->exten : "NULL");
+						return; /* the first match is all we need */
+					}
+				}
+			} else if (p->x[0] == '/' && p->x[1] == 0) {
+				/* the pattern in the tree includes the cid match! */
+				if (p->next_char && callerid && *callerid) {
+					new_find_extension(callerid, score, p->next_char, length+1, spec, callerid, label, action);
+					if (score->exten || ((action == E_CANMATCH || action == E_MATCHMORE) && score->canmatch)) {
+						ast_debug(4,"return because scoreboard has exact match OR CANMATCH/MATCHMORE & canmatch set with '/'--- %s\n", score->exten ? score->exten->exten : "NULL");
+						return; /* the first match is all we need */
+					}
 				}
 			}
 		} else if (strchr(p->x, *str)) {




More information about the svn-commits mailing list