185587Sobrien/**************************************************************** 285587SobrienCopyright (C) Lucent Technologies 1997 385587SobrienAll Rights Reserved 485587Sobrien 585587SobrienPermission to use, copy, modify, and distribute this software and 685587Sobrienits documentation for any purpose and without fee is hereby 785587Sobriengranted, provided that the above copyright notice appear in all 885587Sobriencopies and that both that the copyright notice and this 985587Sobrienpermission notice and warranty disclaimer appear in supporting 1085587Sobriendocumentation, and that the name Lucent Technologies or any of 1185587Sobrienits entities not be used in advertising or publicity pertaining 1285587Sobriento distribution of the software without specific, written prior 1385587Sobrienpermission. 1485587Sobrien 1585587SobrienLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 1685587SobrienINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. 1785587SobrienIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY 1885587SobrienSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1985587SobrienWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 2085587SobrienIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 2185587SobrienARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 2285587SobrienTHIS SOFTWARE. 2385587Sobrien****************************************************************/ 2485587Sobrien 2585587SobrienThis is the version of awk described in "The AWK Programming Language", 2685587Sobrienby Al Aho, Brian Kernighan, and Peter Weinberger 2785587Sobrien(Addison-Wesley, 1988, ISBN 0-201-07981-X). 2885587Sobrien 2985587SobrienChanges, mostly bug fixes and occasional enhancements, are listed 3085587Sobrienin FIXES. If you distribute this code further, please please please 3185587Sobriendistribute FIXES with it. If you find errors, please report them 32221381Sruto bwk@cs.princeton.edu. Thanks. 3385587Sobrien 3485587SobrienThe program itself is created by 3585587Sobrien make 3685587Sobrienwhich should produce a sequence of messages roughly like this: 3785587Sobrien 3885587Sobrien yacc -d awkgram.y 3985587Sobrien 4085587Sobrienconflicts: 43 shift/reduce, 85 reduce/reduce 4185587Sobrien mv y.tab.c ytab.c 4285587Sobrien mv y.tab.h ytab.h 43107806Sobrien cc -c ytab.c 44107806Sobrien cc -c b.c 45107806Sobrien cc -c main.c 46107806Sobrien cc -c parse.c 47107806Sobrien cc maketab.c -o maketab 4885587Sobrien ./maketab >proctab.c 49107806Sobrien cc -c proctab.c 50107806Sobrien cc -c tran.c 51107806Sobrien cc -c lib.c 52107806Sobrien cc -c run.c 53107806Sobrien cc -c lex.c 54107806Sobrien cc ytab.o b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o -lm 5585587Sobrien 5685587SobrienThis produces an executable a.out; you will eventually want to 5785587Sobrienmove this to some place like /usr/bin/awk. 5885587Sobrien 59146299SruIf your system does not have yacc or bison (the GNU 6085587Sobrienequivalent), you must compile the pieces manually. We have 6185587Sobrienincluded yacc output in ytab.c and ytab.h, and backup copies in 6285587Sobriencase you overwrite them. We have also included a copy of 6385587Sobrienproctab.c so you do not need to run maketab. 6485587Sobrien 6585587SobrienNOTE: This version uses ANSI C, as you should also. We have 6685587Sobriencompiled this without any changes using gcc -Wall and/or local C 6785587Sobriencompilers on a variety of systems, but new systems or compilers 6885587Sobrienmay raise some new complaint; reports of difficulties are 6985587Sobrienwelcome. 7085587Sobrien 7190902SdesThis also compiles with Visual C++ on all flavors of Windows, 7285587Sobrien*if* you provide versions of popen and pclose. The file 7385587Sobrienmissing95.c contains versions that can be used to get started 7485587Sobrienwith, though the underlying support has mysterious properties, 75112336Sobrienthe symptom of which can be truncated pipe output. Beware. The 76112336Sobrienfile makefile.win gives hints on how to proceed; if you run 77112336Sobrienvcvars32.bat, it will set up necessary paths and parameters so 78112336Sobrienyou can subsequently run nmake -f makefile.win. Beware also that 79112336Sobrienwhen running on Windows under command.com, various quoting 80112336Sobrienconventions are different from Unix systems: single quotes won't 81112336Sobrienwork around arguments, and various characters like % are 82112336Sobrieninterpreted within double quotes. 8385587Sobrien 84107806SobrienThis compiles without change on Macintosh OS X using gcc and 85107806Sobrienthe standard developer tools. 86107806Sobrien 87107806SobrienThis is also said to compile on Macintosh OS 9 systems, using the 8885587Sobrienfile "buildmac" provided by Dan Allen (danallen@microsoft.com), 8990902Sdesto whom many thanks. 9085587Sobrien 9185587SobrienThe version of malloc that comes with some systems is sometimes 9285587Sobrienastonishly slow. If awk seems slow, you might try fixing that. 93107806SobrienMore generally, turning on optimization can significantly improve 94107806Sobrienawk's speed, perhaps by 1/3 for highest levels. 95