10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*12955Srich.burridge@oracle.com * Common Development and Distribution License (the "License"). 6*12955Srich.burridge@oracle.com * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */ 220Sstevel@tonic-gate /* All Rights Reserved */ 230Sstevel@tonic-gate 240Sstevel@tonic-gate 250Sstevel@tonic-gate /* 26*12955Srich.burridge@oracle.com * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. 270Sstevel@tonic-gate */ 280Sstevel@tonic-gate 29*12955Srich.burridge@oracle.com #ifndef _M4_H 30*12955Srich.burridge@oracle.com #define _M4_H 310Sstevel@tonic-gate 320Sstevel@tonic-gate #include <ctype.h> 330Sstevel@tonic-gate #include <stdio.h> 340Sstevel@tonic-gate #include <stdlib.h> 350Sstevel@tonic-gate #include <string.h> 360Sstevel@tonic-gate #include <locale.h> 370Sstevel@tonic-gate #include <limits.h> 380Sstevel@tonic-gate 390Sstevel@tonic-gate #include <wchar.h> 400Sstevel@tonic-gate #include <wctype.h> 410Sstevel@tonic-gate 420Sstevel@tonic-gate #define EOS ((wchar_t)0) 430Sstevel@tonic-gate #define MAXSYM 5 440Sstevel@tonic-gate #define PUSH 1 450Sstevel@tonic-gate #define NOPUSH 0 460Sstevel@tonic-gate #define OK 0 470Sstevel@tonic-gate #define NOT_OK 1 480Sstevel@tonic-gate 49*12955Srich.burridge@oracle.com /* Used in m4.c and m4ext.c */ 50*12955Srich.burridge@oracle.com #define DEF_HSHSIZE 199 /* default hash table size (prime). */ 51*12955Srich.burridge@oracle.com #define DEF_BUFSIZE 4096 /* default pushback & arg text buffers size */ 52*12955Srich.burridge@oracle.com #define DEF_STKSIZE 100 /* default call stack size */ 53*12955Srich.burridge@oracle.com #define DEF_TOKSIZE 512 /* default token buffer size */ 54*12955Srich.burridge@oracle.com 550Sstevel@tonic-gate #define BUILTIN 0x40000000 560Sstevel@tonic-gate #define INVALID_CHAR 0x80000000 570Sstevel@tonic-gate #define builtin(x) ((x) | BUILTIN) 580Sstevel@tonic-gate #define builtin_idx(x) ((x) & (wchar_t)~BUILTIN) 590Sstevel@tonic-gate #define is_builtin(x) ((x) != WEOF && ((x) & BUILTIN)) 600Sstevel@tonic-gate 610Sstevel@tonic-gate /* 620Sstevel@tonic-gate * Since we have expanded char to wchar_t, large vaule(has BUILTIN set) 630Sstevel@tonic-gate * can be given to the ctype macros. First check BUILTIN, and return 640Sstevel@tonic-gate * FALSE if it was set. EOF/WEOF will be in this case. 650Sstevel@tonic-gate */ 660Sstevel@tonic-gate #define is_alpha(x) (!is_builtin(x) && \ 670Sstevel@tonic-gate (wide ? iswalpha(x) : isalpha(x))) 680Sstevel@tonic-gate #define is_alnum(x) (!is_builtin(x) && \ 690Sstevel@tonic-gate (wide ? iswalnum(x) : isalnum(x))) 700Sstevel@tonic-gate #define is_space(x) (!is_builtin(x) && \ 710Sstevel@tonic-gate (wide ? iswspace(x) : isspace(x))) 720Sstevel@tonic-gate #define is_digit(x) (!is_builtin(x) && iswascii(x) && isdigit(x)) 730Sstevel@tonic-gate 740Sstevel@tonic-gate 750Sstevel@tonic-gate struct bs { 760Sstevel@tonic-gate void (*bfunc)(wchar_t **, int); 770Sstevel@tonic-gate wchar_t *bname; 780Sstevel@tonic-gate }; 790Sstevel@tonic-gate 800Sstevel@tonic-gate struct call { 810Sstevel@tonic-gate wchar_t **argp; 820Sstevel@tonic-gate int plev; 830Sstevel@tonic-gate }; 840Sstevel@tonic-gate 850Sstevel@tonic-gate struct nlist { 860Sstevel@tonic-gate wchar_t *name; 870Sstevel@tonic-gate wchar_t *def; 880Sstevel@tonic-gate char tflag; 890Sstevel@tonic-gate struct nlist *next; 900Sstevel@tonic-gate }; 910Sstevel@tonic-gate 920Sstevel@tonic-gate struct Wrap { 930Sstevel@tonic-gate wchar_t *wrapstr; 940Sstevel@tonic-gate struct Wrap *nxt; 950Sstevel@tonic-gate }; 960Sstevel@tonic-gate 970Sstevel@tonic-gate typedef struct { 980Sstevel@tonic-gate unsigned char buffer[MB_LEN_MAX + 1]; 990Sstevel@tonic-gate char nbytes; 1000Sstevel@tonic-gate } ibuf_t; 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate extern FILE *cf; 1030Sstevel@tonic-gate extern FILE *ifile[]; 1040Sstevel@tonic-gate extern FILE *ofile[]; 1050Sstevel@tonic-gate extern FILE *xfopen(char *, char *); 1060Sstevel@tonic-gate extern wchar_t **Ap; 1070Sstevel@tonic-gate extern wchar_t **argstk; 1080Sstevel@tonic-gate extern wchar_t *astklm; 1090Sstevel@tonic-gate extern void *xmalloc(size_t); 1100Sstevel@tonic-gate extern char *fname[]; 1110Sstevel@tonic-gate extern wchar_t *ibuf; 1120Sstevel@tonic-gate extern wchar_t *ibuflm; 1130Sstevel@tonic-gate extern wchar_t *ip; 1140Sstevel@tonic-gate extern wchar_t *ipflr; 1150Sstevel@tonic-gate extern wchar_t *ipstk[10]; 1160Sstevel@tonic-gate extern wchar_t *obuf; 1170Sstevel@tonic-gate extern wchar_t *obuflm; 1180Sstevel@tonic-gate extern wchar_t *op; 1190Sstevel@tonic-gate extern char *procnam; 1200Sstevel@tonic-gate extern char *tempfile; 1210Sstevel@tonic-gate extern wchar_t *token; 1220Sstevel@tonic-gate extern wchar_t *toklm; 1230Sstevel@tonic-gate extern wchar_t C; 1240Sstevel@tonic-gate extern wchar_t getchr(); 1250Sstevel@tonic-gate extern wchar_t lcom[]; 1260Sstevel@tonic-gate extern wchar_t lquote[]; 1270Sstevel@tonic-gate extern wchar_t nullstr[]; 1280Sstevel@tonic-gate extern wchar_t rcom[]; 1290Sstevel@tonic-gate extern wchar_t rquote[]; 1300Sstevel@tonic-gate extern int bufsize; 1310Sstevel@tonic-gate extern int fline[]; 1320Sstevel@tonic-gate extern int hshsize; 1330Sstevel@tonic-gate extern unsigned int hshval; 1340Sstevel@tonic-gate extern int ifx; 1350Sstevel@tonic-gate extern int nflag; 1360Sstevel@tonic-gate extern int ofx; 1370Sstevel@tonic-gate extern int sflag; 1380Sstevel@tonic-gate extern int stksize; 1390Sstevel@tonic-gate extern int sysrval; 1400Sstevel@tonic-gate extern int toksize; 1410Sstevel@tonic-gate extern int trace; 1420Sstevel@tonic-gate extern int exitstat; 1430Sstevel@tonic-gate extern long ctol(wchar_t *); 1440Sstevel@tonic-gate extern struct bs barray[]; 1450Sstevel@tonic-gate extern struct call *Cp; 1460Sstevel@tonic-gate extern struct call *callst; 1470Sstevel@tonic-gate extern struct nlist **hshtab; 1480Sstevel@tonic-gate extern void install(); 1490Sstevel@tonic-gate extern struct nlist *lookup(); 1500Sstevel@tonic-gate extern struct Wrap *wrapstart; 1510Sstevel@tonic-gate extern int wide; 1520Sstevel@tonic-gate extern ibuf_t ibuffer[]; 1530Sstevel@tonic-gate 1540Sstevel@tonic-gate extern void setfname(char *); 1550Sstevel@tonic-gate extern void pbstr(wchar_t *); 1560Sstevel@tonic-gate extern void pbnum(long); 1570Sstevel@tonic-gate extern void pbnbr(long, int, int); 1580Sstevel@tonic-gate extern void undiv(int, int); 1590Sstevel@tonic-gate extern void delexit(int, int); 1600Sstevel@tonic-gate extern void error(char *); 1610Sstevel@tonic-gate extern int min(int, int); 1620Sstevel@tonic-gate extern void putbak(wchar_t); 1630Sstevel@tonic-gate extern void stkchr(wchar_t); 1640Sstevel@tonic-gate extern void error2(char *, int); 1650Sstevel@tonic-gate 1660Sstevel@tonic-gate extern wchar_t *wstrdup(wchar_t *); 1670Sstevel@tonic-gate extern int wstoi(wchar_t *); 1680Sstevel@tonic-gate extern char *wstr2str(wchar_t *, int); 1690Sstevel@tonic-gate extern wchar_t *str2wstr(char *, int); 1700Sstevel@tonic-gate 1710Sstevel@tonic-gate extern void dodef(wchar_t **, int); 1720Sstevel@tonic-gate extern void doundef(wchar_t **, int); 1730Sstevel@tonic-gate extern int undef(wchar_t *); 1740Sstevel@tonic-gate 1750Sstevel@tonic-gate /* 1760Sstevel@tonic-gate * macros for performance reason. 1770Sstevel@tonic-gate */ 1780Sstevel@tonic-gate #define putbak(c) \ 1790Sstevel@tonic-gate if (ip < ibuflm) \ 1800Sstevel@tonic-gate *ip++ = (c); \ 1810Sstevel@tonic-gate else \ 1820Sstevel@tonic-gate error2(gettext("pushed back more than %d chars"), bufsize) 1830Sstevel@tonic-gate 1840Sstevel@tonic-gate #define stkchr(c) \ 1850Sstevel@tonic-gate if (op < obuflm) \ 1860Sstevel@tonic-gate *op++ = (c); \ 1870Sstevel@tonic-gate else \ 1880Sstevel@tonic-gate error2(gettext("more than %d chars of argument text"), bufsize) 189*12955Srich.burridge@oracle.com 190*12955Srich.burridge@oracle.com #endif /* _M4_H */ 191