FIXES revision 172958
185587Sobrien/****************************************************************
285587SobrienCopyright (C) Lucent Technologies 1997
385587SobrienAll Rights Reserved
485587Sobrien
585587SobrienPermission to use, copy, modify, and distribute this software and
685587Sobrienits documentation for any purpose and without fee is hereby
785587Sobriengranted, provided that the above copyright notice appear in all
885587Sobriencopies and that both that the copyright notice and this
985587Sobrienpermission notice and warranty disclaimer appear in supporting
1085587Sobriendocumentation, and that the name Lucent Technologies or any of
1185587Sobrienits entities not be used in advertising or publicity pertaining
1285587Sobriento distribution of the software without specific, written prior
1385587Sobrienpermission.
1485587Sobrien
1585587SobrienLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1685587SobrienINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
1785587SobrienIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
1885587SobrienSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1985587SobrienWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
2085587SobrienIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
2185587SobrienARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
2285587SobrienTHIS SOFTWARE.
2385587Sobrien****************************************************************/
2485587Sobrien
2585587SobrienThis file lists all bug fixes, changes, etc., made since the AWK book
2685587Sobrienwas sent to the printers in August, 1987.
2785587Sobrien
28172958SobrienOct 23, 2007:
29172958Sobrien	minor fix in lib.c: increase inputFS to 100, change malloc
30172958Sobrien	for fields to n+1.  
31172958Sobrien
32172958Sobrien	fixed memory fault caused by out of order test in setsval.
33172958Sobrien
34172958Sobrien	thanks to david o'brien, freebsd, for both fixes.
35172958Sobrien
36170331SrafanMay 1, 2007:
37170331Srafan	fiddle in makefile to fix for BSD make; thanks to igor sobrado.
38170331Srafan
39170331SrafanMar 31, 2007:
40170331Srafan	fixed some null pointer refs calling adjbuf.
41170331Srafan
42170331SrafanFeb 21, 2007:
43170331Srafan	fixed a bug in matching the null RE in sub and gsub.  thanks to al aho
44170331Srafan	who actually did the fix (in b.c), and to wolfgang seeberg for finding
45170331Srafan	it and providing a very compact test case.
46170331Srafan
47170331Srafan	fixed quotation in b.c; thanks to Hal Pratt and the Princeton Dante
48170331Srafan	Project.
49170331Srafan
50170331Srafan	removed some no-effect asserts in run.c.
51170331Srafan
52170331Srafan	fiddled maketab.c to not complain about bison-generated values.
53170331Srafan
54170331Srafan	removed the obsolete -V argument; fixed --version to print the
55170331Srafan	version and exit.
56170331Srafan
57170331Srafan	fixed wording and an outright error in the usage message; thanks to igor
58170331Srafan	sobrado and jason mcintyre.
59170331Srafan
60170331Srafan	fixed a bug in -d that caused core dump if no program followed.
61170331Srafan
62170331SrafanJan 1, 2007:
63170331Srafan	dropped mac.code from makefile; there are few non-MacOSX
64170331Srafan	mac's these days.
65170331Srafan
66170331SrafanJan 17, 2006:
67170331Srafan	system() not flagged as unsafe in the unadvertised -safe option.
68170331Srafan	found it while enhancing tests before shipping the ;login: article.
69170331Srafan	practice what you preach.
70170331Srafan
71170331Srafan	removed the 9-years-obsolete -mr and -mf flags.
72170331Srafan
73170331Srafan	added -version and --version options.
74170331Srafan
75170331Srafan	core dump on linux with BEGIN {nextfile}, now fixed.
76170331Srafan
77170331Srafan	removed some #ifdef's in run.c and lex.c that appear to no 
78170331Srafan	longer be necessary.
79170331Srafan
80146299SruApr 24, 2005:
81146299Sru	modified lib.c so that values of $0 et al are preserved in the END
82146299Sru	block, apparently as required by posix.  thanks to havard eidnes
83146299Sru	for the report and code.
84146299Sru
85146299SruJan 14, 2005:
86146299Sru	fixed infinite loop in parsing, originally found by brian tsang.
87146299Sru	thanks to arnold robbins for a suggestion that started me
88146299Sru	rethinking it.
89146299Sru
90146299SruDec 31, 2004:
91146299Sru	prevent overflow of -f array in main, head off potential error in 
92146299Sru	call of SYNTAX(), test malloc return in lib.c, all with thanks to 
93146299Sru	todd miller.
94146299Sru
95146299SruDec 22, 2004:
96146299Sru	cranked up size of NCHARS; coverity thinks it can be overrun with
97146299Sru	smaller size, and i think that's right.  added some assertions to b.c
98146299Sru	to catch places where it might overrun.  the RE code is still fragile.
99146299Sru
100146299SruDec 5, 2004:
101146299Sru	fixed a couple of overflow problems with ridiculous field numbers:
102146299Sru	e.g., print $(2^32-1).  thanks to ruslan ermilov, giorgos keramidas
103146299Sru	and david o'brien at freebsd.org for patches.  this really should
104146299Sru	be re-done from scratch.
105146299Sru
106146299SruNov 21, 2004:
107146299Sru	fixed another 25-year-old RE bug, in split.  it's another failure
108146299Sru	to (re-)initialize.  thanks to steve fisher for spotting this and
109146299Sru	providing a good test case.
110146299Sru
111125601SruNov 22, 2003:
112125601Sru	fixed a bug in regular expressions that dates (so help me) from 1977;
113125601Sru	it's been there from the beginning.  an anchored longest match that
114125601Sru	was longer than the number of states triggered a failure to initialize
115125601Sru	the machine properly.  many thanks to moinak ghosh for not only finding
116125601Sru	this one but for providing a fix, in some of the most mysterious
117125601Sru	code known to man.
118125601Sru
119125601Sru	fixed a storage leak in call() that appears to have been there since
120125601Sru	1983 or so -- a function without an explicit return that assigns a 
121125601Sru	string to a parameter leaked a Cell.  thanks to moinak ghosh for 
122125601Sru	spotting this very subtle one.
123125601Sru
124125601SruJul 31, 2003:
125125601Sru	fixed, thanks to andrey chernov and ruslan ermilov, a bug in lex.c
126125601Sru	that mis-handled the character 255 in input.  (it was being compared
127125601Sru	to EOF with a signed comparison.)
128125601Sru
129118194SruJul 29, 2003:
130118194Sru	fixed (i think) the long-standing botch that included the beginning of
131118194Sru	line state ^ for RE's in the set of valid characters; this led to a
132118194Sru	variety of odd problems, including failure to properly match certain
133118194Sru	regular expressions in non-US locales.  thanks to ruslan for keeping
134118194Sru	at this one.
135118194Sru
136118194SruJul 28, 2003:
137118194Sru	n-th try at getting internationalization right, with thanks to volker
138118194Sru	kiefel, arnold robbins and ruslan ermilov for advice, though they
139118194Sru	should not be blamed for the outcome.  according to posix, "."  is the
140118194Sru	radix character in programs and command line arguments regardless of
141118194Sru	the locale; otherwise, the locale should prevail for input and output
142118194Sru	of numbers.  so it's intended to work that way.
143118194Sru	
144118194Sru	i have rescinded the attempt to use strcoll in expanding shorthands in
145118194Sru	regular expressions (cclenter).  its properties are much too
146118194Sru	surprising; for example [a-c] matches aAbBc in locale en_US but abBcC
147118194Sru	in locale fr_CA.  i can see how this might arise by implementation
148118194Sru	but i cannot explain it to a human user.  (this behavior can be seen
149118194Sru	in gawk as well; we're leaning on the same library.)
150118194Sru
151118194Sru	the issue appears to be that strcoll is meant for sorting, where
152118194Sru	merging upper and lower case may make sense (though note that unix
153118194Sru	sort does not do this by default either).  it is not appropriate
154118194Sru	for regular expressions, where the goal is to match specific
155118194Sru	patterns of characters.  in any case, the notations [:lower:], etc.,
156118194Sru	are available in awk, and they are more likely to work correctly in
157118194Sru	most locales.
158118194Sru
159118194Sru	a moratorium is hereby declared on internationalization changes.
160118194Sru	i apologize to friends and colleagues in other parts of the world.
161118194Sru	i would truly like to get this "right", but i don't know what
162118194Sru	that is, and i do not want to keep making changes until it's clear.
163118194Sru
164118194SruJul 4, 2003:
165118194Sru	fixed bug that permitted non-terminated RE, as in "awk /x".
166118194Sru
167118194SruJun 1, 2003:
168118194Sru	subtle change to split: if source is empty, number of elems
169118194Sru	is always 0 and the array is not set.
170118194Sru
171118194SruMar 21, 2003:
172118194Sru	added some parens to isblank, in another attempt to make things
173118194Sru	internationally portable.
174118194Sru
175112336SobrienMar 14, 2003:
176112336Sobrien	the internationalization changes, somewhat modified, are now
177112336Sobrien	reinstated.  in theory awk will now do character comparisons
178112336Sobrien	and case conversions in national language, but "." will always
179112336Sobrien	be the decimal point separator on input and output regardless
180112336Sobrien	of national language.  isblank(){} has an #ifndef.
181112336Sobrien
182112336Sobrien	this no longer compiles on windows: LC_MESSAGES isn't defined
183112336Sobrien	in vc6++.
184112336Sobrien
185112336Sobrien	fixed subtle behavior in field and record splitting: if FS is
186112336Sobrien	a single character and RS is not empty, \n is NOT a separator.
187112336Sobrien	this tortuous reading is found in the awk book; behavior now
188112336Sobrien	matches gawk and mawk.
189112336Sobrien
190108072SobrienDec 13, 2002:
191108072Sobrien	for the moment, the internationalization changes of nov 29 are
192108072Sobrien	rolled back -- programs like x = 1.2 don't work in some locales,
193108072Sobrien	because the parser is expecting x = 1,2.  until i understand this
194108072Sobrien	better, this will have to wait.
195108072Sobrien
196107806SobrienNov 29, 2002:
197107806Sobrien	modified b.c (with tiny changes in main and run) to support
198107806Sobrien	locales, using strcoll and iswhatever tests for posix character
199107806Sobrien	classes.  thanks to ruslan ermilov (ru@freebsd.org) for code.
200107806Sobrien	the function isblank doesn't seem to have propagated to any
201107806Sobrien	header file near me, so it's there explicitly.  not properly
202107806Sobrien	tested on non-ascii character sets by me.
203107806Sobrien
204107806SobrienJun 28, 2002:
205107806Sobrien	modified run/format() and tran/getsval() to do a slightly better
206107806Sobrien	job on using OFMT for output from print and CONVFMT for other
207107806Sobrien	number->string conversions, as promised by posix and done by 
208107806Sobrien	gawk and mawk.  there are still places where it doesn't work
209107806Sobrien	right if CONVFMT is changed; by then the STR attribute of the
210107806Sobrien	variable has been irrevocably set.  thanks to arnold robbins for
211107806Sobrien	code and examples.
212107806Sobrien
213107806Sobrien	fixed subtle bug in format that could get core dump.  thanks to
214107806Sobrien	Jaromir Dolecek <jdolecek@NetBSD.org> for finding and fixing.
215107806Sobrien	minor cleanup in run.c / format() at the same time.
216107806Sobrien
217107806Sobrien	added some tests for null pointers to debugging printf's, which
218107806Sobrien	were never intended for external consumption.  thanks to dave
219107806Sobrien	kerns (dkerns@lucent.com) for pointing this out.
220107806Sobrien
221107806Sobrien	GNU compatibility: an empty regexp matches anything (thanks to
222107806Sobrien	dag-erling smorgrav, des@ofug.org).  subject to reversion if
223107806Sobrien	this does more harm than good.
224107806Sobrien
225107806Sobrien	pervasive small changes to make things more const-correct, as
226107806Sobrien	reported by gcc's -Wwrite-strings.  as it says in the gcc manual,
227107806Sobrien	this may be more nuisance than useful.  provoked by a suggestion
228107806Sobrien	and code from arnaud desitter, arnaud@nimbus.geog.ox.ac.uk
229107806Sobrien
230107806Sobrien	minor documentation changes to note that this now compiles out
231107806Sobrien	of the box on Mac OS X.
232107806Sobrien
23390902SdesFeb 10, 2002:
23490902Sdes	changed types in posix chars structure to quiet solaris cc.
23590902Sdes
23690902SdesJan 1, 2002:
23790902Sdes	fflush() or fflush("") flushes all files and pipes.
23890902Sdes
23990902Sdes	length(arrayname) returns number of elements; thanks to 
24090902Sdes	arnold robbins for suggestion.
24190902Sdes
24290902Sdes	added a makefile.win to make it easier to build on windows.
24390902Sdes	based on dan allen's buildwin.bat.
24490902Sdes
24590902SdesNov 16, 2001:
24690902Sdes	added support for posix character class names like [:digit:],
24790902Sdes	which are not exactly shorter than [0-9] and perhaps no more
24890902Sdes	portable.  thanks to dag-erling smorgrav for code.
24990902Sdes
25090902SdesFeb 16, 2001:
25190902Sdes	removed -m option; no longer needed, and it was actually
25290902Sdes	broken (noted thanks to volker kiefel).
25390902Sdes
25490902SdesFeb 10, 2001:
25590902Sdes	fixed an appalling bug in gettok: any sequence of digits, +,-, E, e,
25690902Sdes	and period was accepted as a valid number if it started with a period.
25790902Sdes	this would never have happened with the lex version.
25890902Sdes
25990902Sdes	other 1-character botches, now fixed, include a bare $ and a
26090902Sdes	bare " at the end of the input.
26190902Sdes
26290902SdesFeb 7, 2001:
26390902Sdes	more (const char *) casts in b.c and tran.c to silence warnings.
26490902Sdes
26585587SobrienNov 15, 2000:
26685587Sobrien	fixed a bug introduced in august 1997 that caused expressions
26785587Sobrien	like $f[1] to be syntax errors.  thanks to arnold robbins for
26885587Sobrien	noticing this and providing a fix.
26985587Sobrien
27085587SobrienOct 30, 2000:
27185587Sobrien	fixed some nextfile bugs: not handling all cases.  thanks to
27285587Sobrien	arnold robbins for pointing this out.  new regressions added.
27385587Sobrien
27485587Sobrien	close() is now a function.  it returns whatever the library
27585587Sobrien	fclose returns, and -1 for closing a file or pipe that wasn't
27685587Sobrien	opened.
27785587Sobrien
27885587SobrienSep 24, 2000:
27985587Sobrien	permit \n explicitly in character classes; won't work right
28085587Sobrien	if comes in as "[\n]" but ok as /[\n]/, because of multiple
28185587Sobrien	processing of \'s.  thanks to arnold robbins.
28285587Sobrien
28385587SobrienJuly 5, 2000:
28485587Sobrien	minor fiddles in tran.c to keep compilers happy about uschar.
28585587Sobrien	thanks to norman wilson.
28685587Sobrien
28785587SobrienMay 25, 2000:
28885587Sobrien	yet another attempt at making 8-bit input work, with another
28985587Sobrien	band-aid in b.c (member()), and some (uschar) casts to head 
29085587Sobrien	off potential errors in subscripts (like isdigit).  also
29185587Sobrien	changed HAT to NCHARS-2.  thanks again to santiago vila.
29285587Sobrien
29385587Sobrien	changed maketab.c to ignore apparently out of range definitions
29485587Sobrien	instead of halting; new freeBSD generates one.  thanks to
29585587Sobrien	jon snader <jsnader@ix.netcom.com> for pointing out the problem.
29685587Sobrien
29785587SobrienMay 2, 2000:
29885587Sobrien	fixed an 8-bit problem in b.c by making several char*'s into
29985587Sobrien	unsigned char*'s.  not clear i have them all yet.  thanks to
30085587Sobrien	Santiago Vila <sanvila@unex.es> for the bug report.
30185587Sobrien
30285587SobrienApr 21, 2000:
30385587Sobrien	finally found and fixed a memory leak in function call; it's
30485587Sobrien	been there since functions were added ~1983.  thanks to
30585587Sobrien	jon bentley for the test case that found it.
30685587Sobrien
30785587Sobrien	added test in envinit to catch environment "variables" with
308146299Sru	names beginning with '='; thanks to Berend Hasselman.
30985587Sobrien
31085587SobrienJul 28, 1999:
31185587Sobrien	added test in defn() to catch function foo(foo), which
31285587Sobrien	otherwise recurses until core dump.  thanks to arnold
31385587Sobrien	robbins for noticing this.
31485587Sobrien
31585587SobrienJun 20, 1999:
31685587Sobrien	added *bp in gettok in lex.c; appears possible to exit function
31785587Sobrien	without terminating the string.  thanks to russ cox.
31885587Sobrien
31985587SobrienJun 2, 1999:
32085587Sobrien	added function stdinit() to run to initialize files[] array,
32185587Sobrien	in case stdin, etc., are not constants; some compilers care.
32285587Sobrien
32385587SobrienMay 10, 1999:
32485587Sobrien	replaced the ERROR ... FATAL, etc., macros with functions
32585587Sobrien	based on vprintf, to avoid problems caused by overrunning
32685587Sobrien	fixed-size errbuf array.  thanks to ralph corderoy for the
32785587Sobrien	impetus, and for pointing out a string termination bug in
32885587Sobrien	qstring as well.
32985587Sobrien
33085587SobrienApr 21, 1999:
33185587Sobrien	fixed bug that caused occasional core dumps with commandline
33285587Sobrien	variable with value ending in \.  (thanks to nelson beebe for
33385587Sobrien	the test case.)
33485587Sobrien
33585587SobrienApr 16, 1999:
33685587Sobrien	with code kindly provided by Bruce Lilly, awk now parses 
33785587Sobrien	/=/ and similar constructs more sensibly in more places.
33885587Sobrien	Bruce also provided some helpful test cases.
33985587Sobrien
34085587SobrienApr 5, 1999:
34185587Sobrien	changed true/false to True/False in run.c to make it
34285587Sobrien	easier to compile with C++.  Added some casts on malloc
34385587Sobrien	and realloc to be honest about casts; ditto.  changed
34485587Sobrien	ltype int to long in struct rrow to reduce some 64-bit
34585587Sobrien	complaints; other changes scattered throughout for the
34685587Sobrien	same purpose.  thanks to Nelson Beebe for these portability
34785587Sobrien	improvements.
34885587Sobrien
34985587Sobrien	removed some horrible pointer-int casting in b.c and elsewhere
35085587Sobrien	by adding ptoi and itonp to localize the casts, which are
35185587Sobrien	all benign.  fixed one incipient bug that showed up on sgi
35285587Sobrien	in 64-bit mode.
35385587Sobrien
35485587Sobrien	reset lineno for new source file; include filename in error
35585587Sobrien	message.  also fixed line number error in continuation lines.
35685587Sobrien	(thanks to Nelson Beebe for both of these.)
35785587Sobrien
35885587SobrienMar 24, 1999:
35985587Sobrien	Nelson Beebe notes that irix 5.3 yacc dies with a bogus
36085587Sobrien	error; use a newer version or switch to bison, since sgi
36185587Sobrien	is unlikely to fix it.
36285587Sobrien
36385587SobrienMar 5, 1999:
36485587Sobrien	changed isnumber to is_number to avoid the problem caused by
36585587Sobrien	versions of ctype.h that include the name isnumber.
36685587Sobrien
36785587Sobrien	distribution now includes a script for building on a Mac,
36885587Sobrien	thanks to Dan Allen.
36985587Sobrien
37085587SobrienFeb 20, 1999:
37185587Sobrien	fixed memory leaks in run.c (call) and tran.c (setfval).
37285587Sobrien	thanks to Stephen Nutt for finding these and providing the fixes.
37385587Sobrien
37485587SobrienJan 13, 1999:
37585587Sobrien	replaced srand argument by (unsigned int) in run.c;
37685587Sobrien	avoids problem on Mac and potentially on Unix & Windows.
37785587Sobrien	thanks to Dan Allen.
37885587Sobrien
37985587Sobrien	added a few (int) casts to silence useless compiler warnings.
38085587Sobrien	e.g., errorflag= in run.c jump().
38185587Sobrien
38285587Sobrien	added proctab.c to the bundle outout; one less thing
38385587Sobrien	to have to compile out of the box.
38485587Sobrien
38585587Sobrien	added calls to _popen and _pclose to the win95 stub for
38685587Sobrien	pipes (thanks to Steve Adams for this helpful suggestion).
38785587Sobrien	seems to work, though properties are not well understood
38885587Sobrien	by me, and it appears that under some circumstances the
38985587Sobrien	pipe output is truncated.  Be careful.
39085587Sobrien
39185587SobrienOct 19, 1998:
39285587Sobrien	fixed a couple of bugs in getrec: could fail to update $0
39385587Sobrien	after a getline var; because inputFS wasn't initialized, 
39485587Sobrien	could split $0 on every character, a misleading diversion.
39585587Sobrien
39685587Sobrien	fixed caching bug in makedfa: LRU was actually removing
39785587Sobrien	least often used.
39885587Sobrien
39985587Sobrien	thanks to ross ridge for finding these, and for providing
40085587Sobrien	great bug reports.
40185587Sobrien
40285587SobrienMay 12, 1998:
40385587Sobrien	fixed potential bug in readrec: might fail to update record
40485587Sobrien	pointer after growing.  thanks to dan levy for spotting this
40585587Sobrien	and suggesting the fix.
40685587Sobrien
40785587SobrienMar 12, 1998:
40885587Sobrien	added -V to print version number and die.
40985587Sobrien
41085587SobrienFeb 11, 1998:
41185587Sobrien	subtle silent bug in lex.c: if the program ended with a number
41285587Sobrien	longer than 1 digit, part of the input would be pushed back and
41385587Sobrien	parsed again because token buffer wasn't terminated right.
41485587Sobrien	example:  awk 'length($0) > 10'.  blush.  at least i found it
41585587Sobrien	myself.
41685587Sobrien
41785587SobrienAug 31, 1997:
41885587Sobrien	s/adelete/awkdelete/: SGI uses this in malloc.h.
41985587Sobrien	thanks to nelson beebe for pointing this one out.
42085587Sobrien
42185587SobrienAug 21, 1997:
42285587Sobrien	fixed some bugs in sub and gsub when replacement includes \\.
42385587Sobrien	this is a dark, horrible corner, but at least now i believe that
42485587Sobrien	the behavior is the same as gawk and the intended posix standard.
42585587Sobrien	thanks to arnold robbins for advice here.
42685587Sobrien
42785587SobrienAug 9, 1997:
42885587Sobrien	somewhat regretfully, replaced the ancient lex-based lexical
42985587Sobrien	analyzer with one written in C.  it's longer, generates less code,
43085587Sobrien	and more portable; the old one depended too much on mysterious
43185587Sobrien	properties of lex that were not preserved in other environments.
43285587Sobrien	in theory these recognize the same language.
43385587Sobrien
43485587Sobrien	now using strtod to test whether a string is a number, instead of
43585587Sobrien	the convoluted original function.  should be more portable and
43685587Sobrien	reliable if strtod is implemented right.
43785587Sobrien
43885587Sobrien	removed now-pointless optimization in makefile that tries to avoid
43985587Sobrien	recompilation when awkgram.y is changed but symbols are not.
44085587Sobrien
44185587Sobrien	removed most fixed-size arrays, though a handful remain, some
44285587Sobrien	of which are unchecked.  you have been warned.
44385587Sobrien
44485587SobrienAug 4, 1997:
44585587Sobrien	with some trepidation, replaced the ancient code that managed
44685587Sobrien	fields and $0 in fixed-size arrays with arrays that grow on
44785587Sobrien	demand.  there is still some tension between trying to make this
44885587Sobrien	run fast and making it clean; not sure it's right yet.
44985587Sobrien
45085587Sobrien	the ill-conceived -mr and -mf arguments are now useful only
45185587Sobrien	for debugging.  previous dynamic string code removed.
45285587Sobrien
45385587Sobrien	numerous other minor cleanups along the way.
45485587Sobrien
45585587SobrienJul 30, 1997:
45685587Sobrien	using code provided by dan levy (to whom profuse thanks), replaced
45785587Sobrien	fixed-size arrays and awkward kludges by a fairly uniform mechanism
45885587Sobrien	to grow arrays as needed for printf, sub, gsub, etc.
45985587Sobrien
46085587SobrienJul 23, 1997:
46185587Sobrien	falling off the end of a function returns "" and 0, not 0.
46285587Sobrien	thanks to arnold robbins.
46385587Sobrien
46485587SobrienJun 17, 1997:
46585587Sobrien	replaced several fixed-size arrays by dynamically-created ones
46685587Sobrien	in run.c; added overflow tests to some previously unchecked cases.
46785587Sobrien	getline, toupper, tolower.
46885587Sobrien
46985587Sobrien	getline code is still broken in that recursive calls may wind
47085587Sobrien	up using the same space.  [fixed later]
47185587Sobrien
47285587Sobrien	increased RECSIZE to 8192 to push problems further over the horizon.
47385587Sobrien
47485587Sobrien	added \r to \n as input line separator for programs, not data.
47585587Sobrien	damn CRLFs.
47685587Sobrien
47785587Sobrien	modified format() to permit explicit printf("%c", 0) to include
47885587Sobrien	a null byte in output.  thanks to ken stailey for the fix.
47985587Sobrien
48085587Sobrien	added a "-safe" argument that disables file output (print >,
48185587Sobrien	print >>), process creation (cmd|getline, print |, system), and
48285587Sobrien	access to the environment (ENVIRON).  this is a first approximation
48385587Sobrien	to a "safe" version of awk, but don't rely on it too much.  thanks
48485587Sobrien	to joan feigenbaum and matt blaze for the inspiration long ago.
48585587Sobrien
48685587SobrienJul 8, 1996:
48785587Sobrien	fixed long-standing bug in sub, gsub(/a/, "\\\\&"); thanks to
48885587Sobrien	ralph corderoy.
48985587Sobrien
49085587SobrienJun 29, 1996:
49185587Sobrien	fixed awful bug in new field splitting; didn't get all the places
49285587Sobrien	where input was done.
49385587Sobrien
49485587SobrienJun 28, 1996:
49585587Sobrien	changed field-splitting to conform to posix definition: fields are
49685587Sobrien	split using the value of FS at the time of input; it used to be
49785587Sobrien	the value when the field or NF was first referred to, a much less
49885587Sobrien	predictable definition.  thanks to arnold robbins for encouragement
49985587Sobrien	to do the right thing.
50085587Sobrien
50185587SobrienMay 28, 1996:
50285587Sobrien	fixed appalling but apparently unimportant bug in parsing octal
50385587Sobrien	numbers in reg exprs.
50485587Sobrien
50585587Sobrien	explicit hex in reg exprs now limited to 2 chars: \xa, \xaa.
50685587Sobrien
50785587SobrienMay 27, 1996:
50885587Sobrien	cleaned up some declarations so gcc -Wall is now almost silent.
50985587Sobrien
51085587Sobrien	makefile now includes backup copies of ytab.c and lexyy.c in case
51185587Sobrien	one makes before looking; it also avoids recreating lexyy.c unless
51285587Sobrien	really needed.
51385587Sobrien
51485587Sobrien	s/aprintf/awkprint, s/asprintf/awksprintf/ to avoid some name clashes
51585587Sobrien	with unwisely-written header files.
51685587Sobrien
51785587Sobrien	thanks to jeffrey friedl for several of these.
51885587Sobrien
51985587SobrienMay 26, 1996:
52085587Sobrien	an attempt to rationalize the (unsigned) char issue.  almost all
52185587Sobrien	instances of unsigned char have been removed; the handful of places
52285587Sobrien	in b.c where chars are used as table indices have been hand-crafted.
52385587Sobrien	added some latin-1 tests to the regression, but i'm not confident;
52485587Sobrien	none of my compilers seem to care much.  thanks to nelson beebe for
52585587Sobrien	pointing out some others that do care.
52685587Sobrien
52785587SobrienMay 2, 1996:
52885587Sobrien	removed all register declarations.
52985587Sobrien
53085587Sobrien	enhanced split(), as in gawk, etc:  split(s, a, "") splits s into
53185587Sobrien	a[1]...a[length(s)] with each character a single element.
53285587Sobrien
53385587Sobrien	made the same changes for field-splitting if FS is "".
53485587Sobrien
53585587Sobrien	added nextfile, as in gawk: causes immediate advance to next
53685587Sobrien	input file. (thanks to arnold robbins for inspiration and code).
53785587Sobrien
53885587Sobrien	small fixes to regexpr code:  can now handle []], [[], and
53985587Sobrien	variants;  [] is now a syntax error, rather than matching 
54085587Sobrien	everything;  [z-a] is now empty, not z.  far from complete
54185587Sobrien	or correct, however.  (thanks to jeffrey friedl for pointing out
54285587Sobrien	some awful behaviors.)
54385587Sobrien
54485587SobrienApr 29, 1996:
545146299Sru	replaced uchar by uschar everywhere; apparently some compilers
54685587Sobrien	usurp this name and this causes conflicts.
54785587Sobrien
54885587Sobrien	fixed call to time in run.c (bltin); arg is time_t *.
54985587Sobrien
55085587Sobrien	replaced horrible pointer/long punning in b.c by a legitimate
55185587Sobrien	union.  should be safer on 64-bit machines and cleaner everywhere.
55285587Sobrien	(thanks to nelson beebe for pointing out some of these problems.)
55385587Sobrien
55485587Sobrien	replaced nested comments by #if 0...#endif in run.c, lib.c.
55585587Sobrien
55685587Sobrien	removed getsval, setsval, execute macros from run.c and lib.c.
55785587Sobrien	machines are 100x faster than they were when these macros were
55885587Sobrien	first used.
55985587Sobrien
56085587Sobrien	revised filenames: awk.g.y => awkgram.y, awk.lx.l => awklex.l,
56185587Sobrien	y.tab.[ch] => ytab.[ch], lex.yy.c => lexyy.c, all in the aid of
56285587Sobrien	portability to nameless systems.
56385587Sobrien
56485587Sobrien	"make bundle" now includes yacc and lex output files for recipients
56585587Sobrien	who don't have yacc or lex.
56685587Sobrien
56785587SobrienAug 15, 1995:
56885587Sobrien	initialized Cells in setsymtab more carefully; some fields
56985587Sobrien	were not set.  (thanks to purify, all of whose complaints i
57085587Sobrien	think i now understand.)
57185587Sobrien
57285587Sobrien	fixed at least one error in gsub that looked at -1-th element
57385587Sobrien	of an array when substituting for a null match (e.g., $).
57485587Sobrien
57585587Sobrien	delete arrayname is now legal; it clears the elements but leaves
57685587Sobrien	the array, which may not be the right behavior.
57785587Sobrien
57885587Sobrien	modified makefile: my current make can't cope with the test used
57985587Sobrien	to avoid unnecessary yacc invocations.
58085587Sobrien
58185587SobrienJul 17, 1995:
58285587Sobrien	added dynamically growing strings to awk.lx.l and b.c
58385587Sobrien	to permit regular expressions to be much bigger.
58485587Sobrien	the state arrays can still overflow.
58585587Sobrien
58685587SobrienAug 24, 1994:
58785587Sobrien	detect duplicate arguments in function definitions (mdm).
58885587Sobrien
58985587SobrienMay 11, 1994:
59085587Sobrien	trivial fix to printf to limit string size in sub().
59185587Sobrien
59285587SobrienApr 22, 1994:
59385587Sobrien	fixed yet another subtle self-assignment problem:
59485587Sobrien	$1 = $2; $1 = $1 clobbered $1.
59585587Sobrien
59685587Sobrien	Regression tests now use private echo, to avoid quoting problems.
59785587Sobrien
59885587SobrienFeb 2, 1994:
59985587Sobrien	changed error() to print line number as %d, not %g.
60085587Sobrien
60185587SobrienJul 23, 1993:
60285587Sobrien	cosmetic changes: increased sizes of some arrays,
60385587Sobrien	reworded some error messages.
60485587Sobrien
60585587Sobrien	added CONVFMT as in posix (just replaced OFMT in getsval)
60685587Sobrien
60785587Sobrien	FILENAME is now "" until the first thing that causes a file
60885587Sobrien	to be opened.
60985587Sobrien
61085587SobrienNov 28, 1992:
61185587Sobrien	deleted yyunput and yyoutput from proto.h;
61285587Sobrien	different versions of lex give these different declarations.
61385587Sobrien
61485587SobrienMay 31, 1992:
61585587Sobrien	added -mr N and -mf N options: more record and fields.
61685587Sobrien	these really ought to adjust automatically.
61785587Sobrien
61885587Sobrien	cleaned up some error messages; "out of space" now means
61985587Sobrien	malloc returned NULL in all cases.
62085587Sobrien
62185587Sobrien	changed rehash so that if it runs out, it just returns;
62285587Sobrien	things will continue to run slow, but maybe a bit longer.
62385587Sobrien
62485587SobrienApr 24, 1992:
62585587Sobrien	remove redundant close of stdin when using -f -.
62685587Sobrien
62785587Sobrien	got rid of core dump with -d; awk -d just prints date.
62885587Sobrien
62985587SobrienApr 12, 1992:
63085587Sobrien	added explicit check for /dev/std(in,out,err) in redirection.
63185587Sobrien	unlike gawk, no /dev/fd/n yet.
63285587Sobrien
63385587Sobrien	added (file/pipe) builtin.  hard to test satisfactorily.
63485587Sobrien	not posix.
63585587Sobrien
63685587SobrienFeb 20, 1992:
63785587Sobrien	recompile after abortive changes;  should be unchanged.
63885587Sobrien
63985587SobrienDec 2, 1991:
64085587Sobrien	die-casting time:  converted to ansi C, installed that.
64185587Sobrien
64285587SobrienNov 30, 1991:
64385587Sobrien	fixed storage leak in freefa, failing to recover [N]CCL.
64485587Sobrien	thanks to Bill Jones (jones@cs.usask.ca)
64585587Sobrien
64685587SobrienNov 19, 1991:
64785587Sobrien	use RAND_MAX instead of literal in builtin().
64885587Sobrien
64985587SobrienNov 12, 1991:
65085587Sobrien	cranked up some fixed-size arrays in b.c, and added a test for
65185587Sobrien	overflow in penter.  thanks to mark larsen.
65285587Sobrien
65385587SobrienSep 24, 1991:
65485587Sobrien	increased buffer in gsub.  a very crude fix to a general problem.
65585587Sobrien	and again on Sep 26.
65685587Sobrien
65785587SobrienAug 18, 1991:
65885587Sobrien	enforce variable name syntax for commandline variables: has to
65985587Sobrien	start with letter or _.
66085587Sobrien
66185587SobrienJul 27, 1991:
66285587Sobrien	allow newline after ; in for statements.
66385587Sobrien
66485587SobrienJul 21, 1991:
66585587Sobrien	fixed so that in self-assignment like $1=$1, side effects
66685587Sobrien	like recomputing $0 take place.  (this is getting subtle.)
66785587Sobrien
66885587SobrienJun 30, 1991:
66985587Sobrien	better test for detecting too-long output record.
67085587Sobrien
67185587SobrienJun 2, 1991:
67285587Sobrien	better defense against very long printf strings.
67385587Sobrien	made break and continue illegal outside of loops.
67485587Sobrien
67585587SobrienMay 13, 1991:
67685587Sobrien	removed extra arg on gettemp, tempfree.  minor error message rewording.
67785587Sobrien
67885587SobrienMay 6, 1991:
67985587Sobrien	fixed silly bug in hex parsing in hexstr().
68085587Sobrien	removed an apparently unnecessary test in isnumber().
68185587Sobrien	warn about weird printf conversions.
68285587Sobrien	fixed unchecked array overwrite in relex().
68385587Sobrien
68485587Sobrien	changed for (i in array) to access elements in sorted order.
68585587Sobrien	then unchanged it -- it really does run slower in too many cases.
68685587Sobrien	left the code in place, commented out.
68785587Sobrien
68885587SobrienFeb 10, 1991:
68985587Sobrien	check error status on all writes, to avoid banging on full disks.
69085587Sobrien
69185587SobrienJan 28, 1991:
69285587Sobrien	awk -f - reads the program from stdin.
69385587Sobrien
69485587SobrienJan 11, 1991:
69585587Sobrien	failed to set numeric state on $0 in cmd|getline context in run.c.
69685587Sobrien
69785587SobrienNov 2, 1990:
69885587Sobrien	fixed sleazy test for integrality in getsval;  use modf.
69985587Sobrien
70085587SobrienOct 29, 1990:
70185587Sobrien	fixed sleazy buggy code in lib.c that looked (incorrectly) for
70285587Sobrien	too long input lines.
70385587Sobrien
70485587SobrienOct 14, 1990:
70585587Sobrien	fixed the bug on p. 198 in which it couldn't deduce that an
70685587Sobrien	argument was an array in some contexts.  replaced the error
70785587Sobrien	message in intest() by code that damn well makes it an array.
70885587Sobrien
70985587SobrienOct 8, 1990:
71085587Sobrien	fixed horrible bug:  types and values were not preserved in
71185587Sobrien	some kinds of self-assignment. (in assign().)
71285587Sobrien
71385587SobrienAug 24, 1990:
71485587Sobrien	changed NCHARS to 256 to handle 8-bit characters in strings
71585587Sobrien	presented to match(), etc.
71685587Sobrien
71785587SobrienJun 26, 1990:
71885587Sobrien	changed struct rrow (awk.h) to use long instead of int for lval,
71985587Sobrien	since cfoll() stores a pointer in it.  now works better when int's
72085587Sobrien	are smaller than pointers!
72185587Sobrien
72285587SobrienMay 6, 1990:
72385587Sobrien	AVA fixed the grammar so that ! is uniformly of the same precedence as
72485587Sobrien	unary + and -.  This renders illegal some constructs like !x=y, which
72585587Sobrien	now has to be parenthesized as !(x=y), and makes others work properly:
72685587Sobrien	!x+y is (!x)+y, and x!y is x !y, not two pattern-action statements.
72785587Sobrien	(These problems were pointed out by Bob Lenk of Posix.)
72885587Sobrien
72985587Sobrien	Added \x to regular expressions (already in strings).
73085587Sobrien	Limited octal to octal digits; \8 and \9 are not octal.
73185587Sobrien	Centralized the code for parsing escapes in regular expressions.
73285587Sobrien	Added a bunch of tests to T.re and T.sub to verify some of this.
73385587Sobrien
73485587SobrienFeb 9, 1990:
73585587Sobrien	fixed null pointer dereference bug in main.c:  -F[nothing].  sigh.
73685587Sobrien
73785587Sobrien	restored srand behavior:  it returns the current seed.
73885587Sobrien
73985587SobrienJan 18, 1990:
74085587Sobrien	srand now returns previous seed value (0 to start).
74185587Sobrien
74285587SobrienJan 5, 1990:
74385587Sobrien	fix potential problem in tran.c -- something was freed,
74485587Sobrien	then used in freesymtab.
74585587Sobrien
74685587SobrienOct 18, 1989:
74785587Sobrien	another try to get the max number of open files set with
74885587Sobrien	relatively machine-independent code.
74985587Sobrien
75085587Sobrien	small fix to input() in case of multiple reads after EOF.
75185587Sobrien
75285587SobrienOct 11, 1989:
75385587Sobrien	FILENAME is now defined in the BEGIN block -- too many old
75485587Sobrien	programs broke.
75585587Sobrien
75685587Sobrien	"-" means stdin in getline as well as on the commandline.
75785587Sobrien
75885587Sobrien	added a bunch of casts to the code to tell the truth about
75985587Sobrien	char * vs. unsigned char *, a right royal pain.  added a
76085587Sobrien	setlocale call to the front of main, though probably no one
76185587Sobrien	has it usefully implemented yet.
76285587Sobrien
76385587SobrienAug 24, 1989:
76485587Sobrien	removed redundant relational tests against nullnode if parse
76585587Sobrien	tree already had a relational at that point.
76685587Sobrien
76785587SobrienAug 11, 1989:
76885587Sobrien	fixed bug:  commandline variable assignment has to look like
76985587Sobrien	var=something.  (consider the man page for =, in file =.1)
77085587Sobrien
77185587Sobrien	changed number of arguments to functions to static arrays
77285587Sobrien	to avoid repeated malloc calls.
77385587Sobrien
77485587SobrienAug 2, 1989:
77585587Sobrien	restored -F (space) separator
77685587Sobrien
77785587SobrienJul 30, 1989:
77885587Sobrien	added -v x=1 y=2 ... for immediate commandline variable assignment;
77985587Sobrien	done before the BEGIN block for sure.  they have to precede the
78085587Sobrien	program if the program is on the commandline.
78185587Sobrien	Modified Aug 2 to require a separate -v for each assignment.
78285587Sobrien
78385587SobrienJul 10, 1989:
78485587Sobrien	fixed ref-thru-zero bug in environment code in tran.c
78585587Sobrien
78685587SobrienJun 23, 1989:
78785587Sobrien	add newline to usage message.
78885587Sobrien
78985587SobrienJun 14, 1989:
79085587Sobrien	added some missing ansi printf conversion letters: %i %X %E %G.
79185587Sobrien	no sensible meaning for h or L, so they may not do what one expects.
79285587Sobrien
79385587Sobrien	made %* conversions work.
79485587Sobrien
79585587Sobrien	changed x^y so that if n is a positive integer, it's done
79685587Sobrien	by explicit multiplication, thus achieving maximum accuracy.
79785587Sobrien	(this should be done by pow() but it seems not to be locally.)
79885587Sobrien	done to x ^= y as well.
79985587Sobrien
80085587SobrienJun 4, 1989:
80185587Sobrien	ENVIRON array contains environment: if shell variable V=thing,
80285587Sobrien		ENVIRON["V"] is "thing"
80385587Sobrien
80485587Sobrien	multiple -f arguments permitted.  error reporting is naive.
80585587Sobrien	(they were permitted before, but only the last was used.)
80685587Sobrien
80785587Sobrien	fixed a really stupid botch in the debugging macro dprintf
80885587Sobrien
80985587Sobrien	fixed order of evaluation of commandline assignments to match
81085587Sobrien	what the book claims:  an argument of the form x=e is evaluated
81185587Sobrien	at the time it would have been opened if it were a filename (p 63).
81285587Sobrien	this invalidates the suggested answer to ex 4-1 (p 195).
81385587Sobrien
81485587Sobrien	removed some code that permitted -F (space) fieldseparator,
81585587Sobrien	since it didn't quite work right anyway.  (restored aug 2)
81685587Sobrien
81785587SobrienApr 27, 1989:
81885587Sobrien	Line number now accumulated correctly for comment lines.
81985587Sobrien
82085587SobrienApr 26, 1989:
82185587Sobrien	Debugging output now includes a version date,
82285587Sobrien	if one compiles it into the source each time.
82385587Sobrien
82485587SobrienApr 9, 1989:
82585587Sobrien	Changed grammar to prohibit constants as 3rd arg of sub and gsub;
82685587Sobrien	prevents class of overwriting-a-constant errors.  (Last one?)
82785587Sobrien	This invalidates the "banana" example on page 43 of the book.
82885587Sobrien
82985587Sobrien	Added \a ("alert"), \v (vertical tab), \xhhh (hexadecimal),
83085587Sobrien	as in ANSI, for strings.  Rescinded the sloppiness that permitted
83185587Sobrien	non-octal digits in \ooo.  Warning:  not all compilers and libraries
83285587Sobrien	will be able to deal with \x correctly.
83385587Sobrien
83485587SobrienJan 9, 1989:
83585587Sobrien	Fixed bug that caused tempcell list to contain a duplicate.
83685587Sobrien	The fix is kludgy.
83785587Sobrien
83885587SobrienDec 17, 1988:
83985587Sobrien	Catches some more commandline errors in main.
84085587Sobrien	Removed redundant decl of modf in run.c (confuses some compilers).
84185587Sobrien	Warning:  there's no single declaration of malloc, etc., in awk.h
84285587Sobrien	that seems to satisfy all compilers.
84385587Sobrien
84485587SobrienDec 7, 1988:
84585587Sobrien	Added a bit of code to error printing to avoid printing nulls.
84685587Sobrien	(Not clear that it actually would.)
84785587Sobrien
84885587SobrienNov 27, 1988:
84985587Sobrien	With fear and trembling, modified the grammar to permit
85085587Sobrien	multiple pattern-action statements on one line without
85185587Sobrien	an explicit separator.  By definition, this capitulation
85285587Sobrien	to the ghost of ancient implementations remains undefined
85385587Sobrien	and thus subject to change without notice or apology.
85485587Sobrien	DO NOT COUNT ON IT.
85585587Sobrien
85685587SobrienOct 30, 1988:
85785587Sobrien	Fixed bug in call() that failed to recover storage.
85885587Sobrien
85985587Sobrien	A warning is now generated if there are more arguments
86085587Sobrien	in the call than in the definition (in lieu of fixing
86185587Sobrien	another storage leak).
86285587Sobrien
86385587SobrienOct 20, 1988:
86485587Sobrien	Fixed %c:  if expr is numeric, use numeric value;
86585587Sobrien	otherwise print 1st char of string value.  still
86685587Sobrien	doesn't work if the value is 0 -- won't print \0.
86785587Sobrien
86885587Sobrien	Added a few more checks for running out of malloc.
86985587Sobrien
87085587SobrienOct 12, 1988:
87185587Sobrien	Fixed bug in call() that freed local arrays twice.
87285587Sobrien
87385587Sobrien	Fixed to handle deletion of non-existent array right;
87485587Sobrien	complains about attempt to delete non-array element.
87585587Sobrien
87685587SobrienSep 30, 1988:
87785587Sobrien	Now guarantees to evaluate all arguments of built-in
87885587Sobrien	functions, as in C;  the appearance is that arguments
87985587Sobrien	are evaluated before the function is called.  Places
88085587Sobrien	affected are sub (gsub was ok), substr, printf, and
88185587Sobrien	all the built-in arithmetic functions in bltin().
88285587Sobrien	A warning is generated if a bltin() is called with
88385587Sobrien	the wrong number of arguments.
88485587Sobrien
88585587Sobrien	This requires changing makeprof on p167 of the book.
88685587Sobrien
88785587SobrienAug 23, 1988:
88885587Sobrien	setting FILENAME in BEGIN caused core dump, apparently
88985587Sobrien	because it was freeing space not allocated by malloc.
89085587Sobrien
89185587SobrienJuly 24, 1988:
89285587Sobrien	fixed egregious error in toupper/tolower functions.
89385587Sobrien	still subject to rescinding, however.
89485587Sobrien
89585587SobrienJuly 2, 1988:
89685587Sobrien	flush stdout before opening file or pipe
89785587Sobrien
89885587SobrienJuly 2, 1988:
89985587Sobrien	performance bug in b.c/cgoto(): not freeing some sets of states.
90085587Sobrien	partial fix only right now, and the number of states increased
90185587Sobrien	to make it less obvious.
90285587Sobrien
90385587SobrienJune 1, 1988:
90485587Sobrien	check error status on close
90585587Sobrien
90685587SobrienMay 28, 1988:
90785587Sobrien	srand returns seed value it's using.
90885587Sobrien	see 1/18/90
90985587Sobrien
91085587SobrienMay 22, 1988:
91185587Sobrien	Removed limit on depth of function calls.
91285587Sobrien
91385587SobrienMay 10, 1988:
91485587Sobrien	Fixed lib.c to permit _ in commandline variable names.
91585587Sobrien
91685587SobrienMar 25, 1988:
91785587Sobrien	main.c fixed to recognize -- as terminator of command-
91885587Sobrien	line options.  Illegal options flagged.
91985587Sobrien	Error reporting slightly cleaned up.
92085587Sobrien
92185587SobrienDec 2, 1987:
92285587Sobrien	Newer C compilers apply a strict scope rule to extern
92385587Sobrien	declarations within functions.  Two extern declarations in
92485587Sobrien	lib.c and tran.c have been moved to obviate this problem.
92585587Sobrien
92685587SobrienOct xx, 1987:
92785587Sobrien	Reluctantly added toupper and tolower functions.
92885587Sobrien	Subject to rescinding without notice.
92985587Sobrien
93085587SobrienSep 17, 1987:
93185587Sobrien	Error-message printer had printf(s) instead of
93285587Sobrien	printf("%s",s);  got core dumps when the message
93385587Sobrien	included a %.
93485587Sobrien
93585587SobrienSep 12, 1987:
93685587Sobrien	Very long printf strings caused core dump;
93785587Sobrien	fixed aprintf, asprintf, format to catch them.
93885587Sobrien	Can still get a core dump in printf itself.
93985587Sobrien
94085587Sobrien
941