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.
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.
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]
21 /* Copyright (c) 1988 AT&T */
22 /* All Rights Reserved */
26 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
30 * Copyright (c) 2011 Gary Mills
47 #define EOS ((wchar_t)0)
54 /* Used in m4.c and m4ext.c */
55 #define DEF_HSHSIZE 199 /* default hash table size (prime). */
56 #define DEF_BUFSIZE 4096 /* default pushback & arg text buffers size */
57 #define DEF_STKSIZE 100 /* default call stack size */
58 #define DEF_TOKSIZE 512 /* default token buffer size */
60 #define BUILTIN 0x40000000
61 #define INVALID_CHAR 0x80000000
62 #define builtin(x) ((x) | BUILTIN)
63 #define builtin_idx(x) ((x) & (wchar_t)~BUILTIN)
64 #define is_builtin(x) ((x) != WEOF && ((x) & BUILTIN))
67 * Since we have expanded char to wchar_t, large vaule(has BUILTIN set)
68 * can be given to the ctype macros. First check BUILTIN, and return
69 * FALSE if it was set. EOF/WEOF will be in this case.
71 #define is_alpha(x) (!is_builtin(x) && \
72 (wide ? iswalpha(x) : isalpha(x)))
73 #define is_alnum(x) (!is_builtin(x) && \
74 (wide ? iswalnum(x) : isalnum(x)))
75 #define is_space(x) (!is_builtin(x) && \
76 (wide ? iswspace(x) : isspace(x)))
77 #define is_digit(x) (!is_builtin(x) && iswascii(x) && isdigit(x))
81 void (*bfunc
)(wchar_t **, int);
103 unsigned char buffer
[MB_LEN_MAX
+ 1];
108 extern FILE *ifile
[];
109 extern FILE *ofile
[];
110 extern FILE *xfopen(char *, char *);
112 extern wchar_t **argstk
;
113 extern wchar_t *astklm
;
114 extern void *xmalloc(size_t);
115 extern char *fname
[];
116 extern wchar_t *ibuf
;
117 extern wchar_t *ibuflm
;
119 extern wchar_t *ipflr
;
120 extern wchar_t *ipstk
[10];
121 extern wchar_t *obuf
;
122 extern wchar_t *obuflm
;
124 extern char *procnam
;
125 extern char *tempfile
;
126 extern wchar_t *token
;
127 extern wchar_t *toklm
;
129 extern wchar_t getchr();
130 extern wchar_t lcom
[];
131 extern wchar_t lquote
[];
132 extern wchar_t nullstr
[];
133 extern wchar_t rcom
[];
134 extern wchar_t rquote
[];
138 extern unsigned int hshval
;
148 extern long ctol(wchar_t *);
149 extern struct bs barray
[];
150 extern struct call
*Cp
;
151 extern struct call
*callst
;
152 extern struct nlist
**hshtab
;
153 extern void install();
154 extern struct nlist
*lookup();
155 extern struct Wrap
*wrapstart
;
157 extern ibuf_t ibuffer
[];
159 extern void setfname(char *);
160 extern void pbstr(wchar_t *);
161 extern void pbnum(long);
162 extern void pbnbr(long, int, int);
163 extern void undiv(int, int);
164 extern void delexit(int, int);
165 extern void error(char *);
166 extern int min(int, int);
167 extern void putbak(wchar_t);
168 extern void stkchr(wchar_t);
169 extern void errorf(char *, char *);
170 extern void error2(char *, int);
172 extern wchar_t *wstrdup(wchar_t *);
173 extern int wstoi(wchar_t *);
174 extern char *wstr2str(wchar_t *, int);
175 extern wchar_t *str2wstr(char *, int);
177 extern void dodef(wchar_t **, int);
178 extern void doundef(wchar_t **, int);
179 extern int undef(wchar_t *);
182 * macros for performance reason.
188 error2(gettext("pushed back more than %d chars"), bufsize)
194 error2(gettext("more than %d chars of argument text"), bufsize)