Correction for bug 8128 in trunk
authorSteve Murphy <murf@digium.com>
Fri, 13 Oct 2006 18:08:33 +0000 (18:08 +0000)
committerSteve Murphy <murf@digium.com>
Fri, 13 Oct 2006 18:08:33 +0000 (18:08 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45078 65c4cc65-6c06-0410-ace0-fbb531ad65f3

pbx/ael/ael-test/ael-vtest17/extensions.ael [new file with mode: 0644]
pbx/ael/ael-test/ref.ael-test3
pbx/ael/ael-test/ref.ael-vtest17 [new file with mode: 0644]
pbx/pbx_ael.c

diff --git a/pbx/ael/ael-test/ael-vtest17/extensions.ael b/pbx/ael/ael-test/ael-vtest17/extensions.ael
new file mode 100644 (file)
index 0000000..d13fe99
--- /dev/null
@@ -0,0 +1,116 @@
+context dialextens
+{
+       /* 
+               101 thru 123, 149 thru 152
+        */
+       _10X => Dial(Zap/${EXTEN:2},30,tw);
+       _1ZX => Dial(Zap/${EXTEN:1},30,tw);
+}
+/* 
+    Due to extenal wiring:
+
+  dialing 125 will ring 101
+  dialing 126 will ring 102
+   and so on until
+  dialing 147 will ring 123
+
+We can dial out on zap 69 thru 72; and 25-47
+
+*/
+
+context dialthrus
+{
+       /*  369-372; 325-347 */
+       _3XX => Dial(Zap/${EXTEN:1},30,tw);
+}
+
+context t1incoming
+{
+       includes
+       {
+               dialextens;
+               parkedcalls;
+       }
+       s => {
+               Answer();
+               Background(welcome-to-test-machine);
+       }
+
+}
+
+context t1extension
+{
+       includes
+       {
+               dialextens;
+               dialthrus;
+       }
+
+}
+
+context incoming
+{
+       includes
+       {
+               dialextens;
+               parkedcalls;
+       }
+       s => {
+               Answer();
+               Background(welcome-to-test-machine);
+       }
+}
+
+context extension
+{
+       includes
+       {
+               dialextens;
+               dialthrus;
+       }
+       5 => {
+               Record(recording:gsm);
+               Background(recording);
+       }
+
+       81 => {
+               iterations=1000000;
+               Set(time1=${EPOCH});
+               for(i=1; ${i}<${iterations}; i=${i}+1)
+               {
+                       NoOp(Hello);
+               }
+               Set(time2=${EPOCH});
+               Verbose(The time diff is $[${time2} - ${time1} ] seconds);
+               Verbose(Which means that the priorities/sec = $[4* ${iterations} / (${time2} - ${time1}) ]);
+               SayNumber($[4 * ${iterations} / (${time2} - ${time1}) ]);
+       }
+       82 => {
+                       &ndeep(100000);
+                       Verbose(Finished 100000 levels deep call!);
+               }
+       83 => {
+               switch (${EXTEN}) 
+               {
+               pattern 8X:
+                       Verbose(do something to prepare it);
+               pattern 9X:
+                       Verbose(handle both 8x and 9x calls);
+               pattern [4-7]X:
+                       Verbose(and this too!);
+
+               }
+
+       }
+}
+
+macro ndeep(level)
+{
+        if( ${level} == 0)
+        {
+                Verbose(2|Got to Level 0);
+                return;
+        }
+        &ndeep($[${level}-1]);
+        return;
+}
index 4b65c8c..fdd79f1 100644 (file)
@@ -2,17 +2,17 @@
 (If you find progress and other non-error messages irritating, you can use -q to suppress them)
 
 (You can use the -w option to dump extensions.conf format to extensions.conf.aeldump)
-LOG: lev:2 file:pbx_ael.c  line:3910 func: pbx_load_module  Starting AEL load process.
-LOG: lev:2 file:pbx_ael.c  line:3917 func: pbx_load_module  AEL load process: calculated config file name './extensions.ael'.
+LOG: lev:2 file:pbx_ael.c  line:3941 func: pbx_load_module  Starting AEL load process.
+LOG: lev:2 file:pbx_ael.c  line:3948 func: pbx_load_module  AEL load process: calculated config file name './extensions.ael'.
 LOG: lev:2 file:ael.flex  line:429 func: ael_yylex    --Read in included file ./include1.ael2, 78 chars
 LOG: lev:2 file:ael.flex  line:429 func: ael_yylex    --Read in included file ./include2.ael2, 98 chars
 LOG: lev:2 file:ael.flex  line:429 func: ael_yylex    --Read in included file ./include3.ael2, 57 chars
 LOG: lev:2 file:ael.flex  line:429 func: ael_yylex    --Read in included file ./include5.ael2, 56 chars
 LOG: lev:2 file:ael.flex  line:429 func: ael_yylex    --Read in included file ./include4.ael2, 87 chars
 LOG: lev:2 file:ael.flex  line:429 func: ael_yylex    --Read in included file ./telemarket_torture.ael2, 28036 chars
-LOG: lev:2 file:pbx_ael.c  line:3925 func: pbx_load_module  AEL load process: parsed config file name './extensions.ael'.
+LOG: lev:2 file:pbx_ael.c  line:3956 func: pbx_load_module  AEL load process: parsed config file name './extensions.ael'.
 LOG: lev:3 file:pbx_ael.c  line:712 func: check_macro_returns  Warning: file ./extensions.ael, line 14-34: The macro std-exten does not end with a return; I will insert one.
-LOG: lev:3 file:pbx_ael.c  line:1352 func: check_goto  Warning: file ./extensions.ael, line 17-17: It's bad form to have a goto in a macro to a target outside the macro!
+LOG: lev:3 file:pbx_ael.c  line:1378 func: check_goto  Warning: file ./extensions.ael, line 17-17: It's bad form to have a goto in a macro to a target outside the macro!
 LOG: lev:3 file:pbx_ael.c  line:712 func: check_macro_returns  Warning: file ./extensions.ael, line 36-59: The macro std-priv-exten_1 does not end with a return; I will insert one.
 LOG: lev:3 file:pbx_ael.c  line:712 func: check_macro_returns  Warning: file ./extensions.ael, line 62-85: The macro std-priv-exten_2 does not end with a return; I will insert one.
 LOG: lev:3 file:pbx_ael.c  line:712 func: check_macro_returns  Warning: file ./extensions.ael, line 88-111: The macro std-priv-exten_3 does not end with a return; I will insert one.
@@ -93,8 +93,11 @@ LOG: lev:3 file:pbx_ael.c  line:712 func: check_macro_returns  Warning: file ./e
 LOG: lev:3 file:pbx_ael.c  line:712 func: check_macro_returns  Warning: file ./extensions.ael, line 2030-2048: The macro ciddial2 does not end with a return; I will insert one.
 LOG: lev:3 file:pbx_ael.c  line:712 func: check_macro_returns  Warning: file ./extensions.ael, line 2050-2065: The macro callerid-liar does not end with a return; I will insert one.
 LOG: lev:3 file:pbx_ael.c  line:712 func: check_macro_returns  Warning: file ./extensions.ael, line 2067-2072: The macro callerid-bad does not end with a return; I will insert one.
-LOG: lev:2 file:pbx_ael.c  line:3928 func: pbx_load_module  AEL load process: checked config file name './extensions.ael'.
-LOG: lev:2 file:pbx_ael.c  line:3930 func: pbx_load_module  AEL load process: compiled config file name './extensions.ael'.
-LOG: lev:2 file:pbx_ael.c  line:3933 func: pbx_load_module  AEL load process: merged config file name './extensions.ael'.
-LOG: lev:2 file:pbx_ael.c  line:3936 func: pbx_load_module  AEL load process: verified config file name './extensions.ael'.
+LOG: lev:3 file:pbx_ael.c  line:863 func: check_includes  Warning: file ./extensions.ael, line 2748-2752: The included context 'parkedcalls' cannot be found.
+LOG: lev:3 file:pbx_ael.c  line:863 func: check_includes  Warning: file ./extensions.ael, line 2955-2958: The included context 'parkedcalls' cannot be found.
+LOG: lev:3 file:pbx_ael.c  line:863 func: check_includes  Warning: file ./extensions.ael, line 3006-3013: The included context 'parkedcalls' cannot be found.
+LOG: lev:2 file:pbx_ael.c  line:3959 func: pbx_load_module  AEL load process: checked config file name './extensions.ael'.
+LOG: lev:2 file:pbx_ael.c  line:3961 func: pbx_load_module  AEL load process: compiled config file name './extensions.ael'.
+LOG: lev:2 file:pbx_ael.c  line:3964 func: pbx_load_module  AEL load process: merged config file name './extensions.ael'.
+LOG: lev:2 file:pbx_ael.c  line:3967 func: pbx_load_module  AEL load process: verified config file name './extensions.ael'.
 LOG: lev:4 file:ael2_parse  line:479 func: main  172 contexts, 858 extensions, 2406 priorities
diff --git a/pbx/ael/ael-test/ref.ael-vtest17 b/pbx/ael/ael-test/ref.ael-vtest17
new file mode 100644 (file)
index 0000000..bf18154
--- /dev/null
@@ -0,0 +1,67 @@
+
+
+[dialextens]
+exten => _10X,1,Dial(Zap/${EXTEN:2}|30|tw)
+exten => _1ZX,1,Dial(Zap/${EXTEN:1}|30|tw)
+
+
+[dialthrus]
+exten => _3XX,1,Dial(Zap/${EXTEN:1}|30|tw)
+
+
+[t1incoming]
+include => dialextens
+include => parkedcalls
+exten => s,1,Answer()
+exten => s,2,Background(welcome-to-test-machine)
+
+
+[incoming]
+include => dialextens
+include => parkedcalls
+exten => s,1,Answer()
+exten => s,2,Background(welcome-to-test-machine)
+
+
+[extension]
+include => dialextens
+include => dialthrus
+exten => 5,1,Record(recording:gsm)
+exten => 5,2,Background(recording)
+exten => 81,1,Set(iterations=$[1000000])
+exten => 81,2,Set(time1=${EPOCH})
+exten => 81,3,Set(i=$[1])
+exten => 81,4,GotoIf($[${i}<${iterations}]?5:8)
+exten => 81,5,NoOp(Hello)
+exten => 81,6,Set(i=$[${i}+1])
+exten => 81,7,Goto(4)
+exten => 81,8,NoOp(Finish for-extension-1)
+exten => 81,9,Set(time2=${EPOCH})
+exten => 81,10,Verbose(The time diff is $[${time2} - ${time1} ] seconds)
+exten => 81,11,Verbose(Which means that the priorities/sec = $[4* ${iterations} / (${time2} - ${time1}) ])
+exten => 81,12,SayNumber($[4 * ${iterations} / (${time2} - ${time1}) ])
+exten => 82,1,Gosub(ndeep|s|1(100000))
+exten => 82,2,Verbose(Finished 100000 levels deep call!)
+exten => 83,1,Goto(sw-2-${EXTEN}|1)
+exten => 83,2,NoOp(Finish switch-extension-2)
+exten => _sw-2-[4-7]X,1,Verbose(and this too!)
+exten => _sw-2-[4-7]X,2,Goto(83|2)
+exten => _sw-2-9X,1,Verbose(handle both 8x and 9x calls)
+exten => _sw-2-9X,2,Goto(sw-2-49|1)
+exten => _sw-2-8X,1,Verbose(do something to prepare it)
+exten => _sw-2-8X,2,Goto(sw-2-99|1)
+
+
+[ndeep]
+exten => s,1,Set(level=${ARG1})
+exten => s,2,GotoIf($[${level} == 0]?3:5)
+exten => s,3,Verbose(2|Got to Level 0)
+exten => s,4,Return()
+exten => s,5,NoOp(Finish if-ndeep-3)
+exten => s,6,Gosub(ndeep|s|1($[${level}-1]))
+exten => s,7,Return()
+
+
+[t1extension]
+include => dialextens
+include => dialthrus
index 3aae866..194fd32 100644 (file)
@@ -2926,6 +2926,29 @@ static void remove_spaces_before_equals(char *str)
        }
 }
 
