xref: /freebsd/contrib/one-true-awk/README.md (revision 044f94adff55f13130f03c0c170fa879c8febb5b)
1 # The One True Awk
2 
3 This is the version of `awk` described in _The AWK Programming Language_,
4 Second 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 
9 This version of Awk handles UTF-8 and comma-separated values (CSV) input.
10 
11 ### Strings ###
12 
13 Functions that process strings now count Unicode code points, not bytes;
14 this affects `length`, `substr`, `index`, `match`, `split`,
15 `sub`, `gsub`, and others.  Note that code
16 points are not necessarily characters.
17 
18 UTF-8 sequences may appear in literal strings and regular expressions.
19 Arbitrary characters may be included with `\u` followed by 1 to 8 hexadecimal digits.
20 
21 ### Regular expressions ###
22 
23 Regular expressions may include UTF-8 code points, including `\u`.
24 
25 ### CSV ###
26 
27 The option `--csv` turns on CSV processing of input:
28 fields are separated by commas, fields may be quoted with
29 double-quote (`"`) characters, quoted fields may contain embedded newlines.
30 Double-quotes in fields have to be doubled and enclosed in quoted fields.
31 In CSV mode, `FS` is ignored.
32 
33 If no explicit separator argument is provided,
34 field-splitting in `split` is determined by CSV mode.
35 
36 ## Copyright
37 
38 Copyright (C) Lucent Technologies 1997<br/>
39 All Rights Reserved
40 
41 Permission to use, copy, modify, and distribute this software and
42 its documentation for any purpose and without fee is hereby
43 granted, provided that the above copyright notice appear in all
44 copies and that both that the copyright notice and this
45 permission notice and warranty disclaimer appear in supporting
46 documentation, and that the name Lucent Technologies or any of
47 its entities not be used in advertising or publicity pertaining
48 to distribution of the software without specific, written prior
49 permission.
50 
51 LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
52 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
53 IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
54 SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
55 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
56 IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
57 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
58 THIS SOFTWARE.
59 
60 ## Distribution and Reporting Problems
61 
62 Changes, mostly bug fixes and occasional enhancements, are listed
63 in `FIXES`.  If you distribute this code further, please please please
64 distribute `FIXES` with it.
65 
66 If you find errors, please report them
67 to the current maintainer, ozan.yigit@gmail.com.
68 Please _also_ open an issue in the GitHub issue tracker, to make
69 it easy to track issues.
70 Thanks.
71 
72 ## Submitting Pull Requests
73 
74 Pull 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
80 posting 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
87 to merge into the `staging` branch instead of into the `master` branch.
88 This allows us to do testing, and to make any additional edits or changes
89 after the merge but before merging to `master`.
90 
91 ## Building
92 
93 The program itself is created by
94 
95 	make
96 
97 which 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 
116 This produces an executable `a.out`; you will eventually want to
117 move this to some place like `/usr/bin/awk`.
118 
119 If your system does not have `yacc` or `bison` (the GNU
120 equivalent), you need to install one of them first.
121 The default in the `makefile` is `bison`; you will have
122 to edit the `makefile` to use `yacc`.
123 
124 NOTE: This version uses ISO/IEC C99, as you should also.  We have
125 compiled this without any changes using `gcc -Wall` and/or local C
126 compilers on a variety of systems, but new systems or compilers
127 may raise some new complaint; reports of difficulties are
128 welcome.
129 
130 This compiles without change on Macintosh OS X using `gcc` and
131 the standard developer tools.
132 
133 You can also use `make CC=g++` to build with the GNU C++ compiler,
134 should you choose to do so.
135 
136 ## A Note About Releases
137 
138 We don't usually do releases.
139 
140 ## A Note About Maintenance
141 
142 NOTICE! Maintenance of this program is on a ''best effort''
143 basis.  We try to get to issues and pull requests as quickly
144 as we can.  Unfortunately, however, keeping this program going
145 is not at the top of our priority list.
146 
147 #### Last Updated
148 
149 Mon 05 Feb 2024 08:46:55 IST
150