1ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner/**************************************************************** 2ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David TurnerCopyright (C) Lucent Technologies 1997 3ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David TurnerAll Rights Reserved 4ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner 5ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David TurnerPermission to use, copy, modify, and distribute this software and 6ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerits documentation for any purpose and without fee is hereby 7ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnergranted, provided that the above copyright notice appear in all 8ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnercopies and that both that the copyright notice and this 9ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerpermission notice and warranty disclaimer appear in supporting 10ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerdocumentation, and that the name Lucent Technologies or any of 11ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerits entities not be used in advertising or publicity pertaining 12ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerto distribution of the software without specific, written prior 13ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerpermission. 14ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner 15ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David TurnerLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 16ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David TurnerINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. 17ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David TurnerIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY 18ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David TurnerSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David TurnerWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 20ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David TurnerIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 21ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David TurnerARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 22ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David TurnerTHIS SOFTWARE. 23ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner****************************************************************/ 24ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner 25ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David TurnerThis is the version of awk described in "The AWK Programming Language", 26ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerby Al Aho, Brian Kernighan, and Peter Weinberger 27ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner(Addison-Wesley, 1988, ISBN 0-201-07981-X). 28ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner 29ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David TurnerChanges, mostly bug fixes and occasional enhancements, are listed 30ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerin FIXES. If you distribute this code further, please please please 31ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerdistribute FIXES with it. If you find errors, please report them 32ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerto bwk@bell-labs.com. Thanks. 33ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner 34ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David TurnerThe program itself is created by 35ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner make 36ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerwhich should produce a sequence of messages roughly like this: 37ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner 38ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner yacc -d awkgram.y 39ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner 40ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerconflicts: 43 shift/reduce, 85 reduce/reduce 41ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner mv y.tab.c ytab.c 42ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner mv y.tab.h ytab.h 43ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner cc -c ytab.c 44ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner cc -c b.c 45ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner cc -c main.c 46ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner cc -c parse.c 47ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner cc maketab.c -o maketab 48ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner ./maketab >proctab.c 49ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner cc -c proctab.c 50ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner cc -c tran.c 51ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner cc -c lib.c 52ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner cc -c run.c 53ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner cc -c lex.c 54ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner cc ytab.o b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o -lm 55ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner 56ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David TurnerThis produces an executable a.out; you will eventually want to 57ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnermove this to some place like /usr/bin/awk. 58ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner 59ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David TurnerIf your system does not have yacc or bison (the GNU 60ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerequivalent), you must compile the pieces manually. We have 61ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerincluded yacc output in ytab.c and ytab.h, and backup copies in 62ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnercase you overwrite them. We have also included a copy of 63ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerproctab.c so you do not need to run maketab. 64ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner 65ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David TurnerNOTE: This version uses ANSI C, as you should also. We have 66ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnercompiled this without any changes using gcc -Wall and/or local C 67ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnercompilers on a variety of systems, but new systems or compilers 68ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnermay raise some new complaint; reports of difficulties are 69ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerwelcome. 70ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner 71ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David TurnerThis also compiles with Visual C++ on all flavors of Windows, 72ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner*if* you provide versions of popen and pclose. The file 73ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnermissing95.c contains versions that can be used to get started 74ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerwith, though the underlying support has mysterious properties, 75ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerthe symptom of which can be truncated pipe output. Beware. The 76ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerfile makefile.win gives hints on how to proceed; if you run 77ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnervcvars32.bat, it will set up necessary paths and parameters so 78ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turneryou can subsequently run nmake -f makefile.win. Beware also that 79ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerwhen running on Windows under command.com, various quoting 80ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerconventions are different from Unix systems: single quotes won't 81ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerwork around arguments, and various characters like % are 82ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerinterpreted within double quotes. 83ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner 84ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David TurnerThis compiles without change on Macintosh OS X using gcc and 85ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerthe standard developer tools. 86ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner 87ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David TurnerThis is also said to compile on Macintosh OS 9 systems, using the 88ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerfile "buildmac" provided by Dan Allen (danallen@microsoft.com), 89ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerto whom many thanks. 90ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turner 91ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David TurnerThe version of malloc that comes with some systems is sometimes 92ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerastonishly slow. If awk seems slow, you might try fixing that. 93ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David TurnerMore generally, turning on optimization can significantly improve 94ce5707c0255040b895f1c90ac9a435d8a4b8f2d6David Turnerawk's speed, perhaps by 1/3 for highest levels. 95