xref: /onnv-gate/usr/src/cmd/sgs/m4/common/m4ext.c (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
23*0Sstevel@tonic-gate /*	  All Rights Reserved  	*/
24*0Sstevel@tonic-gate 
25*0Sstevel@tonic-gate 
26*0Sstevel@tonic-gate /*
27*0Sstevel@tonic-gate  * Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
28*0Sstevel@tonic-gate  * Use is subject to license terms.
29*0Sstevel@tonic-gate  */
30*0Sstevel@tonic-gate 
31*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
32*0Sstevel@tonic-gate 
33*0Sstevel@tonic-gate #include	"m4.h"
34*0Sstevel@tonic-gate 
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate /* storage params */
37*0Sstevel@tonic-gate int	hshsize 	= 199;		/* hash table size (prime) */
38*0Sstevel@tonic-gate int	bufsize 	= 4096;		/* pushback & arg text buffers */
39*0Sstevel@tonic-gate int	stksize 	= 100;		/* call stack */
40*0Sstevel@tonic-gate int	toksize 	= 512;		/* biggest word ([a-z_][a-z0-9_]*) */
41*0Sstevel@tonic-gate 
42*0Sstevel@tonic-gate 
43*0Sstevel@tonic-gate /* pushback buffer */
44*0Sstevel@tonic-gate wchar_t	*ibuf;				/* buffer */
45*0Sstevel@tonic-gate wchar_t	*ibuflm;			/* highest buffer addr */
46*0Sstevel@tonic-gate wchar_t	*ip;				/* current position */
47*0Sstevel@tonic-gate wchar_t	*ipflr;				/* buffer floor */
48*0Sstevel@tonic-gate wchar_t 	*ipstk[10];			/* stack for "ipflr"s */
49*0Sstevel@tonic-gate 
50*0Sstevel@tonic-gate 
51*0Sstevel@tonic-gate /* arg collection buffer */
52*0Sstevel@tonic-gate wchar_t	*obuf;				/* buffer */
53*0Sstevel@tonic-gate wchar_t	*obuflm;			/* high address */
54*0Sstevel@tonic-gate wchar_t	*op;				/* current position */
55*0Sstevel@tonic-gate 
56*0Sstevel@tonic-gate 
57*0Sstevel@tonic-gate /* call stack */
58*0Sstevel@tonic-gate struct call	*callst;		/* stack */
59*0Sstevel@tonic-gate struct call	*Cp 	= NULL;		/* position */
60*0Sstevel@tonic-gate 
61*0Sstevel@tonic-gate 
62*0Sstevel@tonic-gate /* token storage */
63*0Sstevel@tonic-gate wchar_t	*token;				/* buffer */
64*0Sstevel@tonic-gate wchar_t	*toklm;				/* high addr */
65*0Sstevel@tonic-gate 
66*0Sstevel@tonic-gate 
67*0Sstevel@tonic-gate /* file name and current line storage for line sync and diagnostics */
68*0Sstevel@tonic-gate char	*fname[11];			/* file name ptr stack */
69*0Sstevel@tonic-gate int	fline[10];			/* current line nbr stack */
70*0Sstevel@tonic-gate 
71*0Sstevel@tonic-gate 
72*0Sstevel@tonic-gate /* input file stuff for "include"s */
73*0Sstevel@tonic-gate FILE	*ifile[10] 	= {stdin};	/* stack */
74*0Sstevel@tonic-gate int	ifx;				/* stack index */
75*0Sstevel@tonic-gate ibuf_t	ibuffer[11];			/* input buffer */
76*0Sstevel@tonic-gate 
77*0Sstevel@tonic-gate /* stuff for output diversions */
78*0Sstevel@tonic-gate FILE	*cf 	= stdout;		/* current output file */
79*0Sstevel@tonic-gate FILE	*ofile[11] 	= {stdout};	/* output file stack */
80*0Sstevel@tonic-gate int	ofx;				/* stack index */
81*0Sstevel@tonic-gate 
82*0Sstevel@tonic-gate 
83*0Sstevel@tonic-gate /* comment markers */
84*0Sstevel@tonic-gate wchar_t	lcom[MAXSYM+1] 	= L"#";
85*0Sstevel@tonic-gate wchar_t	rcom[MAXSYM+1] 	= L"\n";
86*0Sstevel@tonic-gate 
87*0Sstevel@tonic-gate 
88*0Sstevel@tonic-gate /* quote markers */
89*0Sstevel@tonic-gate wchar_t	lquote[MAXSYM+1]  = L"`";
90*0Sstevel@tonic-gate wchar_t	rquote[MAXSYM+1]  = L"\'";
91*0Sstevel@tonic-gate 
92*0Sstevel@tonic-gate 
93*0Sstevel@tonic-gate /* argument ptr stack */
94*0Sstevel@tonic-gate wchar_t	**argstk;
95*0Sstevel@tonic-gate wchar_t	*astklm;			/* high address */
96*0Sstevel@tonic-gate wchar_t	**Ap;				/* current position */
97*0Sstevel@tonic-gate 
98*0Sstevel@tonic-gate 
99*0Sstevel@tonic-gate /* symbol table */
100*0Sstevel@tonic-gate struct nlist	**hshtab;		/* hash table */
101*0Sstevel@tonic-gate unsigned int	hshval;			/* last hash val */
102*0Sstevel@tonic-gate 
103*0Sstevel@tonic-gate 
104*0Sstevel@tonic-gate /* misc */
105*0Sstevel@tonic-gate char	*procnam;			/* argv[0] */
106*0Sstevel@tonic-gate char	*tempfile;			/* used for diversion files */
107*0Sstevel@tonic-gate struct	Wrap *wrapstart = NULL;	/* first entry in of list of "m4wrap" strings */
108*0Sstevel@tonic-gate wchar_t	nullstr[] 	= {0};
109*0Sstevel@tonic-gate int	nflag 	= 1;			/* name flag, used for line sync code */
110*0Sstevel@tonic-gate int	sflag;				/* line sync flag */
111*0Sstevel@tonic-gate int	sysrval;			/* return val from syscmd */
112*0Sstevel@tonic-gate int	trace;				/* global trace flag */
113*0Sstevel@tonic-gate int	exitstat = OK;			/* global exit status */
114*0Sstevel@tonic-gate int	wide;				/* multi-byte locale */
115