]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Move loop exit conditionals
authorTravis Cross <tc@traviscross.com>
Wed, 9 Apr 2014 07:40:18 +0000 (07:40 +0000)
committerTravis Cross <tc@traviscross.com>
Sat, 19 Apr 2014 01:49:26 +0000 (01:49 +0000)
The net effect here is the code looks more "regular" and reads more
linearly.

src/switch_ivr_play_say.c

index b174f25aa99c58e5ca4e3dd74e7f4185df2e4d76..c8b51a8cafe1ca5d65356066eaf0119958c16142 100644 (file)
@@ -171,7 +171,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro_event(switch_core_sessio
                goto done;
        }
 
-       while (input && !done) {
+       while (input) {
                char *field = (char *) switch_xml_attr(input, "field");
                char *pattern = (char *) switch_xml_attr(input, "pattern");
                const char *do_break = switch_xml_attr_soft(input, "break_on_match");
@@ -212,7 +212,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro_event(switch_core_sessio
 
                if (match) {
                        matches++;
-                       for (action = switch_xml_child(match, "action"); action && status == SWITCH_STATUS_SUCCESS; action = action->next) {
+                       for (action = switch_xml_child(match, "action"); action; action = action->next) {
                                char *adata = (char *) switch_xml_attr_soft(action, "data");
                                char *func = (char *) switch_xml_attr_soft(action, "function");
                                char *substituted = NULL;
@@ -312,15 +312,15 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro_event(switch_core_sessio
                                switch_ivr_sleep(session, pause, SWITCH_FALSE, NULL);
                                switch_safe_free(expanded);
                                switch_safe_free(substituted);
-                               if (done) break;
+                               if (done || status != SWITCH_STATUS_SUCCESS) break;
                        }
                }
 
                switch_regex_safe_free(re);
                switch_safe_free(field_expanded_alloc);
 
-               if ((match && do_break && switch_true(do_break))
-                       || status != SWITCH_STATUS_SUCCESS) {
+               if (done || status != SWITCH_STATUS_SUCCESS
+                       || (match && do_break && switch_true(do_break))) {
                        break;
                }