17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*4c56998aSRich Burridge * Common Development and Distribution License (the "License"). 6*4c56998aSRich Burridge * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */ 227c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 237c478bd9Sstevel@tonic-gate 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate /* 26*4c56998aSRich Burridge * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. 277c478bd9Sstevel@tonic-gate */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include "m4.h" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate /* storage params */ 33*4c56998aSRich Burridge int hshsize = DEF_HSHSIZE; /* hash table size (prime) */ 34*4c56998aSRich Burridge int bufsize = DEF_BUFSIZE; /* pushback & arg text buffers */ 35*4c56998aSRich Burridge int stksize = DEF_STKSIZE; /* call stack */ 36*4c56998aSRich Burridge int toksize = DEF_TOKSIZE; /* biggest word ([a-z_][a-z0-9_]*) */ 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate /* pushback buffer */ 407c478bd9Sstevel@tonic-gate wchar_t *ibuf; /* buffer */ 417c478bd9Sstevel@tonic-gate wchar_t *ibuflm; /* highest buffer addr */ 427c478bd9Sstevel@tonic-gate wchar_t *ip; /* current position */ 437c478bd9Sstevel@tonic-gate wchar_t *ipflr; /* buffer floor */ 447c478bd9Sstevel@tonic-gate wchar_t *ipstk[10]; /* stack for "ipflr"s */ 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate /* arg collection buffer */ 487c478bd9Sstevel@tonic-gate wchar_t *obuf; /* buffer */ 497c478bd9Sstevel@tonic-gate wchar_t *obuflm; /* high address */ 507c478bd9Sstevel@tonic-gate wchar_t *op; /* current position */ 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate /* call stack */ 547c478bd9Sstevel@tonic-gate struct call *callst; /* stack */ 557c478bd9Sstevel@tonic-gate struct call *Cp = NULL; /* position */ 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate /* token storage */ 597c478bd9Sstevel@tonic-gate wchar_t *token; /* buffer */ 607c478bd9Sstevel@tonic-gate wchar_t *toklm; /* high addr */ 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate /* file name and current line storage for line sync and diagnostics */ 647c478bd9Sstevel@tonic-gate char *fname[11]; /* file name ptr stack */ 657c478bd9Sstevel@tonic-gate int fline[10]; /* current line nbr stack */ 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate /* input file stuff for "include"s */ 697c478bd9Sstevel@tonic-gate FILE *ifile[10] = {stdin}; /* stack */ 707c478bd9Sstevel@tonic-gate int ifx; /* stack index */ 717c478bd9Sstevel@tonic-gate ibuf_t ibuffer[11]; /* input buffer */ 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate /* stuff for output diversions */ 747c478bd9Sstevel@tonic-gate FILE *cf = stdout; /* current output file */ 757c478bd9Sstevel@tonic-gate FILE *ofile[11] = {stdout}; /* output file stack */ 767c478bd9Sstevel@tonic-gate int ofx; /* stack index */ 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate /* comment markers */ 807c478bd9Sstevel@tonic-gate wchar_t lcom[MAXSYM+1] = L"#"; 817c478bd9Sstevel@tonic-gate wchar_t rcom[MAXSYM+1] = L"\n"; 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate /* quote markers */ 857c478bd9Sstevel@tonic-gate wchar_t lquote[MAXSYM+1] = L"`"; 867c478bd9Sstevel@tonic-gate wchar_t rquote[MAXSYM+1] = L"\'"; 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate /* argument ptr stack */ 907c478bd9Sstevel@tonic-gate wchar_t **argstk; 917c478bd9Sstevel@tonic-gate wchar_t *astklm; /* high address */ 927c478bd9Sstevel@tonic-gate wchar_t **Ap; /* current position */ 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate /* symbol table */ 967c478bd9Sstevel@tonic-gate struct nlist **hshtab; /* hash table */ 977c478bd9Sstevel@tonic-gate unsigned int hshval; /* last hash val */ 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate /* misc */ 1017c478bd9Sstevel@tonic-gate char *procnam; /* argv[0] */ 1027c478bd9Sstevel@tonic-gate char *tempfile; /* used for diversion files */ 1037c478bd9Sstevel@tonic-gate struct Wrap *wrapstart = NULL; /* first entry in of list of "m4wrap" strings */ 1047c478bd9Sstevel@tonic-gate wchar_t nullstr[] = {0}; 1057c478bd9Sstevel@tonic-gate int nflag = 1; /* name flag, used for line sync code */ 1067c478bd9Sstevel@tonic-gate int sflag; /* line sync flag */ 1077c478bd9Sstevel@tonic-gate int sysrval; /* return val from syscmd */ 1087c478bd9Sstevel@tonic-gate int trace; /* global trace flag */ 1097c478bd9Sstevel@tonic-gate int exitstat = OK; /* global exit status */ 1107c478bd9Sstevel@tonic-gate int wide; /* multi-byte locale */ 111