1*74a4d8c2SCharles.Forsyth/**************************************************************** 2*74a4d8c2SCharles.ForsythCopyright (C) Lucent Technologies 1997 3*74a4d8c2SCharles.ForsythAll Rights Reserved 4*74a4d8c2SCharles.Forsyth 5*74a4d8c2SCharles.ForsythPermission to use, copy, modify, and distribute this software and 6*74a4d8c2SCharles.Forsythits documentation for any purpose and without fee is hereby 7*74a4d8c2SCharles.Forsythgranted, provided that the above copyright notice appear in all 8*74a4d8c2SCharles.Forsythcopies and that both that the copyright notice and this 9*74a4d8c2SCharles.Forsythpermission notice and warranty disclaimer appear in supporting 10*74a4d8c2SCharles.Forsythdocumentation, and that the name Lucent Technologies or any of 11*74a4d8c2SCharles.Forsythits entities not be used in advertising or publicity pertaining 12*74a4d8c2SCharles.Forsythto distribution of the software without specific, written prior 13*74a4d8c2SCharles.Forsythpermission. 14*74a4d8c2SCharles.Forsyth 15*74a4d8c2SCharles.ForsythLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 16*74a4d8c2SCharles.ForsythINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. 17*74a4d8c2SCharles.ForsythIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY 18*74a4d8c2SCharles.ForsythSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19*74a4d8c2SCharles.ForsythWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 20*74a4d8c2SCharles.ForsythIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 21*74a4d8c2SCharles.ForsythARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 22*74a4d8c2SCharles.ForsythTHIS SOFTWARE. 23*74a4d8c2SCharles.Forsyth****************************************************************/ 24*74a4d8c2SCharles.Forsyth 25*74a4d8c2SCharles.ForsythThis is the version of awk described in "The AWK Programming Language", 26*74a4d8c2SCharles.Forsythby Al Aho, Brian Kernighan, and Peter Weinberger 27*74a4d8c2SCharles.Forsyth(Addison-Wesley, 1988, ISBN 0-201-07981-X). 28*74a4d8c2SCharles.Forsyth 29*74a4d8c2SCharles.ForsythChanges, mostly bug fixes and occasional enhancements, are listed 30*74a4d8c2SCharles.Forsythin FIXES. If you distribute this code further, please please please 31*74a4d8c2SCharles.Forsythdistribute FIXES with it. If you find errors, please report them 32*74a4d8c2SCharles.Forsythto bwk@bell-labs.com. Thanks. 33*74a4d8c2SCharles.Forsyth 34*74a4d8c2SCharles.ForsythThe program itself is created by 35*74a4d8c2SCharles.Forsyth make 36*74a4d8c2SCharles.Forsythwhich should produce a sequence of messages roughly like this: 37*74a4d8c2SCharles.Forsyth 38*74a4d8c2SCharles.Forsyth yacc -d awkgram.y 39*74a4d8c2SCharles.Forsyth 40*74a4d8c2SCharles.Forsythconflicts: 43 shift/reduce, 85 reduce/reduce 41*74a4d8c2SCharles.Forsyth mv y.tab.c ytab.c 42*74a4d8c2SCharles.Forsyth mv y.tab.h ytab.h 43*74a4d8c2SCharles.Forsyth cc -O -c ytab.c 44*74a4d8c2SCharles.Forsyth cc -O -c b.c 45*74a4d8c2SCharles.Forsyth cc -O -c main.c 46*74a4d8c2SCharles.Forsyth cc -O -c parse.c 47*74a4d8c2SCharles.Forsyth cc -O maketab.c -o maketab 48*74a4d8c2SCharles.Forsyth ./maketab >proctab.c 49*74a4d8c2SCharles.Forsyth cc -O -c proctab.c 50*74a4d8c2SCharles.Forsyth cc -O -c tran.c 51*74a4d8c2SCharles.Forsyth cc -O -c lib.c 52*74a4d8c2SCharles.Forsyth cc -O -c run.c 53*74a4d8c2SCharles.Forsyth cc -O -c lex.c 54*74a4d8c2SCharles.Forsyth cc -O ytab.o b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o -lm 55*74a4d8c2SCharles.Forsyth 56*74a4d8c2SCharles.ForsythThis produces an executable a.out; you will eventually want to 57*74a4d8c2SCharles.Forsythmove this to some place like /usr/bin/awk. 58*74a4d8c2SCharles.Forsyth 59*74a4d8c2SCharles.ForsythIf your system is does not have yacc or bison (the GNU 60*74a4d8c2SCharles.Forsythequivalent), you must compile the pieces manually. We have 61*74a4d8c2SCharles.Forsythincluded yacc output in ytab.c and ytab.h, and backup copies in 62*74a4d8c2SCharles.Forsythcase you overwrite them. We have also included a copy of 63*74a4d8c2SCharles.Forsythproctab.c so you do not need to run maketab. 64*74a4d8c2SCharles.Forsyth 65*74a4d8c2SCharles.ForsythNOTE: This version uses ANSI C, as you should also. We have 66*74a4d8c2SCharles.Forsythcompiled this without any changes using gcc -Wall and/or local C 67*74a4d8c2SCharles.Forsythcompilers on a variety of systems, but new systems or compilers 68*74a4d8c2SCharles.Forsythmay raise some new complaint; reports of difficulties are 69*74a4d8c2SCharles.Forsythwelcome. 70*74a4d8c2SCharles.Forsyth 71*74a4d8c2SCharles.ForsythThis also compiles with Visual C++ on Windows 95 and Windows NT, 72*74a4d8c2SCharles.Forsyth*if* you provide versions of popen and pclose. The file 73*74a4d8c2SCharles.Forsythmissing95.c contains versions that can be used to get started 74*74a4d8c2SCharles.Forsythwith, though the underlying support has mysterious properties, 75*74a4d8c2SCharles.Forsyththe symptom of which can be truncated pipe output. Beware. 76*74a4d8c2SCharles.Forsyth 77*74a4d8c2SCharles.ForsythThis is also said to compile on Macintosh systems, using the 78*74a4d8c2SCharles.Forsythfile "buildmac" provided by Dan Allen (danallen@microsoft.com), 79*74a4d8c2SCharles.Forsythto whom many thanks. Dan also provided buildwin.bat, a simple 80*74a4d8c2SCharles.Forsythscript for compiling on NT if you prefer. 81*74a4d8c2SCharles.Forsyth 82*74a4d8c2SCharles.ForsythThe version of malloc that comes with some systems is sometimes 83*74a4d8c2SCharles.Forsythastonishly slow. If awk seems slow, you might try fixing that. 84