xref: /titanic_41/usr/src/cmd/sgs/m4/common/m4ext.c (revision cde2885fdf538266ee2a3b08dee2d5075ce8fa2b)
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 /*	Copyright (c) 1988 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 
26 /*
27  * Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
28  * Use is subject to license terms.
29  */
30 
31 #pragma ident	"%Z%%M%	%I%	%E% SMI"
32 
33 #include	"m4.h"
34 
35 
36 /* storage params */
37 int	hshsize 	= 199;		/* hash table size (prime) */
38 int	bufsize 	= 4096;		/* pushback & arg text buffers */
39 int	stksize 	= 100;		/* call stack */
40 int	toksize 	= 512;		/* biggest word ([a-z_][a-z0-9_]*) */
41 
42 
43 /* pushback buffer */
44 wchar_t	*ibuf;				/* buffer */
45 wchar_t	*ibuflm;			/* highest buffer addr */
46 wchar_t	*ip;				/* current position */
47 wchar_t	*ipflr;				/* buffer floor */
48 wchar_t 	*ipstk[10];			/* stack for "ipflr"s */
49 
50 
51 /* arg collection buffer */
52 wchar_t	*obuf;				/* buffer */
53 wchar_t	*obuflm;			/* high address */
54 wchar_t	*op;				/* current position */
55 
56 
57 /* call stack */
58 struct call	*callst;		/* stack */
59 struct call	*Cp 	= NULL;		/* position */
60 
61 
62 /* token storage */
63 wchar_t	*token;				/* buffer */
64 wchar_t	*toklm;				/* high addr */
65 
66 
67 /* file name and current line storage for line sync and diagnostics */
68 char	*fname[11];			/* file name ptr stack */
69 int	fline[10];			/* current line nbr stack */
70 
71 
72 /* input file stuff for "include"s */
73 FILE	*ifile[10] 	= {stdin};	/* stack */
74 int	ifx;				/* stack index */
75 ibuf_t	ibuffer[11];			/* input buffer */
76 
77 /* stuff for output diversions */
78 FILE	*cf 	= stdout;		/* current output file */
79 FILE	*ofile[11] 	= {stdout};	/* output file stack */
80 int	ofx;				/* stack index */
81 
82 
83 /* comment markers */
84 wchar_t	lcom[MAXSYM+1] 	= L"#";
85 wchar_t	rcom[MAXSYM+1] 	= L"\n";
86 
87 
88 /* quote markers */
89 wchar_t	lquote[MAXSYM+1]  = L"`";
90 wchar_t	rquote[MAXSYM+1]  = L"\'";
91 
92 
93 /* argument ptr stack */
94 wchar_t	**argstk;
95 wchar_t	*astklm;			/* high address */
96 wchar_t	**Ap;				/* current position */
97 
98 
99 /* symbol table */
100 struct nlist	**hshtab;		/* hash table */
101 unsigned int	hshval;			/* last hash val */
102 
103 
104 /* misc */
105 char	*procnam;			/* argv[0] */
106 char	*tempfile;			/* used for diversion files */
107 struct	Wrap *wrapstart = NULL;	/* first entry in of list of "m4wrap" strings */
108 wchar_t	nullstr[] 	= {0};
109 int	nflag 	= 1;			/* name flag, used for line sync code */
110 int	sflag;				/* line sync flag */
111 int	sysrval;			/* return val from syscmd */
112 int	trace;				/* global trace flag */
113 int	exitstat = OK;			/* global exit status */
114 int	wide;				/* multi-byte locale */
115