--- old/usr/src/cmd/awk/awk.h	2013-05-11 15:20:42.909278564 +0000
+++ new/usr/src/cmd/awk/awk.h	2013-05-11 15:20:42.920110534 +0000
@@ -23,13 +23,35 @@
  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
-/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
-/*	  All Rights Reserved  	*/
+/*
+ * Copyright (C) Lucent Technologies 1997
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose and without fee is hereby
+ * granted, provided that the above copyright notice appear in all
+ * copies and that both that the copyright notice and this
+ * permission notice and warranty disclaimer appear in supporting
+ * documentation, and that the name Lucent Technologies or any of
+ * its entities not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission.
+ *
+ * LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+ * IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
 
 #ifndef AWK_H
 #define	AWK_H
 
 #include <sys/types.h>
+#include <assert.h>
 #include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -40,7 +62,7 @@
 typedef double	Awkfloat;
 typedef	unsigned char uchar;
 
-#define	xfree(a)	{ if ((a) != NULL) { free(a); a = NULL; } }
+#define	xfree(a)	{ if ((a) != NULL) { free((void *)(a)); (a) = NULL; } }
 
 #define	DEBUG
 #ifdef	DEBUG
@@ -50,26 +72,10 @@
 #define	dprintf(x)
 #endif
 
-extern	char	errbuf[200];
-extern	void	error(int, char *);
-#define	ERROR	(void) snprintf(errbuf, sizeof (errbuf),
-/*CSTYLED*/
-#define	FATAL	), error(1, errbuf)
-/*CSTYLED*/
-#define	WARNING	), error(0, errbuf)
-/*CSTYLED*/
-#define	SYNTAX	), yyerror(errbuf)
-/*CSTYLED*/
-#define	CONT	)
-
 extern int	compile_time;	/* 1 if compiling, 0 if running */
+extern int	safe;		/* 0 => unsafe, 1 => safe */
 
-#define	FLD_INCR	64
-#define	LINE_INCR	256
-
-/* ensure that there is extra 1 byte in the buffer */
-#define	expand_buf(p, n, r)	\
-	if (*(n) == 0 || (r) >= (*(n) - 1)) r_expand_buf(p, n, r)
+#define	RECSIZE	(8 * 1024)	/* sets limit on records, fields, etc., etc. */
 
 extern uchar	**FS;
 extern uchar	**RS;
@@ -101,12 +107,12 @@
 	uchar	*nval;		/* name, for variables only */
 	uchar	*sval;		/* string value */
 	Awkfloat fval;		/* value as number */
-	unsigned tval;
+	int	tval;
 		/* type info: STR|NUM|ARR|FCN|FLD|CON|DONTFREE */
 	struct Cell *cnext;	/* ptr to next if chained */
 } Cell;
 
