1 /****************************************************************
2 Copyright (C) Lucent Technologies 1997
5 Permission to use, copy, modify, and distribute this software and
6 its documentation for any purpose and without fee is hereby
7 granted, provided that the above copyright notice appear in all
8 copies and that both that the copyright notice and this
9 permission notice and warranty disclaimer appear in supporting
10 documentation, and that the name Lucent Technologies or any of
11 its entities not be used in advertising or publicity pertaining
12 to distribution of the software without specific, written prior
15 LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
17 IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
18 SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
20 IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
21 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
23 ****************************************************************/
25 This file lists all bug fixes, changes, etc., made since the AWK book
26 was sent to the printers in August, 1987.
29 Small fix so that awk will compile again with g++. Thanks to
33 Fix a decision bug with trailing stuff in lib.c:is_valid_number
34 after recent changes. Thanks to Ozan Yigit.
37 Fix problems converting inf and NaN values in lib.c:is_valid_number.
38 Enhance number to string conversion to do the right thing for
39 NaN and inf values. Things are now pretty much the same as in
40 gawk. (Found a gawk bug while we're at it.) Added a torture
41 test for these values. Thanks to Arnold Robbins. Allows closing
45 Merge PR #99, which gets the right header for strcasecmp.
46 Thanks to GitHub user michaelforney.
49 Merge PR #98: Disallow hex data. Allow only +nan, -nan,
50 +inf, -inf (case independent) to give NaN and infinity values.
51 Improve things so that string to double conversion is only
52 done once, yielding something of a speedup. This obviate
53 PR #95. Thanks to Arnold Robbins.
56 Fix to argument parsing to avoid printing spurious newlines.
57 Thanks to Todd Miller. Merges PR #97.
60 Add casts before all the calls to malloc/calloc/realloc in order
61 to get it to compile with g++. Thanks to Arnold Robbins.
64 Additional fixes for DJGPP. Thanks to Eli Zaretskii for
68 Merge PR #93, which adds casts to (void*) for debug prints
69 using the %p format specifier. Thanks to GitHub user YongHaoWu
70 ("Chris") for the fixes.
73 In run.c, use non-restartable multibyte routines to attain
74 portability to DJGPP. Should fix Issue 92. Thanks to Albert Wik
75 for the report and to Todd Miller for the suggested fix.
78 Merge PRs 88-91 which fix small bugs. Thanks to Todd Miller and
79 Tim van der Molen for the fixes.
81 In order to make life easier, we move exclusively to bison
82 as the parser generator.
85 Merge PRs 85 and 86 which fix regressions. Thanks to
86 Tim van der Molen for the fixes.
89 Merge PRs 82 and 84. The latter fixes issue #83. Thanks to
90 Todd Miller and awkfan77.
93 Clear errno before calling errcheck to avoid any spurious errors
94 left over from previous calls that may have set it. Thanks to
95 Todd Miller for the fix, from PR #80.
97 Fix Issue #78 by allowing \r to follow floating point numbers in
98 lib.c:is_number. Thanks to GitHub user ajcarr for the report
99 and to Arnold Robbins for the fix.
102 In fldbld(), make sure that inputFS is set before trying to
103 use it. Thanks to Steffen Nurpmeso <steffen@sdaoden.eu>
107 Fix checks for compilers that can handle noreturn. Thanks to
108 GitHub user enh-google for pointing it out. Closes Issue #79.
111 Handle old compilers that don't support C11 (for noreturn).
112 Thanks to Arnold Robbins.
115 Use <stdnoreturn.h> and noreturn instead of GCC attributes.
116 Thanks to GitHub user awkfan77. Closes PR #77.
119 More cleanups from Christos Zoulas: notably backslash continuation
120 inside strings removes the newline and a fix for RS = "^a".
121 Fix for address sanitizer-found problem. Thanks to GitHub user
125 More small cleanups from Christos Zoulas.
128 Additional cleanups from Christos Zoulas. It's no longer necessary
129 to use the -y flag to bison.
132 Additional small cleanups from Christos Zoulas. awk is now
133 a little more robust about reporting I/O errors upon exit.
136 Merge PR #70, which avoids use of variable length arrays. Thanks
137 to GitHub user michaelforney. Fix issue #60 ({0} in interval
138 expressions doesn't work). Also get all tests working again.
139 Thanks to Arnold Robbins.
142 A number of small cleanups from Christos Zoulas. Add the close
143 on exec flag to files/pipes opened for redirection; courtesy of
147 If POSIXLY_CORRECT is set in the environment, then sub and gsub
148 use POSIX rules for multiple backslashes. This fixes Issue #66,
149 while maintaining backwards compatibility.
152 Input/output errors on closing files are now fatal instead of
153 mere warnings. Thanks to Martijn Dekker <martijn@inlv.org>.
156 Fix a bug in the concatentation of two string constants into
157 one done in the grammar. Fixes GitHub issue #61. Thanks
158 to GitHub user awkfan77 for pointing out the direction for
159 the fix. New test T.concat added to the test suite.
160 Fix a few memory leaks reported by valgrind, as well.
163 Fix a bug whereby a{0,3} could match four a's. Thanks to
164 "Anonymous AWK fan" for the report.
167 Further printf-related fixes for 32 bit systems.
168 Thanks again to Christos Zoulas.
171 Fix the return value of sprintf("%d") on 32 bit systems.
172 Thanks to Jim Lowe for the report and to Christos Zoulas
176 Convert a number of Boolean integer variables into
177 actual bools. Convert compile_time variable into an
178 enum and simplify some of the related code. Thanks
182 Fix from Ori Bernstein to get UTF-8 characters instead of
183 bytes when FS = "". This is currently the only bit of
184 the One True Awk that understands multibyte characters.
185 From Arnold Robbins, apply some cleanups in the test suite.
188 More fixes and cleanups from NetBSD, courtesy of Christos
189 Zoulas. Merges PRs 54 and 55.
192 Import second round of code cleanups from NetBSD. Much thanks
193 to Christos Zoulas (GitHub user zoulasc). Merges PR 53.
194 Add an optimization for string concatenation, also from
198 Import code cleanups from NetBSD. Much thanks to Christos
199 Zoulas (GitHub user zoulasc). Merges PR 51.
202 Import code from NetBSD awk that implements RS as a regular
206 Fixes for various array / memory overruns found via gcc's
207 -fsanitize=unknown. Thanks to Alexander Richardson (GitHub
208 user arichardson). Merges PRs 47 and 48.
211 Import grammar optimization from NetBSD: Two string constants
212 concatenated together get turned into a single string.
215 Support POSIX-specified C-style escape sequences "\a" (alarm)
216 and "\v" (vertical tab) in command line arguments and regular
217 expressions, further to the support for them in strings added on
218 Apr 9, 1989. These now no longer match as literal "a" and "v"
219 characters (as they don't on other awk implementations).
220 Thanks to Martijn Dekker.
223 Pull in a number of code cleanups and minor fixes from
224 Warner Losh's bsd-ota branch. The only user visible change
225 is the use of random(3) as the random number generator.
226 Thanks to Warner Losh for collecting all these fixes in
227 one easy place to get them from.
230 Fix field splitting to use FS value as of the time a record
231 was read or assigned to. Thanks to GitHub user Cody Mello (melloc)
232 for the fix. (Merged from his branch, via PR #42.) Updated
233 testdir/T.split per said PR as well.
236 Extract awktest.tar into testdir directory. Add some very
237 simple mechanics to the makefile for running the tests and
238 for cleaning up. No changes to awk itself.
241 Disallow deleting SYMTAB and its elements, which creates
242 use-after-free bugs. Thanks to GitHub user Cody Mello (melloc)
243 for the fix. (Merged from PR #43.)
246 Allow unmatched right parenthesis in a regular expression to
247 be treated literally. Fixes Issue #40. Thanks to GitHub user
248 Warner Losh (bsdimp) for the report. Thanks to Arnold Robbins
252 Fix check for command line arguments to no longer require that
253 first character after '=' not be another '='. Reverts change of
254 August 11, 1989. Thanks to GitHub user Jamie Landeg Jones for
255 pointing out the issue; from Issue #38.
258 Update awktest.tar(p.50) to use modern options to sort. Needed
259 for Android development. Thanks to GitHub user mohd-akram (Mohamed
260 Akram). From Issue #33.
263 Added very simplistic support for cross-compiling in the
264 makefile. We are NOT going to go in the direction of the
265 autotools, though. Thanks to GitHub user nee-san for
266 the basic change. (Merged from PR #34.)
269 Added support for POSIX-standard interval expressions (a.k.a.
270 bounds, a.k.a. repetition expressions) in regular expressions,
271 backported (via NetBSD) from Apple awk-24 (20070501).
272 Thanks to Martijn Dekker <martijn@inlv.org> for the port.
273 (Merged from PR #30.)
276 Merge PRs as follows:
277 #12: Avoid undefined behaviour when using ctype(3) functions in
278 relex(). Thanks to GitHub user iamleot.
279 #31: Make getline handle numeric strings, and update FIXES. Thanks
280 to GitHub user arnoldrobbins.
281 #32: maketab: support build systems with read-only source. Thanks
285 Make getline handle numeric strings properly in all cases.
289 Merged a number of small fixes from GitHub pull requests.
290 Thanks to GitHub users Arnold Robbins (arnoldrobbins),
291 Cody Mello (melloc) and Christoph Junghans (junghans).
292 PR numbers: 13-21, 23, 24, 27.
295 Added test in maketab.c to prevent generating a proctab entry
296 for YYSTYPE_IS_DEFINED. It was harmless but some gcc settings
297 generated a warning message. Thanks to Nan Xiao for report.
300 Disallow '$' in printf formats; arguments evaluated in order
301 and printed in order.
303 Added some casts to silence warnings on debugging printfs.
307 A long list of fixes courtesy of Arnold Robbins,
308 to whom profound thanks.
310 1. ofs-rebuild: OFS value used to rebuild the record was incorrect.
311 Fixed August 19, 2014. Revised fix August 2018.
313 2. system-status: Instead of a floating-point division by 256, use
314 the wait(2) macros to create a reasonable exit status.
315 Fixed March 12, 2016.
317 3. space: Use provided xisblank() function instead of ispace() for
318 matching [[:blank:]].
320 4. a-format: Add POSIX standard %a and %A to supported formats. Check
321 at runtime that this format is available.
323 5. decr-NF: Decrementing NF did not change $0. This is a decades-old
324 bug. There are interactions with the old and new value of OFS as well.
325 Most of the fix came from the NetBSD awk.
327 6. string-conv: String conversions of scalars were sticky. Once a
328 conversion to string happened, even with OFMT, that value was used until
329 a new numeric value was assigned, even if OFMT differed from CONVFMT,
330 and also if CONVFMT changed.
332 7. unary-plus: Unary plus on a string constant returned the string.
333 Instead, it should convert the value to numeric and give that value.
335 Also added Arnold's tests for these to awktest.tar as T.arnold.
338 fixed mangled awktest.tar (thanks, Arnold), posted all
339 current (very minor) fixes to github / onetrueawk
343 Updated some broken tests (beebe.tar, T.lilly)
344 [thanks to Arnold Robbins]
347 buffer overflow in error reporting; thanks to tobias ulmer
348 and john-mark gurney for spotting it and the fix.
351 cleaned up a handful of tests that didn't seem to actually
352 test for correct behavior: T.latin1, T.gawk.
355 added ,NULL initializer to static Cells in run.c; not really
356 needed but cleaner. Thanks to Michael Bombardieri.
359 fiddled makefile to get correct yacc and bison flags. pick yacc
360 (linux) or bison (mac) as necessary.
362 added __attribute__((__noreturn__)) to a couple of lines in
363 proto.h, to silence someone's enthusiastic checker.
365 fixed obscure call by value bug in split(a[1],a) reported on
366 9fans. the management of temporary values is just a mess; i
367 took a shortcut by making an extra string copy. thanks
368 to paul patience and arnold robbins for passing it on and for
371 tiny fiddle in setfval to eliminate -0 results in T.expr, which
372 has irritated me for 20+ years.
375 another fix to avoid core dump with delete(ARGV); again, many thanks
379 split(s, a, //) now behaves the same as split(s, a, "")
382 /pat/, \n /pat/ {...} is now legal, though bad style to use.
384 added checks to new -v code that permits -vnospace; thanks to
385 ruslan ermilov for spotting this and providing the patch.
387 removed fixed limit on number of open files; thanks to aleksey
388 cheusov and christos zoulos.
390 fixed day 1 bug that resurrected deleted elements of ARGV when
391 used as filenames (in lib.c).
393 minor type fiddles to make gcc -Wall -pedantic happier (but not
394 totally so); turned on -fno-strict-aliasing in makefile.
397 added #ifdef for isblank.
398 now allows -ffoo as well as -f foo arguments.
402 after advice from todd miller, kevin lo, ruslan ermilov,
403 and arnold robbins, changed srand() to return the previous
404 seed (which is 1 on the first call of srand). the seed is
405 an Awkfloat internally though converted to unsigned int to
406 pass to the library srand(). thanks, everyone.
408 fixed a subtle (and i hope low-probability) overflow error
409 in fldbld, by adding space for one extra \0. thanks to
410 robert bassett for spotting this one and providing a fix.
412 removed the files related to compilation on windows. i no
413 longer have anything like a current windows environment, so
414 i can't test any of it.
417 fixed long-standing overflow bug in run.c; many thanks to
418 nelson beebe for spotting it and providing the fix.
420 fixed bug that didn't parse -vd=1 properly; thanks to santiago
421 vila for spotting it.
424 i give up. replaced isblank with isspace in b.c; there are
425 no consistent header files.
428 fixed a long-standing issue with when FS takes effect. a
429 change to FS is now noticed immediately for subsequent splits.
431 changed the name getline() to awkgetline() to avoid yet another
432 name conflict somewhere.
435 temporarily for now defined HAS_ISBLANK, since that seems to
436 be the best way through the thicket. isblank arrived in C99,
437 but seems to be arriving at different systems at different
441 fixed typo in b.c that set tmpvec wrongly. no one had ever
442 run into the problem, apparently. thanks to alistair crooks.
445 minor fix in lib.c: increase inputFS to 100, change malloc
448 fixed memory fault caused by out of order test in setsval.
450 thanks to david o'brien, freebsd, for both fixes.
453 fiddle in makefile to fix for BSD make; thanks to igor sobrado.
456 fixed some null pointer refs calling adjbuf.
459 fixed a bug in matching the null RE in sub and gsub. thanks to al aho
460 who actually did the fix (in b.c), and to wolfgang seeberg for finding
461 it and providing a very compact test case.
463 fixed quotation in b.c; thanks to Hal Pratt and the Princeton Dante
466 removed some no-effect asserts in run.c.
468 fiddled maketab.c to not complain about bison-generated values.
470 removed the obsolete -V argument; fixed --version to print the
473 fixed wording and an outright error in the usage message; thanks to igor
474 sobrado and jason mcintyre.
476 fixed a bug in -d that caused core dump if no program followed.
479 dropped mac.code from makefile; there are few non-MacOSX
483 system() not flagged as unsafe in the unadvertised -safe option.
484 found it while enhancing tests before shipping the ;login: article.
485 practice what you preach.
487 removed the 9-years-obsolete -mr and -mf flags.
489 added -version and --version options.
491 core dump on linux with BEGIN {nextfile}, now fixed.
493 removed some #ifdef's in run.c and lex.c that appear to no
497 modified lib.c so that values of $0 et al are preserved in the END
498 block, apparently as required by posix. thanks to havard eidnes
499 for the report and code.
502 fixed infinite loop in parsing, originally found by brian tsang.
503 thanks to arnold robbins for a suggestion that started me
507 prevent overflow of -f array in main, head off potential error in
508 call of SYNTAX(), test malloc return in lib.c, all with thanks to
512 cranked up size of NCHARS; coverity thinks it can be overrun with
513 smaller size, and i think that's right. added some assertions to b.c
514 to catch places where it might overrun. the RE code is still fragile.
517 fixed a couple of overflow problems with ridiculous field numbers:
518 e.g., print $(2^32-1). thanks to ruslan ermilov, giorgos keramidas
519 and david o'brien at freebsd.org for patches. this really should
520 be re-done from scratch.
523 fixed another 25-year-old RE bug, in split. it's another failure
524 to (re-)initialize. thanks to steve fisher for spotting this and
525 providing a good test case.
528 fixed a bug in regular expressions that dates (so help me) from 1977;
529 it's been there from the beginning. an anchored longest match that
530 was longer than the number of states triggered a failure to initialize
531 the machine properly. many thanks to moinak ghosh for not only finding
532 this one but for providing a fix, in some of the most mysterious
535 fixed a storage leak in call() that appears to have been there since
536 1983 or so -- a function without an explicit return that assigns a
537 string to a parameter leaked a Cell. thanks to moinak ghosh for
538 spotting this very subtle one.
541 fixed, thanks to andrey chernov and ruslan ermilov, a bug in lex.c
542 that mis-handled the character 255 in input. (it was being compared
543 to EOF with a signed comparison.)
546 fixed (i think) the long-standing botch that included the beginning of
547 line state ^ for RE's in the set of valid characters; this led to a
548 variety of odd problems, including failure to properly match certain
549 regular expressions in non-US locales. thanks to ruslan for keeping
553 n-th try at getting internationalization right, with thanks to volker
554 kiefel, arnold robbins and ruslan ermilov for advice, though they
555 should not be blamed for the outcome. according to posix, "." is the
556 radix character in programs and command line arguments regardless of
557 the locale; otherwise, the locale should prevail for input and output
558 of numbers. so it's intended to work that way.
560 i have rescinded the attempt to use strcoll in expanding shorthands in
561 regular expressions (cclenter). its properties are much too
562 surprising; for example [a-c] matches aAbBc in locale en_US but abBcC
563 in locale fr_CA. i can see how this might arise by implementation
564 but i cannot explain it to a human user. (this behavior can be seen
565 in gawk as well; we're leaning on the same library.)
567 the issue appears to be that strcoll is meant for sorting, where
568 merging upper and lower case may make sense (though note that unix
569 sort does not do this by default either). it is not appropriate
570 for regular expressions, where the goal is to match specific
571 patterns of characters. in any case, the notations [:lower:], etc.,
572 are available in awk, and they are more likely to work correctly in
575 a moratorium is hereby declared on internationalization changes.
576 i apologize to friends and colleagues in other parts of the world.
577 i would truly like to get this "right", but i don't know what
578 that is, and i do not want to keep making changes until it's clear.
581 fixed bug that permitted non-terminated RE, as in "awk /x".
584 subtle change to split: if source is empty, number of elems
585 is always 0 and the array is not set.
588 added some parens to isblank, in another attempt to make things
589 internationally portable.
592 the internationalization changes, somewhat modified, are now
593 reinstated. in theory awk will now do character comparisons
594 and case conversions in national language, but "." will always
595 be the decimal point separator on input and output regardless
596 of national language. isblank(){} has an #ifndef.
598 this no longer compiles on windows: LC_MESSAGES isn't defined
601 fixed subtle behavior in field and record splitting: if FS is
602 a single character and RS is not empty, \n is NOT a separator.
603 this tortuous reading is found in the awk book; behavior now
604 matches gawk and mawk.
607 for the moment, the internationalization changes of nov 29 are
608 rolled back -- programs like x = 1.2 don't work in some locales,
609 because the parser is expecting x = 1,2. until i understand this
610 better, this will have to wait.
613 modified b.c (with tiny changes in main and run) to support
614 locales, using strcoll and iswhatever tests for posix character
615 classes. thanks to ruslan ermilov (ru@freebsd.org) for code.
616 the function isblank doesn't seem to have propagated to any
617 header file near me, so it's there explicitly. not properly
618 tested on non-ascii character sets by me.
621 modified run/format() and tran/getsval() to do a slightly better
622 job on using OFMT for output from print and CONVFMT for other
623 number->string conversions, as promised by posix and done by
624 gawk and mawk. there are still places where it doesn't work
625 right if CONVFMT is changed; by then the STR attribute of the
626 variable has been irrevocably set. thanks to arnold robbins for
629 fixed subtle bug in format that could get core dump. thanks to
630 Jaromir Dolecek <jdolecek@NetBSD.org> for finding and fixing.
631 minor cleanup in run.c / format() at the same time.
633 added some tests for null pointers to debugging printf's, which
634 were never intended for external consumption. thanks to dave
635 kerns (dkerns@lucent.com) for pointing this out.
637 GNU compatibility: an empty regexp matches anything (thanks to
638 dag-erling smorgrav, des@ofug.org). subject to reversion if
639 this does more harm than good.
641 pervasive small changes to make things more const-correct, as
642 reported by gcc's -Wwrite-strings. as it says in the gcc manual,
643 this may be more nuisance than useful. provoked by a suggestion
644 and code from arnaud desitter, arnaud@nimbus.geog.ox.ac.uk
646 minor documentation changes to note that this now compiles out
647 of the box on Mac OS X.
650 changed types in posix chars structure to quiet solaris cc.
653 fflush() or fflush("") flushes all files and pipes.
655 length(arrayname) returns number of elements; thanks to
656 arnold robbins for suggestion.
658 added a makefile.win to make it easier to build on windows.
659 based on dan allen's buildwin.bat.
662 added support for posix character class names like [:digit:],
663 which are not exactly shorter than [0-9] and perhaps no more
664 portable. thanks to dag-erling smorgrav for code.
667 removed -m option; no longer needed, and it was actually
668 broken (noted thanks to volker kiefel).
671 fixed an appalling bug in gettok: any sequence of digits, +,-, E, e,
672 and period was accepted as a valid number if it started with a period.
673 this would never have happened with the lex version.
675 other 1-character botches, now fixed, include a bare $ and a
676 bare " at the end of the input.
679 more (const char *) casts in b.c and tran.c to silence warnings.
682 fixed a bug introduced in august 1997 that caused expressions
683 like $f[1] to be syntax errors. thanks to arnold robbins for
684 noticing this and providing a fix.
687 fixed some nextfile bugs: not handling all cases. thanks to
688 arnold robbins for pointing this out. new regressions added.
690 close() is now a function. it returns whatever the library
691 fclose returns, and -1 for closing a file or pipe that wasn't
695 permit \n explicitly in character classes; won't work right
696 if comes in as "[\n]" but ok as /[\n]/, because of multiple
697 processing of \'s. thanks to arnold robbins.
700 minor fiddles in tran.c to keep compilers happy about uschar.
701 thanks to norman wilson.
704 yet another attempt at making 8-bit input work, with another
705 band-aid in b.c (member()), and some (uschar) casts to head
706 off potential errors in subscripts (like isdigit). also
707 changed HAT to NCHARS-2. thanks again to santiago vila.
709 changed maketab.c to ignore apparently out of range definitions
710 instead of halting; new freeBSD generates one. thanks to
711 jon snader <jsnader@ix.netcom.com> for pointing out the problem.
714 fixed an 8-bit problem in b.c by making several char*'s into
715 unsigned char*'s. not clear i have them all yet. thanks to
716 Santiago Vila <sanvila@unex.es> for the bug report.
719 finally found and fixed a memory leak in function call; it's
720 been there since functions were added ~1983. thanks to
721 jon bentley for the test case that found it.
723 added test in envinit to catch environment "variables" with
724 names beginning with '='; thanks to Berend Hasselman.
727 added test in defn() to catch function foo(foo), which
728 otherwise recurses until core dump. thanks to arnold
729 robbins for noticing this.
732 added *bp in gettok in lex.c; appears possible to exit function
733 without terminating the string. thanks to russ cox.
736 added function stdinit() to run to initialize files[] array,
737 in case stdin, etc., are not constants; some compilers care.
740 replaced the ERROR ... FATAL, etc., macros with functions
741 based on vprintf, to avoid problems caused by overrunning
742 fixed-size errbuf array. thanks to ralph corderoy for the
743 impetus, and for pointing out a string termination bug in
747 fixed bug that caused occasional core dumps with commandline
748 variable with value ending in \. (thanks to nelson beebe for
752 with code kindly provided by Bruce Lilly, awk now parses
753 /=/ and similar constructs more sensibly in more places.
754 Bruce also provided some helpful test cases.
757 changed true/false to True/False in run.c to make it
758 easier to compile with C++. Added some casts on malloc
759 and realloc to be honest about casts; ditto. changed
760 ltype int to long in struct rrow to reduce some 64-bit
761 complaints; other changes scattered throughout for the
762 same purpose. thanks to Nelson Beebe for these portability
765 removed some horrible pointer-int casting in b.c and elsewhere
766 by adding ptoi and itonp to localize the casts, which are
767 all benign. fixed one incipient bug that showed up on sgi
770 reset lineno for new source file; include filename in error
771 message. also fixed line number error in continuation lines.
772 (thanks to Nelson Beebe for both of these.)
775 Nelson Beebe notes that irix 5.3 yacc dies with a bogus
776 error; use a newer version or switch to bison, since sgi
777 is unlikely to fix it.
780 changed isnumber to is_number to avoid the problem caused by
781 versions of ctype.h that include the name isnumber.
783 distribution now includes a script for building on a Mac,
787 fixed memory leaks in run.c (call) and tran.c (setfval).
788 thanks to Stephen Nutt for finding these and providing the fixes.
791 replaced srand argument by (unsigned int) in run.c;
792 avoids problem on Mac and potentially on Unix & Windows.
795 added a few (int) casts to silence useless compiler warnings.
796 e.g., errorflag= in run.c jump().
798 added proctab.c to the bundle outout; one less thing
799 to have to compile out of the box.
801 added calls to _popen and _pclose to the win95 stub for
802 pipes (thanks to Steve Adams for this helpful suggestion).
803 seems to work, though properties are not well understood
804 by me, and it appears that under some circumstances the
805 pipe output is truncated. Be careful.
808 fixed a couple of bugs in getrec: could fail to update $0
809 after a getline var; because inputFS wasn't initialized,
810 could split $0 on every character, a misleading diversion.
812 fixed caching bug in makedfa: LRU was actually removing
815 thanks to ross ridge for finding these, and for providing
819 fixed potential bug in readrec: might fail to update record
820 pointer after growing. thanks to dan levy for spotting this
821 and suggesting the fix.
824 added -V to print version number and die.
826 [notify dave kerns, dkerns@dacsoup.ih.lucent.com]
829 subtle silent bug in lex.c: if the program ended with a number
830 longer than 1 digit, part of the input would be pushed back and
831 parsed again because token buffer wasn't terminated right.
832 example: awk 'length($0) > 10'. blush. at least i found it
836 s/adelete/awkdelete/: SGI uses this in malloc.h.
837 thanks to nelson beebe for pointing this one out.
840 fixed some bugs in sub and gsub when replacement includes \\.
841 this is a dark, horrible corner, but at least now i believe that
842 the behavior is the same as gawk and the intended posix standard.
843 thanks to arnold robbins for advice here.
846 somewhat regretfully, replaced the ancient lex-based lexical
847 analyzer with one written in C. it's longer, generates less code,
848 and more portable; the old one depended too much on mysterious
849 properties of lex that were not preserved in other environments.
850 in theory these recognize the same language.
852 now using strtod to test whether a string is a number, instead of
853 the convoluted original function. should be more portable and
854 reliable if strtod is implemented right.
856 removed now-pointless optimization in makefile that tries to avoid
857 recompilation when awkgram.y is changed but symbols are not.
859 removed most fixed-size arrays, though a handful remain, some
860 of which are unchecked. you have been warned.
863 with some trepidation, replaced the ancient code that managed
864 fields and $0 in fixed-size arrays with arrays that grow on
865 demand. there is still some tension between trying to make this
866 run fast and making it clean; not sure it's right yet.
868 the ill-conceived -mr and -mf arguments are now useful only
869 for debugging. previous dynamic string code removed.
871 numerous other minor cleanups along the way.
874 using code provided by dan levy (to whom profuse thanks), replaced
875 fixed-size arrays and awkward kludges by a fairly uniform mechanism
876 to grow arrays as needed for printf, sub, gsub, etc.
879 falling off the end of a function returns "" and 0, not 0.
880 thanks to arnold robbins.
883 replaced several fixed-size arrays by dynamically-created ones
884 in run.c; added overflow tests to some previously unchecked cases.
885 getline, toupper, tolower.
887 getline code is still broken in that recursive calls may wind
888 up using the same space. [fixed later]
890 increased RECSIZE to 8192 to push problems further over the horizon.
892 added \r to \n as input line separator for programs, not data.
895 modified format() to permit explicit printf("%c", 0) to include
896 a null byte in output. thanks to ken stailey for the fix.
898 added a "-safe" argument that disables file output (print >,
899 print >>), process creation (cmd|getline, print |, system), and
900 access to the environment (ENVIRON). this is a first approximation
901 to a "safe" version of awk, but don't rely on it too much. thanks
902 to joan feigenbaum and matt blaze for the inspiration long ago.
905 fixed long-standing bug in sub, gsub(/a/, "\\\\&"); thanks to
909 fixed awful bug in new field splitting; didn't get all the places
910 where input was done.
913 changed field-splitting to conform to posix definition: fields are
914 split using the value of FS at the time of input; it used to be
915 the value when the field or NF was first referred to, a much less
916 predictable definition. thanks to arnold robbins for encouragement
917 to do the right thing.
920 fixed appalling but apparently unimportant bug in parsing octal
921 numbers in reg exprs.
923 explicit hex in reg exprs now limited to 2 chars: \xa, \xaa.
926 cleaned up some declarations so gcc -Wall is now almost silent.
928 makefile now includes backup copies of ytab.c and lexyy.c in case
929 one makes before looking; it also avoids recreating lexyy.c unless
932 s/aprintf/awkprint, s/asprintf/awksprintf/ to avoid some name clashes
933 with unwisely-written header files.
935 thanks to jeffrey friedl for several of these.
938 an attempt to rationalize the (unsigned) char issue. almost all
939 instances of unsigned char have been removed; the handful of places
940 in b.c where chars are used as table indices have been hand-crafted.
941 added some latin-1 tests to the regression, but i'm not confident;
942 none of my compilers seem to care much. thanks to nelson beebe for
943 pointing out some others that do care.
946 removed all register declarations.
948 enhanced split(), as in gawk, etc: split(s, a, "") splits s into
949 a[1]...a[length(s)] with each character a single element.
951 made the same changes for field-splitting if FS is "".
953 added nextfile, as in gawk: causes immediate advance to next
954 input file. (thanks to arnold robbins for inspiration and code).
956 small fixes to regexpr code: can now handle []], [[], and
957 variants; [] is now a syntax error, rather than matching
958 everything; [z-a] is now empty, not z. far from complete
959 or correct, however. (thanks to jeffrey friedl for pointing out
960 some awful behaviors.)
963 replaced uchar by uschar everywhere; apparently some compilers
964 usurp this name and this causes conflicts.
966 fixed call to time in run.c (bltin); arg is time_t *.
968 replaced horrible pointer/long punning in b.c by a legitimate
969 union. should be safer on 64-bit machines and cleaner everywhere.
970 (thanks to nelson beebe for pointing out some of these problems.)
972 replaced nested comments by #if 0...#endif in run.c, lib.c.
974 removed getsval, setsval, execute macros from run.c and lib.c.
975 machines are 100x faster than they were when these macros were
978 revised filenames: awk.g.y => awkgram.y, awk.lx.l => awklex.l,
979 y.tab.[ch] => ytab.[ch], lex.yy.c => lexyy.c, all in the aid of
980 portability to nameless systems.
982 "make bundle" now includes yacc and lex output files for recipients
983 who don't have yacc or lex.
986 initialized Cells in setsymtab more carefully; some fields
987 were not set. (thanks to purify, all of whose complaints i
988 think i now understand.)
990 fixed at least one error in gsub that looked at -1-th element
991 of an array when substituting for a null match (e.g., $).
993 delete arrayname is now legal; it clears the elements but leaves
994 the array, which may not be the right behavior.
996 modified makefile: my current make can't cope with the test used
997 to avoid unnecessary yacc invocations.
1000 added dynamically growing strings to awk.lx.l and b.c
1001 to permit regular expressions to be much bigger.
1002 the state arrays can still overflow.
1005 detect duplicate arguments in function definitions (mdm).
1008 trivial fix to printf to limit string size in sub().
1011 fixed yet another subtle self-assignment problem:
1012 $1 = $2; $1 = $1 clobbered $1.
1014 Regression tests now use private echo, to avoid quoting problems.
1017 changed error() to print line number as %d, not %g.
1020 cosmetic changes: increased sizes of some arrays,
1021 reworded some error messages.
1023 added CONVFMT as in posix (just replaced OFMT in getsval)
1025 FILENAME is now "" until the first thing that causes a file
1029 deleted yyunput and yyoutput from proto.h;
1030 different versions of lex give these different declarations.
1033 added -mr N and -mf N options: more record and fields.
1034 these really ought to adjust automatically.
1036 cleaned up some error messages; "out of space" now means
1037 malloc returned NULL in all cases.
1039 changed rehash so that if it runs out, it just returns;
1040 things will continue to run slow, but maybe a bit longer.
1043 remove redundant close of stdin when using -f -.
1045 got rid of core dump with -d; awk -d just prints date.
1048 added explicit check for /dev/std(in,out,err) in redirection.
1049 unlike gawk, no /dev/fd/n yet.
1051 added (file/pipe) builtin. hard to test satisfactorily.
1055 recompile after abortive changes; should be unchanged.
1058 die-casting time: converted to ansi C, installed that.
1061 fixed storage leak in freefa, failing to recover [N]CCL.
1062 thanks to Bill Jones (jones@cs.usask.ca)
1065 use RAND_MAX instead of literal in builtin().
1068 cranked up some fixed-size arrays in b.c, and added a test for
1069 overflow in penter. thanks to mark larsen.
1072 increased buffer in gsub. a very crude fix to a general problem.
1073 and again on Sep 26.
1076 enforce variable name syntax for commandline variables: has to
1077 start with letter or _.
1080 allow newline after ; in for statements.
1083 fixed so that in self-assignment like $1=$1, side effects
1084 like recomputing $0 take place. (this is getting subtle.)
1087 better test for detecting too-long output record.
1090 better defense against very long printf strings.
1091 made break and continue illegal outside of loops.
1094 removed extra arg on gettemp, tempfree. minor error message rewording.
1097 fixed silly bug in hex parsing in hexstr().
1098 removed an apparently unnecessary test in isnumber().
1099 warn about weird printf conversions.
1100 fixed unchecked array overwrite in relex().
1102 changed for (i in array) to access elements in sorted order.
1103 then unchanged it -- it really does run slower in too many cases.
1104 left the code in place, commented out.
1107 check error status on all writes, to avoid banging on full disks.
1110 awk -f - reads the program from stdin.
1113 failed to set numeric state on $0 in cmd|getline context in run.c.
1116 fixed sleazy test for integrality in getsval; use modf.
1119 fixed sleazy buggy code in lib.c that looked (incorrectly) for
1120 too long input lines.
1123 fixed the bug on p. 198 in which it couldn't deduce that an
1124 argument was an array in some contexts. replaced the error
1125 message in intest() by code that damn well makes it an array.
1128 fixed horrible bug: types and values were not preserved in
1129 some kinds of self-assignment. (in assign().)
1132 changed NCHARS to 256 to handle 8-bit characters in strings
1133 presented to match(), etc.
1136 changed struct rrow (awk.h) to use long instead of int for lval,
1137 since cfoll() stores a pointer in it. now works better when int's
1138 are smaller than pointers!
1141 AVA fixed the grammar so that ! is uniformly of the same precedence as
1142 unary + and -. This renders illegal some constructs like !x=y, which
1143 now has to be parenthesized as !(x=y), and makes others work properly:
1144 !x+y is (!x)+y, and x!y is x !y, not two pattern-action statements.
1145 (These problems were pointed out by Bob Lenk of Posix.)
1147 Added \x to regular expressions (already in strings).
1148 Limited octal to octal digits; \8 and \9 are not octal.
1149 Centralized the code for parsing escapes in regular expressions.
1150 Added a bunch of tests to T.re and T.sub to verify some of this.
1153 fixed null pointer dereference bug in main.c: -F[nothing]. sigh.
1155 restored srand behavior: it returns the current seed.
1158 srand now returns previous seed value (0 to start).
1161 fix potential problem in tran.c -- something was freed,
1162 then used in freesymtab.
1165 another try to get the max number of open files set with
1166 relatively machine-independent code.
1168 small fix to input() in case of multiple reads after EOF.
1171 FILENAME is now defined in the BEGIN block -- too many old
1174 "-" means stdin in getline as well as on the commandline.
1176 added a bunch of casts to the code to tell the truth about
1177 char * vs. unsigned char *, a right royal pain. added a
1178 setlocale call to the front of main, though probably no one
1179 has it usefully implemented yet.
1182 removed redundant relational tests against nullnode if parse
1183 tree already had a relational at that point.
1186 fixed bug: commandline variable assignment has to look like
1187 var=something. (consider the man page for =, in file =.1)
1189 changed number of arguments to functions to static arrays
1190 to avoid repeated malloc calls.
1193 restored -F (space) separator
1196 added -v x=1 y=2 ... for immediate commandline variable assignment;
1197 done before the BEGIN block for sure. they have to precede the
1198 program if the program is on the commandline.
1199 Modified Aug 2 to require a separate -v for each assignment.
1202 fixed ref-thru-zero bug in environment code in tran.c
1205 add newline to usage message.
1208 added some missing ansi printf conversion letters: %i %X %E %G.
1209 no sensible meaning for h or L, so they may not do what one expects.
1211 made %* conversions work.
1213 changed x^y so that if n is a positive integer, it's done
1214 by explicit multiplication, thus achieving maximum accuracy.
1215 (this should be done by pow() but it seems not to be locally.)
1216 done to x ^= y as well.
1219 ENVIRON array contains environment: if shell variable V=thing,
1220 ENVIRON["V"] is "thing"
1222 multiple -f arguments permitted. error reporting is naive.
1223 (they were permitted before, but only the last was used.)
1225 fixed a really stupid botch in the debugging macro dprintf
1227 fixed order of evaluation of commandline assignments to match
1228 what the book claims: an argument of the form x=e is evaluated
1229 at the time it would have been opened if it were a filename (p 63).
1230 this invalidates the suggested answer to ex 4-1 (p 195).
1232 removed some code that permitted -F (space) fieldseparator,
1233 since it didn't quite work right anyway. (restored aug 2)
1236 Line number now accumulated correctly for comment lines.
1239 Debugging output now includes a version date,
1240 if one compiles it into the source each time.
1243 Changed grammar to prohibit constants as 3rd arg of sub and gsub;
1244 prevents class of overwriting-a-constant errors. (Last one?)
1245 This invalidates the "banana" example on page 43 of the book.
1247 Added \a ("alert"), \v (vertical tab), \xhhh (hexadecimal),
1248 as in ANSI, for strings. Rescinded the sloppiness that permitted
1249 non-octal digits in \ooo. Warning: not all compilers and libraries
1250 will be able to deal with \x correctly.
1253 Fixed bug that caused tempcell list to contain a duplicate.
1257 Catches some more commandline errors in main.
1258 Removed redundant decl of modf in run.c (confuses some compilers).
1259 Warning: there's no single declaration of malloc, etc., in awk.h
1260 that seems to satisfy all compilers.
1263 Added a bit of code to error printing to avoid printing nulls.
1264 (Not clear that it actually would.)
1267 With fear and trembling, modified the grammar to permit
1268 multiple pattern-action statements on one line without
1269 an explicit separator. By definition, this capitulation
1270 to the ghost of ancient implementations remains undefined
1271 and thus subject to change without notice or apology.
1275 Fixed bug in call() that failed to recover storage.
1277 A warning is now generated if there are more arguments
1278 in the call than in the definition (in lieu of fixing
1279 another storage leak).
1282 Fixed %c: if expr is numeric, use numeric value;
1283 otherwise print 1st char of string value. still
1284 doesn't work if the value is 0 -- won't print \0.
1286 Added a few more checks for running out of malloc.
1289 Fixed bug in call() that freed local arrays twice.
1291 Fixed to handle deletion of non-existent array right;
1292 complains about attempt to delete non-array element.
1295 Now guarantees to evaluate all arguments of built-in
1296 functions, as in C; the appearance is that arguments
1297 are evaluated before the function is called. Places
1298 affected are sub (gsub was ok), substr, printf, and
1299 all the built-in arithmetic functions in bltin().
1300 A warning is generated if a bltin() is called with
1301 the wrong number of arguments.
1303 This requires changing makeprof on p167 of the book.
1306 setting FILENAME in BEGIN caused core dump, apparently
1307 because it was freeing space not allocated by malloc.
1310 fixed egregious error in toupper/tolower functions.
1311 still subject to rescinding, however.
1314 flush stdout before opening file or pipe
1317 performance bug in b.c/cgoto(): not freeing some sets of states.
1318 partial fix only right now, and the number of states increased
1319 to make it less obvious.
1322 check error status on close
1325 srand returns seed value it's using.
1329 Removed limit on depth of function calls.
1332 Fixed lib.c to permit _ in commandline variable names.
1335 main.c fixed to recognize -- as terminator of command-
1336 line options. Illegal options flagged.
1337 Error reporting slightly cleaned up.
1340 Newer C compilers apply a strict scope rule to extern
1341 declarations within functions. Two extern declarations in
1342 lib.c and tran.c have been moved to obviate this problem.
1345 Reluctantly added toupper and tolower functions.
1346 Subject to rescinding without notice.
1349 Error-message printer had printf(s) instead of
1350 printf("%s",s); got core dumps when the message
1354 Very long printf strings caused core dump;
1355 fixed aprintf, asprintf, format to catch them.
1356 Can still get a core dump in printf itself.