| 1 |
# From [email protected] Sat May 17 21:31:27 2003 |
| 2 |
# Return-Path: <[email protected]> |
| 3 |
# Received: from localhost (aahz [127.0.0.1]) |
| 4 |
# by skeeve.com (8.12.5/8.12.5) with ESMTP id h4HIQmCw001380 |
| 5 |
# for <arnold@localhost>; Sat, 17 May 2003 21:31:27 +0300 |
| 6 |
# Received: from actcom.co.il [192.114.47.1] |
| 7 |
# by localhost with POP3 (fetchmail-5.9.0) |
| 8 |
# for arnold@localhost (single-drop); Sat, 17 May 2003 21:31:27 +0300 (IDT) |
| 9 |
# Received: by actcom.co.il (mbox arobbins) |
| 10 |
# (with Cubic Circle's cucipop (v1.31 1998/05/13) Sat May 17 21:34:07 2003) |
| 11 |
# X-From_: [email protected] Fri May 16 20:38:45 2003 |
| 12 |
# Received: from smtp1.actcom.net.il by actcom.co.il with ESMTP |
| 13 |
# (8.11.6/actcom-0.2) id h4GHcd226764 for <[email protected]>; |
| 14 |
# Fri, 16 May 2003 20:38:40 +0300 (EET DST) |
| 15 |
# (rfc931-sender: mail.actcom.co.il [192.114.47.13]) |
| 16 |
# Received: from f7.net (consort.superb.net [209.61.216.22]) |
| 17 |
# by smtp1.actcom.net.il (8.12.8/8.12.8) with ESMTP id h4GHgBc2023067 |
| 18 |
# for <[email protected]>; Fri, 16 May 2003 20:42:13 +0300 |
| 19 |
# Received: from sunshine.math.utah.edu (sunshine.math.utah.edu [128.110.198.2]) |
| 20 |
# by f7.net (8.11.7/8.11.6) with ESMTP id h4GHcbf09202 |
| 21 |
# for <[email protected]>; Fri, 16 May 2003 13:38:37 -0400 |
| 22 |
# Received: from suncore.math.utah.edu (IDENT:[email protected] [128.110.198.5]) |
| 23 |
# by sunshine.math.utah.edu (8.9.3p2/8.9.3) with ESMTP id LAA09111; |
| 24 |
# Fri, 16 May 2003 11:38:34 -0600 (MDT) |
| 25 |
# Received: (from beebe@localhost) |
| 26 |
# by suncore.math.utah.edu (8.9.3p2/8.9.3) id LAA01743; |
| 27 |
# Fri, 16 May 2003 11:38:34 -0600 (MDT) |
| 28 |
# Date: Fri, 16 May 2003 11:38:34 -0600 (MDT) |
| 29 |
# From: "Nelson H. F. Beebe" <[email protected]> |
| 30 |
# To: "Arnold Robbins" <[email protected]> |
| 31 |
# Cc: [email protected] |
| 32 |
# X-US-Mail: "Center for Scientific Computing, Department of Mathematics, 110 |
| 33 |
# LCB, University of Utah, 155 S 1400 E RM 233, Salt Lake City, UT |
| 34 |
# 84112-0090, USA" |
| 35 |
# X-Telephone: +1 801 581 5254 |
| 36 |
# X-FAX: +1 801 585 1640, +1 801 581 4148 |
| 37 |
# X-URL: http://www.math.utah.edu/~beebe |
| 38 |
# Subject: gawk-3.1.2[ab]: bug in delete |
| 39 |
# Message-ID: <[email protected]> |
| 40 |
# |
| 41 |
# I discovered yesterday that one of my tools got broken by the upgrade |
| 42 |
# to gawk-3.1.2a and gawk-3.1.2b. For now, I've temporarily reset |
| 43 |
# /usr/local/bin/gawk on the Sun Solaris and Intel GNU/Linux systems |
| 44 |
# back to be gawk-3.1.2. |
| 45 |
# |
| 46 |
# This morning, I isolated the problem to the following small test case: |
| 47 |
# |
| 48 |
# % cat bug.awk |
| 49 |
BEGIN { |
| 50 |
clear_array(table) |
| 51 |
foo(table) |
| 52 |
# 3/2022: This was the original. Use of 'k' in the print was |
| 53 |
# undoubtedly a typo but it helped find a bug, so let's |
| 54 |
# make it for real |
| 55 |
# for (key in table) |
| 56 |
# print key, table[k] |
| 57 |
for (key in table) |
| 58 |
print key, table[key], "<" table[k] ">" |
| 59 |
clear_array(table) |
| 60 |
exit(0) |
| 61 |
} |
| 62 |
|
| 63 |
function clear_array(array, key) |
| 64 |
{ |
| 65 |
for (key in array) |
| 66 |
delete array[key] |
| 67 |
} |
| 68 |
|
| 69 |
function foo(a) |
| 70 |
{ |
| 71 |
a[1] = "one" |
| 72 |
a[2] = "two" |
| 73 |
} |
| 74 |
# |
| 75 |
# With nawk, mawk, and also gawk-3.1.2 or earlier, I get this: |
| 76 |
# |
| 77 |
# % mawk -f bug.awk |
| 78 |
# 1 |
| 79 |
# 2 |
| 80 |
# |
| 81 |
# However, with the two most recent gawk releases, I get: |
| 82 |
# |
| 83 |
# % gawk-3.1.2b -f bug.awk |
| 84 |
# gawk-3.1.2b: bug.awk:12: fatal: delete: illegal use of variable `table' as |
| 85 |
# array |
| 86 |
# |
| 87 |
# If the first clear_array() statement is commented out, it runs. |
| 88 |
# However, the problem is that in a large program, it may not be easy to |
| 89 |
# identify places where it is safe to invoke delete, so I believe the |
| 90 |
# old behavior is more desirable. |
| 91 |
# |
| 92 |
# ------------------------------------------------------------------------------- |
| 93 |
# - Nelson H. F. Beebe Tel: +1 801 581 5254 - |
| 94 |
# - Center for Scientific Computing FAX: +1 801 581 4148 - |
| 95 |
# - University of Utah Internet e-mail: [email protected] - |
| 96 |
# - Department of Mathematics, 110 LCB [email protected] [email protected] - |
| 97 |
# - 155 S 1400 E RM 233 [email protected] - |
| 98 |
# - Salt Lake City, UT 84112-0090, USA URL: http://www.math.utah.edu/~beebe - |
| 99 |
# ------------------------------------------------------------------------------- |
| 100 |
# |