xref: /titanic_50/usr/src/cmd/sgs/lex/common/nceucform (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate/*
2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate *
4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate * with the License.
8*7c478bd9Sstevel@tonic-gate *
9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate *
14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate *
20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate */
22*7c478bd9Sstevel@tonic-gate/*
23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate * All rights reserved.
25*7c478bd9Sstevel@tonic-gate * Use is subject to license terms.
26*7c478bd9Sstevel@tonic-gate */
27*7c478bd9Sstevel@tonic-gate
28*7c478bd9Sstevel@tonic-gate/*	Copyright (c) 1989 AT&T	*/
29*7c478bd9Sstevel@tonic-gate/*	  All Rights Reserved  	*/
30*7c478bd9Sstevel@tonic-gate
31*7c478bd9Sstevel@tonic-gate
32*7c478bd9Sstevel@tonic-gate#pragma ident	"%Z%%M%	%I%	%E% SMI"
33*7c478bd9Sstevel@tonic-gate
34*7c478bd9Sstevel@tonic-gateint yylineno =1;
35*7c478bd9Sstevel@tonic-gateint yygid;
36*7c478bd9Sstevel@tonic-gate#define LONG_WCHAR_T 1
37*7c478bd9Sstevel@tonic-gate# define YYU(x) x
38*7c478bd9Sstevel@tonic-gate# define NLSTATE yyprevious=YYNEWLINE
39*7c478bd9Sstevel@tonic-gatewchar_t yysbuf[YYLMAX];
40*7c478bd9Sstevel@tonic-gatewchar_t *yysptr = yysbuf;
41*7c478bd9Sstevel@tonic-gatestruct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
42*7c478bd9Sstevel@tonic-gateint *yyfnd;
43*7c478bd9Sstevel@tonic-gateextern struct yysvf *yyestate;
44*7c478bd9Sstevel@tonic-gateint yyprevious = YYNEWLINE;
45*7c478bd9Sstevel@tonic-gate#if defined(__cplusplus) || defined(__STDC__)
46*7c478bd9Sstevel@tonic-gateint yylook(void)
47*7c478bd9Sstevel@tonic-gate#else
48*7c478bd9Sstevel@tonic-gateyylook()
49*7c478bd9Sstevel@tonic-gate#endif
50*7c478bd9Sstevel@tonic-gate{
51*7c478bd9Sstevel@tonic-gate	struct yysvf *yystate, **lsp;
52*7c478bd9Sstevel@tonic-gate	struct yywork *yyt;
53*7c478bd9Sstevel@tonic-gate	struct yysvf *yyz;
54*7c478bd9Sstevel@tonic-gate	int yych, yyfirst;
55*7c478bd9Sstevel@tonic-gate	struct yywork *yyr;
56*7c478bd9Sstevel@tonic-gate# ifdef LEXDEBUG
57*7c478bd9Sstevel@tonic-gate	int debug;
58*7c478bd9Sstevel@tonic-gate# endif
59*7c478bd9Sstevel@tonic-gate	wchar_t *yylastch;
60*7c478bd9Sstevel@tonic-gate	/* start off machines */
61*7c478bd9Sstevel@tonic-gate# ifdef LEXDEBUG
62*7c478bd9Sstevel@tonic-gate	debug = 0;
63*7c478bd9Sstevel@tonic-gate# endif
64*7c478bd9Sstevel@tonic-gate	yyfirst=1;
65*7c478bd9Sstevel@tonic-gate	if (!yymorfg)
66*7c478bd9Sstevel@tonic-gate		yylastch = YYTEXT;
67*7c478bd9Sstevel@tonic-gate	else {
68*7c478bd9Sstevel@tonic-gate		yymorfg=0;
69*7c478bd9Sstevel@tonic-gate		yylastch = YYTEXT+YYLENG;
70*7c478bd9Sstevel@tonic-gate		}
71*7c478bd9Sstevel@tonic-gate	for(;;){
72*7c478bd9Sstevel@tonic-gate		lsp = yylstate;
73*7c478bd9Sstevel@tonic-gate		yyestate = yystate = yybgin;
74*7c478bd9Sstevel@tonic-gate		if (yyprevious==YYNEWLINE) yystate++;
75*7c478bd9Sstevel@tonic-gate		for (;;){
76*7c478bd9Sstevel@tonic-gate# ifdef LEXDEBUG
77*7c478bd9Sstevel@tonic-gate			if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
78*7c478bd9Sstevel@tonic-gate# endif
79*7c478bd9Sstevel@tonic-gate			yyt = yystate->yystoff;
80*7c478bd9Sstevel@tonic-gate			if(yyt == yycrank && !yyfirst){  /* may not be any transitions */
81*7c478bd9Sstevel@tonic-gate				yyz = yystate->yyother;
82*7c478bd9Sstevel@tonic-gate				if(yyz == 0)break;
83*7c478bd9Sstevel@tonic-gate				if(yyz->yystoff == yycrank)break;
84*7c478bd9Sstevel@tonic-gate				}
85*7c478bd9Sstevel@tonic-gate			*yylastch++ = yych = YYINPUT();
86*7c478bd9Sstevel@tonic-gate#ifdef YYISARRAY
87*7c478bd9Sstevel@tonic-gate			if(yylastch > &YYTEXT[YYLMAX]) {
88*7c478bd9Sstevel@tonic-gate				fprintf(yyout,"Input string too long, limit %d\n",YYLMAX);
89*7c478bd9Sstevel@tonic-gate				exit(1);
90*7c478bd9Sstevel@tonic-gate			}
91*7c478bd9Sstevel@tonic-gate#else
92*7c478bd9Sstevel@tonic-gate			if (yylastch >= &YYTEXT[ yytextsz ]) {
93*7c478bd9Sstevel@tonic-gate				int	x = yylastch - YYTEXT;
94*7c478bd9Sstevel@tonic-gate
95*7c478bd9Sstevel@tonic-gate				yytextsz += YYTEXTSZINC;
96*7c478bd9Sstevel@tonic-gate#ifdef YYLEX_E /* -e */
97*7c478bd9Sstevel@tonic-gate				if (YYTEXT == yy_twbuf) {
98*7c478bd9Sstevel@tonic-gate					YYTEXT = (wchar_t *)
99*7c478bd9Sstevel@tonic-gate						malloc(yytextsz *
100*7c478bd9Sstevel@tonic-gate							sizeof (wchar_t));
101*7c478bd9Sstevel@tonic-gate					memcpy(YYTEXT, yy_twbuf,
102*7c478bd9Sstevel@tonic-gate						sizeof (yy_twbuf));
103*7c478bd9Sstevel@tonic-gate					yytext = (wchar_t *)
104*7c478bd9Sstevel@tonic-gate						malloc(yytextsz *
105*7c478bd9Sstevel@tonic-gate							sizeof (wchar_t));
106*7c478bd9Sstevel@tonic-gate					memcpy(yytext, yy_tbuf,
107*7c478bd9Sstevel@tonic-gate						sizeof (yy_tbuf));
108*7c478bd9Sstevel@tonic-gate#else
109*7c478bd9Sstevel@tonic-gate				if (YYTEXT == yy_tbuf) {
110*7c478bd9Sstevel@tonic-gate					YYTEXT = (wchar_t *)
111*7c478bd9Sstevel@tonic-gate						malloc(yytextsz *
112*7c478bd9Sstevel@tonic-gate							sizeof (wchar_t));
113*7c478bd9Sstevel@tonic-gate					memcpy(YYTEXT, yy_tbuf,
114*7c478bd9Sstevel@tonic-gate						sizeof (yy_tbuf));
115*7c478bd9Sstevel@tonic-gate#endif
116*7c478bd9Sstevel@tonic-gate				}
117*7c478bd9Sstevel@tonic-gate				else {
118*7c478bd9Sstevel@tonic-gate					YYTEXT = (wchar_t *)
119*7c478bd9Sstevel@tonic-gate						realloc(YYTEXT, yytextsz);
120*7c478bd9Sstevel@tonic-gate#ifdef YYLEX_E /* -e */
121*7c478bd9Sstevel@tonic-gate					yytext = (wchar_t *)
122*7c478bd9Sstevel@tonic-gate						realloc(yytext,
123*7c478bd9Sstevel@tonic-gate						yytextsz * sizeof (wchar_t));
124*7c478bd9Sstevel@tonic-gate#endif
125*7c478bd9Sstevel@tonic-gate				}
126*7c478bd9Sstevel@tonic-gate				if (!YYTEXT) {
127*7c478bd9Sstevel@tonic-gate					fprintf(yyout,
128*7c478bd9Sstevel@tonic-gate					"Cannot realloc YYTEXT\n");
129*7c478bd9Sstevel@tonic-gate					exit(1);
130*7c478bd9Sstevel@tonic-gate				}
131*7c478bd9Sstevel@tonic-gate				yylastch = YYTEXT + x;
132*7c478bd9Sstevel@tonic-gate			}
133*7c478bd9Sstevel@tonic-gate#endif
134*7c478bd9Sstevel@tonic-gate			yygid = yycgid(yych);
135*7c478bd9Sstevel@tonic-gate			yyfirst=0;
136*7c478bd9Sstevel@tonic-gate		tryagain:
137*7c478bd9Sstevel@tonic-gate# ifdef LEXDEBUG
138*7c478bd9Sstevel@tonic-gate			if(debug){
139*7c478bd9Sstevel@tonic-gate				fprintf(yyout,"wchar_t ");
140*7c478bd9Sstevel@tonic-gate				allprint(yych);
141*7c478bd9Sstevel@tonic-gate				fprintf(yyout," gid %d\n", yygid);
142*7c478bd9Sstevel@tonic-gate				}
143*7c478bd9Sstevel@tonic-gate# endif
144*7c478bd9Sstevel@tonic-gate			yyr = yyt;
145*7c478bd9Sstevel@tonic-gate			if ( (uintptr_t)yyt > (uintptr_t)yycrank){
146*7c478bd9Sstevel@tonic-gate				yyt = yyr + yygid;
147*7c478bd9Sstevel@tonic-gate				if (yyt <= yytop && yyt->verify+yysvec == yystate){
148*7c478bd9Sstevel@tonic-gate					if(yyt->advance+yysvec == YYLERR)	/* error transitions */
149*7c478bd9Sstevel@tonic-gate						{YYUNPUT(*--yylastch);break;}
150*7c478bd9Sstevel@tonic-gate					*lsp++ = yystate = yyt->advance+yysvec;
151*7c478bd9Sstevel@tonic-gate					if(lsp > &yylstate[YYLMAX]) {
152*7c478bd9Sstevel@tonic-gate						fprintf(yyout,"Input string too long, limit %d\n",YYLMAX);
153*7c478bd9Sstevel@tonic-gate						exit(1);
154*7c478bd9Sstevel@tonic-gate					}
155*7c478bd9Sstevel@tonic-gate					goto contin;
156*7c478bd9Sstevel@tonic-gate					}
157*7c478bd9Sstevel@tonic-gate				}
158*7c478bd9Sstevel@tonic-gate# ifdef YYOPTIM
159*7c478bd9Sstevel@tonic-gate			else if((uintptr_t)yyt < (uintptr_t)yycrank) {	/* r < yycrank */
160*7c478bd9Sstevel@tonic-gate				yyt = yyr = yycrank+(yycrank-yyt);
161*7c478bd9Sstevel@tonic-gate# ifdef LEXDEBUG
162*7c478bd9Sstevel@tonic-gate				if(debug)fprintf(yyout,"compressed state\n");
163*7c478bd9Sstevel@tonic-gate# endif
164*7c478bd9Sstevel@tonic-gate				yyt = yyt + yygid;
165*7c478bd9Sstevel@tonic-gate				if(yyt <= yytop && yyt->verify+yysvec == yystate){
166*7c478bd9Sstevel@tonic-gate					if(yyt->advance+yysvec == YYLERR)	/* error transitions */
167*7c478bd9Sstevel@tonic-gate						{YYUNPUT(*--yylastch);break;}
168*7c478bd9Sstevel@tonic-gate					*lsp++ = yystate = yyt->advance+yysvec;
169*7c478bd9Sstevel@tonic-gate					if(lsp > &yylstate[YYLMAX]) {
170*7c478bd9Sstevel@tonic-gate						fprintf(yyout,"Input string too long, limit %d\n",YYLMAX);
171*7c478bd9Sstevel@tonic-gate						exit(1);
172*7c478bd9Sstevel@tonic-gate					}
173*7c478bd9Sstevel@tonic-gate					goto contin;
174*7c478bd9Sstevel@tonic-gate					}
175*7c478bd9Sstevel@tonic-gate				yyt = yyr + YYU(yymatch[yygid]);
176*7c478bd9Sstevel@tonic-gate# ifdef LEXDEBUG
177*7c478bd9Sstevel@tonic-gate				if(debug){
178*7c478bd9Sstevel@tonic-gate					fprintf(yyout,"try fall back character ");
179*7c478bd9Sstevel@tonic-gate					allprint_w(YYU(yymatch[yygid]));
180*7c478bd9Sstevel@tonic-gate					fprintf(yyout," gid %d\n", yygid);
181*7c478bd9Sstevel@tonic-gate					}
182*7c478bd9Sstevel@tonic-gate# endif
183*7c478bd9Sstevel@tonic-gate				if(yyt <= yytop && yyt->verify+yysvec == yystate){
184*7c478bd9Sstevel@tonic-gate					if(yyt->advance+yysvec == YYLERR)	/* error transition */
185*7c478bd9Sstevel@tonic-gate						{YYUNPUT(*--yylastch);break;}
186*7c478bd9Sstevel@tonic-gate					*lsp++ = yystate = yyt->advance+yysvec;
187*7c478bd9Sstevel@tonic-gate					if(lsp > &yylstate[YYLMAX]) {
188*7c478bd9Sstevel@tonic-gate						fprintf(yyout,"Input string too long, limit %d\n",YYLMAX);
189*7c478bd9Sstevel@tonic-gate						exit(1);
190*7c478bd9Sstevel@tonic-gate					}
191*7c478bd9Sstevel@tonic-gate					goto contin;
192*7c478bd9Sstevel@tonic-gate					}
193*7c478bd9Sstevel@tonic-gate				}
194*7c478bd9Sstevel@tonic-gate			if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){
195*7c478bd9Sstevel@tonic-gate# ifdef LEXDEBUG
196*7c478bd9Sstevel@tonic-gate				if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1);
197*7c478bd9Sstevel@tonic-gate# endif
198*7c478bd9Sstevel@tonic-gate				goto tryagain;
199*7c478bd9Sstevel@tonic-gate				}
200*7c478bd9Sstevel@tonic-gate# endif
201*7c478bd9Sstevel@tonic-gate			else
202*7c478bd9Sstevel@tonic-gate				{YYUNPUT(*--yylastch);break;}
203*7c478bd9Sstevel@tonic-gate		contin:
204*7c478bd9Sstevel@tonic-gate# ifdef LEXDEBUG
205*7c478bd9Sstevel@tonic-gate			if(debug){
206*7c478bd9Sstevel@tonic-gate				fprintf(yyout,"state %d wchar_t ",yystate-yysvec-1);
207*7c478bd9Sstevel@tonic-gate				allprint_w(yych);
208*7c478bd9Sstevel@tonic-gate				fprintf(yyout," gid %d\n", yygid);
209*7c478bd9Sstevel@tonic-gate				}
210*7c478bd9Sstevel@tonic-gate# endif
211*7c478bd9Sstevel@tonic-gate			;
212*7c478bd9Sstevel@tonic-gate			}
213*7c478bd9Sstevel@tonic-gate# ifdef LEXDEBUG
214*7c478bd9Sstevel@tonic-gate		if(debug){
215*7c478bd9Sstevel@tonic-gate			fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1);
216*7c478bd9Sstevel@tonic-gate			allprint_w(yych);
217*7c478bd9Sstevel@tonic-gate			fprintf(yyout," gid %d\n", yygid);
218*7c478bd9Sstevel@tonic-gate			}
219*7c478bd9Sstevel@tonic-gate# endif
220*7c478bd9Sstevel@tonic-gate		while (lsp-- > yylstate){
221*7c478bd9Sstevel@tonic-gate			*yylastch-- = 0;
222*7c478bd9Sstevel@tonic-gate			if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){
223*7c478bd9Sstevel@tonic-gate				yyolsp = lsp;
224*7c478bd9Sstevel@tonic-gate				if(yyextra[*yyfnd]){		/* must backup */
225*7c478bd9Sstevel@tonic-gate					while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){
226*7c478bd9Sstevel@tonic-gate						lsp--;
227*7c478bd9Sstevel@tonic-gate						YYUNPUT(*yylastch--);
228*7c478bd9Sstevel@tonic-gate						}
229*7c478bd9Sstevel@tonic-gate					}
230*7c478bd9Sstevel@tonic-gate				yyprevious = YYU(*yylastch);
231*7c478bd9Sstevel@tonic-gate				yylsp = lsp;
232*7c478bd9Sstevel@tonic-gate				YYLENG = yylastch-YYTEXT+1;
233*7c478bd9Sstevel@tonic-gate				YYTEXT[YYLENG] = 0;
234*7c478bd9Sstevel@tonic-gate# ifdef LEXDEBUG
235*7c478bd9Sstevel@tonic-gate				if(debug){
236*7c478bd9Sstevel@tonic-gate					fprintf(yyout,"\nmatch ");
237*7c478bd9Sstevel@tonic-gate					sprint_w(YYTEXT);
238*7c478bd9Sstevel@tonic-gate					fprintf(yyout," action %d\n",*yyfnd);
239*7c478bd9Sstevel@tonic-gate					}
240*7c478bd9Sstevel@tonic-gate# endif
241*7c478bd9Sstevel@tonic-gate#ifdef YYLEX_E /* -e */
242*7c478bd9Sstevel@tonic-gate				yyleng=wcstombs((char *)yytext, YYTEXT, sizeof(yytext)-1);
243*7c478bd9Sstevel@tonic-gate#ifdef LEXDEBUG
244*7c478bd9Sstevel@tonic-gate				if(yyleng>=sizeof(yytext)-1)
245*7c478bd9Sstevel@tonic-gate					fprintf(yyout, "yytext[] too short\n");
246*7c478bd9Sstevel@tonic-gate#endif
247*7c478bd9Sstevel@tonic-gate#endif
248*7c478bd9Sstevel@tonic-gate				return(*yyfnd++);
249*7c478bd9Sstevel@tonic-gate				}
250*7c478bd9Sstevel@tonic-gate			YYUNPUT(*yylastch);
251*7c478bd9Sstevel@tonic-gate			}
252*7c478bd9Sstevel@tonic-gate		if (YYTEXT[0] == 0  /* && feof(yyin) */)
253*7c478bd9Sstevel@tonic-gate			{
254*7c478bd9Sstevel@tonic-gate			yysptr=yysbuf;
255*7c478bd9Sstevel@tonic-gate			return(0);
256*7c478bd9Sstevel@tonic-gate			}
257*7c478bd9Sstevel@tonic-gate		yyprevious = YYTEXT[0] = YYINPUT();
258*7c478bd9Sstevel@tonic-gate		if (yyprevious>0)
259*7c478bd9Sstevel@tonic-gate			YYOUTPUT(yyprevious);
260*7c478bd9Sstevel@tonic-gate		yylastch=YYTEXT;
261*7c478bd9Sstevel@tonic-gate# ifdef LEXDEBUG
262*7c478bd9Sstevel@tonic-gate		if(debug)putchar('\n');
263*7c478bd9Sstevel@tonic-gate# endif
264*7c478bd9Sstevel@tonic-gate		}
265*7c478bd9Sstevel@tonic-gate	}
266*7c478bd9Sstevel@tonic-gateint
267*7c478bd9Sstevel@tonic-gate#if defined(__cplusplus) || defined(__STDC__)
268*7c478bd9Sstevel@tonic-gateyyback(int *p, int m)
269*7c478bd9Sstevel@tonic-gate#else
270*7c478bd9Sstevel@tonic-gateyyback(p, m)
271*7c478bd9Sstevel@tonic-gate	int *p;
272*7c478bd9Sstevel@tonic-gate	int m;
273*7c478bd9Sstevel@tonic-gate#endif
274*7c478bd9Sstevel@tonic-gate{
275*7c478bd9Sstevel@tonic-gate	if (p==0) return(0);
276*7c478bd9Sstevel@tonic-gate	while (*p) {
277*7c478bd9Sstevel@tonic-gate		if (*p++ == m)
278*7c478bd9Sstevel@tonic-gate			return(1);
279*7c478bd9Sstevel@tonic-gate	}
280*7c478bd9Sstevel@tonic-gate	return(0);
281*7c478bd9Sstevel@tonic-gate}
282*7c478bd9Sstevel@tonic-gate
283*7c478bd9Sstevel@tonic-gate#ifdef YYLEX_E /* -e */
284*7c478bd9Sstevel@tonic-gatewchar_t
285*7c478bd9Sstevel@tonic-gate#if defined(__cplusplus) || defined(__STDC__)
286*7c478bd9Sstevel@tonic-gateyywinput(void){
287*7c478bd9Sstevel@tonic-gate#else
288*7c478bd9Sstevel@tonic-gateyywinput(){
289*7c478bd9Sstevel@tonic-gate#endif
290*7c478bd9Sstevel@tonic-gate	unsigned char eucbuf[MB_LEN_MAX];
291*7c478bd9Sstevel@tonic-gate	wchar_t wc;
292*7c478bd9Sstevel@tonic-gate	unsigned char *p=eucbuf;
293*7c478bd9Sstevel@tonic-gate	int n;
294*7c478bd9Sstevel@tonic-gate
295*7c478bd9Sstevel@tonic-gate#ifndef __cplusplus
296*7c478bd9Sstevel@tonic-gate	*p++=input();
297*7c478bd9Sstevel@tonic-gate	n=euclen(eucbuf);
298*7c478bd9Sstevel@tonic-gate	while(--n>0) *p++=input();
299*7c478bd9Sstevel@tonic-gate#else
300*7c478bd9Sstevel@tonic-gate	*p++=lex_input();
301*7c478bd9Sstevel@tonic-gate	n=euclen(eucbuf);
302*7c478bd9Sstevel@tonic-gate	while(--n>0) *p++=lex_input();
303*7c478bd9Sstevel@tonic-gate#endif
304*7c478bd9Sstevel@tonic-gate	*p=0;
305*7c478bd9Sstevel@tonic-gate
306*7c478bd9Sstevel@tonic-gate	mbtowc( &wc, (char *)eucbuf, MB_LEN_MAX );
307*7c478bd9Sstevel@tonic-gate	return wc;
308*7c478bd9Sstevel@tonic-gate}
309*7c478bd9Sstevel@tonic-gate
310*7c478bd9Sstevel@tonic-gate#if defined(__cplusplus) || defined(__STDC__)
311*7c478bd9Sstevel@tonic-gatevoid
312*7c478bd9Sstevel@tonic-gateyywoutput(wchar_t wc)
313*7c478bd9Sstevel@tonic-gate#else
314*7c478bd9Sstevel@tonic-gateyywoutput(wc)
315*7c478bd9Sstevel@tonic-gate	wchar_t wc;
316*7c478bd9Sstevel@tonic-gate#endif
317*7c478bd9Sstevel@tonic-gate{
318*7c478bd9Sstevel@tonic-gate	unsigned char eucbuf[MB_LEN_MAX];
319*7c478bd9Sstevel@tonic-gate	int n;
320*7c478bd9Sstevel@tonic-gate	unsigned char *p=eucbuf;
321*7c478bd9Sstevel@tonic-gate
322*7c478bd9Sstevel@tonic-gate	n=wctomb( (char *)eucbuf, wc );
323*7c478bd9Sstevel@tonic-gate#ifndef __cplusplus
324*7c478bd9Sstevel@tonic-gate	while(n-->0) output(*p++);
325*7c478bd9Sstevel@tonic-gate#else
326*7c478bd9Sstevel@tonic-gate	while(n-->0) lex_output(*p++);
327*7c478bd9Sstevel@tonic-gate#endif
328*7c478bd9Sstevel@tonic-gate}
329*7c478bd9Sstevel@tonic-gate
330*7c478bd9Sstevel@tonic-gate#if defined(__cplusplus) || defined(__STDC__)
331*7c478bd9Sstevel@tonic-gatevoid
332*7c478bd9Sstevel@tonic-gateyywunput(wchar_t wc)
333*7c478bd9Sstevel@tonic-gate#else
334*7c478bd9Sstevel@tonic-gateyywunput(wc)
335*7c478bd9Sstevel@tonic-gate	wchar_t wc;
336*7c478bd9Sstevel@tonic-gate#endif
337*7c478bd9Sstevel@tonic-gate{
338*7c478bd9Sstevel@tonic-gate	unsigned char eucbuf[MB_LEN_MAX];
339*7c478bd9Sstevel@tonic-gate	int n;
340*7c478bd9Sstevel@tonic-gate	unsigned char *p;
341*7c478bd9Sstevel@tonic-gate
342*7c478bd9Sstevel@tonic-gate	n=wctomb( (char *)eucbuf, wc );
343*7c478bd9Sstevel@tonic-gate	p=eucbuf+n;
344*7c478bd9Sstevel@tonic-gate	while(n-->0) unput(*--p);
345*7c478bd9Sstevel@tonic-gate}
346*7c478bd9Sstevel@tonic-gate#endif
347*7c478bd9Sstevel@tonic-gate
348*7c478bd9Sstevel@tonic-gate#ifdef LONG_WCHAR_T
349*7c478bd9Sstevel@tonic-gate#define yylinearize(lc) lc
350*7c478bd9Sstevel@tonic-gate#else/*!LONG_WCHAR_T*/
351*7c478bd9Sstevel@tonic-gateunsigned long
352*7c478bd9Sstevel@tonic-gateyylinearize(wc)
353*7c478bd9Sstevel@tonic-gate     wchar_t    wc;
354*7c478bd9Sstevel@tonic-gate{
355*7c478bd9Sstevel@tonic-gate	unsigned long   prefix;
356*7c478bd9Sstevel@tonic-gate	switch(wc&0x8080){
357*7c478bd9Sstevel@tonic-gate	      case 0x0000:      prefix=0x00000000; break;
358*7c478bd9Sstevel@tonic-gate	      case 0x0080:      prefix=0x20000000; break;
359*7c478bd9Sstevel@tonic-gate	      case 0x8000:      prefix=0x40000000; break;
360*7c478bd9Sstevel@tonic-gate	      case 0x8080:      prefix=0x60000000; break;
361*7c478bd9Sstevel@tonic-gate	}
362*7c478bd9Sstevel@tonic-gate	return prefix|wc;
363*7c478bd9Sstevel@tonic-gate}
364*7c478bd9Sstevel@tonic-gate#endif/*!LONG_WCHAR_T*/
365*7c478bd9Sstevel@tonic-gateint
366*7c478bd9Sstevel@tonic-gateyycgid(c)
367*7c478bd9Sstevel@tonic-gate     wchar_t	c;
368*7c478bd9Sstevel@tonic-gate{
369*7c478bd9Sstevel@tonic-gate	int first = 0;
370*7c478bd9Sstevel@tonic-gate	int last = YYNCGIDTBL - 1;
371*7c478bd9Sstevel@tonic-gate	unsigned long lc=yylinearize(c);
372*7c478bd9Sstevel@tonic-gate
373*7c478bd9Sstevel@tonic-gate	if( yycgidtbl[YYNCGIDTBL-1] < lc ) return YYNCGIDTBL*2-1;
374*7c478bd9Sstevel@tonic-gate
375*7c478bd9Sstevel@tonic-gate	while (last >= 0) {
376*7c478bd9Sstevel@tonic-gate		int i = (first+last)/2;
377*7c478bd9Sstevel@tonic-gate		if (lc == yycgidtbl[i])
378*7c478bd9Sstevel@tonic-gate		    return (2*i);
379*7c478bd9Sstevel@tonic-gate		else if ( yycgidtbl[i]<lc) {
380*7c478bd9Sstevel@tonic-gate			if (lc<yycgidtbl[i+1])
381*7c478bd9Sstevel@tonic-gate			    return (2*i+1);
382*7c478bd9Sstevel@tonic-gate			else
383*7c478bd9Sstevel@tonic-gate			    first = i + 1;
384*7c478bd9Sstevel@tonic-gate		}else
385*7c478bd9Sstevel@tonic-gate		    last = i - 1;
386*7c478bd9Sstevel@tonic-gate	}
387*7c478bd9Sstevel@tonic-gate	return 0; /*Error*/
388*7c478bd9Sstevel@tonic-gate}
389*7c478bd9Sstevel@tonic-gate
390*7c478bd9Sstevel@tonic-gate
391*7c478bd9Sstevel@tonic-gate
392*7c478bd9Sstevel@tonic-gate
393*7c478bd9Sstevel@tonic-gate
394*7c478bd9Sstevel@tonic-gate	/* the following are only used in the lex library */
395*7c478bd9Sstevel@tonic-gateint
396*7c478bd9Sstevel@tonic-gate#if defined(__cplusplus) || defined(__STDC__)
397*7c478bd9Sstevel@tonic-gateyyinput(void)
398*7c478bd9Sstevel@tonic-gate#else
399*7c478bd9Sstevel@tonic-gateyyinput()
400*7c478bd9Sstevel@tonic-gate#endif
401*7c478bd9Sstevel@tonic-gate{
402*7c478bd9Sstevel@tonic-gate#ifndef __cplusplus
403*7c478bd9Sstevel@tonic-gate	return(input());
404*7c478bd9Sstevel@tonic-gate#else
405*7c478bd9Sstevel@tonic-gate	return(lex_input());
406*7c478bd9Sstevel@tonic-gate#endif
407*7c478bd9Sstevel@tonic-gate	}
408*7c478bd9Sstevel@tonic-gate#if defined(__cplusplus) || defined(__STDC__)
409*7c478bd9Sstevel@tonic-gatevoid
410*7c478bd9Sstevel@tonic-gateyyoutput(int c)
411*7c478bd9Sstevel@tonic-gate#else
412*7c478bd9Sstevel@tonic-gateyyoutput(c)
413*7c478bd9Sstevel@tonic-gate  int c;
414*7c478bd9Sstevel@tonic-gate#endif
415*7c478bd9Sstevel@tonic-gate{
416*7c478bd9Sstevel@tonic-gate#ifndef __cplusplus
417*7c478bd9Sstevel@tonic-gate	output(c);
418*7c478bd9Sstevel@tonic-gate#else
419*7c478bd9Sstevel@tonic-gate	lex_output(c);
420*7c478bd9Sstevel@tonic-gate#endif
421*7c478bd9Sstevel@tonic-gate	}
422*7c478bd9Sstevel@tonic-gate#if defined(__cplusplus) || defined(__STDC__)
423*7c478bd9Sstevel@tonic-gatevoid
424*7c478bd9Sstevel@tonic-gateyyunput(int c)
425*7c478bd9Sstevel@tonic-gate#else
426*7c478bd9Sstevel@tonic-gateyyunput(c)
427*7c478bd9Sstevel@tonic-gate   int c;
428*7c478bd9Sstevel@tonic-gate#endif
429*7c478bd9Sstevel@tonic-gate{
430*7c478bd9Sstevel@tonic-gate	unput(c);
431*7c478bd9Sstevel@tonic-gate	}
432