|
From: | Louis Jean-Richard |
Subject: | [bug-gawk] Function call bug in GNU Awk 3.1.6 |
Date: | Tue, 15 Nov 2011 17:08:43 +0100 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.23) Gecko/20110921 Thunderbird/3.1.15 |
Here after a simplified down awk program that
misbehaves: awk --version awk '# function indexKey(data) { "echo \x22" "30c9a839" data "\x22" | getline key return substr(key, 1, 32) } BEGIN { TW = sprintf("%032d756f36b", 1357) TWK = indexKey(TW) # keyAAAA = indexKey("AAAA-" TWK) keyBBBB = indexKey("BBBB-" TWK) keyCCCC = indexKey("CCCC-" TWK) print "AAAA " keyAAAA print "AAAA- " indexKey("AAAA-23056") print "BBBB " keyBBBB print "CCCC " keyCCCC print " The following four lines should be the same as the four preceding." print "AAAA " indexKey("AAAA-" TWK) print "AAAA- " indexKey("AAAA-23056") print "BBBB " indexKey("BBBB-" TWK) print "CCCC " indexKey("CCCC-" TWK) } ' on my box with ubuntu this gives: louis$ gawk_bug GNU Awk 3.1.6 Copyright (C) 1989, 1991-2007 Free Software Foundation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. AAAA 30c9a839AAAA-30c9a83900000000000 AAAA- 30c9a839AAAA-23056 BBBB 30c9a839BBBB-30c9a83900000000000 CCCC 30c9a839CCCC-30c9a83900000000000 The following four lines should be the same as the four preceding. AAAA 30c9a839AAAA-23056 AAAA- 30c9a839AAAA-23056 BBBB 30c9a839AAAA-23056 CCCC 30c9a839AAAA-23056 This bug took half of my work day to pin down... Sincerely Louis Jean-Richard |
[Prev in Thread] | Current Thread | [Next in Thread] |