git: 23f24377b1a9 - main - awk: Merge 20210729 from One True Awk upstream (0592de4a)
Warner Losh
imp at FreeBSD.org
Sun Aug 1 17:01:44 UTC 2021
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=23f24377b1a9ab6677f00f2302484d6658d94cab
commit 23f24377b1a9ab6677f00f2302484d6658d94cab
Merge: a61c24ddb7d6 f9002b856130
Author: Warner Losh <imp at FreeBSD.org>
AuthorDate: 2021-08-01 16:22:39 +0000
Commit: Warner Losh <imp at FreeBSD.org>
CommitDate: 2021-08-01 16:22:39 +0000
awk: Merge 20210729 from One True Awk upstream (0592de4a)
July 27, 2021:
As per IEEE Std 1003.1-2008, -F "str" is now consistent with
-v FS="str" when str is null. Thanks to Warner Losh.
July 24, 2021:
Fix readrec's definition of a record. This fixes an issue
with NetBSD's RS regular expression support that can cause
an infinite read loop. Thanks to Miguel Pineiro Jr.
Fix regular expression RS ^-anchoring. RS ^-anchoring needs to
know if it is reading the first record of a file. This change
restores a missing line that was overlooked when porting NetBSD's
RS regex functionality. Thanks to Miguel Pineiro Jr.
Fix size computation in replace_repeat() for special case
REPEAT_WITH_Q. Thanks to Todd C. Miller.
Also, included the tests from upstream, though they aren't yet connected
to the tree.
Sponsored by: Netflix
contrib/one-true-awk/FIXES | 17 +
contrib/one-true-awk/README.md | 8 +-
contrib/one-true-awk/TODO | 19 +
contrib/one-true-awk/b.c | 9 +-
contrib/one-true-awk/bugs-fixed/REGRESS | 28 +
contrib/one-true-awk/bugs-fixed/fs-overflow.ok | 1 +
.../one-true-awk/bugs-fixed/inf-nan-torture.awk | 4 +
contrib/one-true-awk/bugs-fixed/inf-nan-torture.in | 1 +
contrib/one-true-awk/bugs-fixed/inf-nan-torture.ok | 16 +
contrib/one-true-awk/bugs-fixed/pfile-overflow.awk | 1 +
contrib/one-true-awk/bugs-fixed/pfile-overflow.ok | 4 +
contrib/one-true-awk/bugs-fixed/rs_underflow.awk | 1 +
contrib/one-true-awk/bugs-fixed/rs_underflow.in | 1 +
contrib/one-true-awk/bugs-fixed/rs_underflow.ok | 1 +
contrib/one-true-awk/lib.c | 4 +-
contrib/one-true-awk/main.c | 2 +-
contrib/one-true-awk/testdir/Compare.T1 | 10 +
contrib/one-true-awk/testdir/Compare.drek | 35 +
contrib/one-true-awk/testdir/Compare.p | 17 +
contrib/one-true-awk/testdir/Compare.t | 17 +
contrib/one-true-awk/testdir/Compare.tt | 49 +
contrib/one-true-awk/testdir/NOTES | 10 +
contrib/one-true-awk/testdir/README.TESTS | 44 +
contrib/one-true-awk/testdir/REGRESS | 21 +
contrib/one-true-awk/testdir/T.-f-f | 35 +
contrib/one-true-awk/testdir/T.argv | 144 +
contrib/one-true-awk/testdir/T.arnold | 19 +
contrib/one-true-awk/testdir/T.beebe | 8 +
contrib/one-true-awk/testdir/T.builtin | 90 +
contrib/one-true-awk/testdir/T.chem | 11 +
contrib/one-true-awk/testdir/T.close | 36 +
contrib/one-true-awk/testdir/T.clv | 181 +
contrib/one-true-awk/testdir/T.csconcat | 29 +
contrib/one-true-awk/testdir/T.delete | 21 +
contrib/one-true-awk/testdir/T.errmsg | 215 +
contrib/one-true-awk/testdir/T.expr | 235 +
contrib/one-true-awk/testdir/T.exprconv | 21 +
contrib/one-true-awk/testdir/T.flags | 24 +
contrib/one-true-awk/testdir/T.func | 196 +
contrib/one-true-awk/testdir/T.gawk | 390 +
contrib/one-true-awk/testdir/T.getline | 98 +
contrib/one-true-awk/testdir/T.int-expr | 124 +
contrib/one-true-awk/testdir/T.latin1 | 37 +
contrib/one-true-awk/testdir/T.lilly | 28 +
contrib/one-true-awk/testdir/T.main | 32 +
contrib/one-true-awk/testdir/T.misc | 506 +
contrib/one-true-awk/testdir/T.nextfile | 86 +
contrib/one-true-awk/testdir/T.overflow | 86 +
contrib/one-true-awk/testdir/T.re | 340 +
contrib/one-true-awk/testdir/T.recache | 33 +
contrib/one-true-awk/testdir/T.redir | 38 +
contrib/one-true-awk/testdir/T.split | 224 +
contrib/one-true-awk/testdir/T.sub | 315 +
contrib/one-true-awk/testdir/T.system | 15 +
contrib/one-true-awk/testdir/arnold-fixes.tar | Bin 0 -> 30720 bytes
contrib/one-true-awk/testdir/beebe.tar | Bin 0 -> 389120 bytes
contrib/one-true-awk/testdir/bib | 31102 +++++++++++++++++++
contrib/one-true-awk/testdir/bundle.awk | 3 +
contrib/one-true-awk/testdir/chem.awk | 492 +
contrib/one-true-awk/testdir/cleanup | 5 +
contrib/one-true-awk/testdir/countries | 11 +
contrib/one-true-awk/testdir/ctimes | 40 +
contrib/one-true-awk/testdir/echo.c | 19 +
contrib/one-true-awk/testdir/funstack.awk | 977 +
contrib/one-true-awk/testdir/funstack.in | 27220 ++++++++++++++++
contrib/one-true-awk/testdir/funstack.ok | 3705 +++
contrib/one-true-awk/testdir/ind | 1 +
contrib/one-true-awk/testdir/latin1 | 11 +
contrib/one-true-awk/testdir/lilly.ifile | 16 +
contrib/one-true-awk/testdir/lilly.out | 1258 +
contrib/one-true-awk/testdir/lilly.progs | 126 +
contrib/one-true-awk/testdir/lsd1.p | 15 +
contrib/one-true-awk/testdir/p.1 | 1 +
contrib/one-true-awk/testdir/p.10 | 1 +
contrib/one-true-awk/testdir/p.11 | 1 +
contrib/one-true-awk/testdir/p.12 | 1 +
contrib/one-true-awk/testdir/p.13 | 1 +
contrib/one-true-awk/testdir/p.14 | 1 +
contrib/one-true-awk/testdir/p.15 | 1 +
contrib/one-true-awk/testdir/p.16 | 1 +
contrib/one-true-awk/testdir/p.17 | 1 +
contrib/one-true-awk/testdir/p.18 | 1 +
contrib/one-true-awk/testdir/p.19 | 2 +
contrib/one-true-awk/testdir/p.2 | 1 +
contrib/one-true-awk/testdir/p.20 | 1 +
contrib/one-true-awk/testdir/p.21 | 1 +
contrib/one-true-awk/testdir/p.21a | 1 +
contrib/one-true-awk/testdir/p.22 | 1 +
contrib/one-true-awk/testdir/p.23 | 1 +
contrib/one-true-awk/testdir/p.24 | 1 +
contrib/one-true-awk/testdir/p.25 | 1 +
contrib/one-true-awk/testdir/p.26 | 3 +
contrib/one-true-awk/testdir/p.26a | 3 +
contrib/one-true-awk/testdir/p.27 | 2 +
contrib/one-true-awk/testdir/p.28 | 1 +
contrib/one-true-awk/testdir/p.29 | 1 +
contrib/one-true-awk/testdir/p.3 | 1 +
contrib/one-true-awk/testdir/p.30 | 1 +
contrib/one-true-awk/testdir/p.31 | 2 +
contrib/one-true-awk/testdir/p.32 | 1 +
contrib/one-true-awk/testdir/p.33 | 2 +
contrib/one-true-awk/testdir/p.34 | 1 +
contrib/one-true-awk/testdir/p.35 | 4 +
contrib/one-true-awk/testdir/p.36 | 2 +
contrib/one-true-awk/testdir/p.37 | 1 +
contrib/one-true-awk/testdir/p.38 | 6 +
contrib/one-true-awk/testdir/p.39 | 6 +
contrib/one-true-awk/testdir/p.4 | 1 +
contrib/one-true-awk/testdir/p.40 | 3 +
contrib/one-true-awk/testdir/p.41 | 3 +
contrib/one-true-awk/testdir/p.42 | 4 +
contrib/one-true-awk/testdir/p.43 | 4 +
contrib/one-true-awk/testdir/p.44 | 7 +
contrib/one-true-awk/testdir/p.45 | 2 +
contrib/one-true-awk/testdir/p.46 | 1 +
contrib/one-true-awk/testdir/p.47 | 2 +
contrib/one-true-awk/testdir/p.48 | 4 +
contrib/one-true-awk/testdir/p.48a | 6 +
contrib/one-true-awk/testdir/p.48b | 5 +
contrib/one-true-awk/testdir/p.49 | 1 +
contrib/one-true-awk/testdir/p.5 | 3 +
contrib/one-true-awk/testdir/p.50 | 4 +
contrib/one-true-awk/testdir/p.51 | 7 +
contrib/one-true-awk/testdir/p.52 | 16 +
contrib/one-true-awk/testdir/p.5a | 3 +
contrib/one-true-awk/testdir/p.6 | 1 +
contrib/one-true-awk/testdir/p.7 | 1 +
contrib/one-true-awk/testdir/p.8 | 1 +
contrib/one-true-awk/testdir/p.9 | 1 +
contrib/one-true-awk/testdir/p.table | 33 +
contrib/one-true-awk/testdir/penicil.p | 39 +
contrib/one-true-awk/testdir/res.p | 26 +
contrib/one-true-awk/testdir/sgi.ctimes | 40 +
contrib/one-true-awk/testdir/t.0 | 1 +
contrib/one-true-awk/testdir/t.0a | 1 +
contrib/one-true-awk/testdir/t.1 | 2 +
contrib/one-true-awk/testdir/t.1.x | 1 +
contrib/one-true-awk/testdir/t.2 | 2 +
contrib/one-true-awk/testdir/t.2.x | 1 +
contrib/one-true-awk/testdir/t.3 | 1 +
contrib/one-true-awk/testdir/t.3.x | 7 +
contrib/one-true-awk/testdir/t.4 | 1 +
contrib/one-true-awk/testdir/t.4.x | 1 +
contrib/one-true-awk/testdir/t.5.x | 1 +
contrib/one-true-awk/testdir/t.6 | 8 +
contrib/one-true-awk/testdir/t.6.x | 1 +
contrib/one-true-awk/testdir/t.6a | 5 +
contrib/one-true-awk/testdir/t.6b | 5 +
contrib/one-true-awk/testdir/t.8.x | 4 +
contrib/one-true-awk/testdir/t.8.y | 7 +
contrib/one-true-awk/testdir/t.NF | 1 +
contrib/one-true-awk/testdir/t.a | 6 +
contrib/one-true-awk/testdir/t.addops | 24 +
contrib/one-true-awk/testdir/t.aeiou | 1 +
contrib/one-true-awk/testdir/t.aeiouy | 1 +
contrib/one-true-awk/testdir/t.arith | 6 +
contrib/one-true-awk/testdir/t.array | 13 +
contrib/one-true-awk/testdir/t.array1 | 10 +
contrib/one-true-awk/testdir/t.array2 | 4 +
contrib/one-true-awk/testdir/t.assert | 9 +
contrib/one-true-awk/testdir/t.avg | 5 +
contrib/one-true-awk/testdir/t.b.x | 1 +
contrib/one-true-awk/testdir/t.be | 6 +
contrib/one-true-awk/testdir/t.beginexit | 6 +
contrib/one-true-awk/testdir/t.beginnext | 6 +
contrib/one-true-awk/testdir/t.break | 7 +
contrib/one-true-awk/testdir/t.break1 | 10 +
contrib/one-true-awk/testdir/t.break2 | 10 +
contrib/one-true-awk/testdir/t.break3 | 8 +
contrib/one-true-awk/testdir/t.bug1 | 3 +
contrib/one-true-awk/testdir/t.builtins | 6 +
contrib/one-true-awk/testdir/t.cat | 4 +
contrib/one-true-awk/testdir/t.cat1 | 1 +
contrib/one-true-awk/testdir/t.cat2 | 1 +
contrib/one-true-awk/testdir/t.cmp | 1 +
contrib/one-true-awk/testdir/t.coerce | 4 +
contrib/one-true-awk/testdir/t.coerce2 | 7 +
contrib/one-true-awk/testdir/t.comment | 5 +
contrib/one-true-awk/testdir/t.comment1 | 7 +
contrib/one-true-awk/testdir/t.concat | 1 +
contrib/one-true-awk/testdir/t.cond | 3 +
contrib/one-true-awk/testdir/t.contin | 9 +
contrib/one-true-awk/testdir/t.count | 1 +
contrib/one-true-awk/testdir/t.crlf | 4 +
contrib/one-true-awk/testdir/t.cum | 4 +
contrib/one-true-awk/testdir/t.d.x | 2 +
contrib/one-true-awk/testdir/t.delete0 | 11 +
contrib/one-true-awk/testdir/t.delete1 | 7 +
contrib/one-true-awk/testdir/t.delete2 | 12 +
contrib/one-true-awk/testdir/t.delete3 | 7 +
contrib/one-true-awk/testdir/t.do | 14 +
contrib/one-true-awk/testdir/t.e | 1 +
contrib/one-true-awk/testdir/t.else | 3 +
contrib/one-true-awk/testdir/t.exit | 2 +
contrib/one-true-awk/testdir/t.exit1 | 15 +
contrib/one-true-awk/testdir/t.f | 1 +
contrib/one-true-awk/testdir/t.f.x | 1 +
contrib/one-true-awk/testdir/t.f0 | 1 +
contrib/one-true-awk/testdir/t.f1 | 1 +
contrib/one-true-awk/testdir/t.f2 | 1 +
contrib/one-true-awk/testdir/t.f3 | 1 +
contrib/one-true-awk/testdir/t.f4 | 1 +
contrib/one-true-awk/testdir/t.for | 3 +
contrib/one-true-awk/testdir/t.for1 | 9 +
contrib/one-true-awk/testdir/t.for2 | 7 +
contrib/one-true-awk/testdir/t.for3 | 8 +
contrib/one-true-awk/testdir/t.format4 | 9 +
contrib/one-true-awk/testdir/t.fun | 3 +
contrib/one-true-awk/testdir/t.fun0 | 2 +
contrib/one-true-awk/testdir/t.fun1 | 2 +
contrib/one-true-awk/testdir/t.fun2 | 10 +
contrib/one-true-awk/testdir/t.fun3 | 3 +
contrib/one-true-awk/testdir/t.fun4 | 9 +
contrib/one-true-awk/testdir/t.fun5 | 9 +
contrib/one-true-awk/testdir/t.getline1 | 10 +
contrib/one-true-awk/testdir/t.getval | 6 +
contrib/one-true-awk/testdir/t.gsub | 1 +
contrib/one-true-awk/testdir/t.gsub1 | 1 +
contrib/one-true-awk/testdir/t.gsub3 | 1 +
contrib/one-true-awk/testdir/t.gsub4 | 4 +
contrib/one-true-awk/testdir/t.i.x | 2 +
contrib/one-true-awk/testdir/t.if | 1 +
contrib/one-true-awk/testdir/t.in | 9 +
contrib/one-true-awk/testdir/t.in1 | 7 +
contrib/one-true-awk/testdir/t.in2 | 4 +
contrib/one-true-awk/testdir/t.in3 | 7 +
contrib/one-true-awk/testdir/t.incr | 2 +
contrib/one-true-awk/testdir/t.incr2 | 8 +
contrib/one-true-awk/testdir/t.incr3 | 5 +
contrib/one-true-awk/testdir/t.index | 10 +
contrib/one-true-awk/testdir/t.intest | 9 +
contrib/one-true-awk/testdir/t.intest2 | 16 +
contrib/one-true-awk/testdir/t.j.x | 2 +
contrib/one-true-awk/testdir/t.longstr | 5 +
contrib/one-true-awk/testdir/t.makef | 1 +
contrib/one-true-awk/testdir/t.match | 1 +
contrib/one-true-awk/testdir/t.match1 | 6 +
contrib/one-true-awk/testdir/t.max | 2 +
contrib/one-true-awk/testdir/t.mod | 1 +
contrib/one-true-awk/testdir/t.monotone | 1 +
contrib/one-true-awk/testdir/t.nameval | 7 +
contrib/one-true-awk/testdir/t.next | 2 +
contrib/one-true-awk/testdir/t.not | 4 +
contrib/one-true-awk/testdir/t.null0 | 15 +
contrib/one-true-awk/testdir/t.ofmt | 2 +
contrib/one-true-awk/testdir/t.ofs | 2 +
contrib/one-true-awk/testdir/t.ors | 2 +
contrib/one-true-awk/testdir/t.pat | 4 +
contrib/one-true-awk/testdir/t.pipe | 1 +
contrib/one-true-awk/testdir/t.pp | 1 +
contrib/one-true-awk/testdir/t.pp1 | 3 +
contrib/one-true-awk/testdir/t.pp2 | 3 +
contrib/one-true-awk/testdir/t.printf | 5 +
contrib/one-true-awk/testdir/t.printf2 | 6 +
contrib/one-true-awk/testdir/t.quote | 1 +
contrib/one-true-awk/testdir/t.randk | 13 +
contrib/one-true-awk/testdir/t.re1 | 2 +
contrib/one-true-awk/testdir/t.re1a | 6 +
contrib/one-true-awk/testdir/t.re2 | 2 +
contrib/one-true-awk/testdir/t.re3 | 6 +
contrib/one-true-awk/testdir/t.re4 | 10 +
contrib/one-true-awk/testdir/t.re5 | 3 +
contrib/one-true-awk/testdir/t.re7 | 1 +
contrib/one-true-awk/testdir/t.reFS | 2 +
contrib/one-true-awk/testdir/t.rec | 1 +
contrib/one-true-awk/testdir/t.redir1 | 2 +
contrib/one-true-awk/testdir/t.reg | 4 +
contrib/one-true-awk/testdir/t.roff | 23 +
contrib/one-true-awk/testdir/t.sep | 2 +
contrib/one-true-awk/testdir/t.seqno | 1 +
contrib/one-true-awk/testdir/t.set0 | 3 +
contrib/one-true-awk/testdir/t.set0a | 1 +
contrib/one-true-awk/testdir/t.set0b | 3 +
contrib/one-true-awk/testdir/t.set1 | 3 +
contrib/one-true-awk/testdir/t.set2 | 4 +
contrib/one-true-awk/testdir/t.set3 | 1 +
contrib/one-true-awk/testdir/t.split1 | 2 +
contrib/one-true-awk/testdir/t.split2 | 1 +
contrib/one-true-awk/testdir/t.split2a | 4 +
contrib/one-true-awk/testdir/t.split3 | 4 +
contrib/one-true-awk/testdir/t.split4 | 4 +
contrib/one-true-awk/testdir/t.split8 | 9 +
contrib/one-true-awk/testdir/t.split9 | 8 +
contrib/one-true-awk/testdir/t.split9a | 9 +
contrib/one-true-awk/testdir/t.stately | 1 +
contrib/one-true-awk/testdir/t.strcmp | 1 +
contrib/one-true-awk/testdir/t.strcmp1 | 1 +
contrib/one-true-awk/testdir/t.strnum | 1 +
contrib/one-true-awk/testdir/t.sub0 | 18 +
contrib/one-true-awk/testdir/t.sub1 | 1 +
contrib/one-true-awk/testdir/t.sub2 | 2 +
contrib/one-true-awk/testdir/t.sub3 | 1 +
contrib/one-true-awk/testdir/t.substr | 3 +
contrib/one-true-awk/testdir/t.substr1 | 1 +
contrib/one-true-awk/testdir/t.time | 18 +
contrib/one-true-awk/testdir/t.vf | 3 +
contrib/one-true-awk/testdir/t.vf1 | 7 +
contrib/one-true-awk/testdir/t.vf2 | 1 +
contrib/one-true-awk/testdir/t.vf3 | 2 +
contrib/one-true-awk/testdir/t.x | 1 +
contrib/one-true-awk/testdir/td.1 | 1397 +
contrib/one-true-awk/testdir/test.countries | 10 +
contrib/one-true-awk/testdir/test.data | 199 +
contrib/one-true-awk/testdir/time.c | 31 +
contrib/one-true-awk/testdir/try | 10 +
contrib/one-true-awk/testdir/tt.01 | 1 +
contrib/one-true-awk/testdir/tt.02 | 1 +
contrib/one-true-awk/testdir/tt.02a | 1 +
contrib/one-true-awk/testdir/tt.03 | 2 +
contrib/one-true-awk/testdir/tt.03a | 2 +
contrib/one-true-awk/testdir/tt.04 | 3 +
contrib/one-true-awk/testdir/tt.05 | 6 +
contrib/one-true-awk/testdir/tt.06 | 7 +
contrib/one-true-awk/testdir/tt.07 | 1 +
contrib/one-true-awk/testdir/tt.08 | 1 +
contrib/one-true-awk/testdir/tt.09 | 1 +
contrib/one-true-awk/testdir/tt.10 | 1 +
contrib/one-true-awk/testdir/tt.10a | 2 +
contrib/one-true-awk/testdir/tt.11 | 1 +
contrib/one-true-awk/testdir/tt.12 | 1 +
contrib/one-true-awk/testdir/tt.13 | 5 +
contrib/one-true-awk/testdir/tt.13a | 5 +
contrib/one-true-awk/testdir/tt.14 | 7 +
contrib/one-true-awk/testdir/tt.15 | 33 +
contrib/one-true-awk/testdir/tt.16 | 6 +
contrib/one-true-awk/testdir/tt.big | 51 +
contrib/one-true-awk/testdir/u.main | 9 +
contrib/one-true-awk/testdir/unbundle.awk | 4 +
contrib/one-true-awk/testdir/xc | 17 +
contrib/one-true-awk/testdir/yc | 17 +
330 files changed, 71810 insertions(+), 10 deletions(-)
diff --cc contrib/one-true-awk/README.md
index b8089b3a4803,000000000000..76ae3d48c983
mode 100644,000000..100644
--- a/contrib/one-true-awk/README.md
+++ b/contrib/one-true-awk/README.md
@@@ -1,119 -1,0 +1,123 @@@
+# The One True Awk
+
+This is the version of `awk` described in _The AWK Programming Language_,
+by Al Aho, Brian Kernighan, and Peter Weinberger
+(Addison-Wesley, 1988, ISBN 0-201-07981-X).
+
+## Copyright
+
+Copyright (C) Lucent Technologies 1997<br/>
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name Lucent Technologies or any of
+its entities not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+## Distribution and Reporting Problems
+
+Changes, mostly bug fixes and occasional enhancements, are listed
+in `FIXES`. If you distribute this code further, please please please
+distribute `FIXES` with it.
+
+If you find errors, please report them
+to bwk at cs.princeton.edu.
+Please _also_ open an issue in the GitHub issue tracker, to make
+it easy to track issues.
+Thanks.
+
+## Submitting Pull Requests
+
+Pull requests are welcome. Some guidelines:
+
+* Please do not use functions or facilities that are not standard (e.g.,
+`strlcpy()`, `fpurge()`).
+
+* Please run the test suite and make sure that your changes pass before
+posting the pull request. To do so:
+
+ 1. Save the previous version of `awk` somewhere in your path. Call it `nawk` (for example).
+ 1. Run `oldawk=nawk make check > check.out 2>&1`.
+ 1. Search for `BAD` or `error` in the result. In general, look over it manually to make sure there are no errors.
+
+* Please create the pull request with a request
+to merge into the `staging` branch instead of into the `master` branch.
+This allows us to do testing, and to make any additional edits or changes
+after the merge but before merging to `master`.
+
+## Building
+
+The program itself is created by
+
+ make
+
+which should produce a sequence of messages roughly like this:
+
+ yacc -d awkgram.y
+ conflicts: 43 shift/reduce, 85 reduce/reduce
+ mv y.tab.c ytab.c
+ mv y.tab.h ytab.h
+ cc -c ytab.c
+ cc -c b.c
+ cc -c main.c
+ cc -c parse.c
+ cc maketab.c -o maketab
+ ./maketab >proctab.c
+ cc -c proctab.c
+ cc -c tran.c
+ cc -c lib.c
+ cc -c run.c
+ cc -c lex.c
+ cc ytab.o b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o -lm
+
+This produces an executable `a.out`; you will eventually want to
+move this to some place like `/usr/bin/awk`.
+
+If your system does not have `yacc` or `bison` (the GNU
+equivalent), you need to install one of them first.
+
+NOTE: This version uses ANSI C (C 99), as you should also. We have
+compiled this without any changes using `gcc -Wall` and/or local C
+compilers on a variety of systems, but new systems or compilers
+may raise some new complaint; reports of difficulties are
+welcome.
+
+This compiles without change on Macintosh OS X using `gcc` and
+the standard developer tools.
+
+You can also use `make CC=g++` to build with the GNU C++ compiler,
+should you choose to do so.
+
+The version of `malloc` that comes with some systems is sometimes
+astonishly slow. If `awk` seems slow, you might try fixing that.
+More generally, turning on optimization can significantly improve
+`awk`'s speed, perhaps by 1/3 for highest levels.
+
++## A Note About Releases
++
++We don't do releases.
++
+## A Note About Maintenance
+
- NOTICE! Maintenance of this program is on a ``best effort''
++NOTICE! Maintenance of this program is on a ''best effort''
+basis. We try to get to issues and pull requests as quickly
+as we can. Unfortunately, however, keeping this program going
+is not at the top of our priority list.
+
+#### Last Updated
+
- Fri Dec 25 16:53:34 EST 2020
++Sat Jul 25 14:00:07 EDT 2021
diff --cc contrib/one-true-awk/TODO
index 000000000000,13f2925544b7..13f2925544b7
mode 000000,100644..100644
--- a/contrib/one-true-awk/TODO
+++ b/contrib/one-true-awk/TODO
diff --cc contrib/one-true-awk/bugs-fixed/REGRESS
index 000000000000,07160031ca07..07160031ca07
mode 000000,100755..100755
--- a/contrib/one-true-awk/bugs-fixed/REGRESS
+++ b/contrib/one-true-awk/bugs-fixed/REGRESS
diff --cc contrib/one-true-awk/bugs-fixed/fs-overflow.ok
index 000000000000,257cc5642cb1..257cc5642cb1
mode 000000,100644..100644
--- a/contrib/one-true-awk/bugs-fixed/fs-overflow.ok
+++ b/contrib/one-true-awk/bugs-fixed/fs-overflow.ok
diff --cc contrib/one-true-awk/bugs-fixed/inf-nan-torture.awk
index 000000000000,8d145f2a5496..8d145f2a5496
mode 000000,100644..100644
--- a/contrib/one-true-awk/bugs-fixed/inf-nan-torture.awk
+++ b/contrib/one-true-awk/bugs-fixed/inf-nan-torture.awk
diff --cc contrib/one-true-awk/bugs-fixed/inf-nan-torture.in
index 000000000000,45dfdc85d556..45dfdc85d556
mode 000000,100644..100644
--- a/contrib/one-true-awk/bugs-fixed/inf-nan-torture.in
+++ b/contrib/one-true-awk/bugs-fixed/inf-nan-torture.in
diff --cc contrib/one-true-awk/bugs-fixed/inf-nan-torture.ok
index 000000000000,40d3194207c6..40d3194207c6
mode 000000,100644..100644
--- a/contrib/one-true-awk/bugs-fixed/inf-nan-torture.ok
+++ b/contrib/one-true-awk/bugs-fixed/inf-nan-torture.ok
diff --cc contrib/one-true-awk/bugs-fixed/pfile-overflow.awk
index 000000000000,b7d5379f9e3b..b7d5379f9e3b
mode 000000,100644..100644
--- a/contrib/one-true-awk/bugs-fixed/pfile-overflow.awk
+++ b/contrib/one-true-awk/bugs-fixed/pfile-overflow.awk
diff --cc contrib/one-true-awk/bugs-fixed/pfile-overflow.ok
index 000000000000,a0de50f9007f..a0de50f9007f
mode 000000,100644..100644
--- a/contrib/one-true-awk/bugs-fixed/pfile-overflow.ok
+++ b/contrib/one-true-awk/bugs-fixed/pfile-overflow.ok
diff --cc contrib/one-true-awk/bugs-fixed/rs_underflow.awk
index 000000000000,4cf17026d760..4cf17026d760
mode 000000,100644..100644
--- a/contrib/one-true-awk/bugs-fixed/rs_underflow.awk
+++ b/contrib/one-true-awk/bugs-fixed/rs_underflow.awk
diff --cc contrib/one-true-awk/bugs-fixed/rs_underflow.in
index 000000000000,74c803545d16..74c803545d16
mode 000000,100644..100644
--- a/contrib/one-true-awk/bugs-fixed/rs_underflow.in
+++ b/contrib/one-true-awk/bugs-fixed/rs_underflow.in
diff --cc contrib/one-true-awk/bugs-fixed/rs_underflow.ok
index 000000000000,74c803545d16..74c803545d16
mode 000000,100644..100644
--- a/contrib/one-true-awk/bugs-fixed/rs_underflow.ok
+++ b/contrib/one-true-awk/bugs-fixed/rs_underflow.ok
diff --cc contrib/one-true-awk/lib.c
index 6bfe5e8eaad9,000000000000..ee77207564b7
mode 100644,000000..100644
--- a/contrib/one-true-awk/lib.c
+++ b/contrib/one-true-awk/lib.c
@@@ -1,847 -1,0 +1,849 @@@
+/****************************************************************
+Copyright (C) Lucent Technologies 1997
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name Lucent Technologies or any of
+its entities not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+****************************************************************/
+
+#define DEBUG
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <ctype.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <limits.h>
+#include <math.h>
+#include "awk.h"
+
+char EMPTY[] = { '\0' };
+FILE *infile = NULL;
+bool innew; /* true = infile has not been read by readrec */
+char *file = EMPTY;
+char *record;
+int recsize = RECSIZE;
+char *fields;
+int fieldssize = RECSIZE;
+
+Cell **fldtab; /* pointers to Cells */
+static size_t len_inputFS = 0;
+static char *inputFS = NULL; /* FS at time of input, for field splitting */
+
+#define MAXFLD 2
+int nfields = MAXFLD; /* last allocated slot for $i */
+
+bool donefld; /* true = implies rec broken into fields */
+bool donerec; /* true = record is valid (no flds have changed) */
+
+int lastfld = 0; /* last used field */
+int argno = 1; /* current input argument number */
+extern Awkfloat *ARGC;
+
+static Cell dollar0 = { OCELL, CFLD, NULL, EMPTY, 0.0, REC|STR|DONTFREE, NULL, NULL };
+static Cell dollar1 = { OCELL, CFLD, NULL, EMPTY, 0.0, FLD|STR|DONTFREE, NULL, NULL };
+
+void recinit(unsigned int n)
+{
+ if ( (record = (char *) malloc(n)) == NULL
+ || (fields = (char *) malloc(n+1)) == NULL
+ || (fldtab = (Cell **) calloc(nfields+2, sizeof(*fldtab))) == NULL
+ || (fldtab[0] = (Cell *) malloc(sizeof(**fldtab))) == NULL)
+ FATAL("out of space for $0 and fields");
+ *record = '\0';
+ *fldtab[0] = dollar0;
+ fldtab[0]->sval = record;
+ fldtab[0]->nval = tostring("0");
+ makefields(1, nfields);
+}
+
+void makefields(int n1, int n2) /* create $n1..$n2 inclusive */
+{
+ char temp[50];
+ int i;
+
+ for (i = n1; i <= n2; i++) {
+ fldtab[i] = (Cell *) malloc(sizeof(**fldtab));
+ if (fldtab[i] == NULL)
+ FATAL("out of space in makefields %d", i);
+ *fldtab[i] = dollar1;
+ snprintf(temp, sizeof(temp), "%d", i);
+ fldtab[i]->nval = tostring(temp);
+ }
+}
+
+void initgetrec(void)
+{
+ int i;
+ char *p;
+
+ for (i = 1; i < *ARGC; i++) {
+ p = getargv(i); /* find 1st real filename */
+ if (p == NULL || *p == '\0') { /* deleted or zapped */
+ argno++;
+ continue;
+ }
+ if (!isclvar(p)) {
+ setsval(lookup("FILENAME", symtab), p);
+ return;
+ }
+ setclvar(p); /* a commandline assignment before filename */
+ argno++;
+ }
+ infile = stdin; /* no filenames, so use stdin */
+ innew = true;
+}
+
+/*
+ * POSIX specifies that fields are supposed to be evaluated as if they were
+ * split using the value of FS at the time that the record's value ($0) was
+ * read.
+ *
+ * Since field-splitting is done lazily, we save the current value of FS
+ * whenever a new record is read in (implicitly or via getline), or when
+ * a new value is assigned to $0.
+ */
+void savefs(void)
+{
+ size_t len;
+ if ((len = strlen(getsval(fsloc))) < len_inputFS) {
+ strcpy(inputFS, *FS); /* for subsequent field splitting */
+ return;
+ }
+
+ len_inputFS = len + 1;
+ inputFS = (char *) realloc(inputFS, len_inputFS);
+ if (inputFS == NULL)
+ FATAL("field separator %.10s... is too long", *FS);
+ memcpy(inputFS, *FS, len_inputFS);
+}
+
+static bool firsttime = true;
+
+int getrec(char **pbuf, int *pbufsize, bool isrecord) /* get next input record */
+{ /* note: cares whether buf == record */
+ int c;
+ char *buf = *pbuf;
+ uschar saveb0;
+ int bufsize = *pbufsize, savebufsize = bufsize;
+
+ if (firsttime) {
+ firsttime = false;
+ initgetrec();
+ }
+ DPRINTF("RS=<%s>, FS=<%s>, ARGC=%g, FILENAME=%s\n",
+ *RS, *FS, *ARGC, *FILENAME);
+ if (isrecord) {
+ donefld = false;
+ donerec = true;
+ savefs();
+ }
+ saveb0 = buf[0];
+ buf[0] = 0;
+ while (argno < *ARGC || infile == stdin) {
+ DPRINTF("argno=%d, file=|%s|\n", argno, file);
+ if (infile == NULL) { /* have to open a new file */
+ file = getargv(argno);
+ if (file == NULL || *file == '\0') { /* deleted or zapped */
+ argno++;
+ continue;
+ }
+ if (isclvar(file)) { /* a var=value arg */
+ setclvar(file);
+ argno++;
+ continue;
+ }
+ *FILENAME = file;
+ DPRINTF("opening file %s\n", file);
+ if (*file == '-' && *(file+1) == '\0')
+ infile = stdin;
+ else if ((infile = fopen(file, "r")) == NULL)
+ FATAL("can't open file %s", file);
++ innew = true;
+ setfval(fnrloc, 0.0);
+ }
+ c = readrec(&buf, &bufsize, infile, innew);
+ if (innew)
+ innew = false;
+ if (c != 0 || buf[0] != '\0') { /* normal record */
+ if (isrecord) {
+ double result;
+
+ if (freeable(fldtab[0]))
+ xfree(fldtab[0]->sval);
+ fldtab[0]->sval = buf; /* buf == record */
+ fldtab[0]->tval = REC | STR | DONTFREE;
+ if (is_number(fldtab[0]->sval, & result)) {
+ fldtab[0]->fval = result;
+ fldtab[0]->tval |= NUM;
+ }
+ }
+ setfval(nrloc, nrloc->fval+1);
+ setfval(fnrloc, fnrloc->fval+1);
+ *pbuf = buf;
+ *pbufsize = bufsize;
+ return 1;
+ }
+ /* EOF arrived on this file; set up next */
+ if (infile != stdin)
+ fclose(infile);
+ infile = NULL;
+ argno++;
+ }
+ buf[0] = saveb0;
+ *pbuf = buf;
+ *pbufsize = savebufsize;
+ return 0; /* true end of file */
+}
+
+void nextfile(void)
+{
+ if (infile != NULL && infile != stdin)
+ fclose(infile);
+ infile = NULL;
+ argno++;
+}
+
+int readrec(char **pbuf, int *pbufsize, FILE *inf, bool newflag) /* read one record into buf */
+{
+ int sep, c, isrec;
+ char *rr, *buf = *pbuf;
+ int bufsize = *pbufsize;
+ char *rs = getsval(rsloc);
+
+ if (*rs && rs[1]) {
+ bool found;
+
+ fa *pfa = makedfa(rs, 1);
+ if (newflag)
+ found = fnematch(pfa, inf, &buf, &bufsize, recsize);
+ else {
+ int tempstat = pfa->initstat;
+ pfa->initstat = 2;
+ found = fnematch(pfa, inf, &buf, &bufsize, recsize);
+ pfa->initstat = tempstat;
+ }
+ if (found)
+ setptr(patbeg, '\0');
++ isrec = (found == 0 && *buf == '\0') ? false : true;
+ } else {
+ if ((sep = *rs) == 0) {
+ sep = '\n';
+ while ((c=getc(inf)) == '\n' && c != EOF) /* skip leading \n's */
+ ;
+ if (c != EOF)
+ ungetc(c, inf);
+ }
+ for (rr = buf; ; ) {
+ for (; (c=getc(inf)) != sep && c != EOF; ) {
+ if (rr-buf+1 > bufsize)
+ if (!adjbuf(&buf, &bufsize, 1+rr-buf,
+ recsize, &rr, "readrec 1"))
+ FATAL("input record `%.30s...' too long", buf);
+ *rr++ = c;
+ }
+ if (*rs == sep || c == EOF)
+ break;
+ if ((c = getc(inf)) == '\n' || c == EOF) /* 2 in a row */
+ break;
+ if (!adjbuf(&buf, &bufsize, 2+rr-buf, recsize, &rr,
+ "readrec 2"))
+ FATAL("input record `%.30s...' too long", buf);
+ *rr++ = '\n';
+ *rr++ = c;
+ }
+ if (!adjbuf(&buf, &bufsize, 1+rr-buf, recsize, &rr, "readrec 3"))
+ FATAL("input record `%.30s...' too long", buf);
+ *rr = 0;
++ isrec = (c == EOF && rr == buf) ? false : true;
+ }
+ *pbuf = buf;
+ *pbufsize = bufsize;
- isrec = *buf || !feof(inf);
+ DPRINTF("readrec saw <%s>, returns %d\n", buf, isrec);
+ return isrec;
+}
+
+char *getargv(int n) /* get ARGV[n] */
+{
+ Cell *x;
+ char *s, temp[50];
+ extern Array *ARGVtab;
+
+ snprintf(temp, sizeof(temp), "%d", n);
+ if (lookup(temp, ARGVtab) == NULL)
+ return NULL;
+ x = setsymtab(temp, "", 0.0, STR, ARGVtab);
+ s = getsval(x);
+ DPRINTF("getargv(%d) returns |%s|\n", n, s);
+ return s;
+}
+
+void setclvar(char *s) /* set var=value from s */
+{
+ char *p;
+ Cell *q;
+ double result;
+
+ for (p=s; *p != '='; p++)
+ ;
+ *p++ = 0;
+ p = qstring(p, '\0');
+ q = setsymtab(s, p, 0.0, STR, symtab);
+ setsval(q, p);
+ if (is_number(q->sval, & result)) {
+ q->fval = result;
+ q->tval |= NUM;
+ }
+ DPRINTF("command line set %s to |%s|\n", s, p);
+}
+
+
+void fldbld(void) /* create fields from current record */
+{
+ /* this relies on having fields[] the same length as $0 */
+ /* the fields are all stored in this one array with \0's */
+ /* possibly with a final trailing \0 not associated with any field */
+ char *r, *fr, sep;
+ Cell *p;
+ int i, j, n;
+
+ if (donefld)
+ return;
+ if (!isstr(fldtab[0]))
+ getsval(fldtab[0]);
+ r = fldtab[0]->sval;
+ n = strlen(r);
+ if (n > fieldssize) {
+ xfree(fields);
+ if ((fields = (char *) malloc(n+2)) == NULL) /* possibly 2 final \0s */
+ FATAL("out of space for fields in fldbld %d", n);
+ fieldssize = n;
+ }
+ fr = fields;
+ i = 0; /* number of fields accumulated here */
+ if (inputFS == NULL) /* make sure we have a copy of FS */
+ savefs();
+ if (strlen(inputFS) > 1) { /* it's a regular expression */
+ i = refldbld(r, inputFS);
+ } else if ((sep = *inputFS) == ' ') { /* default whitespace */
+ for (i = 0; ; ) {
+ while (*r == ' ' || *r == '\t' || *r == '\n')
+ r++;
+ if (*r == 0)
+ break;
+ i++;
+ if (i > nfields)
+ growfldtab(i);
+ if (freeable(fldtab[i]))
+ xfree(fldtab[i]->sval);
+ fldtab[i]->sval = fr;
+ fldtab[i]->tval = FLD | STR | DONTFREE;
+ do
+ *fr++ = *r++;
+ while (*r != ' ' && *r != '\t' && *r != '\n' && *r != '\0');
+ *fr++ = 0;
+ }
+ *fr = 0;
+ } else if ((sep = *inputFS) == 0) { /* new: FS="" => 1 char/field */
+ for (i = 0; *r != '\0'; r += n) {
+ char buf[MB_LEN_MAX + 1];
+
+ i++;
+ if (i > nfields)
+ growfldtab(i);
+ if (freeable(fldtab[i]))
+ xfree(fldtab[i]->sval);
+ n = mblen(r, MB_LEN_MAX);
+ if (n < 0)
+ n = 1;
+ memcpy(buf, r, n);
+ buf[n] = '\0';
+ fldtab[i]->sval = tostring(buf);
+ fldtab[i]->tval = FLD | STR;
+ }
+ *fr = 0;
+ } else if (*r != 0) { /* if 0, it's a null field */
+ /* subtlecase : if length(FS) == 1 && length(RS > 0)
+ * \n is NOT a field separator (cf awk book 61,84).
+ * this variable is tested in the inner while loop.
+ */
+ int rtest = '\n'; /* normal case */
+ if (strlen(*RS) > 0)
+ rtest = '\0';
+ for (;;) {
+ i++;
+ if (i > nfields)
+ growfldtab(i);
+ if (freeable(fldtab[i]))
+ xfree(fldtab[i]->sval);
+ fldtab[i]->sval = fr;
+ fldtab[i]->tval = FLD | STR | DONTFREE;
+ while (*r != sep && *r != rtest && *r != '\0') /* \n is always a separator */
+ *fr++ = *r++;
+ *fr++ = 0;
+ if (*r++ == 0)
+ break;
+ }
+ *fr = 0;
+ }
+ if (i > nfields)
+ FATAL("record `%.30s...' has too many fields; can't happen", r);
+ cleanfld(i+1, lastfld); /* clean out junk from previous record */
+ lastfld = i;
+ donefld = true;
+ for (j = 1; j <= lastfld; j++) {
+ double result;
+
+ p = fldtab[j];
+ if(is_number(p->sval, & result)) {
+ p->fval = result;
+ p->tval |= NUM;
+ }
+ }
+ setfval(nfloc, (Awkfloat) lastfld);
+ donerec = true; /* restore */
+ if (dbg) {
+ for (j = 0; j <= lastfld; j++) {
+ p = fldtab[j];
+ printf("field %d (%s): |%s|\n", j, p->nval, p->sval);
+ }
+ }
*** 2256 LINES SKIPPED ***
More information about the dev-commits-src-main
mailing list