res_ael: Use Gosub in for loop expressions

In AEL2, if a 'for' statement contains macro* calls, like:

    for (&iterator(${TRY},A); "${A}" != ""; &iterate(A)) {

The AEL2 parser will translate these into calls to the deprecated Macro
dialplan application and use the antiquated pipe delimiter.

Instead, convert these into calls to the Gosub dialplan application and
use commas as argument separators.

ASTERISK-18593 #close
Reported by: Luke-Jr

* 'macro' in this context means AEL2 macros, not the 'Macro' application

Change-Id: I3d73716033b8e3e42e0209d355bf5f10c97045fc
This commit is contained in:
Sean Bright 2019-04-11 16:29:20 -04:00
parent cb282d5c17
commit f7f1a2cbb7
1 changed files with 3 additions and 7 deletions

View File

@ -3540,18 +3540,14 @@ static int gen_prios(struct ael_extension *exten, char *label, pval *statement,
strcpy(buf2, strp3);
strp3 = strchr(buf2,'(');
if (strp3) {
*strp3 = '|';
}
while ((strp3=strchr(buf2,','))) {
*strp3 = '|';
*strp3 = ',';
}
strp3 = strrchr(buf2, ')');
if (strp3)
*strp3 = 0; /* remove the closing paren */
for_init->appargs = strdup(buf2);
free(for_init->app);
for_init->app = strdup("Macro");
for_init->app = strdup("Gosub");
} else { /* must be a regular app call */
char *strp3;
strcpy(buf2, strp2);
@ -3598,7 +3594,7 @@ static int gen_prios(struct ael_extension *exten, char *label, pval *statement,
for_inc->appargs = strdup(buf2);
for_inc->app = strdup("Macro");
for_inc->app = strdup("Gosub");
} else { /* must be a regular app call */
char *strp3;
strcpy(buf2, strp2);