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