Possible issue with awk

Denys Vlasenko vda.linux at googlemail.com
Thu Mar 11 11:19:05 UTC 2010


On Thu, Mar 11, 2010 at 1:52 AM, Harald Becker <ralda at gmx.de> wrote:
>> To change the busybox for-in loop behavior of awk to that of gawk the
>> following steps are required:
>> - add an extra node OC_WALKDONE to the end of the for-in loop node list

Yes. And/or create OC_BREAK operation which is executed by break statement.
IIUC, in current code break becomes just an unconditional jump -
no cleanup is performed.

>> - save the current variable contents in hashwalk_init (OC_WALKINIT)

No need, we don't need to restore old var contents

>> - save the current walker list in hashwalk_init (OC_WALKINIT)
>> - do NOT modify hashwalk_next (OC_WALKNEXT)
>> - add an execution node for OC_WALKDONE
>> - restore previous walker list in OC_WALKDONE
>> - restore previous variable contents in OC_WALKDONE
>
> In addition to those the variable contents and walker list has to be
> restored if the loop is exited with a return statement (in a function).

Yep. I added tests for both cases to testsuite/awk.tests...

> That makes it even more complicated. Saving the loop variable contents
> and walker list on the variable stack is possibly a good choice, but
> variable stack code (nvalloc/nvfree) needs modification/rewrite to work
> properly in all cases.

Didn't look at it yet. What it also needs for sure is comments on its design...
-- 
vda


More information about the busybox mailing list