awk: fix the case where nested "for" loops with the same variable misbehave

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2010-03-10 19:20:32 +01:00
parent eae697fb93
commit 3cb60c3973
2 changed files with 59 additions and 11 deletions

View File

@@ -67,4 +67,42 @@ testing "awk string cast (bug 725)" \
testing "awk handles whitespace before array subscript" \
"awk 'BEGIN { arr [3] = 1; print arr [3] }'" "1\n" "" ""
prg='
BEGIN {
v["q"]=1
v["w"]=1
v["e"]=1
for (l in v) {
print "outer1", l;
for (l in v) {
print " inner", l;
}
print "outer2", l;
}
print "end", l;
l="a"
exit;
}'
testing "awk nested loops with the same variable" \
"awk '$prg'" \
"\
outer1 e
inner e
inner q
inner w
outer2 w
outer1 q
inner e
inner q
inner w
outer2 w
outer1 w
inner e
inner q
inner w
outer2 w
end w
" \
"" ""
exit $FAILCOUNT