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