xref: /titanic_50/usr/src/cmd/oawk/README (revision 2df1fe9ca32bb227b9158c67f5c00b54c20b10fd)
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#
22#ident	"%Z%%M%	%I%	%E% SMI"
23CHANGES as of July 12:
24
251. \ddd allowed in regular expressions.
26
272. exit <expression> causes the expression to
28to be the status return upon completion.
29
303. a new builtin called "getline" causes the next
31input line to be read immediately.  Fields, NR, etc.,
32are all set, but you are left at exactly the same place
33in the awk program.  Getline returns 0 for end of file;
341 for a normal record.
35
36
37CHANGES SINCE MEMO:
38Update to TM of Sept 1, 1978:
39
401. A new form of for loop
41	for (i in array)
42		statement
43is now available. It provides a way to walk
44along the members of an array, most usefully
45for associative arrays with non-numeric subscripts.
46Elements are accessed in an unpredictable order,
47so don't count on anything.
48Futhermore, havoc ensues if elements are created
49during this operation, or if the index variable
50is fiddled.
51
522. index(s1, s2) returns the position in s1
53where s2 first occurs, or 0 if it doesn't.
54
553. Multi-line records are now supported more
56conveniently. If the record separator is null
57	RS = ""
58then a blank line terminates a record, and newline
59is a default field separator, along with
60blank and tab.
61
624. The syntax of split has been changed.
63	n = split(str, arrayname, sep)
64splits the string str into the array using
65the separator sep (a single character).
66If no sep field is given, FS is used instead.
67The elements are array[1] ... array[n]; n
68is the function value.
69
705. some minor bugs have been fixed.
71
72IMPLEMENTATION NOTES:
73
74Things to watch out for when trying to make awk:
75
761. The yacc -d business creates a new file y.tab.h
77with the yacc #defines in it. this is compared to
78awk.h on each successive compile, and major recompilation
79is done only if the files differ. (This permits editing
80the grammar file without causing everything in sight
81to be recompiled, so long as the definitions don't
82change.)
83
842. The program proc.c is compiled into proc, which
85is used to create proctab.c. proctab.c is the
86table of function pointers used by run to actually
87execute things. Don't try to load proc.c with the
88other .c files; it also contains a "main()".
89
903. Awk uses structure assignment. Be sure your
91version of the C compiler has it.
92
934. The loader flag -lm is used to fetch the standard
94math library on the Research system. It is more likely
95that you will want to use -lS on yours.
96run.c also includes "math.h", which contains sensible
97definitions for log(), sqrt(), etc. If you don't have this
98include file, comment the line out, and all will be well
99anyway.
100
1015. The basic sequence of events (in case make doesn't
102seem to do the job) is
103	yacc -d awk.g.y
104	cc -O -c y.tab.c
105	mv y.tab.o awk.g.o
106	lex awk.lx.l
107	cc -O -c lex.yy.c
108	mv lex.yy.o awk.lx.o
109	cc -O -c b.c
110	cc -O -c main.c
111	e - <tokenscript
112	cc -O -c token.c
113	cc -O -c tran.c
114	cc -O -c lib.c
115	cc -O -c run.c
116	cc -O -c parse.c
117	cc -O -c proc.c
118	cc -o proc proc.c token.o
119	proc >proctab.c
120	cc -O -c proctab.c
121	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