res_ael: Use Gosub in for loop expressions
authorSean Bright <sean.bright@gmail.com>
Thu, 11 Apr 2019 20:29:20 +0000 (16:29 -0400)
committerSean Bright <sean.bright@gmail.com>
Thu, 11 Apr 2019 20:38:19 +0000 (14:38 -0600)
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

res/ael/pval.c

index f927077..4e9a525 100644 (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);