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