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