]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix logic in dmachine parser for overlap bindings so they work regardless of the...
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 6 Sep 2012 16:53:58 +0000 (11:53 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 6 Sep 2012 16:54:03 +0000 (11:54 -0500)
src/switch_ivr_async.c

index c684c8f14c091d32016375fb564df1b66f5a1859..4ab523a3a5e619745c196c921d6eed3f3db4735e 100644 (file)
@@ -311,9 +311,18 @@ static dm_match_t switch_ivr_dmachine_check_match(switch_ivr_dmachine_t *dmachin
 
        for(bp = dmachine->realm->binding_list; bp; bp = bp->next) {
                if (bp->is_regex) {
-                       switch_status_t r_status = switch_regex_match(dmachine->digits, bp->digits);
-                       pmatches = 1;
+                       pmatches++;
+               } else {
+                       if (!strncmp(dmachine->digits, bp->digits, strlen(dmachine->digits))) {
+                               pmatches++;
+                       }
+               }
+       }
 
+       for(bp = dmachine->realm->binding_list; bp; bp = bp->next) {
+               if (bp->is_regex) {
+                       switch_status_t r_status = switch_regex_match(dmachine->digits, bp->digits);
+                       
                        if (r_status == SWITCH_STATUS_SUCCESS) {
                                if (is_timeout || (bp == dmachine->realm->binding_list && !bp->next)) {
                                        best = DM_MATCH_EXACT;
@@ -325,11 +334,7 @@ static dm_match_t switch_ivr_dmachine_check_match(switch_ivr_dmachine_t *dmachin
                } else {
                        int pmatch = !strncmp(dmachine->digits, bp->digits, strlen(dmachine->digits));
 
-                       if (pmatch) {
-                               pmatches++;
-                       }
-
-                       if (!exact_bp && pmatch && !strcmp(bp->digits, dmachine->digits)) {
+                       if (!exact_bp && pmatch && (pmatches == 1 || is_timeout) && !strcmp(bp->digits, dmachine->digits)) {
                                best = DM_MATCH_EXACT;
                                exact_bp = bp;
                                if (dmachine->cur_digit_len == dmachine->max_digit_len) break;