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