awk: fix 'delete array[var--]' decrementing var twice
function old new delta evaluate 3395 3390 -5 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
@@ -261,6 +261,25 @@ end d
|
||||
" \
|
||||
"" ""
|
||||
|
||||
prg='
|
||||
BEGIN{
|
||||
cnt = 0
|
||||
a[cnt] = "zeroth"
|
||||
a[++cnt] = "first"
|
||||
delete a[cnt--]
|
||||
print cnt
|
||||
print "[0]:" a[0]
|
||||
print "[1]:" a[1]
|
||||
}'
|
||||
testing "awk 'delete a[v--]' evaluates v-- once" \
|
||||
"awk '$prg'" \
|
||||
"\
|
||||
0
|
||||
[0]:zeroth
|
||||
[1]:
|
||||
" \
|
||||
"" ""
|
||||
|
||||
testing "awk handles empty ()" \
|
||||
"awk 'BEGIN {print()}' 2>&1" "awk: cmd. line:1: Empty sequence\n" "" ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user