[asterisk-commits] trunk r26624 - /trunk/pbx.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed May 10 13:34:19 MST 2006
Author: rizzo
Date: Wed May 10 15:34:18 2006
New Revision: 26624
URL: http://svn.digium.com/view/asterisk?rev=26624&view=rev
Log:
lots of comments trying to document the agreed behaviour of
E_MATCHMORE and '!'.
If the comments are correct, the code must be slightly changed
(simplified).
Modified:
trunk/pbx.c
Modified: trunk/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx.c?rev=26624&r1=26623&r2=26624&view=diff
==============================================================================
--- trunk/pbx.c (original)
+++ trunk/pbx.c Wed May 10 15:34:18 2006
@@ -569,6 +569,12 @@
* a pattern.
* ! zero or more of anything. Also impacts the result of CANMATCH
* and MATCHMORE. Only allowed at the end of a pattern.
+ * In the core routine, ! causes a match with a return code of 2.
+ * In turn, depending on the search mode: (XXX check if it is implemented)
+ * - E_MATCH retuns 1 (does match)
+ * - E_MATCHMORE returns 0 (no match)
+ * - E_CANMATCH returns 1 (does match)
+ *
* / should not appear as it is considered the separator of the CID info.
* XXX at the moment we may stop on this char.
*
@@ -939,22 +945,25 @@
}
if (q->status < STATUS_NO_EXTENSION)
q->status = STATUS_NO_EXTENSION;
+
+ /* scan the list trying to match extension and CID */
for (eroot = tmp->root; eroot; eroot = eroot->next) {
- int match;
- /* Match extension */
- if ( (match = extension_match_core(eroot->exten, exten, action)) &&
- (!eroot->matchcid || matchcid(eroot->cidmatch, callerid))) {
-
- if (action == E_MATCHMORE && match == 2 && !earlymatch) {
- /* XXX not sure the logic is correct here.
- * we should go in irrespective of earlymatch
+ int match = extension_match_core(eroot->exten, exten, action);
+ /* 0 on fail, 1 on match, 2 on earlymatch */
+
+ if (match && (!eroot->matchcid || matchcid(eroot->cidmatch, callerid))) {
+ if (match == 2 && action == E_MATCHMORE && !earlymatch) {
+ /* Match an extension ending in '!'.
+ * As far as I can tell the decision in this case is final
+ * and we should just return NULL to mark failure
+ * (and get rid of the earlymatch variable and the associated
+ * processing outside the loop).
*/
- /* It matched an extension ending in a '!' wildcard
- So ignore it for now, unless there's a better match */
earlymatch = eroot;
} else {
if (q->status < STATUS_NO_PRIORITY)
q->status = STATUS_NO_PRIORITY;
+ /* now look for the right priority */
for (e = eroot; e; e = e->peer) {
/* Match priority */
if (action == E_FINDLABEL) {
@@ -1000,7 +1009,7 @@
aswf = asw->canmatch;
else if (action == E_MATCHMORE)
aswf = asw->matchmore;
- else
+ else /* action == E_MATCH */
aswf = asw->exists;
datap = sw->eval ? sw->tmpdata : sw->data;
res = !aswf ? 0 : aswf(chan, context, exten, priority, callerid, datap);
More information about the asterisk-commits
mailing list