-typedef struct {		/* symbol table array */
+typedef struct Array {		/* symbol table array */
 	int	nelem;		/* elements in table right now */
 	int	size;		/* size of tab */
 	Cell	**tab;		/* hash table pointers */
@@ -114,8 +120,9 @@
 
 #define	NSYMTAB	50	/* initial size of a symbol table */
 extern Array	*symtab, *makesymtab(int);
-extern Cell	*setsymtab(uchar *, uchar *, Awkfloat, unsigned int, Array *);
-extern Cell	*lookup(uchar *, Array *);
+extern Cell	*setsymtab(const uchar *, const uchar *, Awkfloat,
+    unsigned int, Array *);
+extern Cell	*lookup(const uchar *, Array *);
 
 extern Cell	*recloc;	/* location of input record */
 extern Cell	*nrloc;		/* NR */
@@ -134,16 +141,13 @@
 #define	FLD	0100	/* this is a field $1, $2, ... */
 #define	REC	0200	/* this is $0 */
 
-#define	freeable(p)	(!((p)->tval & DONTFREE))
 
 extern Awkfloat setfval(Cell *, Awkfloat), getfval(Cell *), r_getfval(Cell *);
-extern uchar	*setsval(Cell *, uchar *), *getsval(Cell *), *r_getsval(Cell *);
-extern uchar	*tostring(uchar *), *tokname(int), *qstring(uchar *, int);
-
-#define	getfval(p)	\
-	(((p)->tval & (ARR|FLD|REC|NUM)) == NUM ? (p)->fval : r_getfval(p))
-#define	getsval(p)	\
-	(((p)->tval & (ARR|FLD|REC|STR)) == STR ? (p)->sval : r_getsval(p))
+extern	uchar	*setsval(Cell *, const uchar *);
+extern	uchar	*getsval(Cell *);
+extern	uchar	*tostring(const uchar *);
+extern	uchar	*tokname(int);
+extern	uchar	*qstring(const uchar *, int);
 
 /* function types */
 #define	FLENGTH	1
@@ -159,6 +163,7 @@
 #define	FATAN	11
 #define	FTOUPPER 12
 #define	FTOLOWER 13
+#define	FFLUSH	14
 
 /* Node:  parse tree is made of nodes, with Cell's at bottom */
 
@@ -190,6 +195,7 @@
 #define	CNAME	3
 #define	CVAR	2
 #define	CFLD	1
+#define	CUNK	0
 
 /* bool subtypes */
 #define	BTRUE	11
@@ -201,6 +207,7 @@
 #define	JBREAK	23
 #define	JCONT	24
 #define	JRET	25
+#define	JNEXTFILE	26
 
 /* node types */
 #define	NVALUE	1
@@ -212,16 +219,21 @@
 extern	Cell	*nullproc(Node **, int);
 extern	int	pairstack[], paircnt;
 
-extern	Node	*stat1(int, Node *), *stat2(int, Node *, Node *);
+extern	int	pgetc(void);
+extern	Node	*stat1(int, Node *);
+extern	Node	*stat2(int, Node *, Node *);
 extern	Node	*stat3(int, Node *, Node *, Node *);
 extern	Node	*stat4(int, Node *, Node *, Node *, Node *);
 extern	Node	*pa2stat(Node *, Node *, Node *);
-extern	Node	*op1(int, Node *), *op2(int, Node *, Node *);
+extern	Node	*op1(int, Node *);
+extern	Node	*op2(int, Node *, Node *);
 extern	Node	*op3(int, Node *, Node *, Node *);
 extern	Node	*op4(int, Node *, Node *, Node *, Node *);
-extern	Node	*linkum(Node *, Node *), *valtonode(Cell *, int);
+extern	Node	*linkum(Node *, Node *);
+extern	Node	*celltonode(Cell *, int);
 extern	Node	*rectonode(void), *exptostat(Node *);
 extern	Node	*makearr(Node *);
+extern	Node	*itonp(int);
 
 #define	notlegal(n)	\
 	(n <= FIRSTTOKEN || n >= LASTTOKEN || proctab[n-FIRSTTOKEN] == nullproc)
@@ -231,47 +243,64 @@
 #define	isexit(n)	((n)->csub == JEXIT)
 #define	isbreak(n)	((n)->csub == JBREAK)
 #define	iscont(n)	((n)->csub == JCONT)
-#define	isnext(n)	((n)->csub == JNEXT)
+#define	isnext(n)	((n)->csub == JNEXT || (n)->csub == JNEXTFILE)
 #define	isret(n)	((n)->csub == JRET)
+#define	isrec(n)	((n)->tval & REC)
+#define	isfld(n)	((n)->tval & FLD)
 #define	isstr(n)	((n)->tval & STR)
 #define	isnum(n)	((n)->tval & NUM)
 #define	isarr(n)	((n)->tval & ARR)
-#define	isfunc(n)	((n)->tval & FCN)
+#define	isfcn(n)	((n)->tval & FCN)
 #define	istrue(n)	((n)->csub == BTRUE)
 #define	istemp(n)	((n)->csub == CTEMP)
+#define	isargument(n)	((n)->nobj == ARG)
+/* #define	freeable(p)	(!((p)->tval & DONTFREE)) */
+#define	freeable(p)	(((p)->tval & (STR|DONTFREE)) == STR)
 
-#define	NCHARS	(256+1)
+#define	NCHARS	(256+3)		/* 256 handles 8-bit chars; 128 does 7-bit */
+				/* watch out in match(), etc. */
 #define	NSTATES	32
 
 typedef struct rrow {
-	int	ltype;
-	int	lval;
+	long	ltype;	/* long avoids pointer warnings on 64-bit */
+	union {
+		int i;
+		Node *np;
+		uchar *up;
+	} lval;		/* because Al stores a pointer in it! */
 	int	*lfollow;
 } rrow;
 
 typedef struct fa {
+	uchar	gototab[NSTATES][NCHARS];
+	uchar	out[NSTATES];
 	uchar	*restr;
+	int	*posns[NSTATES];
 	int	anchor;
 	int	use;
-	uchar	gototab[NSTATES][NCHARS];
-	int	*posns[NSTATES];
-	uchar	out[NSTATES];
 	int	initstat;
 	int	curstat;
 	int	accept;
 	int	reset;
-	struct	rrow re[1];
+	struct	rrow re[1]; /* variable: actual size set by calling malloc */
 } fa;
 
 /* b.c */
-extern	fa	*makedfa(uchar *, int);
-extern	int	nematch(fa *, uchar *);
-extern	int	match(fa *, uchar *);
-extern	int	pmatch(fa *, uchar *);
+extern	fa	*makedfa(const uchar *, int);
+extern	int	nematch(fa *, const uchar *);
+extern	int	match(fa *, const uchar *);
+extern	int	pmatch(fa *, const uchar *);
+
+/* lex.c */
+extern	void	unput(int);
+extern	void	unputstr(const char *);
+extern	void	startreg(void);
 
 /* lib.c */
-extern	int	isclvar(uchar *);
-extern	int	is_number(uchar *);
+extern	void	recinit(unsigned int);
+extern	void	growfldtab(int);
+extern	int	isclvar(const uchar *);
+extern	int	is_number(const uchar *);
 extern	void	setclvar(uchar *);
 extern	int	readrec(uchar **, size_t *, FILE *);
 extern	void	bracecheck(void);
@@ -279,16 +308,18 @@
 extern	void	yyerror(char *);
 extern	void	fldbld(void);
 extern	void	recbld(void);
-extern	int	getrec(uchar **, size_t *);
+extern	int	getrec(uchar **, size_t *, int);
 extern	Cell	*fieldadr(int);
 extern	void	newfld(int);
 extern	Cell	*getfld(int);
 extern	int	fldidx(Cell *);
-extern	double	errcheck(double, char *);
+extern	void	SYNTAX(const char *, ...);
+extern	void	FATAL(const char *, ...) __attribute__((__noreturn__));
+extern	void	WARNING(const char *, ...);
+extern	void	error(void);
+extern	double	errcheck(double, const char *);
 extern	void	fpecatch(int);
-extern	void	init_buf(uchar **, size_t *, size_t);
-extern	void	adjust_buf(uchar **, size_t);
-extern	void	r_expand_buf(uchar **, size_t *, size_t);
+extern	void	nextfile(void);
 
 extern	int	donefld;
 extern	int	donerec;
@@ -301,18 +332,20 @@
 extern	uchar	*lexprog;
 extern	int	compile_time;
 extern	char	radixpoint;
+extern	uchar	*cursource(void);
 
 /* tran.c */
 extern	void	syminit(void);
 extern	void	arginit(int, uchar **);
 extern	void	envinit(uchar **);
 extern	void	freesymtab(Cell *);
-extern	void	freeelem(Cell *, uchar *);
+extern	void	freeelem(Cell *, const uchar *);
 extern	void	funnyvar(Cell *, char *);
-extern	int	hash(uchar *, int);
+extern	int	hash(const uchar *, int);
 extern	Awkfloat *ARGC;
 
 /* run.c */
+extern	int	adjbuf(uchar **, size_t *, int, int, uchar **, const char *);
 extern	void	run(Node *);
 
 extern	int	paircnt;
@@ -325,6 +358,11 @@
 extern	FILE	*yyin;
 extern	off_t	lineno;
 
+/* parse.c */
+extern	int	ptoi(void *);
+extern	int	isarg(const uchar *);
+extern	void	defn(Cell *, Node *, Node *);
+
 /* proc */
 extern Cell *nullproc(Node **, int);
 extern Cell *program(Node **, int);
@@ -336,7 +374,7 @@
 extern Cell *sub(Node **, int);
 extern Cell *gsub(Node **, int);
 extern Cell *sindex(Node **, int);
-extern Cell *a_sprintf(Node **, int);
+extern Cell *awksprintf(Node **, int);
 extern Cell *arith(Node **, int);
 extern Cell *incrdecr(Node **, int);
 extern Cell *cat(Node **, int);
@@ -344,10 +382,10 @@
 extern Cell *dopa2(Node **, int);
 extern Cell *matchop(Node **, int);
 extern Cell *intest(Node **, int);
-extern Cell *aprintf(Node **, int);
-extern Cell *print(Node **, int);
+extern Cell *awkprintf(Node **, int);
+extern Cell *printstat(Node **, int);
 extern Cell *closefile(Node **, int);
-extern Cell *delete(Node **, int);
+extern Cell *awkdelete(Node **, int);
 extern Cell *split(Node **, int);
 extern Cell *assign(Node **, int);
 extern Cell *condexpr(Node **, int);
@@ -361,6 +399,6 @@
 extern Cell *call(Node **, int);
 extern Cell *arg(Node **, int);
 extern Cell *getnf(Node **, int);
-extern Cell *getaline(Node **, int);
+extern Cell *awkgetline(Node **, int);
 
 #endif /* AWK_H */
