1*f68a53dbSWarner Losh# The One True Awk 2*f68a53dbSWarner Losh 3*f68a53dbSWarner LoshThis is the version of `awk` described in _The AWK Programming Language_, 4*f68a53dbSWarner Loshby Al Aho, Brian Kernighan, and Peter Weinberger 5*f68a53dbSWarner Losh(Addison-Wesley, 1988, ISBN 0-201-07981-X). 6*f68a53dbSWarner Losh 7*f68a53dbSWarner Losh## Copyright 8*f68a53dbSWarner Losh 9*f68a53dbSWarner LoshCopyright (C) Lucent Technologies 1997<br/> 10*f68a53dbSWarner LoshAll Rights Reserved 11*f68a53dbSWarner Losh 12*f68a53dbSWarner LoshPermission to use, copy, modify, and distribute this software and 13*f68a53dbSWarner Loshits documentation for any purpose and without fee is hereby 14*f68a53dbSWarner Loshgranted, provided that the above copyright notice appear in all 15*f68a53dbSWarner Loshcopies and that both that the copyright notice and this 16*f68a53dbSWarner Loshpermission notice and warranty disclaimer appear in supporting 17*f68a53dbSWarner Loshdocumentation, and that the name Lucent Technologies or any of 18*f68a53dbSWarner Loshits entities not be used in advertising or publicity pertaining 19*f68a53dbSWarner Loshto distribution of the software without specific, written prior 20*f68a53dbSWarner Loshpermission. 21*f68a53dbSWarner Losh 22*f68a53dbSWarner LoshLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 23*f68a53dbSWarner LoshINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. 24*f68a53dbSWarner LoshIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY 25*f68a53dbSWarner LoshSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 26*f68a53dbSWarner LoshWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 27*f68a53dbSWarner LoshIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 28*f68a53dbSWarner LoshARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 29*f68a53dbSWarner LoshTHIS SOFTWARE. 30*f68a53dbSWarner Losh 31*f68a53dbSWarner Losh## Distribution and Reporting Problems 32*f68a53dbSWarner Losh 33*f68a53dbSWarner LoshChanges, mostly bug fixes and occasional enhancements, are listed 34*f68a53dbSWarner Loshin `FIXES`. If you distribute this code further, please please please 35*f68a53dbSWarner Loshdistribute `FIXES` with it. 36*f68a53dbSWarner Losh 37*f68a53dbSWarner LoshIf you find errors, please report them 38*f68a53dbSWarner Loshto bwk@cs.princeton.edu. 39*f68a53dbSWarner LoshPlease _also_ open an issue in the GitHub issue tracker, to make 40*f68a53dbSWarner Loshit easy to track issues. 41*f68a53dbSWarner LoshThanks. 42*f68a53dbSWarner Losh 43*f68a53dbSWarner Losh## Submitting Pull Requests 44*f68a53dbSWarner Losh 45*f68a53dbSWarner LoshPull requests are welcome. Some guidelines: 46*f68a53dbSWarner Losh 47*f68a53dbSWarner Losh* Please do not use functions or facilities that are not standard (e.g., 48*f68a53dbSWarner Losh`strlcpy()`, `fpurge()`). 49*f68a53dbSWarner Losh 50*f68a53dbSWarner Losh* Please run the test suite and make sure that your changes pass before 51*f68a53dbSWarner Loshposting the pull request. To do so: 52*f68a53dbSWarner Losh 53*f68a53dbSWarner Losh 1. Save the previous version of `awk` somewhere in your path. Call it `nawk` (for example). 54*f68a53dbSWarner Losh 1. Run `oldawk=nawk make check > check.out 2>&1`. 55*f68a53dbSWarner Losh 1. Search for `BAD` or `error` in the result. In general, look over it manually to make sure there are no errors. 56*f68a53dbSWarner Losh 57*f68a53dbSWarner Losh* Please create the pull request with a request 58*f68a53dbSWarner Loshto merge into the `staging` branch instead of into the `master` branch. 59*f68a53dbSWarner LoshThis allows us to do testing, and to make any additional edits or changes 60*f68a53dbSWarner Loshafter the merge but before merging to `master`. 61*f68a53dbSWarner Losh 62*f68a53dbSWarner Losh## Building 63*f68a53dbSWarner Losh 64*f68a53dbSWarner LoshThe program itself is created by 65*f68a53dbSWarner Losh 66*f68a53dbSWarner Losh make 67*f68a53dbSWarner Losh 68*f68a53dbSWarner Loshwhich should produce a sequence of messages roughly like this: 69*f68a53dbSWarner Losh 70*f68a53dbSWarner Losh yacc -d awkgram.y 71*f68a53dbSWarner Losh conflicts: 43 shift/reduce, 85 reduce/reduce 72*f68a53dbSWarner Losh mv y.tab.c ytab.c 73*f68a53dbSWarner Losh mv y.tab.h ytab.h 74*f68a53dbSWarner Losh cc -c ytab.c 75*f68a53dbSWarner Losh cc -c b.c 76*f68a53dbSWarner Losh cc -c main.c 77*f68a53dbSWarner Losh cc -c parse.c 78*f68a53dbSWarner Losh cc maketab.c -o maketab 79*f68a53dbSWarner Losh ./maketab >proctab.c 80*f68a53dbSWarner Losh cc -c proctab.c 81*f68a53dbSWarner Losh cc -c tran.c 82*f68a53dbSWarner Losh cc -c lib.c 83*f68a53dbSWarner Losh cc -c run.c 84*f68a53dbSWarner Losh cc -c lex.c 85*f68a53dbSWarner Losh cc ytab.o b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o -lm 86*f68a53dbSWarner Losh 87*f68a53dbSWarner LoshThis produces an executable `a.out`; you will eventually want to 88*f68a53dbSWarner Loshmove this to some place like `/usr/bin/awk`. 89*f68a53dbSWarner Losh 90*f68a53dbSWarner LoshIf your system does not have `yacc` or `bison` (the GNU 91*f68a53dbSWarner Loshequivalent), you need to install one of them first. 92*f68a53dbSWarner Losh 93*f68a53dbSWarner LoshNOTE: This version uses ANSI C (C 99), as you should also. We have 94*f68a53dbSWarner Loshcompiled this without any changes using `gcc -Wall` and/or local C 95*f68a53dbSWarner Loshcompilers on a variety of systems, but new systems or compilers 96*f68a53dbSWarner Loshmay raise some new complaint; reports of difficulties are 97*f68a53dbSWarner Loshwelcome. 98*f68a53dbSWarner Losh 99*f68a53dbSWarner LoshThis compiles without change on Macintosh OS X using `gcc` and 100*f68a53dbSWarner Loshthe standard developer tools. 101*f68a53dbSWarner Losh 102*f68a53dbSWarner LoshYou can also use `make CC=g++` to build with the GNU C++ compiler, 103*f68a53dbSWarner Loshshould you choose to do so. 104*f68a53dbSWarner Losh 105*f68a53dbSWarner LoshThe version of `malloc` that comes with some systems is sometimes 106*f68a53dbSWarner Loshastonishly slow. If `awk` seems slow, you might try fixing that. 107*f68a53dbSWarner LoshMore generally, turning on optimization can significantly improve 108*f68a53dbSWarner Losh`awk`'s speed, perhaps by 1/3 for highest levels. 109*f68a53dbSWarner Losh 110*f68a53dbSWarner Losh## A Note About Maintenance 111*f68a53dbSWarner Losh 112*f68a53dbSWarner LoshNOTICE! Maintenance of this program is on a ``best effort'' 113*f68a53dbSWarner Loshbasis. We try to get to issues and pull requests as quickly 114*f68a53dbSWarner Loshas we can. Unfortunately, however, keeping this program going 115*f68a53dbSWarner Loshis not at the top of our priority list. 116*f68a53dbSWarner Losh 117*f68a53dbSWarner Losh#### Last Updated 118*f68a53dbSWarner Losh 119*f68a53dbSWarner LoshFri Dec 25 16:53:34 EST 2020 120