1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. 24*0Sstevel@tonic-gate * All rights reserved. 25*0Sstevel@tonic-gate * Use is subject to license terms. 26*0Sstevel@tonic-gate */ 27*0Sstevel@tonic-gate 28*0Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */ 29*0Sstevel@tonic-gate /* All Rights Reserved */ 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 32*0Sstevel@tonic-gate 33*0Sstevel@tonic-gate #include "ldefs.c" 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate /* once.c */ 36*0Sstevel@tonic-gate /* because of external definitions, this code should occur only once */ 37*0Sstevel@tonic-gate int ctable[2*NCH] = { 38*0Sstevel@tonic-gate 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 39*0Sstevel@tonic-gate 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 40*0Sstevel@tonic-gate 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 41*0Sstevel@tonic-gate 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 42*0Sstevel@tonic-gate 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 43*0Sstevel@tonic-gate 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 44*0Sstevel@tonic-gate 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 45*0Sstevel@tonic-gate 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 46*0Sstevel@tonic-gate 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 47*0Sstevel@tonic-gate 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 48*0Sstevel@tonic-gate 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 49*0Sstevel@tonic-gate 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 50*0Sstevel@tonic-gate 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 51*0Sstevel@tonic-gate 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 52*0Sstevel@tonic-gate 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 53*0Sstevel@tonic-gate 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 54*0Sstevel@tonic-gate 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 55*0Sstevel@tonic-gate 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 56*0Sstevel@tonic-gate 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 57*0Sstevel@tonic-gate 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 58*0Sstevel@tonic-gate 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 59*0Sstevel@tonic-gate 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 60*0Sstevel@tonic-gate 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 61*0Sstevel@tonic-gate 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 62*0Sstevel@tonic-gate 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 63*0Sstevel@tonic-gate 250, 251, 252, 253, 254, 255 64*0Sstevel@tonic-gate }; 65*0Sstevel@tonic-gate 66*0Sstevel@tonic-gate int ZCH = NCH; 67*0Sstevel@tonic-gate FILE *fout = NULL, *errorf = {stderr}; 68*0Sstevel@tonic-gate int sect = DEFSECTION; 69*0Sstevel@tonic-gate int prev = '\n'; /* previous input character */ 70*0Sstevel@tonic-gate int pres = '\n'; /* present input character */ 71*0Sstevel@tonic-gate int peek = '\n'; /* next input character */ 72*0Sstevel@tonic-gate CHR *pushptr = pushc; 73*0Sstevel@tonic-gate CHR *slptr = slist; 74*0Sstevel@tonic-gate 75*0Sstevel@tonic-gate #ifndef CNAME 76*0Sstevel@tonic-gate #define CNAME "./ncform" 77*0Sstevel@tonic-gate #endif 78*0Sstevel@tonic-gate #ifndef RATNAME 79*0Sstevel@tonic-gate #define RATNAME "./nrform" 80*0Sstevel@tonic-gate #endif 81*0Sstevel@tonic-gate char *cname = CNAME; 82*0Sstevel@tonic-gate char *ratname = RATNAME; 83*0Sstevel@tonic-gate 84*0Sstevel@tonic-gate int ccount = 1; 85*0Sstevel@tonic-gate int casecount = 1; 86*0Sstevel@tonic-gate int aptr = 1; 87*0Sstevel@tonic-gate int nstates = NSTATES, maxpos = MAXPOS; 88*0Sstevel@tonic-gate int treesize = TREESIZE, ntrans = NTRANS; 89*0Sstevel@tonic-gate int yytop; 90*0Sstevel@tonic-gate int outsize = NOUTPUT; 91*0Sstevel@tonic-gate int sptr = 1; 92*0Sstevel@tonic-gate int optim = TRUE; 93*0Sstevel@tonic-gate int report = 2; 94*0Sstevel@tonic-gate int debug; /* 1 = on */ 95*0Sstevel@tonic-gate int charc; 96*0Sstevel@tonic-gate char *v_stmp = "n"; 97*0Sstevel@tonic-gate int no_input; 98*0Sstevel@tonic-gate int copy_line; 99*0Sstevel@tonic-gate int n_error = 0; 100*0Sstevel@tonic-gate int fatal = 1; 101*0Sstevel@tonic-gate int sargc; 102*0Sstevel@tonic-gate char **sargv; 103*0Sstevel@tonic-gate CHR buf[BUF_SIZ]; 104*0Sstevel@tonic-gate int ratfor; /* 1 = ratfor, 0 = C */ 105*0Sstevel@tonic-gate int yyline; /* line number of file */ 106*0Sstevel@tonic-gate int eof; 107*0Sstevel@tonic-gate int lgatflg; 108*0Sstevel@tonic-gate int divflg; 109*0Sstevel@tonic-gate int funcflag; 110*0Sstevel@tonic-gate int pflag; 111*0Sstevel@tonic-gate int chset; /* 1 = char set modified */ 112*0Sstevel@tonic-gate FILE *fin, *fother; 113*0Sstevel@tonic-gate int fptr; 114*0Sstevel@tonic-gate int *name; 115*0Sstevel@tonic-gate int *left; 116*0Sstevel@tonic-gate int *right; 117*0Sstevel@tonic-gate int *parent; 118*0Sstevel@tonic-gate Boolean *nullstr; 119*0Sstevel@tonic-gate int tptr; 120*0Sstevel@tonic-gate CHR pushc[TOKENSIZE]; 121*0Sstevel@tonic-gate CHR slist[STARTSIZE]; 122*0Sstevel@tonic-gate CHR **def, **subs, *dchar; 123*0Sstevel@tonic-gate /* XCU4: %x exclusive start */ 124*0Sstevel@tonic-gate int *exclusive; 125*0Sstevel@tonic-gate CHR **sname, *schar; 126*0Sstevel@tonic-gate CHR *ccl; 127*0Sstevel@tonic-gate CHR *ccptr; 128*0Sstevel@tonic-gate CHR *dp, *sp; 129*0Sstevel@tonic-gate int dptr; 130*0Sstevel@tonic-gate CHR *bptr; /* store input position */ 131*0Sstevel@tonic-gate CHR *tmpstat; 132*0Sstevel@tonic-gate int count; 133*0Sstevel@tonic-gate int **foll; 134*0Sstevel@tonic-gate int *nxtpos; 135*0Sstevel@tonic-gate int *positions; 136*0Sstevel@tonic-gate int *gotof; 137*0Sstevel@tonic-gate int *nexts; 138*0Sstevel@tonic-gate CHR *nchar; 139*0Sstevel@tonic-gate int **state; 140*0Sstevel@tonic-gate int *sfall; /* fallback state num */ 141*0Sstevel@tonic-gate Boolean *cpackflg; /* true if state has been character packed */ 142*0Sstevel@tonic-gate int *atable; 143*0Sstevel@tonic-gate int nptr; 144*0Sstevel@tonic-gate Boolean symbol[MAXNCG]; 145*0Sstevel@tonic-gate CHR cindex[MAXNCG]; 146*0Sstevel@tonic-gate int xstate; 147*0Sstevel@tonic-gate int stnum; 148*0Sstevel@tonic-gate CHR match[MAXNCG]; 149*0Sstevel@tonic-gate BYTE extra[NACTIONS]; 150*0Sstevel@tonic-gate CHR *pchar, *pcptr; 151*0Sstevel@tonic-gate int pchlen = TOKENSIZE; 152*0Sstevel@tonic-gate long rcount; 153*0Sstevel@tonic-gate int *verify, *advance, *stoff; 154*0Sstevel@tonic-gate int scon; 155*0Sstevel@tonic-gate CHR *psave; 156*0Sstevel@tonic-gate 157*0Sstevel@tonic-gate Boolean handleeuc = FALSE; 158*0Sstevel@tonic-gate Boolean widecio = FALSE; 159*0Sstevel@tonic-gate 160*0Sstevel@tonic-gate int isArray = 1; /* XCU4: for %array %pointer */ 161