Summary: | ASTERISK-14627: [patch] ARG Variables are not overwritten when using empty values on macros | ||
Reporter: | dillec (dillec) | Labels: | |
Date Opened: | 2009-08-10 16:12:31 | Date Closed: | 2011-06-07 14:08:16 |
Priority: | Minor | Regression? | No |
Status: | Closed/Complete | Components: | PBX/pbx_ael |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ( 0) asterisk-1.6.1.2-ael_macro_null_args.diff ( 1) asterisk-1.6.2.0-rc8-ael_macro_null_args.diff.txt | |
Description: | If you pass emtpy values inside of a macro to another macro, the ARG arguments are not overwritten: &MacroOne("one","two","three","four"); macro MacroOne (var1, var2, var3, var4) { var3=""; // also tried var=${} here - makes no difference &MacroTwo(${var1},${var2},${var4},${var3}); }; macro MacroTwo (var1, var2, var3, var4) { Verbose("Arg1 ${ARG1} Arg2 ${ARG2} Arg3 ${ARG3} Arg4 ${ARG4}"); }; As you can see in the output below, four is also assigned to var4 in MacroTwo although it is passed as an empty value. ****** ADDITIONAL INFORMATION ****** -- Executing [flow@2307_1:2] Gosub("SIP/micha-ee937418", "MacroOne,s,1("one","two","three","four")") in new stack -- Executing [s@MacroOne:1] MSet("SIP/micha-ee937418", "LOCAL(var1)=one") in new stack -- Executing [s@MacroOne:2] MSet("SIP/micha-ee937418", "LOCAL(var2)=two") in new stack -- Executing [s@MacroOne:3] MSet("SIP/micha-ee937418", "LOCAL(var3)=three") in new stack -- Executing [s@MacroOne:4] MSet("SIP/micha-ee937418", "LOCAL(var4)=four") in new stack -- Executing [s@MacroOne:5] MSet("SIP/micha-ee937418", "var3=""") in new stack -- Executing [s@MacroOne:6] Gosub("SIP/micha-ee937418", "MacroTwo,s,1(one,two,four,)") in new stack -- Executing [s@MacroTwo:1] MSet("SIP/micha-ee937418", "LOCAL(var1)=one") in new stack -- Executing [s@MacroTwo:2] MSet("SIP/micha-ee937418", "LOCAL(var2)=two") in new stack -- Executing [s@MacroTwo:3] MSet("SIP/micha-ee937418", "LOCAL(var3)=four") in new stack -- Executing [s@MacroTwo:4] MSet("SIP/micha-ee937418", "LOCAL(var4)=four") in new stack -- Executing [s@MacroTwo:5] Verbose("SIP/micha-ee937418", ""Arg1 one Arg2 two Arg3 four Arg4 four"") in new stack Arg1 one Arg2 two Arg3 four Arg4 four | ||
Comments: | By: Tim Ferguson (crashhd) 2009-12-17 01:40:42.000-0600 Possible relation to 16458? By: Corey Farrell (coreyfarrell) 2009-12-29 12:52:59.000-0600 CrashHD: I don't believe this ticket is related to 16458. By: Corey Farrell (coreyfarrell) 2009-12-29 13:32:01.000-0600 I've experience this issue as well, I've worked around in AEL scripts by clearing ARG# variables. AEL uses ARG# variables for temporary storage of macro/gosub parameters, but never clears the variables. AEL generates the following contexts for MacroOne: [ Context 'MacroOne' created by 'pbx_ael' ] 's' => 1. MSet(LOCAL(var1)=${ARG1}) [pbx_ael] 2. MSet(LOCAL(var2)=${ARG2}) [pbx_ael] 3. MSet(LOCAL(var3)=${ARG3}) [pbx_ael] 4. MSet(LOCAL(var4)=${ARG4}) [pbx_ael] 5. MSet(var3=$[""]) [pbx_ael] 6. Gosub(MacroTwo,s,1(${var1},${var2},${var4},${var3})) [pbx_ael] 7. Return() [pbx_ael] The problem is that ARG4 is never cleared. Gosub(MacroTwo,s,1(${var1},${var2},${var4},${var3})) seems to skip assignment of ARG4 since ${var3} is blank. My patch causes the following context to be generated by the same AEL code: [ Context 'MacroOne' created by 'pbx_ael' ] 's' => 1. MSet(LOCAL(var1)=${ARG1},ARG1=) [pbx_ael] 2. MSet(LOCAL(var2)=${ARG2},ARG2=) [pbx_ael] 3. MSet(LOCAL(var3)=${ARG3},ARG3=) [pbx_ael] 4. MSet(LOCAL(var4)=${ARG4},ARG4=) [pbx_ael] 5. MSet(var3=$[""]) [pbx_ael] 6. Gosub(MacroTwo,s,1(${var1},${var2},${var4},${var3})) [pbx_ael] 7. Return() [pbx_ael] I'm not sure if this should corrected in the Gosub code (ensure that blank parameters are processed). I choose to clear ARG# variables at the start of each procedure. The patch attached for 1.6.2.0-rc8 is good for 1.6.2.0 release. Without the patch this issue can be worked around by manually clearing ARG# variables at the start of procedures: macro MacroOne (var1, var2, var3, var4) { ARG1=""; ARG2=""; ARG3=""; ARG4=""; // this set's the default value of ARG4 to blank instead of retaining the value of ${var4} var3=""; &MacroTwo(${var1},${var2},${var4},${var3}); // can also use: &MacroTwo(${var1},${var2},${var4},); }; By: Tilghman Lesher (tilghman) 2009-12-29 17:32:52.000-0600 Already fixed in 1.6.0.14 and 1.6.1.5. Please, in the future, try the latest release before reporting an issue, because the problem you're reporting may already be fixed. |