head 1.5; access; symbols pkgsrc-2023Q4:1.5.0.4 pkgsrc-2023Q4-base:1.5 pkgsrc-2023Q3:1.5.0.2 pkgsrc-2023Q3-base:1.5 pkgsrc-2023Q2:1.3.0.4 pkgsrc-2023Q2-base:1.3 pkgsrc-2023Q1:1.3.0.2 pkgsrc-2023Q1-base:1.3 pkgsrc-2022Q4:1.2.0.72 pkgsrc-2022Q4-base:1.2 pkgsrc-2022Q3:1.2.0.70 pkgsrc-2022Q3-base:1.2 pkgsrc-2022Q2:1.2.0.68 pkgsrc-2022Q2-base:1.2 pkgsrc-2022Q1:1.2.0.66 pkgsrc-2022Q1-base:1.2 pkgsrc-2021Q4:1.2.0.64 pkgsrc-2021Q4-base:1.2 pkgsrc-2021Q3:1.2.0.62 pkgsrc-2021Q3-base:1.2 pkgsrc-2021Q2:1.2.0.60 pkgsrc-2021Q2-base:1.2 pkgsrc-2021Q1:1.2.0.58 pkgsrc-2021Q1-base:1.2 pkgsrc-2020Q4:1.2.0.56 pkgsrc-2020Q4-base:1.2 pkgsrc-2020Q3:1.2.0.54 pkgsrc-2020Q3-base:1.2 pkgsrc-2020Q2:1.2.0.50 pkgsrc-2020Q2-base:1.2 pkgsrc-2020Q1:1.2.0.30 pkgsrc-2020Q1-base:1.2 pkgsrc-2019Q4:1.2.0.52 pkgsrc-2019Q4-base:1.2 pkgsrc-2019Q3:1.2.0.48 pkgsrc-2019Q3-base:1.2 pkgsrc-2019Q2:1.2.0.46 pkgsrc-2019Q2-base:1.2 pkgsrc-2019Q1:1.2.0.44 pkgsrc-2019Q1-base:1.2 pkgsrc-2018Q4:1.2.0.42 pkgsrc-2018Q4-base:1.2 pkgsrc-2018Q3:1.2.0.40 pkgsrc-2018Q3-base:1.2 pkgsrc-2018Q2:1.2.0.38 pkgsrc-2018Q2-base:1.2 pkgsrc-2018Q1:1.2.0.36 pkgsrc-2018Q1-base:1.2 pkgsrc-2017Q4:1.2.0.34 pkgsrc-2017Q4-base:1.2 pkgsrc-2017Q3:1.2.0.32 pkgsrc-2017Q3-base:1.2 pkgsrc-2017Q2:1.2.0.28 pkgsrc-2017Q2-base:1.2 pkgsrc-2017Q1:1.2.0.26 pkgsrc-2017Q1-base:1.2 pkgsrc-2016Q4:1.2.0.24 pkgsrc-2016Q4-base:1.2 pkgsrc-2016Q3:1.2.0.22 pkgsrc-2016Q3-base:1.2 pkgsrc-2016Q2:1.2.0.20 pkgsrc-2016Q2-base:1.2 pkgsrc-2016Q1:1.2.0.18 pkgsrc-2016Q1-base:1.2 pkgsrc-2015Q4:1.2.0.16 pkgsrc-2015Q4-base:1.2 pkgsrc-2015Q3:1.2.0.14 pkgsrc-2015Q3-base:1.2 pkgsrc-2015Q2:1.2.0.12 pkgsrc-2015Q2-base:1.2 pkgsrc-2015Q1:1.2.0.10 pkgsrc-2015Q1-base:1.2 pkgsrc-2014Q4:1.2.0.8 pkgsrc-2014Q4-base:1.2 pkgsrc-2014Q3:1.2.0.6 pkgsrc-2014Q3-base:1.2 pkgsrc-2014Q2:1.2.0.4 pkgsrc-2014Q2-base:1.2 pkgsrc-2014Q1:1.2.0.2 pkgsrc-2014Q1-base:1.2 pkgsrc-2013Q4:1.1.0.64 pkgsrc-2013Q4-base:1.1 pkgsrc-2013Q3:1.1.0.62 pkgsrc-2013Q3-base:1.1 pkgsrc-2013Q2:1.1.0.60 pkgsrc-2013Q2-base:1.1 pkgsrc-2013Q1:1.1.0.58 pkgsrc-2013Q1-base:1.1 pkgsrc-2012Q4:1.1.0.56 pkgsrc-2012Q4-base:1.1 pkgsrc-2012Q3:1.1.0.54 pkgsrc-2012Q3-base:1.1 pkgsrc-2012Q2:1.1.0.52 pkgsrc-2012Q2-base:1.1 pkgsrc-2012Q1:1.1.0.50 pkgsrc-2012Q1-base:1.1 pkgsrc-2011Q4:1.1.0.48 pkgsrc-2011Q4-base:1.1 pkgsrc-2011Q3:1.1.0.46 pkgsrc-2011Q3-base:1.1 pkgsrc-2011Q2:1.1.0.44 pkgsrc-2011Q2-base:1.1 pkgsrc-2011Q1:1.1.0.42 pkgsrc-2011Q1-base:1.1 pkgsrc-2010Q4:1.1.0.40 pkgsrc-2010Q4-base:1.1 pkgsrc-2010Q3:1.1.0.38 pkgsrc-2010Q3-base:1.1 pkgsrc-2010Q2:1.1.0.36 pkgsrc-2010Q2-base:1.1 pkgsrc-2010Q1:1.1.0.34 pkgsrc-2010Q1-base:1.1 pkgsrc-2009Q4:1.1.0.32 pkgsrc-2009Q4-base:1.1 pkgsrc-2009Q3:1.1.0.30 pkgsrc-2009Q3-base:1.1 pkgsrc-2009Q2:1.1.0.28 pkgsrc-2009Q2-base:1.1 pkgsrc-2009Q1:1.1.0.26 pkgsrc-2009Q1-base:1.1 pkgsrc-2008Q4:1.1.0.24 pkgsrc-2008Q4-base:1.1 pkgsrc-2008Q3:1.1.0.22 pkgsrc-2008Q3-base:1.1 cube-native-xorg:1.1.0.20 cube-native-xorg-base:1.1 pkgsrc-2008Q2:1.1.0.18 pkgsrc-2008Q2-base:1.1 cwrapper:1.1.0.16 pkgsrc-2008Q1:1.1.0.14 pkgsrc-2008Q1-base:1.1 pkgsrc-2007Q4:1.1.0.12 pkgsrc-2007Q4-base:1.1 pkgsrc-2007Q3:1.1.0.10 pkgsrc-2007Q3-base:1.1 pkgsrc-2007Q2:1.1.0.8 pkgsrc-2007Q2-base:1.1 pkgsrc-2007Q1:1.1.0.6 pkgsrc-2007Q1-base:1.1 pkgsrc-2006Q4:1.1.0.4 pkgsrc-2006Q4-base:1.1 pkgsrc-2006Q3:1.1.0.2 pkgsrc-2006Q3-base:1.1; locks; strict; comment @# @; 1.5 date 2023.09.17.10.32.05; author vins; state Exp; branches; next 1.4; commitid p7Ajr0pAGxC4W6FE; 1.4 date 2023.09.12.19.16.52; author vins; state Exp; branches; next 1.3; commitid nL3lE486Ygr00wEE; 1.3 date 2023.02.24.20.57.50; author vins; state Exp; branches; next 1.2; commitid LjxGGFZN8RxOYOeE; 1.2 date 2014.03.12.14.20.43; author ryoon; state Exp; branches; next 1.1; commitid AcBFUxrunFdPVpsx; 1.1 date 2006.07.14.14.23.06; author jlam; state Exp; branches; next ; desc @@ 1.5 log @lang/nawk: downgrade to 20230909. Partially revert previous commit, by downgrading the package to the most recent release tag supporting ASCII encoded input files (and processing strings as sequences of bytes). This is needed by security/mozilla-rootcerts and likely other packages; see https://mail-index.netbsd.org/tech-pkg/2023/09/17/msg028190.html. This version incorporates all the changes described in the FIXES file up to 2023-09-09, minus support for UTF-8 and comma-separated values (CSV) input. @ text @# 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
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 the current maintainer, ozan.yigit@@gmail.com. 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 ISO/IEC C99, 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 usually do releases. ## A Note About Maintenance 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 Sun 23 Jan 2022 03:48:01 PM EST @ 1.4 log @lang/nawk: update to release 20230911 This release marks the official 2nd edition of the AWK programming language! # CHANGES (since 20220122) Sep 11, 2023: Added --csv option to enable processing of comma-separated values inputs. When --csv is enabled, fields are separated by commas, fields may be quoted with " double quotes, fields may contain embedded newlines. If no explicit separator argument is provided, split() uses the setting of --csv to determine how fields are split. Strings may now contain UTF-8 code points (not necessarily characters). Functions that operate on characters, like length, substr, index, match, etc., use UTF-8, so the length of a string of 3 emojis is 3, not 12 as it would be if bytes were counted. Regular expressions are processes as UTF-8. Unicode literals can be written as \u followed by one to eight hexadecimal digits. These may appear in strings and regular expressions. Sep 06, 2023: Fix edge case where FS is changed on commandline. Thanks to Gordon Shephard and Miguel Pineiro Jr. Fix regular expression clobbering in the lexer, where lexer does not make a copy of regexp literals. also makedfa memory leaks have been plugged. Thanks to Miguel Pineiro Jr. Dec 15, 2022: Force hex escapes in strings to be no more than two characters, as they already are in regular expressions. This brings internal consistency, as well as consistency with gawk. Thanks to Arnold Robbins. Sep 12, 2022: adjbuf minlen error (cannot be 0) in cat, resulting in NULL pbuf. discovered by todd miller. also use-after-free issue with tempfree in cat, thanks to Miguel Pineiro Jr and valgrind. Aug 30, 2022: Various leaks and use-after-free issues plugged/fixed. Thanks to Miguel Pineiro Jr. . May 23, 2022: Memory leak when assigning a string to some of the built-in variables. allocated string erroneously marked DONTFREE. Thanks to Miguel Pineiro Jr. . Mar 14, 2022: Historic bug: command-line "name=value" assignment had been truncating its entry in ARGV. (circa 1989) Thanks to Miguel Pineiro Jr. . Mar 3, 2022: Fixed file management memory leak that appears to have been there since the files array was first initialized with stdin, stdout, and stderr (circa 1992). Thanks to Miguel Pineiro Jr. . @ text @d4 2 a5 32 Second Edition, by Al Aho, Brian Kernighan, and Peter Weinberger (Addison-Wesley, 2024, ISBN-13 978-0138269722, ISBN-10 0138269726). ## What's New? ## This version of Awk handles UTF-8 and comma-separated values (CSV) input. ### Strings ### Functions that process strings now count Unicode code points, not bytes; this affects `length`, `substr`, `index`, `match`, `split`, `sub`, `gsub`, and others. Note that code points are not necessarily characters. UTF-8 sequences may appear in literal strings and regular expressions. Aribtrary characters may be included with `\u` followed by 1 to 8 hexadecimal digits. ### Regular expressions ### Regular expressions may include UTF-8 code points, including `\u`. Character classes are likely to be limited to about 256 characters when expanded. ### CSV ### The option `--csv` turns on CSV processing of input: fields are separated by commas, fields may be quoted with double-quote (`"`) characters, fields may contain embedded newlines. In CSV mode, `FS` is ignored. If no explicit separator argument is provided, field-splitting in `split` is determined by CSV mode. d69 17 a85 15 yacc -d -b awkgram awkgram.y yacc: 44 shift/reduce conflicts, 85 reduce/reduce conflicts. cc -g -Wall -pedantic -Wcast-qual -O2 -c -o awkgram.tab.o awkgram.tab.c cc -g -Wall -pedantic -Wcast-qual -O2 -c -o b.o b.c cc -g -Wall -pedantic -Wcast-qual -O2 -c -o main.o main.c cc -g -Wall -pedantic -Wcast-qual -O2 -c -o parse.o parse.c cc -g -Wall -pedantic -Wcast-qual -O2 maketab.c -o maketab ./maketab awkgram.tab.h >proctab.c cc -g -Wall -pedantic -Wcast-qual -O2 -c -o proctab.o proctab.c cc -g -Wall -pedantic -Wcast-qual -O2 -c -o tran.o tran.c cc -g -Wall -pedantic -Wcast-qual -O2 -c -o lib.o lib.c cc -g -Wall -pedantic -Wcast-qual -O2 -c -o run.o run.c cc -g -Wall -pedantic -Wcast-qual -O2 -c -o lex.o lex.c cc -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 d105 5 d112 1 a112 1 We don't usually do releases. d123 2 a124 1 Sun Sep 3 09:26:43 EDT 2023 @ 1.3 log @lang/nawk: update to release 20220122. ## CHANGES 2020-07-30 Arnold D. Robbins By fiat, we use bison for $(YACC). Trying to accommodate different versions didn't work. * makefile: Significant cleanup. Replace all ytab* references with awkgram.tab.* and simplify definition of YACC. * .gitignore: Remove ytab* references. * b.c, lex.c, maketab.c, parse.c, run.c: Replace include of ytab.h with awkgram.tab.h. * lib.c, main.c, tran.c: Remove include of ytab.h, wasn't needed. 2020-01-20 Arnold D. Robbins * run.c (openfile): Set the close-on-exec flag for file and pipe redirections that aren't stdin/stdout/stderr. 2020-01-06 Arnold D. Robbins Minor fixes. * b.c (replace_repeat): Turn init_q back into an int. * lex.c (string): Use \a instead of \007. * tran.c (catstr): Use snprintf instead of sprintf. 2020-01-01 Arnold D. Robbins * tran.c (syminit, arginit, envinit): Free sval member before setting it. Thanks to valgrind. * b.c: Small formatting cleanups in several routines. 2019-12-27 Arnold D. Robbins * b.c (replace_repeat): Fix a bug whereby a{0,3} could match four a's. Thanks to Anonymous AWK fan for the report. Also, minor code formatting cleanups. * testdir/T.int-expr: New file. 2019-12-11 Arnold D. Robbins * README: Renamed to ... * README.md: ... this. Cleaned up some as well, including moving to Markdown. 2019-11-08 Arnold D. Robbins * test/T.chem: Use $oldawk instead of hardwiring 'awk'. * test/T.lilly: Remove gawk warnings from output, improves portability. 2019-10-07 Arnold D. Robbins * b.c (fnematch): Change type of pbuf from unsigned char to char. * proto.h (fnematch): Ditto. 2019-10-06 Arnold D. Robbins * lib.c (readrec): Allow RS a regular expression. Imported the code from the NetBSD awk. * b.c (fnematch): New function for implementing the feature. * awk.1: Updated. * main.c (version): Updated. 2019-06-24 Arnold D. Robbins * makefile: Revise to take into account there is no more awktest.tar, add targets 'check' and 'test', and also 'testclean' to clean up after test run. Have 'clean' and 'cleaner' depend upon 'testclean'. 2019-06-23 Arnold D. Robbins * testdir: Extracted from awktest.tar and added to Git. * awktest.tar: Removed. 2019-06-06 Arnold D. Robbins * awk.1: Fix a typo, minor edits. 2019-06-05 Arnold D. Robbins * b.c (relex): Count parentheses and treat umatched right paren as a literal character. * awktest.tar (testdir/T.re): Added a test case. * main.c (version): Updated. 2019-05-29 Arnold D. Robbins * lib.c (isclvar): Remove check for additional '=' after first one. No longer needed. 2019-01-26 Arnold D. Robbins * main.c (version): Updated. 2019-01-25 Arnold D. Robbins * run.c (awkgetline): Check for numeric value in all getline variants. See the numeric-getline.* files in bugs-fixed directory. 2018-08-29 Arnold D. Robbins * REGRESS: Check for existence of a.out. If not there, run make. Enable core dumps for T.arnold system status test to work on MacOS X. 2018-08-22 Arnold D. Robbins * awktest.tar (testdir/T.expr): Fix test for unary plus. 2018-08-22 Arnold D. Robbins * REGRESS: Extract tests if necessary, set PATH to include '.'. * regdir/beebe.tar (Makefile): Fix longwrds test to prefix sort with LC_ALL=C. * awktest.tar: Updated from fixed test suite, directory it extracts is now called 'testdir' to match what's in top-level REGRESS script. * regdir: Removed, as Brian wants to keep the test suite in the tar file. 2018-08-22 Arnold D. Robbins * FIXES, lib.c, run.c, makefile, main.c: Merge from Brian's tree. * REGRESS: New file, from Brian. * awktest.tar: Restored from Brian's tree. 2018-08-22 Arnold D. Robbins * awkgram.y (UPLUS): New token. In the grammar, call op1() with it. * maketab.c (proc): Add entry for UPLUS. * run.c (arith): Handle UPLUS. * main.c (version): Updated. * bugs-fixed/unary-plus.awk, bugs-fixed/unary-plus.bad, bugs-fixed/unary-plus.ok: New files. 2018-08-10 Arnold D. Robbins * TODO: Updated. * awk.1: Improve use of macros, add some additional explanation in a few places, alphabetize list of variables. 2018-08-08 Arnold D. Robbins * awk.h (Cell): Add new field `fmt' to track xFMT value used for a string conversion. [CONVC, CONVO]: New flag macros. * bugs-fixed/README: Updated. * bugs-fixed/string-conv.awk, bugs-fixed/string-conv.bad, bugs-fixed/string-conv.ok: New files. * main.c (version): Updated. * proto.h (flags2str): Add declaration. * tran.c (setfval): Clear CONVC and CONVO flags and set vp->fmt to NULL. (setsval): Ditto. Add large comment and new code to manage correct conversion of number to string based on various flags and the value of vp->fmt. The idea is to not convert again if xFMT is the same as before and we're doing the same conversion. Otherwise, clear the old flags, set the new, and reconvert. (flags2str): New function. For debug prints and for use from a debugger. 2018-08-05 Arnold D. Robbins Fix filename conflicts in regdir where the only difference was in letter case. This caused problems on Windows systems. * regdir/Compare.T1: Renamed from regdir/Compare.T. * regdir/t.delete0: Renamed from regdir/t.delete. * regdir/t.getline1: Renamed from regdir/t.getline. * regdir/t.redir1: Renamed from regdir/t.redir. * regdir/t.split1: Renamed from regdir/t.split. * regdir/t.sub0: Renamed from regdir/t.sub. * regdir/REGRESS: Adjusted. 2018-08-04 Arnold D. Robbins With scalpel, tweasers, magnifying glass and bated breath, borrow code from the NetBSD version of nawk to fix the years-old bug whereby decrementing the value of NF did not change the record. * lib.c (fldbld): Set donerec to 1 when done. (setlastfld): New function. * proto.h (setlastfld): Add declaration. * run.c (copycell): Make code smarter about flags (from NetBSD code). * tran.c (setfree): New function. * tran.c (setfval): Normalize negative zero to positive zero. If setting NF, clear donerec and call setlastfld(). (setsval): Remove call to save_old_OFS(). If setting OFS, call recbld(). If setting NF, clear donerec and call setlastfld(). As part of the process, revert OFS-related changes of 2018-05-22: * awk.h (saveOFS, saveOFSlen, save_old_OFS): Remove declarations. * lib.c (recbld): Use *OFS instead of saveOFS. * run.c (saveOFS, saveOFSlen, save_old_OFS): Remove. * tran.c (syminit): Remove initialization of saveOFS and saveOFSlen. General stuff that goes along with all this: * bugs-fixed/README: Updated. * bugs-fixed/decr-NF.awk, bugs-fixed/decr-NF.bad, bugs-fixed/decr-NF.ok: New files. * main.c (version): Updated. * regdir/README.TESTS: Fix awk book title. * regdir/T.misc: Revise test to match fixed code. * run.c (format): Increase size of buffer used for %a test. (Unrelated to NF or OFS, but fixes a compiler complaint.) 2018-06-07 Arnold D. Robbins * regdir/beebe.tar: Fix longwrds.ok so that the test will pass. The file was incorrectly sorted. 2018-06-06 Arnold D. Robbins * regdir/T.lilly: Fix the bug again in the second instance of the code. Thanks to BWK for pointing this out. 2018-05-31 Arnold D. Robbins * regdir/T.lilly: Fix a syntax error and ordering bug in creating the 'foo' file. 2018-05-23 Arnold D. Robbins * awk.1: Remove standalone 'awk' at the top of file, it messed up the formatting. Arrange built-in variable list in alphabetical order. 2018-05-23 Arnold D. Robbins * main.c (version): Add my email address and a date so that users can tell this isn't straight BWK awk. * README.md: Minor updates. * TODO: Updated. 2018-05-22 Arnold D. Robbins Add POSIX-required formats %a and %A. * run.c (format): Check for %a support in C library. If there, allow %a and %A as valid formats. * TODO: Updated. * bugs-fixed/README: Updated. * bugs-fixed/a-format.awk, bugs-fixed/a-format.bad, bugs-fixed/a-format.ok: New files. 2018-05-22 Arnold D. Robbins * FIXES: Restored a line from a much earlier version that apparently got lost when the dates were reordered. * TODO: Updated. 2018-05-22 Arnold D. Robbins * README.md: New file. 2018-05-22 Arnold D. Robbins * regdir/echo.c, regdir/time.c: Minor fixes to compile without warning on current GCC / Linux. 2018-05-22 Arnold D. Robbins * TODO: New file. 2018-05-22 Arnold D. Robbins * makefile (gitadd, gitpush): Remove these targets. They should not be automated and were incorrect for things that would be done regularly. 2018-05-22 Arnold D. Robbins Fix nawk so that [[:blank:]] only matches space and tab instead of any whitespace character, originally made May 10, 2018. See bugs-fixed/space.awk. This appears to have been a thinko on Brian's part. * b.c (charclasses): Use xisblank() function for [[:blank:]]. * bugs-fixed/README: Updated. * bugs-fixed/space.awk, bugs-fixed/space.bad, bugs-fixed/space.ok: New files. 2018-05-22 Arnold D. Robbins * .gitignore: New file. 2018-05-22 Arnold D. Robbins Fix nawk to provide reasonable exit status for system(), a la gawk, originally made March 12, 2016. See bugs-fixed/system-status.awk. * run.c (bltin): For FSYSTEM, use the macros defined for wait(2) to produce a reasonable exit value, instead of doing a floating-point division by 256. * awk.1: Document the return status values. * bugs-fixed/README: Updated. * bugs-fixed/system-status.awk, bugs-fixed/system-status.bad, bugs-fixed/system-status.ok: New files. 2018-05-22 Arnold D. Robbins Bug fix with respect to rebuilding a record, originally made August 19, 2014. See bugs-fixed/ofs-rebuild.awk. * awk.h (saveOFS, saveOFSlen): Declare new variables. * lib.c (recbld): Use them when rebuilding the record. * run.c (saveOFS, saveOFSlen): Define new variables. (save_old_OFS): New function to save OFS aside. * tran.c (syminit): Initialize saveOFS and saveOFSlen. (setsval): If setting a field, call save_old_OFS(). * bugs-fixed/README, bugs-fixed/ofs-rebuild.awk, bugs-fixed/ofs-rebuild.bad, bugs-fixed/ofs-rebuild.ok: New files. 2018-05-22 Arnold D. Robbins * makefile (YACC): Use bison. 2018-05-22 Arnold D. Robbins * ChangeLog: Created. * regdir: Created. Based on contents of awktest.a. * .gitattributes: Created, to preserve CR LF in regdir/t.crlf. * awktest.a: Removed. * regdir/T.gawk, regdir/T.latin1: Updated from awktest.tar. * awktest.tar: Removed. @ text @d4 32 a35 2 by Al Aho, Brian Kernighan, and Peter Weinberger (Addison-Wesley, 1988, ISBN 0-201-07981-X). d68 1 a68 1 to bwk@@cs.princeton.edu. d99 15 a113 17 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 d121 1 a121 1 NOTE: This version uses ANSI C (C 99), as you should also. We have a132 5 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. d135 1 a135 1 We don't do releases. d146 1 a146 1 Sat Jul 25 14:00:07 EDT 2021 @ 1.2 log @Update to 20121220 * Works fine under Debian GNU/Linux 7.4, NetBSD/amd64 6.99.36 * Merge pkgsrc specific changes Changelog: Dec 20, 2012: fiddled makefile to get correct yacc and bison flags. pick yacc (linux) or bison (mac) as necessary. added __attribute__((__noreturn__)) to a couple of lines in proto.h, to silence someone's enthusiastic checker. fixed obscure call by value bug in split(a[1],a) reported on 9fans. the management of temporary values is just a mess; i took a shortcut by making an extra string copy. thanks to paul patience and arnold robbins for passing it on and for proposed patches. tiny fiddle in setfval to eliminate -0 results in T.expr, which has irritated me for 20+ years. Aug 10, 2011: another fix to avoid core dump with delete(ARGV); again, many thanks to ruslan ermilov. Aug 7, 2011: split(s, a, //) now behaves the same as split(s, a, "") Jun 12, 2011: /pat/, \n /pat/ {...} is now legal, though bad style to use. added checks to new -v code that permits -vnospace; thanks to ruslan ermilov for spotting this and providing the patch. removed fixed limit on number of open files; thanks to aleksey cheusov and christos zoulos. fixed day 1 bug that resurrected deleted elements of ARGV when used as filenames (in lib.c). minor type fiddles to make gcc -Wall -pedantic happier (but not totally so); turned on -fno-strict-aliasing in makefile. May 6, 2011: added #ifdef for isblank. now allows -ffoo as well as -f foo arguments. (thanks, ruslan) May 1, 2011: after advice from todd miller, kevin lo, ruslan ermilov, and arnold robbins, changed srand() to return the previous seed (which is 1 on the first call of srand). the seed is an Awkfloat internally though converted to unsigned int to pass to the library srand(). thanks, everyone. fixed a subtle (and i hope low-probability) overflow error in fldbld, by adding space for one extra \0. thanks to robert bassett for spotting this one and providing a fix. removed the files related to compilation on windows. i no longer have anything like a current windows environment, so i can't test any of it. May 23, 2010: fixed long-standing overflow bug in run.c; many thanks to nelson beebe for spotting it and providing the fix. fixed bug that didn't parse -vd=1 properly; thanks to santiago vila for spotting it. Feb 8, 2010: i give up. replaced isblank with isspace in b.c; there are no consistent header files. Nov 26, 2009: fixed a long-standing issue with when FS takes effect. a change to FS is now noticed immediately for subsequent splits. changed the name getline() to awkgetline() to avoid yet another name conflict somewhere. Feb 11, 2009: temporarily for now defined HAS_ISBLANK, since that seems to be the best way through the thicket. isblank arrived in C99, but seems to be arriving at different systems at different times. Oct 8, 2008: fixed typo in b.c that set tmpvec wrongly. no one had ever run into the problem, apparently. thanks to alistair crooks. Oct 23, 2007: minor fix in lib.c: increase inputFS to 100, change malloc for fields to n+1. fixed memory fault caused by out of order test in setsval. thanks to david o'brien, freebsd, for both fixes. May 1, 2007: fiddle in makefile to fix for BSD make; thanks to igor sobrado. Mar 31, 2007: fixed some null pointer refs calling adjbuf. Feb 21, 2007: fixed a bug in matching the null RE in sub and gsub. thanks to al aho who actually did the fix (in b.c), and to wolfgang seeberg for finding it and providing a very compact test case. fixed quotation in b.c; thanks to Hal Pratt and the Princeton Dante Project. removed some no-effect asserts in run.c. fiddled maketab.c to not complain about bison-generated values. removed the obsolete -V argument; fixed --version to print the version and exit. fixed wording and an outright error in the usage message; thanks to igor sobrado and jason mcintyre. fixed a bug in -d that caused core dump if no program followed. Jan 1, 2007: dropped mac.code from makefile; there are few non-MacOSX mac's these days. Jan 17, 2006: system() not flagged as unsafe in the unadvertised -safe option. found it while enhancing tests before shipping the ;login: article. practice what you preach. removed the 9-years-obsolete -mr and -mf flags. added -version and --version options. core dump on linux with BEGIN {nextfile}, now fixed. removed some #ifdef's in run.c and lex.c that appear to no longer be necessary. @ text @d1 1 a1 1 $NetBSD: README,v 1.1 2006/07/14 14:23:06 jlam Exp $ d3 7 a9 2 /**************************************************************** Copyright (C) Lucent Technologies 1997 a29 1 ****************************************************************/ d31 1 a31 3 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). d34 29 a62 3 in FIXES. If you distribute this code further, please please please distribute FIXES with it. If you find errors, please report them to bwk@@cs.princeton.edu. Thanks. d65 1 d67 1 d71 1 a71 2 conflicts: 43 shift/reduce, 85 reduce/reduce d87 2 a88 2 This produces an executable a.out; you will eventually want to move this to some place like /usr/bin/awk. d90 2 a91 5 If your system does not have yacc or bison (the GNU equivalent), you must compile the pieces manually. We have included yacc output in ytab.c and ytab.h, and backup copies in case you overwrite them. We have also included a copy of proctab.c so you do not need to run maketab. d93 2 a94 2 NOTE: This version uses ANSI C, as you should also. We have compiled this without any changes using gcc -Wall and/or local C d99 1 a99 14 This also compiles with Visual C++ on all flavors of Windows, *if* you provide versions of popen and pclose. The file missing95.c contains versions that can be used to get started with, though the underlying support has mysterious properties, the symptom of which can be truncated pipe output. Beware. The file makefile.win gives hints on how to proceed; if you run vcvars32.bat, it will set up necessary paths and parameters so you can subsequently run nmake -f makefile.win. Beware also that when running on Windows under command.com, various quoting conventions are different from Unix systems: single quotes won't work around arguments, and various characters like % are interpreted within double quotes. This compiles without change on Macintosh OS X using gcc and d102 2 a103 3 This is also said to compile on Macintosh OS 9 systems, using the file "buildmac" provided by Dan Allen (danallen@@microsoft.com), to whom many thanks. d105 2 a106 2 The version of malloc that comes with some systems is sometimes astonishly slow. If awk seems slow, you might try fixing that. d108 16 a123 1 awk's speed, perhaps by 1/3 for highest levels. @ 1.1 log @Prepare nawk for use as a bootstrap tool by including the sources directly in pkgsrc/lang/nawk/files and adjusting the package Makefile accordingly. The README.pkgsrc file includes notes on how the source files were (minimally) adjusted. @ text @d1 1 a1 1 $NetBSD$ d34 1 a34 1 to bwk@@bell-labs.com. Thanks. @