xref: /freebsd/contrib/one-true-awk/README.md (revision 8a802df1de2d77fd0a62996bd785ca3f1326887f)
1# The One True Awk
2
3This is the version of `awk` described in _The AWK Programming Language_,
4Second Edition, by Al Aho, Brian Kernighan, and Peter Weinberger
5(Addison-Wesley, 2024, ISBN-13 978-0138269722, ISBN-10 0138269726).
6
7## What's New? ##
8
9This version of Awk handles UTF-8 and comma-separated values (CSV) input.
10
11### Strings ###
12
13Functions that process strings now count Unicode code points, not bytes;
14this affects `length`, `substr`, `index`, `match`, `split`,
15`sub`, `gsub`, and others.  Note that code
16points are not necessarily characters.
17
18UTF-8 sequences may appear in literal strings and regular expressions.
19Aribtrary characters may be included with `\u` followed by 1 to 8 hexadecimal digits.
20
21### Regular expressions ###
22
23Regular expressions may include UTF-8 code points, including `\u`.
24
25### CSV ###
26
27The option `--csv` turns on CSV processing of input:
28fields are separated by commas, fields may be quoted with
29double-quote (`"`) characters, quoted fields may contain embedded newlines.
30Double-quotes in fields have to be doubled and enclosed in quoted fields.
31In CSV mode, `FS` is ignored.
32
33If no explicit separator argument is provided,
34field-splitting in `split` is determined by CSV mode.
35
36## Copyright
37
38Copyright (C) Lucent Technologies 1997<br/>
39All Rights Reserved
40
41Permission to use, copy, modify, and distribute this software and
42its documentation for any purpose and without fee is hereby
43granted, provided that the above copyright notice appear in all
44copies and that both that the copyright notice and this
45permission notice and warranty disclaimer appear in supporting
46documentation, and that the name Lucent Technologies or any of
47its entities not be used in advertising or publicity pertaining
48to distribution of the software without specific, written prior
49permission.
50
51LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
52INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
53IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
54SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
55WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
56IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
57ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
58THIS SOFTWARE.
59
60## Distribution and Reporting Problems
61
62Changes, mostly bug fixes and occasional enhancements, are listed
63in `FIXES`.  If you distribute this code further, please please please
64distribute `FIXES` with it.
65
66If you find errors, please report them
67to the current maintainer, ozan.yigit@gmail.com.
68Please _also_ open an issue in the GitHub issue tracker, to make
69it easy to track issues.
70Thanks.
71
72## Submitting Pull Requests
73
74Pull requests are welcome. Some guidelines:
75
76* Please do not use functions or facilities that are not standard (e.g.,
77`strlcpy()`, `fpurge()`).
78
79* Please run the test suite and make sure that your changes pass before
80posting the pull request. To do so:
81
82  1. Save the previous version of `awk` somewhere in your path. Call it `nawk` (for example).
83  1. Run `oldawk=nawk make check > check.out 2>&1`.
84  1. Search for `BAD` or `error` in the result. In general, look over it manually to make sure there are no errors.
85
86* Please create the pull request with a request
87to merge into the `staging` branch instead of into the `master` branch.
88This allows us to do testing, and to make any additional edits or changes
89after the merge but before merging to `master`.
90
91## Building
92
93The program itself is created by
94
95	make
96
97which should produce a sequence of messages roughly like this:
98
99	bison -d  awkgram.y
100	awkgram.y: warning: 44 shift/reduce conflicts [-Wconflicts-sr]
101	awkgram.y: warning: 85 reduce/reduce conflicts [-Wconflicts-rr]
102	awkgram.y: note: rerun with option '-Wcounterexamples' to generate conflict counterexamples
103	gcc -g -Wall -pedantic -Wcast-qual   -O2   -c -o awkgram.tab.o awkgram.tab.c
104	gcc -g -Wall -pedantic -Wcast-qual   -O2   -c -o b.o b.c
105	gcc -g -Wall -pedantic -Wcast-qual   -O2   -c -o main.o main.c
106	gcc -g -Wall -pedantic -Wcast-qual   -O2   -c -o parse.o parse.c
107	gcc -g -Wall -pedantic -Wcast-qual -O2 maketab.c -o maketab
108	./maketab awkgram.tab.h >proctab.c
109	gcc -g -Wall -pedantic -Wcast-qual   -O2   -c -o proctab.o proctab.c
110	gcc -g -Wall -pedantic -Wcast-qual   -O2   -c -o tran.o tran.c
111	gcc -g -Wall -pedantic -Wcast-qual   -O2   -c -o lib.o lib.c
112	gcc -g -Wall -pedantic -Wcast-qual   -O2   -c -o run.o run.c
113	gcc -g -Wall -pedantic -Wcast-qual   -O2   -c -o lex.o lex.c
114	gcc -g -Wall -pedantic -Wcast-qual   -O2 awkgram.tab.o b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o   -lm
115
116This produces an executable `a.out`; you will eventually want to
117move this to some place like `/usr/bin/awk`.
118
119If your system does not have `yacc` or `bison` (the GNU
120equivalent), you need to install one of them first.
121The default in the `makefile` is `bison`; you will have
122to edit the `makefile` to use `yacc`.
123
124NOTE: This version uses ISO/IEC C99, as you should also.  We have
125compiled this without any changes using `gcc -Wall` and/or local C
126compilers on a variety of systems, but new systems or compilers
127may raise some new complaint; reports of difficulties are
128welcome.
129
130This compiles without change on Macintosh OS X using `gcc` and
131the standard developer tools.
132
133You can also use `make CC=g++` to build with the GNU C++ compiler,
134should you choose to do so.
135
136## A Note About Releases
137
138We don't usually do releases.
139
140## A Note About Maintenance
141
142NOTICE! Maintenance of this program is on a ''best effort''
143basis.  We try to get to issues and pull requests as quickly
144as we can.  Unfortunately, however, keeping this program going
145is not at the top of our priority list.
146
147#### Last Updated
148
149Mon 05 Feb 2024 08:46:55 IST
150