xref: /titanic_41/usr/src/cmd/sgs/lex/common/reject.c (revision 7c2fbfb345896881c631598ee3852ce9ce33fb07)
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 /*	Copyright (c) 1989 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 #include <stdio.h>
29 
30 #ifdef EUC
31 #include <euc.h>
32 #include <widec.h>
33 #include <limits.h>
34 #endif
35 
36 
37 #ifndef JLSLEX
38 #pragma weak yyinput
39 #pragma weak yyleng
40 #pragma weak yytext
41 #pragma weak yyunput
42 
43 #define	CHR    char
44 #define	YYTEXT yytext
45 #define	YYLENG yyleng
46 #define	YYINPUT yyinput
47 #define	YYUNPUT yyunput
48 #define	YYOUTPUT yyoutput
49 #define	YYREJECT yyreject
50 #endif
51 
52 #ifdef WOPTION
53 #pragma weak yyinput
54 #pragma weak yyleng
55 #pragma weak yytext
56 #pragma weak yyunput
57 
58 #define	CHR    wchar_t
59 #define	YYTEXT yytext
60 #define	YYLENG yyleng
61 #define	YYINPUT yyinput
62 #define	YYUNPUT yyunput
63 #define	YYOUTPUT yyoutput
64 #define	YYREJECT yyreject_w
65 #endif
66 
67 #ifdef EOPTION
68 #pragma weak yyleng
69 #pragma weak yytext
70 #pragma weak yywinput
71 #pragma weak yywleng
72 #pragma weak yywtext
73 #pragma weak yywunput
74 
75 #define	CHR    wchar_t
76 #define	YYTEXT yywtext
77 #define	YYLENG yywleng
78 #define	YYINPUT yywinput
79 #define	YYUNPUT yywunput
80 #define	YYOUTPUT yywoutput
81 #define	YYREJECT yyreject_e
82 extern unsigned char yytext[];
83 extern int yyleng;
84 #endif
85 
86 #pragma weak yyback
87 #if defined(__cplusplus) || defined(__STDC__)
88 extern int	yyback(int *, int);
89 extern int	YYINPUT(void);
90 extern void	YYUNPUT(int);
91 #ifdef EUC
92 	static int	yyracc(int);
93 #else
94 	extern int	yyracc(int);
95 #endif
96 #ifdef EOPTION
97 	extern size_t	wcstombs(char *, const wchar_t *, size_t);
98 #endif
99 #endif
100 
101 #pragma weak yyout
102 extern FILE *yyout, *yyin;
103 
104 #pragma weak yyfnd
105 #pragma weak yyprevious
106 extern int yyprevious, *yyfnd;
107 
108 #pragma weak yyextra
109 extern char yyextra[];
110 
111 extern int YYLENG;
112 extern CHR YYTEXT[];
113 
114 #pragma weak yylsp
115 #pragma weak yylstate
116 #pragma weak yyolsp
117 extern struct {int *yyaa, *yybb; int *yystops; } *yylstate[], **yylsp, **yyolsp;
118 #if defined(__cplusplus) || defined(__STDC__)
119 int
120 YYREJECT(void)
121 #else
122 YYREJECT()
123 #endif
124 {
125 	for (; yylsp < yyolsp; yylsp++)
126 		YYTEXT[YYLENG++] = YYINPUT();
127 	if (*yyfnd > 0)
128 		return (yyracc(*yyfnd++));
129 	while (yylsp-- > yylstate) {
130 		YYUNPUT(YYTEXT[YYLENG-1]);
131 		YYTEXT[--YYLENG] = 0;
132 		if (*yylsp != 0 && (yyfnd = (*yylsp)->yystops) && *yyfnd > 0)
133 			return (yyracc(*yyfnd++));
134 	}
135 #ifdef EOPTION
136 	yyleng = wcstombs((char *)yytext, YYTEXT, YYLENG*MB_LEN_MAX);
137 #endif
138 	if (YYTEXT[0] == 0)
139 		return (0);
140 	YYLENG = 0;
141 #ifdef EOPTION
142 	yyleng = 0;
143 #endif
144 	return (-1);
145 }
146 
147 #if defined(__cplusplus) || defined(__STDC__)
148 int
149 yyracc(int m)
150 #else
151 yyracc(m)
152 #endif
153 {
154 	yyolsp = yylsp;
155 	if (yyextra[m]) {
156 		while (yyback((*yylsp)->yystops, -m) != 1 && yylsp > yylstate) {
157 			yylsp--;
158 			YYUNPUT(YYTEXT[--YYLENG]);
159 		}
160 	}
161 	yyprevious = YYTEXT[YYLENG-1];
162 	YYTEXT[YYLENG] = 0;
163 #ifdef EOPTION
164 	yyleng = wcstombs((char *)yytext, YYTEXT, YYLENG*MB_LEN_MAX);
165 #endif
166 	return (m);
167 }
168