nceucform (9987B)
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) 1989 AT&T */ 29 /* All Rights Reserved */ 30 31 32 /* from OpenSolaris "nceucform 1.17 05/06/08 SMI" */ 33 34 /* 35 * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany 36 * 37 * Sccsid @(#)nceucform 1.6 (gritter) 11/18/05 38 */ 39 40 #if defined(__cplusplus) || defined(__STDC__) 41 int yycgid(wchar_t); 42 wint_t yygetwchar(void); 43 #endif 44 int yylineno =1; 45 int yygid; 46 #define LONG_WCHAR_T 1 47 # define YYU(x) x 48 # define NLSTATE yyprevious=YYNEWLINE 49 wchar_t yysbuf[YYLMAX]; 50 wchar_t *yysptr = yysbuf; 51 struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp; 52 int *yyfnd; 53 extern struct yysvf *yyestate; 54 int yyprevious = YYNEWLINE; 55 #if defined(__cplusplus) || defined(__STDC__) 56 int yylook(void) 57 #else 58 yylook() 59 #endif 60 { 61 struct yysvf *yystate, **lsp; 62 struct yywork *yyt; 63 struct yysvf *yyz; 64 int yych, yyfirst; 65 struct yywork *yyr; 66 # ifdef LEXDEBUG 67 int debug; 68 # endif 69 wchar_t *yylastch; 70 /* start off machines */ 71 # ifdef LEXDEBUG 72 debug = 0; 73 # endif 74 yyfirst=1; 75 if (!yymorfg) 76 yylastch = YYTEXT; 77 else { 78 yymorfg=0; 79 yylastch = YYTEXT+YYLENG; 80 } 81 for(;;){ 82 lsp = yylstate; 83 yyestate = yystate = yybgin; 84 if (yyprevious==YYNEWLINE) yystate++; 85 for (;;){ 86 # ifdef LEXDEBUG 87 if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1); 88 # endif 89 yyt = yystate->yystoff; 90 if(yyt == yycrank && !yyfirst){ /* may not be any transitions */ 91 yyz = yystate->yyother; 92 if(yyz == 0)break; 93 if(yyz->yystoff == yycrank)break; 94 } 95 *yylastch++ = yych = YYINPUT(); 96 #ifdef YYISARRAY 97 if(yylastch > &YYTEXT[YYLMAX]) { 98 fprintf(yyout,"Input string too long, limit %d\n",YYLMAX); 99 exit(1); 100 } 101 #else 102 if (yylastch >= &YYTEXT[ yytextsz ]) { 103 int x = yylastch - YYTEXT; 104 105 yytextsz += YYTEXTSZINC; 106 #ifdef YYLEX_E /* -e */ 107 if (YYTEXT == yy_twbuf) { 108 YYTEXT = (wchar_t *) 109 malloc(yytextsz * 110 sizeof (wchar_t)); 111 memcpy(YYTEXT, yy_twbuf, 112 sizeof (yy_twbuf)); 113 yytext = (wchar_t *) 114 malloc(yytextsz * 115 sizeof (wchar_t)); 116 memcpy(yytext, yy_tbuf, 117 sizeof (yy_tbuf)); 118 #else 119 if (YYTEXT == yy_tbuf) { 120 YYTEXT = (wchar_t *) 121 malloc(yytextsz * 122 sizeof (wchar_t)); 123 memcpy(YYTEXT, yy_tbuf, 124 sizeof (yy_tbuf)); 125 #endif 126 } 127 else { 128 YYTEXT = (wchar_t *) 129 realloc(YYTEXT, yytextsz); 130 #ifdef YYLEX_E /* -e */ 131 yytext = (wchar_t *) 132 realloc(yytext, 133 yytextsz * sizeof (wchar_t)); 134 #endif 135 } 136 if (!YYTEXT) { 137 fprintf(yyout, 138 "Cannot realloc YYTEXT\n"); 139 exit(1); 140 } 141 yylastch = YYTEXT + x; 142 } 143 #endif 144 yygid = yycgid(yych); 145 yyfirst=0; 146 tryagain: 147 # ifdef LEXDEBUG 148 if(debug){ 149 fprintf(yyout,"wchar_t "); 150 allprint(yych); 151 fprintf(yyout," gid %d\n", yygid); 152 } 153 # endif 154 yyr = yyt; 155 if ( yyt > yycrank){ 156 yyt = yyr + yygid; 157 if (yyt <= yytop && yyt->verify+yysvec == yystate){ 158 if(yyt->advance+yysvec == YYLERR) /* error transitions */ 159 {YYUNPUT(*--yylastch);break;} 160 *lsp++ = yystate = yyt->advance+yysvec; 161 if(lsp > &yylstate[YYLMAX]) { 162 fprintf(yyout,"Input string too long, limit %d\n",YYLMAX); 163 exit(1); 164 } 165 goto contin; 166 } 167 } 168 # ifdef YYOPTIM 169 else if(yyt < yycrank) { /* r < yycrank */ 170 yyt = yyr = yycrank+(yycrank-yyt); 171 # ifdef LEXDEBUG 172 if(debug)fprintf(yyout,"compressed state\n"); 173 # endif 174 yyt = yyt + yygid; 175 if(yyt <= yytop && yyt->verify+yysvec == yystate){ 176 if(yyt->advance+yysvec == YYLERR) /* error transitions */ 177 {YYUNPUT(*--yylastch);break;} 178 *lsp++ = yystate = yyt->advance+yysvec; 179 if(lsp > &yylstate[YYLMAX]) { 180 fprintf(yyout,"Input string too long, limit %d\n",YYLMAX); 181 exit(1); 182 } 183 goto contin; 184 } 185 yyt = yyr + YYU(yymatch[yygid]); 186 # ifdef LEXDEBUG 187 if(debug){ 188 fprintf(yyout,"try fall back character "); 189 allprint_w(YYU(yymatch[yygid])); 190 fprintf(yyout," gid %d\n", yygid); 191 } 192 # endif 193 if(yyt <= yytop && yyt->verify+yysvec == yystate){ 194 if(yyt->advance+yysvec == YYLERR) /* error transition */ 195 {YYUNPUT(*--yylastch);break;} 196 *lsp++ = yystate = yyt->advance+yysvec; 197 if(lsp > &yylstate[YYLMAX]) { 198 fprintf(yyout,"Input string too long, limit %d\n",YYLMAX); 199 exit(1); 200 } 201 goto contin; 202 } 203 } 204 if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){ 205 # ifdef LEXDEBUG 206 if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1); 207 # endif 208 goto tryagain; 209 } 210 # endif 211 else 212 {YYUNPUT(*--yylastch);break;} 213 contin: 214 # ifdef LEXDEBUG 215 if(debug){ 216 fprintf(yyout,"state %d wchar_t ",yystate-yysvec-1); 217 allprint_w(yych); 218 fprintf(yyout," gid %d\n", yygid); 219 } 220 # endif 221 ; 222 } 223 # ifdef LEXDEBUG 224 if(debug){ 225 fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1); 226 allprint_w(yych); 227 fprintf(yyout," gid %d\n", yygid); 228 } 229 # endif 230 while (lsp-- > yylstate){ 231 *yylastch-- = 0; 232 if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){ 233 yyolsp = lsp; 234 if(yyextra[*yyfnd]){ /* must backup */ 235 while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){ 236 lsp--; 237 YYUNPUT(*yylastch--); 238 } 239 } 240 yyprevious = YYU(*yylastch); 241 yylsp = lsp; 242 YYLENG = yylastch-YYTEXT+1; 243 YYTEXT[YYLENG] = 0; 244 # ifdef LEXDEBUG 245 if(debug){ 246 fprintf(yyout,"\nmatch "); 247 sprint_w(YYTEXT); 248 fprintf(yyout," action %d\n",*yyfnd); 249 } 250 # endif 251 #ifdef YYLEX_E /* -e */ 252 yyleng=wcstombs((char *)yytext, YYTEXT, sizeof(yytext)-1); 253 #ifdef LEXDEBUG 254 if(yyleng>=sizeof(yytext)-1) 255 fprintf(yyout, "yytext[] too short\n"); 256 #endif 257 #endif 258 return(*yyfnd++); 259 } 260 YYUNPUT(*yylastch); 261 } 262 if (YYTEXT[0] == 0 /* && feof(yyin) */) 263 { 264 yysptr=yysbuf; 265 return(0); 266 } 267 yyprevious = YYTEXT[0] = YYINPUT(); 268 if (yyprevious>0) 269 YYOUTPUT(yyprevious); 270 yylastch=YYTEXT; 271 # ifdef LEXDEBUG 272 if(debug)putchar('\n'); 273 # endif 274 } 275 } 276 int 277 #if defined(__cplusplus) || defined(__STDC__) 278 yyback(int *p, int m) 279 #else 280 yyback(p, m) 281 int *p; 282 int m; 283 #endif 284 { 285 if (p==0) return(0); 286 while (*p) { 287 if (*p++ == m) 288 return(1); 289 } 290 return(0); 291 } 292 293 #ifdef YYLEX_E /* -e */ 294 wchar_t 295 #if defined(__cplusplus) || defined(__STDC__) 296 yywinput(void){ 297 #else 298 yywinput(){ 299 #endif 300 static mbstate_t state; 301 wchar_t wc; 302 char b; 303 int n; 304 305 for (;;) { 306 do { 307 #ifndef __cplusplus 308 b=input(); 309 #else 310 b=lex_input(); 311 #endif 312 } while ((n = mbrtowc(&wc, &b, 1, &state)) == (size_t)-2); 313 if (n == (size_t)-1) { 314 for (n = 0; n < sizeof state; n++) 315 ((char *)&state)[n] = 0; 316 continue; 317 } 318 break; 319 } 320 321 return wc; 322 } 323 324 #if defined(__cplusplus) || defined(__STDC__) 325 void 326 yywoutput(wchar_t wc) 327 #else 328 yywoutput(wc) 329 wchar_t wc; 330 #endif 331 { 332 unsigned char eucbuf[MB_LEN_MAX]; 333 int n; 334 unsigned char *p=eucbuf; 335 336 n=wctomb( (char *)eucbuf, wc ); 337 #ifndef __cplusplus 338 while(n-->0) output(*p++); 339 #else 340 while(n-->0) lex_output(*p++); 341 #endif 342 } 343 344 #if defined(__cplusplus) || defined(__STDC__) 345 void 346 yywunput(wchar_t wc) 347 #else 348 yywunput(wc) 349 wchar_t wc; 350 #endif 351 { 352 unsigned char eucbuf[MB_LEN_MAX]; 353 int n; 354 unsigned char *p; 355 356 n=wctomb( (char *)eucbuf, wc ); 357 p=eucbuf+n; 358 while(n-->0) unput(*--p); 359 } 360 #endif 361 362 #ifdef LONG_WCHAR_T 363 #define yylinearize(lc) lc 364 #else/*!LONG_WCHAR_T*/ 365 unsigned long 366 yylinearize(wc) 367 wchar_t wc; 368 { 369 unsigned long prefix; 370 switch(wc&0x8080){ 371 case 0x0000: prefix=0x00000000; break; 372 case 0x0080: prefix=0x20000000; break; 373 case 0x8000: prefix=0x40000000; break; 374 case 0x8080: prefix=0x60000000; break; 375 } 376 return prefix|wc; 377 } 378 #endif/*!LONG_WCHAR_T*/ 379 int 380 yycgid(c) 381 wchar_t c; 382 { 383 int first = 0; 384 int last = YYNCGIDTBL - 1; 385 unsigned long lc=yylinearize(c); 386 387 if( yycgidtbl[YYNCGIDTBL-1] < lc ) return YYNCGIDTBL*2-1; 388 389 while (last >= 0) { 390 int i = (first+last)/2; 391 if (lc == yycgidtbl[i]) 392 return (2*i); 393 else if ( yycgidtbl[i]<lc) { 394 if (lc<yycgidtbl[i+1]) 395 return (2*i+1); 396 else 397 first = i + 1; 398 }else 399 last = i - 1; 400 } 401 return 0; /*Error*/ 402 } 403 404 405 406 407 408 /* the following are only used in the lex library */ 409 int 410 #if defined(__cplusplus) || defined(__STDC__) 411 yyinput(void) 412 #else 413 yyinput() 414 #endif 415 { 416 #ifndef __cplusplus 417 return(input()); 418 #else 419 return(lex_input()); 420 #endif 421 } 422 #if defined(__cplusplus) || defined(__STDC__) 423 void 424 yyoutput(int c) 425 #else 426 yyoutput(c) 427 int c; 428 #endif 429 { 430 #ifndef __cplusplus 431 output(c); 432 #else 433 lex_output(c); 434 #endif 435 } 436 #if defined(__cplusplus) || defined(__STDC__) 437 void 438 yyunput(int c) 439 #else 440 yyunput(c) 441 int c; 442 #endif 443 { 444 unput(c); 445 } 446 447 #ifndef YYLEX_E 448 /* 449 * Just strip all illegal byte sequences from input. 450 */ 451 wint_t 452 #if defined(__cplusplus) || defined(__STDC__) 453 yygetwchar(void) 454 #else 455 yygetwchar() 456 #endif 457 { 458 static mbstate_t state; 459 char b; 460 int c, n; 461 wchar_t wc = WEOF; 462 463 for (;;) { 464 while ((c = getc(yyin)) != EOF) { 465 b = c; 466 if ((n = mbrtowc(&wc, &b, 1, &state)) != (size_t)-2) 467 break; 468 } 469 if (n == (size_t)-1 || n == (size_t)-2) { 470 if (c == EOF) 471 return WEOF; 472 for (n = 0; n < sizeof state; n++) 473 ((char *)&state)[n] = 0; 474 continue; 475 } 476 break; 477 } 478 return wc; 479 } 480 #endif /* !YYLEX_E */