1*7c478bd9Sstevel@tonic-gate# 2*7c478bd9Sstevel@tonic-gate# CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate# 4*7c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate# (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate# with the License. 8*7c478bd9Sstevel@tonic-gate# 9*7c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate# and limitations under the License. 13*7c478bd9Sstevel@tonic-gate# 14*7c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate# 20*7c478bd9Sstevel@tonic-gate# CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate# 22*7c478bd9Sstevel@tonic-gate#ident "%Z%%M% %I% %E% SMI" 23*7c478bd9Sstevel@tonic-gateCHANGES as of July 12: 24*7c478bd9Sstevel@tonic-gate 25*7c478bd9Sstevel@tonic-gate1. \ddd allowed in regular expressions. 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate2. exit <expression> causes the expression to 28*7c478bd9Sstevel@tonic-gateto be the status return upon completion. 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate3. a new builtin called "getline" causes the next 31*7c478bd9Sstevel@tonic-gateinput line to be read immediately. Fields, NR, etc., 32*7c478bd9Sstevel@tonic-gateare all set, but you are left at exactly the same place 33*7c478bd9Sstevel@tonic-gatein the awk program. Getline returns 0 for end of file; 34*7c478bd9Sstevel@tonic-gate1 for a normal record. 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate 37*7c478bd9Sstevel@tonic-gateCHANGES SINCE MEMO: 38*7c478bd9Sstevel@tonic-gateUpdate to TM of Sept 1, 1978: 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate1. A new form of for loop 41*7c478bd9Sstevel@tonic-gate for (i in array) 42*7c478bd9Sstevel@tonic-gate statement 43*7c478bd9Sstevel@tonic-gateis now available. It provides a way to walk 44*7c478bd9Sstevel@tonic-gatealong the members of an array, most usefully 45*7c478bd9Sstevel@tonic-gatefor associative arrays with non-numeric subscripts. 46*7c478bd9Sstevel@tonic-gateElements are accessed in an unpredictable order, 47*7c478bd9Sstevel@tonic-gateso don't count on anything. 48*7c478bd9Sstevel@tonic-gateFuthermore, havoc ensues if elements are created 49*7c478bd9Sstevel@tonic-gateduring this operation, or if the index variable 50*7c478bd9Sstevel@tonic-gateis fiddled. 51*7c478bd9Sstevel@tonic-gate 52*7c478bd9Sstevel@tonic-gate2. index(s1, s2) returns the position in s1 53*7c478bd9Sstevel@tonic-gatewhere s2 first occurs, or 0 if it doesn't. 54*7c478bd9Sstevel@tonic-gate 55*7c478bd9Sstevel@tonic-gate3. Multi-line records are now supported more 56*7c478bd9Sstevel@tonic-gateconveniently. If the record separator is null 57*7c478bd9Sstevel@tonic-gate RS = "" 58*7c478bd9Sstevel@tonic-gatethen a blank line terminates a record, and newline 59*7c478bd9Sstevel@tonic-gateis a default field separator, along with 60*7c478bd9Sstevel@tonic-gateblank and tab. 61*7c478bd9Sstevel@tonic-gate 62*7c478bd9Sstevel@tonic-gate4. The syntax of split has been changed. 63*7c478bd9Sstevel@tonic-gate n = split(str, arrayname, sep) 64*7c478bd9Sstevel@tonic-gatesplits the string str into the array using 65*7c478bd9Sstevel@tonic-gatethe separator sep (a single character). 66*7c478bd9Sstevel@tonic-gateIf no sep field is given, FS is used instead. 67*7c478bd9Sstevel@tonic-gateThe elements are array[1] ... array[n]; n 68*7c478bd9Sstevel@tonic-gateis the function value. 69*7c478bd9Sstevel@tonic-gate 70*7c478bd9Sstevel@tonic-gate5. some minor bugs have been fixed. 71*7c478bd9Sstevel@tonic-gate 72*7c478bd9Sstevel@tonic-gateIMPLEMENTATION NOTES: 73*7c478bd9Sstevel@tonic-gate 74*7c478bd9Sstevel@tonic-gateThings to watch out for when trying to make awk: 75*7c478bd9Sstevel@tonic-gate 76*7c478bd9Sstevel@tonic-gate1. The yacc -d business creates a new file y.tab.h 77*7c478bd9Sstevel@tonic-gatewith the yacc #defines in it. this is compared to 78*7c478bd9Sstevel@tonic-gateawk.h on each successive compile, and major recompilation 79*7c478bd9Sstevel@tonic-gateis done only if the files differ. (This permits editing 80*7c478bd9Sstevel@tonic-gatethe grammar file without causing everything in sight 81*7c478bd9Sstevel@tonic-gateto be recompiled, so long as the definitions don't 82*7c478bd9Sstevel@tonic-gatechange.) 83*7c478bd9Sstevel@tonic-gate 84*7c478bd9Sstevel@tonic-gate2. The program proc.c is compiled into proc, which 85*7c478bd9Sstevel@tonic-gateis used to create proctab.c. proctab.c is the 86*7c478bd9Sstevel@tonic-gatetable of function pointers used by run to actually 87*7c478bd9Sstevel@tonic-gateexecute things. Don't try to load proc.c with the 88*7c478bd9Sstevel@tonic-gateother .c files; it also contains a "main()". 89*7c478bd9Sstevel@tonic-gate 90*7c478bd9Sstevel@tonic-gate3. Awk uses structure assignment. Be sure your 91*7c478bd9Sstevel@tonic-gateversion of the C compiler has it. 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate4. The loader flag -lm is used to fetch the standard 94*7c478bd9Sstevel@tonic-gatemath library on the Research system. It is more likely 95*7c478bd9Sstevel@tonic-gatethat you will want to use -lS on yours. 96*7c478bd9Sstevel@tonic-gaterun.c also includes "math.h", which contains sensible 97*7c478bd9Sstevel@tonic-gatedefinitions for log(), sqrt(), etc. If you don't have this 98*7c478bd9Sstevel@tonic-gateinclude file, comment the line out, and all will be well 99*7c478bd9Sstevel@tonic-gateanyway. 100*7c478bd9Sstevel@tonic-gate 101*7c478bd9Sstevel@tonic-gate5. The basic sequence of events (in case make doesn't 102*7c478bd9Sstevel@tonic-gateseem to do the job) is 103*7c478bd9Sstevel@tonic-gate yacc -d awk.g.y 104*7c478bd9Sstevel@tonic-gate cc -O -c y.tab.c 105*7c478bd9Sstevel@tonic-gate mv y.tab.o awk.g.o 106*7c478bd9Sstevel@tonic-gate lex awk.lx.l 107*7c478bd9Sstevel@tonic-gate cc -O -c lex.yy.c 108*7c478bd9Sstevel@tonic-gate mv lex.yy.o awk.lx.o 109*7c478bd9Sstevel@tonic-gate cc -O -c b.c 110*7c478bd9Sstevel@tonic-gate cc -O -c main.c 111*7c478bd9Sstevel@tonic-gate e - <tokenscript 112*7c478bd9Sstevel@tonic-gate cc -O -c token.c 113*7c478bd9Sstevel@tonic-gate cc -O -c tran.c 114*7c478bd9Sstevel@tonic-gate cc -O -c lib.c 115*7c478bd9Sstevel@tonic-gate cc -O -c run.c 116*7c478bd9Sstevel@tonic-gate cc -O -c parse.c 117*7c478bd9Sstevel@tonic-gate cc -O -c proc.c 118*7c478bd9Sstevel@tonic-gate cc -o proc proc.c token.o 119*7c478bd9Sstevel@tonic-gate proc >proctab.c 120*7c478bd9Sstevel@tonic-gate cc -O -c proctab.c 121*7c478bd9Sstevel@tonic-gate 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 122