hbase

heirloom base
git clone git://git.2f30.org/hbase
Log | Files | Refs | README

ldefs.c (6755B)


      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 /*
     23  * Copyright 2005 Sun Microsystems, Inc.
     24  * All rights reserved.
     25  * Use is subject to license terms.
     26  */
     27 
     28 /*	Copyright (c) 1988 AT&T	*/
     29 /*	All Rights Reserved	*/
     30 
     31 /*	from OpenSolaris "ldefs.c	6.16	05/06/08 SMI"	*/
     32 
     33 /*
     34  * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
     35  *
     36  * Sccsid @(#)ldefs.c	1.7 (gritter) 4/14/07
     37  */
     38 
     39 #include <stdio.h>
     40 #include <stdlib.h>
     41 #include <inttypes.h>
     42 
     43 #ifdef	__sun
     44 #include <widec.h>
     45 #endif
     46 #include <wctype.h>
     47 
     48 #define	CHR wchar_t
     49 #define	BYTE char
     50 #define	Boolean char
     51 #define	LONG_WCHAR_T 1
     52 
     53 #define	PP 1
     54 #ifdef u370
     55 #define	CWIDTH 8
     56 #define	CMASK 0377
     57 #define	ASCII 1
     58 #else
     59 
     60 #ifdef unix
     61 #define	CWIDTH 7
     62 #define	CMASK 0177
     63 #define	ASCII 1
     64 #endif
     65 
     66 #ifdef gcos
     67 #define	CWIDTH 9
     68 #define	CMASK 0777
     69 #define	ASCII 1
     70 #endif
     71 
     72 #ifdef ibm
     73 #define	CWIDTH 8
     74 #define	CMASK 0377
     75 #define	EBCDIC 1
     76 #endif
     77 #endif
     78 
     79 #define	NCH 256
     80 #define	TOKENSIZE 10000
     81 #define	DEFSIZE 1000
     82 #define	DEFCHAR 2000
     83 #define	BUF_SIZ 2000
     84 #define	STARTCHAR 2560
     85 #define	STARTSIZE 256
     86 #define	CCLSIZE 20000
     87 
     88 
     89 #ifdef SMALL
     90 #define	TREESIZE 600
     91 #define	NTRANS 1500
     92 #define	NSTATES 300
     93 #define	MAXPOS 1500
     94 #define	MAXPOSSTATE 500
     95 #define	NOUTPUT 1500
     96 #endif
     97 
     98 #ifndef SMALL
     99 #define	TREESIZE 1000
    100 #define	NSTATES 500
    101 #define	MAXPOS 2500
    102 #define	MAXPOSSTATE 4*1000
    103 #define	NTRANS 2000
    104 #define	NOUTPUT 4*3000
    105 #endif
    106 #define	NACTIONS 4*1000
    107 #define	ALITTLEEXTRA 300
    108 
    109 #define	RCCL		0x4000
    110 #define	RNCCL		0x4001
    111 #define	RSTR		0x4002
    112 #define	RSCON		0x4003
    113 /* XCU4: add RXSCON */
    114 #define	RXSCON		0x4011
    115 #define	RNEWE		0x4004
    116 #define	FINAL		0x4005
    117 #define	RNULLS		0x4006
    118 #define	RCAT		0x4007
    119 #define	STAR		0x4008
    120 #define	PLUS		0x4009
    121 #define	QUEST		0x400a
    122 #define	DIV		0x400b
    123 #define	BAR		0x400c
    124 #define	CARAT		0x400d
    125 #define	S1FINAL		0x400e
    126 #define	S2FINAL		0x400f
    127 #define	DOT		0x4010
    128 #define	ISOPERATOR(n)	((n & 0xc080) == 0x4000)
    129 
    130 /*
    131  * New to JLE; this is not really a node tag.
    132  * This is used in a string pointed to by
    133  * the leaf of an RCCL or RNCCL node as a
    134  * special prefix code that substitutes
    135  * the infix '-' range operator.  For
    136  * example, a lex character class "[_0-9a-zA-Z]"
    137  * would be translated to the intermidiate
    138  * form:
    139  *   	RCCL
    140  *	 |
    141  *	 |
    142  *	 v
    143  *       "_<RANGE>09<RANGE>a-z<RANGE>A-Z"
    144  */
    145 #define	RANGE		0x40ff
    146 
    147 #define	MAXNCG 1000
    148 extern int ncgidtbl;
    149 extern int ncg; /* ncg == ncgidtbl * 2 */
    150 typedef unsigned long lchar;
    151 extern lchar yycgidtbl[];
    152 extern int yycgid(wchar_t);
    153 extern Boolean handleeuc; /* TRUE iff -w or -e option is specified. */
    154 extern Boolean widecio; /* TRUE iff -w option is specified. */
    155 
    156 #define	DEFSECTION 1
    157 #define	RULESECTION 2
    158 #define	ENDSECTION 5
    159 
    160 #define	PC 1
    161 #define	PS 1
    162 
    163 #ifdef DEBUG
    164 #define	LINESIZE 110
    165 extern int yydebug;
    166 extern int debug;		/* 1 = on */
    167 extern int charc;
    168 #endif
    169 
    170 #ifndef DEBUG
    171 #define	freturn(s) s
    172 #endif
    173 
    174 #undef	FALSE
    175 #undef	TRUE
    176 enum {
    177 	FALSE,
    178 	TRUE
    179 };
    180 
    181 
    182 extern int optind;
    183 extern int no_input;
    184 extern int sargc;
    185 extern char **sargv;
    186 extern char *v_stmp;
    187 extern char *release_string;
    188 extern CHR buf[];
    189 extern int ratfor;		/* 1 = ratfor, 0 = C */
    190 extern int fatal;
    191 extern int n_error;
    192 extern int copy_line;
    193 extern int yyline;		/* line number of file */
    194 extern int sect;
    195 extern int eof;
    196 extern int lgatflg;
    197 extern int divflg;
    198 extern int funcflag;
    199 extern int pflag;
    200 extern int casecount;
    201 extern int chset;	/* 1 = CHR set modified */
    202 extern FILE *fin, *fout, *fother, *errorf;
    203 extern int fptr;
    204 extern char *ratname, *cname;
    205 extern int prev;	/* previous input character */
    206 extern int pres;	/* present input character */
    207 extern int peek;	/* next input character */
    208 extern int *name;
    209 extern intptr_t *left;
    210 extern intptr_t *right;
    211 extern int *parent;
    212 extern Boolean *nullstr;
    213 extern int tptr;
    214 extern CHR pushc[TOKENSIZE];
    215 extern CHR *pushptr;
    216 extern CHR slist[STARTSIZE];
    217 extern CHR *slptr;
    218 extern CHR **def, **subs, *dchar;
    219 extern CHR **sname, *schar;
    220 /* XCU4: %x exclusive start */
    221 extern int *exclusive;
    222 extern CHR *ccl;
    223 extern CHR *ccptr;
    224 extern CHR *dp, *sp;
    225 extern int dptr, sptr;
    226 extern CHR *bptr;		/* store input position */
    227 extern CHR *tmpstat;
    228 extern int count;
    229 extern int **foll;
    230 extern int *nxtpos;
    231 extern int *positions;
    232 extern int *gotof;
    233 extern int *nexts;
    234 extern CHR *nchar;
    235 extern int **state;
    236 extern int *sfall;		/* fallback state num */
    237 extern Boolean *cpackflg;	/* true if state has been character packed */
    238 extern int *atable, aptr;
    239 extern int nptr;
    240 extern Boolean symbol[MAXNCG];
    241 extern CHR cindex[MAXNCG];
    242 extern int xstate;
    243 extern int stnum;
    244 extern int ctable[];
    245 extern int ZCH;
    246 extern int ccount;
    247 extern CHR match[MAXNCG];
    248 extern BYTE extra[];
    249 extern CHR *pcptr, *pchar;
    250 extern int pchlen;
    251 extern int nstates, maxpos;
    252 extern int yytop;
    253 extern int report;
    254 extern int ntrans, treesize, outsize;
    255 extern long rcount;
    256 extern int optim;
    257 extern int *verify, *advance, *stoff;
    258 extern int scon;
    259 extern CHR *psave;
    260 extern CHR *getl(CHR *);
    261 extern void *myalloc(int, int);
    262 
    263 void phead1(void);
    264 void phead2(void);
    265 void ptail(void);
    266 void statistics(void);
    267 void error_tail(void);
    268 void error(const char *, ...);
    269 void warning(const char *, ...);
    270 void lgate(void);
    271 void scopy(CHR *s, CHR *t);
    272 void cclinter(int sw);
    273 void cpycom(CHR *p);
    274 void munput(int t, CHR *p);
    275 void cfoll(int v);
    276 void cgoto(void);
    277 void mkmatch(void);
    278 void layout(void);
    279 void remch(wchar_t c);
    280 void sortcgidtbl(void);
    281 void repbycgid(void);
    282 int gch(void);
    283 int slength(CHR *s);
    284 int yyparse(void);
    285 int scomp(CHR *x, CHR *y);
    286 int space(int ch);
    287 int siconv(CHR *t);
    288 int digit(int c);
    289 int ctrans(CHR **ss);
    290 int cpyact(void);
    291 int lookup(CHR *s, CHR **t);
    292 int usescape(int c);
    293 int alpha(int c);
    294 int mn2(int a, intptr_t d, intptr_t c);
    295 int mn1(int a, intptr_t d);
    296 int mn0(int a);
    297 int dupl(int n);
    298 
    299 #undef	getwc
    300 #define	getwc(f)	lex_getwc(f)
    301 extern wint_t lex_getwc(FILE *);
    302 #undef	putwc
    303 #define	putwc(c, f)	lex_putwc(c, f)
    304 extern wint_t lex_putwc(wchar_t, FILE *);
    305 
    306 #undef	index
    307 #define	index		lex_index
    308 
    309 extern int isArray;		/* XCU4: for %array %pointer */