Blame test/getnr2tm.awk

Packit 575503
#From dhw@gamgee.acad.emich.edu  Sat Oct 31 22:54:07 1998
Packit 575503
#Return-Path: <dhw@gamgee.acad.emich.edu>
Packit 575503
#Received: from cssun.mathcs.emory.edu (cssun.mathcs.emory.edu [170.140.150.1])
Packit 575503
#	by amx.netvision.net.il (8.9.0.Beta5/8.8.6) with ESMTP id HAA08891
Packit 575503
#	for <arobbins@netvision.net.il>; Sat, 31 Oct 1998 07:14:07 +0200 (IST)
Packit 575503
#Received: from mescaline.gnu.org (we-refuse-to-spy-on-our-users@mescaline.gnu.org [158.121.106.21]) by cssun.mathcs.emory.edu (8.7.5/8.6.9-940818.01cssun) with ESMTP id AAA14947 for <arnold@mathcs.emory.edu>; Sat, 31 Oct 1998 00:14:32 -0500 (EST)
Packit 575503
#Received: from gamgee.acad.emich.edu (gamgee.acad.emich.edu [164.76.102.76])
Packit 575503
#	by mescaline.gnu.org (8.9.1a/8.9.1) with SMTP id AAA20645
Packit 575503
#	for <arnold@gnu.ai.mit.edu>; Sat, 31 Oct 1998 00:17:54 -0500
Packit 575503
#Received: by gamgee.acad.emich.edu (Smail3.1.29.1 #57)
Packit 575503
#	id m0zZUKY-000IDSC; Sat, 31 Oct 98 00:16 CST
Packit 575503
#Message-Id: <m0zZUKY-000IDSC@gamgee.acad.emich.edu>
Packit 575503
#Date: Sat, 31 Oct 98 00:16 CST
Packit 575503
#From: dhw@gamgee.acad.emich.edu (David H. West)
Packit 575503
#To: bug-gnu-utils@gnu.org
Packit 575503
#Subject: gawk 3.0.3 bug report
Packit 575503
#Cc: arnold@gnu.org
Packit 575503
#X-UIDL: 7474b825cff989adf38f13883d84fdd7
Packit 575503
#Status: RO
Packit 575503
#
Packit 575503
#gawk version: 3.03
Packit 575503
#System used: Linux, kernel 2.0.28, libc 5.4.33, AMD K5PR133 (i586 clone)
Packit 575503
#Remark: There seems to be at least one bug shown by the demo below. 
Packit 575503
#        There may also be a Dark Corner involving the value of NR in an
Packit 575503
#        END block, a topic on which the info file is silent.  In gawk
Packit 575503
#        3.0.3, NR often seems to have the least-surprise value in an
Packit 575503
#        END block, but sometimes it doesn't - see example below.
Packit 575503
#Problem descr: the log below shows a case where:
Packit 575503
#        a) (this may be a red herring) the output of the gawk script
Packit 575503
#           is different depending on whether its input file is named on
Packit 575503
#           the command line or catted to stdin, without any use of the
Packit 575503
#           legitimate means which could produce this effect.
Packit 575503
#        b) NR is clearly getting clobbered; I have tried to simplify
Packit 575503
#           the 19-line script "awkerr1" below, but seemingly unrelated
Packit 575503
#           changes, like shortening constant strings which appear only in
Packit 575503
#           print statements, or removing unexecuted or irrelevant code,
Packit 575503
#           cause the clobbering to go away.  Some previous (larger)
Packit 575503
#           versions of this code would clobber NR also when reading from
Packit 575503
#           stdin, but I thought you'd prefer a shorter example :-).
Packit 575503
#Reproduce-By: using the gawk script "awkerr1", the contents of
Packit 575503
#              which appear in the transcript below as the output of the
Packit 575503
#              command "cat awkerr1".  Comments following # were added
Packit 575503
#              to the transcript later as explanation.
Packit 575503
#---------------------------------------------- Script started on Fri
Packit 575503
#Oct 30 20:04:16 1998 chipmunk:/ram0# ls -l a1 awkerr1 -rw-r--r--   1
Packit 575503
#root     root            2 Oct 30 18:42 a1 -rwxr-xr-x   1 root     root
Packit 575503
#389 Oct 30 19:54 awkerr1 chipmunk:/ram0# cat a1            #a1 contains
Packit 575503
#one printable char and a newline a chipmunk:/ram0# od -c? ?xc a1
Packit 575503
#0000000 0a61
Packit 575503
#          a  \n
Packit 575503
#0000002 chipmunk:/ram0# cat a1 | awkerr1           #no surprises here
Packit 575503
#1 lines in 1 sec: 1 lines/sec;  nlines=1 chipmunk:/ram0# awkerr1 a1 È
Packit 575503
#lines in 1 sec: 1 lines/sec;  nlines=1    #?! first char is an uppercase
Packit 575503
#E-grave chipmunk:/ram0# awkerr1 a1 | od -N1 -xc 0000000 00c8
Packit 575503
#        310  \0
Packit 575503
#0000001 chipmunk:/ram0# cat awkerr1   #the apparent ^M's are not
Packit 575503
#actually in the file
Packit 575503
#!/usr/bin/awk -f
Packit 575503
function process(w) {
Packit 575503
   if(w in ws) {
Packit 575503
      printf " : found\n"; lc[p " " w]++; rc[w " " n]++; }
Packit 575503
   }
Packit 575503
BEGIN {IGNORECASE=1;
Packit 575503
      }
Packit 575503
/^/ {if(NR % 10 ==0)print "processing line " NR;
Packit 575503
     process($1); nlines++;
Packit 575503
    }
Packit 575503
END {p=w; w=n; n="";
Packit 575503
     if(w)process(w); t=1; print NR " lines in " t " sec: " NR+0 " lines/sec;  nlines=" nlines;
Packit 575503
    }
Packit 575503
#chipmunk:/ram0# exit Script done on Fri Oct 30 20:07:31 1998
Packit 575503
#---------------------------------------------
Packit 575503
#
Packit 575503
#-David West     dhw@gamgee.acad.emich.edu
Packit 575503
#