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