1CHANGES as of July 12: 2 31. \ddd allowed in regular expressions. 4 52. exit <expression> causes the expression to 6to be the status return upon completion. 7 83. a new builtin called "getline" causes the next 9input line to be read immediately. Fields, NR, etc., 10are all set, but you are left at exactly the same place 11in the awk program. Getline returns 0 for end of file; 121 for a normal record. 13 14 15CHANGES SINCE MEMO: 16Update to TM of Sept 1, 1978: 17 181. A new form of for loop 19 for (i in array) 20 statement 21is now available. It provides a way to walk 22along the members of an array, most usefully 23for associative arrays with non-numeric subscripts. 24Elements are accessed in an unpredictable order, 25so don't count on anything. 26Futhermore, havoc ensues if elements are created 27during this operation, or if the index variable 28is fiddled. 29 302. index(s1, s2) returns the position in s1 31where s2 first occurs, or 0 if it doesn't. 32 333. Multi-line records are now supported more 34conveniently. If the record separator is null 35 RS = "" 36then a blank line terminates a record, and newline 37is a default field separator, along with 38blank and tab. 39 404. The syntax of split has been changed. 41 n = split(str, arrayname, sep) 42splits the string str into the array using 43the separator sep (a single character). 44If no sep field is given, FS is used instead. 45The elements are array[1] ... array[n]; n 46is the function value. 47 485. some minor bugs have been fixed. 49 50IMPLEMENTATION NOTES: 51 52Things to watch out for when trying to make awk: 53 541. The yacc -d business creates a new file y.tab.h 55with the yacc #defines in it. this is compared to 56awk.h on each successive compile, and major recompilation 57is done only if the files differ. (This permits editing 58the grammar file without causing everything in sight 59to be recompiled, so long as the definitions don't 60change.) 61 622. The program proc.c is compiled into proc, which 63is used to create proctab.c. proctab.c is the 64table of function pointers used by run to actually 65execute things. Don't try to load proc.c with the 66other .c files; it also contains a "main()". 67 683. Awk uses structure assignment. Be sure your 69version of the C compiler has it. 70 714. The loader flag -lm is used to fetch the standard 72math library on the Research system. It is more likely 73that you will want to use -lS on yours. 74run.c also includes "math.h", which contains sensible 75definitions for log(), sqrt(), etc. If you don't have this 76include file, comment the line out, and all will be well 77anyway. 78 795. The basic sequence of events (in case make doesn't 80seem to do the job) is 81 yacc -d awk.g.y 82 cc -O -c y.tab.c 83 mv y.tab.o awk.g.o 84 lex awk.lx.l 85 cc -O -c lex.yy.c 86 mv lex.yy.o awk.lx.o 87 cc -O -c b.c 88 cc -O -c main.c 89 e - <tokenscript 90 cc -O -c token.c 91 cc -O -c tran.c 92 cc -O -c lib.c 93 cc -O -c run.c 94 cc -O -c parse.c 95 cc -O -c proc.c 96 cc -o proc proc.c token.o 97 proc >proctab.c 98 cc -O -c proctab.c 99 cc -i -O awk.g.o awk.lx.o b.o main.o token.o tran.o lib.o run.o parse.o proctab.o -lm 100