[Home]

Summary:ASTERISK-06627: for loops execute iteration (arg 3) after initialization (arg 1)
Reporter:Luke-Jr (luke-jr)Labels:
Date Opened:2006-03-27 16:40:00.000-0600Date Closed:2006-07-06 11:15:57
Priority:MinorRegression?No
Status:Closed/CompleteComponents:PBX/pbx_ael
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:This code:
 for (a; b; c) d;
should expand as:
 a; while(b) { d; c; }
but currently is expanded as:
 a; while(b) { c; d; }

This causes 'c' to be executed prior to the initial iteration of the loop, which resulting in the first step of any for loop to be skipped.

****** ADDITIONAL INFORMATION ******

In current CVS HEAD, the fix is to switch lines 776 and 777 in pbx/pbx_ael.c:
776->777: build_step("for", margs, filename, lineno, con, exten, pos, fields->next->next->data, &fillin, label);
777->776: build_step("for", margs, filename, lineno, con, exten, pos, c, &fillin, label);
Comments:By: Russell Bryant (russell) 2006-03-28 12:14:45.000-0600

fixed in 1.2 and the trunk in reivisions 15658 and 15659, thanks!