[asterisk-commits] branch murf/AEL2 - r8458 /team/murf/AEL2/pbx/pbx_ael2.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Jan 22 21:46:01 MST 2006


Author: murf
Date: Sun Jan 22 22:45:56 2006
New Revision: 8458

URL: http://svn.digium.com/view/asterisk?rev=8458&view=rev
Log:
Since the Random() app seems to be deprecated, it is probably not wise to use it in the compiler.
So, I replaced the use of Random() with GotoIf, with the conditional in this form: $[ ${RAND(0,99)} < (num) ]

It should behave the same.


Modified:
    team/murf/AEL2/pbx/pbx_ael2.c

Modified: team/murf/AEL2/pbx/pbx_ael2.c
URL: http://svn.digium.com/view/asterisk/team/murf/AEL2/pbx/pbx_ael2.c?rev=8458&r1=8457&r2=8458&view=diff
==============================================================================
--- team/murf/AEL2/pbx/pbx_ael2.c (original)
+++ team/murf/AEL2/pbx/pbx_ael2.c Sun Jan 22 22:45:56 2006
@@ -2458,8 +2458,9 @@
 	struct ael_priority *while_test, *while_loop, *while_end;
 	struct ael_priority *switch_test, *switch_end, *fall_thru;
 	struct ael_priority *if_test, *if_end, *if_skip, *if_false;
+#ifdef OLD_RAND_ACTION
 	struct ael_priority *rand_test, *rand_end, *rand_skip;
-	
+#endif
 	char buf1[18000];
 	char buf2[18000];
 	char *strp, *strp2;
@@ -2899,6 +2900,7 @@
 			linkprio(exten, pr);
 			break;
 
+#ifdef OLD_RAND_ACTION
 		case PV_RANDOM:
 			control_statement_count++;
 			snprintf(new_label,sizeof(new_label),"rand-%s-%d", label, control_statement_count);
@@ -2936,7 +2938,8 @@
 			linkprio(exten, rand_end);
 			
 			break;
-			
+#endif			
+
 		case PV_IFTIME:
 			control_statement_count++;
 			snprintf(new_label,sizeof(new_label),"iftime-%s-%d", label, control_statement_count);
@@ -2996,6 +2999,7 @@
 			
 			break;
 
+		case PV_RANDOM:
 		case PV_IF:
 			control_statement_count++;
 			snprintf(new_label,sizeof(new_label),"if-%s-%d", label, control_statement_count);
@@ -3004,7 +3008,10 @@
 			if_end = new_prio();
 			if_test->type = AEL_IF_CONTROL;
 			if_end->type = AEL_APPCALL;
-			snprintf(buf1,sizeof(buf1),"$[%s]",p->u1.str);
+			if ( p->type == PV_RANDOM )
+				snprintf(buf1,sizeof(buf1),"$[${RAND(0,99)} < (%s)]",p->u1.str);
+			else
+				snprintf(buf1,sizeof(buf1),"$[%s]",p->u1.str);
 			if_test->app = 0;
 			if_test->appargs = strdup(buf1);
 			snprintf(buf1,sizeof(buf1),"Finish if-%s-%d", label, control_statement_count);



More information about the asterisk-commits mailing list