[Home]

Summary:ASTERISK-18593: AEL for loops use Macro app and pipe delimiter
Reporter:Luke-Jr (luke-jr)Labels:
Date Opened:2011-09-20 16:40:29Date Closed:2019-04-16 08:10:43
Priority:MajorRegression?Yes
Status:Closed/CompleteComponents:PBX/pbx_ael Utilities/aelparse Utilities/conf2ael
Versions:SVN 1.6.2.20 13.18.4 Frequency of
Occurrence
Constant
Related
Issues:
is related toASTERISK-13716 [patch] Add support in AEL for macro return values and direct assignment of them to variables and functions.
Environment:Attachments:
Description:Using "macros" inside of "for" loops compiles to the old Macro application using pipes as delimiters. It should be modified to use the new Gosub-and-comma syntax. The offending code is on lines 3548-3566 in res/ael/pval.c in at least 1.6.2.9 through Subversion trunk.
Comments:By: Leif Madsen (lmadsen) 2011-09-21 08:21:20.703-0500

Please provide the applicable AEL and console output that shows this happening, and which makes this trivial to reproduce. Thanks!

By: Luke-Jr (luke-jr) 2011-09-21 10:34:11.765-0500

macro route-BASE(exten, Timeout, DialOpts, IsPOTS) {
Dial(SIP/BASE/${exten},${Timeout},o${DialOpts});
return;
};

macro TryRoutes(TRY, exten, Timeout, DialOpts, IsPOTS) {
for (&iterator(${TRY},A); "${A}" != ""; &iterate(A)) {
NoOP(Trying route ${A});
&route-${A}(${exten},${Timeout},${DialOpts},${IsPOTS});
switch(${DIALSTATUS}) {
case BUSY:
Busy();
Hangup(); // is this needed?
break;
default:
NoOP(not busy\, so trying next route...);
break;
};
};
Congestion();
return;
};

context test {
s => &TryRoutes(BASE,${exten},${Timeout},${DialOpts},1);
}

By: Leif Madsen (lmadsen) 2011-09-22 07:26:40.792-0500

This block of dialplan doesn't work for me. Gives syntax errors so I can't reproduce this issue.

By: Tzafrir Cohen (tzafrir) 2011-09-28 06:29:31.602-0500

FWIW, I tried a simpler dialplan and it works as planned (prints variables separately in the trrace) in my 1.6.2.9 package of Debian Squeeze.

macro inner-mac(i,x,y,z) {
       NoOP(<i=${i}> <x=${x}>, <y=${y}>, z=<${z}>);
       return;
}

macro mymac(x,y,z) {
       for (i=${x}; ${i} <= ${y}; i=${i}+${z}) {
               &inner-mac(${i},${x},${y},${z});
       }
       return;
};

context test {
       _XXX => &mymac(${EXTEN:0:1},${EXTEN:1:1},${EXTEN:2:1});
}

By: Luke-Jr (luke-jr) 2011-09-28 10:48:49.812-0500

As I said, this bug involves calling a macro inside a for loop. Your "simpler dialplan" does not do that, it only has expressions. The bug is plainly obvious from lines 3548-3566 in res/ael/pval.c; I'll get around to figuring out a test case if needed eventually, but I'm swamped at the moment.

By: Leif Madsen (lmadsen) 2011-10-03 12:26:59.483-0500

I'm acknowledging this issue as it looks like Tzafrir will take the lead, but I still don't see an updated AEL set of code that really shows what is going on here.

By: Friendly Automation (friendly-automation) 2019-04-16 08:10:45.293-0500

Change 11267 merged by Joshua Colp:
res_ael: Use Gosub in for loop expressions

[https://gerrit.asterisk.org/c/asterisk/+/11267|https://gerrit.asterisk.org/c/asterisk/+/11267]

By: Friendly Automation (friendly-automation) 2019-04-16 08:13:21.211-0500

Change 11269 merged by Joshua Colp:
res_ael: Use Gosub in for loop expressions

[https://gerrit.asterisk.org/c/asterisk/+/11269|https://gerrit.asterisk.org/c/asterisk/+/11269]

By: Friendly Automation (friendly-automation) 2019-04-16 08:13:32.552-0500

Change 11268 merged by Joshua Colp:
res_ael: Use Gosub in for loop expressions

[https://gerrit.asterisk.org/c/asterisk/+/11268|https://gerrit.asterisk.org/c/asterisk/+/11268]