+static void gen_match_to_pattern(char *pattern, char *result)
+{
+       /* the result will be a string that will be matched by pattern */
+       char *p=pattern, *t=result;
+       while (*p) {
+               if (*p == 'x' || *p == 'n' || *p == 'z' || *p == 'X' || *p == 'N' || *p == 'Z')
+                       *t++ = '9';
+               else if (*p == '[') {
+                       char *z = p+1;
+                       while (*z != ']')
+                               z++;
+                       if (*(z+1)== ']')
+                               z++;
+                       *t++=*(p+1); /* use the first char in the set */
+                       p = z;
+               } else {
+                       *t++ = *p;
+               }
+               p++;
+       }
+       *t++ = 0; /* cap it off */
+}
+
 static void gen_prios(struct ael_extension *exten, char *label, pval *statement, struct ael_extension *mother_exten, struct ast_context *this_context )
 {
        pval *p,*p2,*p3;
@@ -3173,14 +3196,15 @@ static void gen_prios(struct ael_extension *exten, char *label, pval *statement,
                                                        fall_thru = new_prio();
                                                        fall_thru->type = AEL_APPCALL;
                                                        fall_thru->app = strdup("Goto");
-                                                       snprintf(buf1,sizeof(buf1),"_sw-%d-%s|1",local_control_statement_count, p2->next->u1.str);
+                                                       gen_match_to_pattern(p2->next->u1.str, buf2);
+                                                       snprintf(buf1,sizeof(buf1),"sw-%d-%s|1", local_control_statement_count, buf2);
                                                        fall_thru->appargs = strdup(buf1);
                                                        linkprio(switch_case, fall_thru);
                                                } else if (p2->next && p2->next->type == PV_DEFAULT) {
                                                        fall_thru = new_prio();
                                                        fall_thru->type = AEL_APPCALL;
                                                        fall_thru->app = strdup("Goto");
-                                                       snprintf(buf1,sizeof(buf1),"_sw-%d-.|1",local_control_statement_count);
+                                                       snprintf(buf1,sizeof(buf1),"sw-%d-.|1",local_control_statement_count);
                                                        fall_thru->appargs = strdup(buf1);
                                                        linkprio(switch_case, fall_thru);
                                                } else if (!p2->next) {
@@ -3234,14 +3258,15 @@ static void gen_prios(struct ael_extension *exten, char *label, pval *statement,
                                                        fall_thru = new_prio();
                                                        fall_thru->type = AEL_APPCALL;
                                                        fall_thru->app = strdup("Goto");
-                                                       snprintf(buf1,sizeof(buf1),"_sw-%d-%s|1",local_control_statement_count, p2->next->u1.str);
+                                                       gen_match_to_pattern(p2->next->u1.str, buf2);
+                                                       snprintf(buf1,sizeof(buf1),"sw-%d-%s|1",local_control_statement_count, buf2);
                                                        fall_thru->appargs = strdup(buf1);
                                                        linkprio(switch_case, fall_thru);
                                                } else if (p2->next && p2->next->type == PV_DEFAULT) {
                                                        fall_thru = new_prio();
                                                        fall_thru->type = AEL_APPCALL;
                                                        fall_thru->app = strdup("Goto");
-                                                       snprintf(buf1,sizeof(buf1),"_sw-%d-.|1",local_control_statement_count);
+                                                       snprintf(buf1,sizeof(buf1),"sw-%d-.|1",local_control_statement_count);
                                                        fall_thru->appargs = strdup(buf1);
                                                        linkprio(switch_case, fall_thru);
                                                } else if (!p2->next) {
@@ -3297,14 +3322,15 @@ static void gen_prios(struct ael_extension *exten, char *label, pval *statement,
                                                        fall_thru = new_prio();
                                                        fall_thru->type = AEL_APPCALL;
                                                        fall_thru->app = strdup("Goto");
-                                                       snprintf(buf1,sizeof(buf1),"_sw-%d-%s|1",local_control_statement_count, p2->next->u1.str);
+                                                       gen_match_to_pattern(p2->next->u1.str, buf2);
+                                                       snprintf(buf1,sizeof(buf1),"sw-%d-%s|1",local_control_statement_count, buf2);
                                                        fall_thru->appargs = strdup(buf1);
                                                        linkprio(switch_case, fall_thru);
                                                } else if (p2->next && p2->next->type == PV_DEFAULT) {
                                                        fall_thru = new_prio();
                                                        fall_thru->type = AEL_APPCALL;
                                                        fall_thru->app = strdup("Goto");
-                                                       snprintf(buf1,sizeof(buf1),"_sw-%d-.|1",local_control_statement_count);
+                                                       snprintf(buf1,sizeof(buf1),"sw-%d-.|1",local_control_statement_count);
                                                        fall_thru->appargs = strdup(buf1);
                                                        linkprio(switch_case, fall_thru);
                                                } else if (!p2->next) {