1 
2 # line 2 "genmsg.y"
3 /*
4  * CDDL HEADER START
5  *
6  * The contents of this file are subject to the terms of the
7  * Common Development and Distribution License (the "License").
8  * You may not use this file except in compliance with the License.
9  *
10  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11  * or http://www.opensolaris.org/os/licensing.
12  * See the License for the specific language governing permissions
13  * and limitations under the License.
14  *
15  * When distributing Covered Code, include this CDDL HEADER in each
16  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17  * If applicable, add the following below this CDDL HEADER, with the
18  * fields enclosed by brackets "[]" replaced with your own identifying
19  * information: Portions Copyright [yyyy] [name of copyright owner]
20  *
21  * CDDL HEADER END
22  */
23 /*
24  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 #pragma ident	"%Z%%M%	%I%	%E% SMI"
29 
30 #include <stdio.h>
31 #include <libintl.h>
32 #include <limits.h>
33 #include "genmsg.h"
34 extern int is_cat_found;		/* from main.c */
35 extern int lineno;			/* genmsg.l */
36 extern int msg_line;			/* genmsg.l */
37 extern int end_of_cat;			/* from genmsg.l */
38 extern void set_linemsgid(int, int);	/* from genmsg.l */
39 extern void add_msg(int, int, char *, char *, int, int); /* from util.c */
40 extern void set_msgid(int, int);
41 extern int get_msgid(char *, int, int, char *);
42 extern void warning(char *);
43 extern void yyerror(char *);
44 
45 static void do_catgets(int, int, char *);
46 static char *add_qstring(char *, char *);
47 
48 # line 48 "genmsg.y"
49 typedef union
50 #ifdef __cplusplus
51 	YYSTYPE
52 #endif
53  {
54 	char *str;
55 	int id;
56 } YYSTYPE;
57 # define CATGETS 257
58 # define CONST 258
59 # define CATD 259
60 # define INT 260
61 # define CHAR 261
62 # define INC 262
63 # define STR 263
64 # define SETID 264
65 # define MSGID 265
66 # define DIGIT 266
67 # define QSTR 267
68 # define UMINUS 268
69 
70 #include <inttypes.h>
71 
72 #ifdef __STDC__
73 #include <stdlib.h>
74 #include <string.h>
75 #define	YYCONST	const
76 #else
77 #include <malloc.h>
78 #include <memory.h>
79 #define	YYCONST
80 #endif
81 
82 #include <values.h>
83 
84 #if defined(__cplusplus) || defined(__STDC__)
85 
86 #if defined(__cplusplus) && defined(__EXTERN_C__)
87 extern "C" {
88 #endif
89 #ifndef yyerror
90 #if defined(__cplusplus)
91 	void yyerror(YYCONST char *);
92 #endif
93 #endif
94 #ifndef yylex
95 	int yylex(void);
96 #endif
97 	int yyparse(void);
98 #if defined(__cplusplus) && defined(__EXTERN_C__)
99 }
100 #endif
101 
102 #endif
103 
104 #define yyclearin yychar = -1
105 #define yyerrok yyerrflag = 0
106 extern int yychar;
107 extern int yyerrflag;
108 YYSTYPE yylval;
109 YYSTYPE yyval;
110 typedef int yytabelem;
111 #ifndef YYMAXDEPTH
112 #define YYMAXDEPTH 150
113 #endif
114 #if YYMAXDEPTH > 0
115 int yy_yys[YYMAXDEPTH], *yys = yy_yys;
116 YYSTYPE yy_yyv[YYMAXDEPTH], *yyv = yy_yyv;
117 #else	/* user does initial allocation */
118 int *yys;
119 YYSTYPE *yyv;
120 #endif
121 static int yymaxdepth = YYMAXDEPTH;
122 # define YYERRCODE 256
123 
124 # line 200 "genmsg.y"
125 
126 
127 static void
128 do_catgets(int setid, int msgid, char *str)
129 {
130 	int id = msgid;
131 	if (IsActiveMode(ReplaceMode)) {
132 		return;
133 	}
134 	if (setid == 0 || setid > NL_SETMAX) {
135 		src_err(srcfile, lineno,
136 		    gettext("improper set number: %d"), setid);
137 		return;
138 	}
139 	if (IsActiveMode(ProjectMode)) {
140 		set_msgid(setid, id);
141 		add_msg(setid, id, str, srcfile, lineno, TRUE);
142 	} else if (IsActiveMode(ReverseMode)) {
143 		set_linemsgid(msg_line, NOMSGID);
144 	} else if (IsActiveMode(AutoNumMode)) {
145 		if (id == NOMSGID) {
146 			id = get_msgid(srcfile, msg_line, setid, str);
147 			set_linemsgid(msg_line, id);
148 		}
149 		if (id != NOMSGID) {
150 			set_msgid(setid, id);
151 			add_msg(setid, id, str, srcfile, lineno, FALSE);
152 		}
153 	} else if (id == NOMSGID) {
154 		warning(gettext("improper message number: -1"));
155 	} else {
156 		add_msg(setid, id, str, srcfile, lineno, FALSE);
157 	}
158 }
159 
160 static char *
161 add_qstring(char *str, char *add)
162 {
163 	int len = strlen(str) + strlen(add) + 3;
164 	/* 3 includes '\', '\n' and '\0' */
165 	char *tmp = malloc(len);
166 	if (tmp == NULL) {
167 		prg_err(gettext("fatal: out of memory"));
168 		exit(EXIT_FAILURE);
169 	}
170 	(void) snprintf(tmp, len, "%s\\\n%s", str, add);
171 	free(str);
172 	free(add);
173 	return (tmp);
174 }
175 static YYCONST yytabelem yyexca[] ={
176 -1, 0,
177 	0, 1,
178 	-2, 0,
179 -1, 1,
180 	0, -1,
181 	-2, 0,
182 -1, 2,
183 	0, 2,
184 	-2, 0,
185 	};
186 # define YYNPROD 64
187 # define YYLAST 274
188 static YYCONST yytabelem yyact[]={
189 
190     79,   146,    16,   144,    77,    51,    48,    44,    16,    54,
191     54,    51,    79,    85,    16,   132,   118,    51,    51,   109,
192     86,    90,   118,   105,   106,   106,    60,    90,   134,    88,
193     25,    35,    16,    60,    90,    93,    27,    70,    35,    16,
194     25,    33,    16,    38,   117,     9,    35,    16,    30,    53,
195     16,    27,    42,     5,     4,    50,    76,    59,    47,    13,
196     12,    14,   121,    82,    68,    11,    43,   122,    83,    23,
197     22,    24,    26,    39,    21,    63,    34,    29,    31,   114,
198     64,    56,    10,    18,    49,    23,    22,    24,   129,    45,
199    108,   148,    55,    65,   121,   119,   145,   120,    78,   122,
200    142,    89,    82,    80,   133,    81,   130,    83,    84,    69,
201     55,   128,    66,    63,    61,    41,    62,    40,    64,    95,
202     96,    97,    98,   135,   121,   119,   126,   120,   125,   122,
203    102,   101,   103,   104,   100,   123,    92,   110,   111,   112,
204    113,    55,    99,   107,    82,    80,    42,    81,    73,    83,
205    124,    94,    63,    61,    72,    62,    71,    64,    67,    37,
206      7,   127,     2,     1,   136,   137,   138,   139,     3,     8,
207     46,     6,    87,   131,    32,     0,     0,     0,   147,     0,
208      0,     0,    78,   140,     0,   141,   143,     0,     0,     0,
209      0,     0,     0,   150,    78,     0,     0,     0,   149,     0,
210      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
211      0,     0,     0,     0,     0,     0,     0,     0,    75,     0,
212     74,    77,     0,    17,     0,     0,    52,    54,     0,    17,
213     54,     0,    52,    54,   116,    17,   115,     0,    52,    52,
214      0,    91,    54,     0,    58,    86,    57,    91,    20,    19,
215     36,     0,    15,    17,    91,     0,     0,    36,    28,    15,
216     17,     0,    15,    17,     0,    36,     0,    15,    17,     0,
217      0,    17,     0,    28 };
218 static YYCONST yytabelem yypact[]={
219 
220   -203,-10000000,  -203,-10000000,   120,-10000000,-10000000,     5,    39,   -10,
221     27,-10000000,-10000000,-10000000,    -4,     8,     8,-10000000,     1,   118,
222   -216,    28,    76,    74,    11,     0,     4,   -34,-10000000,-10000000,
223      8,-10000000,    37,   -14,    71,    -7,-10000000,     0,   117,     2,
224 -10000000,-10000000,-10000000,    -3,-10000000,   115,   113,   107,   -40,    60,
225 -10000000,   -27,-10000000,  -247,-10000000,   105,   -11,    95,  -225,   110,
226     -7,    -7,    -7,    -7,    -7,-10000000,    27,     0,    -3,-10000000,
227     -3,-10000000,-10000000,-10000000,    92,  -237,   102,    48,   -22,   -28,
228    -27,   -27,   -27,   -27,-10000000,   -27,-10000000,    35,   -24,    52,
229    -18,-10000000,    -7,    87,-10000000,    33,    33,-10000000,-10000000,    27,
230     85,    76,    74,    11,   -27,    70,    46,-10000000,    65,-10000000,
231     21,    21,-10000000,-10000000,   -25,    63,  -232,    82,   -18,   -18,
232    -18,   -18,   -18,-10000000,    71,    -7,-10000000,    60,   -27,    59,
233    -37,    55,  -257,   -18,    50,-10000000,    20,    20,-10000000,-10000000,
234     71,    60,   -37,-10000000,  -258,-10000000,  -236,    52,   -18,-10000000,
235     52 };
236 static YYCONST yytabelem yypgo[]={
237 
238      0,   174,    57,   172,    44,   170,    56,   169,    74,    65,
239     60,    59,    61,    58,    55,    49,   163,   162,   168 };
240 static YYCONST yytabelem yyr1[]={
241 
242      0,    16,    16,    17,    17,    18,    18,     7,     7,     7,
243      8,     8,     8,     9,     9,     9,    10,    10,    10,    10,
244     10,    11,    11,    11,    12,    12,    12,     1,     1,     1,
245      2,     2,     2,     2,     2,     2,     2,     3,     3,     3,
246      4,     4,     4,     4,     4,     4,     4,     5,     5,     5,
247      6,     6,     6,     6,     6,     6,     6,    13,    13,    13,
248     14,    14,    15,    15 };
249 static YYCONST yytabelem yyr2[]={
250 
251      0,     1,     3,     3,     5,    21,     2,     9,    11,     2,
252      2,     8,    13,     2,     2,     2,     7,     6,     8,     8,
253      9,     7,     4,     5,     7,     5,     2,     9,    11,     2,
254      7,     7,     7,     7,     5,     7,     2,     9,    11,     2,
255      7,     7,     7,     7,     5,     7,     2,     9,    11,     2,
256      7,     7,     7,     7,     5,     7,     2,    11,    13,     2,
257      7,     2,     2,     5 };
258 static YYCONST yytabelem yychk[]={
259 
260 -10000000,   -16,   -17,   -18,   257,   256,   -18,    40,    -7,    40,
261     -8,    -9,   -10,   -11,   -12,   262,    42,   263,    44,   259,
262    258,    -8,   -10,   -11,   -12,    40,    45,    40,   262,   -12,
263     40,   -12,    -1,    40,    -2,    45,   264,    41,   259,    45,
264     41,    41,    41,    62,    41,   -12,    -5,   -13,    40,    -6,
265    -14,    45,   266,   -15,   267,   -12,    44,   260,   258,    -2,
266     40,    43,    45,    42,    47,    -2,    -8,    41,    62,    -9,
267     40,    41,    41,    41,   260,   258,    -6,   261,   -15,    40,
268     43,    45,    42,    47,    -6,    40,   267,    -3,    40,    -4,
269     45,   265,    41,   260,    41,    -2,    -2,    -2,    -2,    -8,
270     -9,   -10,   -11,   -12,    41,   260,   261,    41,    42,    41,
271     -6,    -6,    -6,    -6,    44,   260,   258,    -4,    40,    43,
272     45,    42,    47,    -4,    -2,    41,    41,    -6,    41,    42,
273     41,   -13,    40,    41,   260,    41,    -4,    -4,    -4,    -4,
274     -2,    -6,    41,   -14,    40,    41,   258,    -4,    41,   -14,
275     -4 };
276 static YYCONST yytabelem yydef[]={
277 
278     -2,    -2,    -2,     3,     0,     6,     4,     0,     0,     0,
279      9,    10,    13,    14,    15,     0,     0,    26,     0,     0,
280      0,     0,    13,    14,    15,     0,     0,     0,    22,    23,
281      0,    25,     0,     0,    29,     0,    36,     0,     0,     0,
282     16,    21,    24,     0,    17,     0,     0,     0,     0,    49,
283     59,     0,    56,    61,    62,     0,     0,     0,     0,     0,
284      0,     0,     0,     0,     0,    34,     7,     0,     0,    11,
285      0,    18,    19,    20,     0,     0,     0,     0,     0,     0,
286      0,     0,     0,     0,    54,     0,    63,     0,     0,    39,
287      0,    46,     0,     0,    35,    30,    31,    32,    33,     8,
288     11,     0,     0,     0,     0,     0,     0,    55,     0,    60,
289     50,    51,    52,    53,     0,     0,     0,     0,     0,     0,
290      0,     0,     0,    44,    27,     0,    12,    47,     0,     0,
291      0,     0,     0,     0,     0,    45,    40,    41,    42,    43,
292     28,    48,     0,    57,     0,     5,     0,    37,     0,    58,
293     38 };
294 typedef struct
295 #ifdef __cplusplus
296 	yytoktype
297 #endif
298 {
299 #ifdef __cplusplus
300 const
301 #endif
302 char *t_name; int t_val; } yytoktype;
303 #ifndef YYDEBUG
304 #	define YYDEBUG	0	/* don't allow debugging */
305 #endif
306 
307 #if YYDEBUG
308 
309 yytoktype yytoks[] =
310 {
311 	"CATGETS",	257,
312 	"CONST",	258,
313 	"CATD",	259,
314 	"INT",	260,
315 	"CHAR",	261,
316 	"INC",	262,
317 	"STR",	263,
318 	"SETID",	264,
319 	"MSGID",	265,
320 	"DIGIT",	266,
321 	"QSTR",	267,
322 	"-",	45,
323 	"+",	43,
324 	"*",	42,
325 	"/",	47,
326 	"UMINUS",	268,
327 	"-unknown-",	-1	/* ends search */
328 };
329 
330 #ifdef __cplusplus
331 const
332 #endif
333 char * yyreds[] =
334 {
335 	"-no such reduction-",
336 	"genmsg_list : /* empty */",
337 	"genmsg_list : genmsg",
338 	"genmsg : catgets",
339 	"genmsg : genmsg catgets",
340 	"catgets : CATGETS '(' catd ',' cast_setid ',' cast_msgid ',' cast_qstr ')'",
341 	"catgets : error",
342 	"catd : '(' CATD ')' arg_list",
343 	"catd : '(' CONST CATD ')' arg_list",
344 	"catd : arg_list",
345 	"arg_list : arg_def",
346 	"arg_list : arg_list '-' '>' arg_def",
347 	"arg_list : '(' arg_list '-' '>' arg_def ')'",
348 	"arg_def : arg_func",
349 	"arg_def : arg_exp",
350 	"arg_def : str",
351 	"arg_func : '(' arg_func ')'",
352 	"arg_func : str '(' ')'",
353 	"arg_func : str '(' str ')'",
354 	"arg_func : str '(' cast_digit ')'",
355 	"arg_func : str '(' cast_qstr ')'",
356 	"arg_exp : '(' arg_exp ')'",
357 	"arg_exp : str INC",
358 	"arg_exp : INC str",
359 	"str : '(' str ')'",
360 	"str : '*' str",
361 	"str : STR",
362 	"cast_setid : '(' INT ')' setid",
363 	"cast_setid : '(' CONST INT ')' setid",
364 	"cast_setid : setid",
365 	"setid : setid '+' setid",
366 	"setid : setid '-' setid",
367 	"setid : setid '*' setid",
368 	"setid : setid '/' setid",
369 	"setid : '-' setid",
370 	"setid : '(' setid ')'",
371 	"setid : SETID",
372 	"cast_msgid : '(' INT ')' msgid",
373 	"cast_msgid : '(' CONST INT ')' msgid",
374 	"cast_msgid : msgid",
375 	"msgid : msgid '+' msgid",
376 	"msgid : msgid '-' msgid",
377 	"msgid : msgid '*' msgid",
378 	"msgid : msgid '/' msgid",
379 	"msgid : '-' msgid",
380 	"msgid : '(' msgid ')'",
381 	"msgid : MSGID",
382 	"cast_digit : '(' INT ')' digit",
383 	"cast_digit : '(' CONST INT ')' digit",
384 	"cast_digit : digit",
385 	"digit : digit '+' digit",
386 	"digit : digit '-' digit",
387 	"digit : digit '*' digit",
388 	"digit : digit '/' digit",
389 	"digit : '-' digit",
390 	"digit : '(' digit ')'",
391 	"digit : DIGIT",
392 	"cast_qstr : '(' CHAR '*' ')' paren_qstr",
393 	"cast_qstr : '(' CONST CHAR '*' ')' paren_qstr",
394 	"cast_qstr : paren_qstr",
395 	"paren_qstr : '(' qstr_list ')'",
396 	"paren_qstr : qstr_list",
397 	"qstr_list : QSTR",
398 	"qstr_list : qstr_list QSTR",
399 };
400 #endif /* YYDEBUG */
401 # line	1 "/usr/share/lib/ccs/yaccpar"
402 /*
403  * CDDL HEADER START
404  *
405  * The contents of this file are subject to the terms of the
406  * Common Development and Distribution License, Version 1.0 only
407  * (the "License").  You may not use this file except in compliance
408  * with the License.
409  *
410  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
411  * or http://www.opensolaris.org/os/licensing.
412  * See the License for the specific language governing permissions
413  * and limitations under the License.
414  *
415  * When distributing Covered Code, include this CDDL HEADER in each
416  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
417  * If applicable, add the following below this CDDL HEADER, with the
418  * fields enclosed by brackets "[]" replaced with your own identifying
419  * information: Portions Copyright [yyyy] [name of copyright owner]
420  *
421  * CDDL HEADER END
422  */
423 /*
424  * Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
425  * Use is subject to license terms.
426  */
427 
428 /* Copyright (c) 1988 AT&T */
429 /* All Rights Reserved */
430 
431 #pragma ident	"%Z%%M%	%I%	%E% SMI"
432 
433 /*
434 ** Skeleton parser driver for yacc output
435 */
436 
437 /*
438 ** yacc user known macros and defines
439 */
440 #define YYERROR		goto yyerrlab
441 #define YYACCEPT	return(0)
442 #define YYABORT		return(1)
443 #define YYBACKUP( newtoken, newvalue )\
444 {\
445 	if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\
446 	{\
447 		yyerror( "syntax error - cannot backup" );\
448 		goto yyerrlab;\
449 	}\
450 	yychar = newtoken;\
451 	yystate = *yyps;\
452 	yylval = newvalue;\
453 	goto yynewstate;\
454 }
455 #define YYRECOVERING()	(!!yyerrflag)
456 #define YYNEW(type)	malloc(sizeof(type) * yynewmax)
457 #define YYCOPY(to, from, type) \
458 	(type *) memcpy(to, (char *) from, yymaxdepth * sizeof (type))
459 #define YYENLARGE( from, type) \
460 	(type *) realloc((char *) from, yynewmax * sizeof(type))
461 #ifndef YYDEBUG
462 #	define YYDEBUG	1	/* make debugging available */
463 #endif
464 
465 /*
466 ** user known globals
467 */
468 int yydebug;			/* set to 1 to get debugging */
469 
470 /*
471 ** driver internal defines
472 */
473 #define YYFLAG		(-10000000)
474 
475 /*
476 ** global variables used by the parser
477 */
478 YYSTYPE *yypv;			/* top of value stack */
479 int *yyps;			/* top of state stack */
480 
481 int yystate;			/* current state */
482 int yytmp;			/* extra var (lasts between blocks) */
483 
484 int yynerrs;			/* number of errors */
485 int yyerrflag;			/* error recovery flag */
486 int yychar;			/* current input token number */
487 
488 
489 
490 #ifdef YYNMBCHARS
491 #define YYLEX()		yycvtok(yylex())
492 /*
493 ** yycvtok - return a token if i is a wchar_t value that exceeds 255.
494 **	If i<255, i itself is the token.  If i>255 but the neither
495 **	of the 30th or 31st bit is on, i is already a token.
496 */
497 #if defined(__STDC__) || defined(__cplusplus)
498 int yycvtok(int i)
499 #else
500 int yycvtok(i) int i;
501 #endif
502 {
503 	int first = 0;
504 	int last = YYNMBCHARS - 1;
505 	int mid;
506 	wchar_t j;
507 
508 	if(i&0x60000000){/*Must convert to a token. */
509 		if( yymbchars[last].character < i ){
510 			return i;/*Giving up*/
511 		}
512 		while ((last>=first)&&(first>=0)) {/*Binary search loop*/
513 			mid = (first+last)/2;
514 			j = yymbchars[mid].character;
515 			if( j==i ){/*Found*/
516 				return yymbchars[mid].tvalue;
517 			}else if( j<i ){
518 				first = mid + 1;
519 			}else{
520 				last = mid -1;
521 			}
522 		}
523 		/*No entry in the table.*/
524 		return i;/* Giving up.*/
525 	}else{/* i is already a token. */
526 		return i;
527 	}
528 }
529 #else/*!YYNMBCHARS*/
530 #define YYLEX()		yylex()
531 #endif/*!YYNMBCHARS*/
532 
533 /*
534 ** yyparse - return 0 if worked, 1 if syntax error not recovered from
535 */
536 #if defined(__STDC__) || defined(__cplusplus)
537 int yyparse(void)
538 #else
539 int yyparse()
540 #endif
541 {
542 	register YYSTYPE *yypvt = 0;	/* top of value stack for $vars */
543 
544 #if defined(__cplusplus) || defined(lint)
545 /*
546 	hacks to please C++ and lint - goto's inside
547 	switch should never be executed
548 */
549 	static int __yaccpar_lint_hack__ = 0;
550 	switch (__yaccpar_lint_hack__)
551 	{
552 		case 1: goto yyerrlab;
553 		case 2: goto yynewstate;
554 	}
555 #endif
556 
557 	/*
558 	** Initialize externals - yyparse may be called more than once
559 	*/
560 	yypv = &yyv[-1];
561 	yyps = &yys[-1];
562 	yystate = 0;
563 	yytmp = 0;
564 	yynerrs = 0;
565 	yyerrflag = 0;
566 	yychar = -1;
567 
568 #if YYMAXDEPTH <= 0
569 	if (yymaxdepth <= 0)
570 	{
571 		if ((yymaxdepth = YYEXPAND(0)) <= 0)
572 		{
573 			yyerror("yacc initialization error");
574 			YYABORT;
575 		}
576 	}
577 #endif
578 
579 	{
580 		register YYSTYPE *yy_pv;	/* top of value stack */
581 		register int *yy_ps;		/* top of state stack */
582 		register int yy_state;		/* current state */
583 		register int  yy_n;		/* internal state number info */
584 	goto yystack;	/* moved from 6 lines above to here to please C++ */
585 
586 		/*
587 		** get globals into registers.
588 		** branch to here only if YYBACKUP was called.
589 		*/
590 	yynewstate:
591 		yy_pv = yypv;
592 		yy_ps = yyps;
593 		yy_state = yystate;
594 		goto yy_newstate;
595 
596 		/*
597 		** get globals into registers.
598 		** either we just started, or we just finished a reduction
599 		*/
600 	yystack:
601 		yy_pv = yypv;
602 		yy_ps = yyps;
603 		yy_state = yystate;
604 
605 		/*
606 		** top of for (;;) loop while no reductions done
607 		*/
608 	yy_stack:
609 		/*
610 		** put a state and value onto the stacks
611 		*/
612 #if YYDEBUG
613 		/*
614 		** if debugging, look up token value in list of value vs.
615 		** name pairs.  0 and negative (-1) are special values.
616 		** Note: linear search is used since time is not a real
617 		** consideration while debugging.
618 		*/
619 		if ( yydebug )
620 		{
621 			register int yy_i;
622 
623 			printf( "State %d, token ", yy_state );
624 			if ( yychar == 0 )
625 				printf( "end-of-file\n" );
626 			else if ( yychar < 0 )
627 				printf( "-none-\n" );
628 			else
629 			{
630 				for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
631 					yy_i++ )
632 				{
633 					if ( yytoks[yy_i].t_val == yychar )
634 						break;
635 				}
636 				printf( "%s\n", yytoks[yy_i].t_name );
637 			}
638 		}
639 #endif /* YYDEBUG */
640 		if ( ++yy_ps >= &yys[ yymaxdepth ] )	/* room on stack? */
641 		{
642 			/*
643 			** reallocate and recover.  Note that pointers
644 			** have to be reset, or bad things will happen
645 			*/
646 			long yyps_index = (yy_ps - yys);
647 			long yypv_index = (yy_pv - yyv);
648 			long yypvt_index = (yypvt - yyv);
649 			int yynewmax;
650 #ifdef YYEXPAND
651 			yynewmax = YYEXPAND(yymaxdepth);
652 #else
653 			yynewmax = 2 * yymaxdepth;	/* double table size */
654 			if (yymaxdepth == YYMAXDEPTH)	/* first time growth */
655 			{
656 				char *newyys = (char *)YYNEW(int);
657 				char *newyyv = (char *)YYNEW(YYSTYPE);
658 				if (newyys != 0 && newyyv != 0)
659 				{
660 					yys = YYCOPY(newyys, yys, int);
661 					yyv = YYCOPY(newyyv, yyv, YYSTYPE);
662 				}
663 				else
664 					yynewmax = 0;	/* failed */
665 			}
666 			else				/* not first time */
667 			{
668 				yys = YYENLARGE(yys, int);
669 				yyv = YYENLARGE(yyv, YYSTYPE);
670 				if (yys == 0 || yyv == 0)
671 					yynewmax = 0;	/* failed */
672 			}
673 #endif
674 			if (yynewmax <= yymaxdepth)	/* tables not expanded */
675 			{
676 				yyerror( "yacc stack overflow" );
677 				YYABORT;
678 			}
679 			yymaxdepth = yynewmax;
680 
681 			yy_ps = yys + yyps_index;
682 			yy_pv = yyv + yypv_index;
683 			yypvt = yyv + yypvt_index;
684 		}
685 		*yy_ps = yy_state;
686 		*++yy_pv = yyval;
687 
688 		/*
689 		** we have a new state - find out what to do
690 		*/
691 	yy_newstate:
692 		if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG )
693 			goto yydefault;		/* simple state */
694 #if YYDEBUG
695 		/*
696 		** if debugging, need to mark whether new token grabbed
697 		*/
698 		yytmp = yychar < 0;
699 #endif
700 		if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) )
701 			yychar = 0;		/* reached EOF */
702 #if YYDEBUG
703 		if ( yydebug && yytmp )
704 		{
705 			register int yy_i;
706 
707 			printf( "Received token " );
708 			if ( yychar == 0 )
709 				printf( "end-of-file\n" );
710 			else if ( yychar < 0 )
711 				printf( "-none-\n" );
712 			else
713 			{
714 				for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
715 					yy_i++ )
716 				{
717 					if ( yytoks[yy_i].t_val == yychar )
718 						break;
719 				}
720 				printf( "%s\n", yytoks[yy_i].t_name );
721 			}
722 		}
723 #endif /* YYDEBUG */
724 		if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) )
725 			goto yydefault;
726 		if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar )	/*valid shift*/
727 		{
728 			yychar = -1;
729 			yyval = yylval;
730 			yy_state = yy_n;
731 			if ( yyerrflag > 0 )
732 				yyerrflag--;
733 			goto yy_stack;
734 		}
735 
736 	yydefault:
737 		if ( ( yy_n = yydef[ yy_state ] ) == -2 )
738 		{
739 #if YYDEBUG
740 			yytmp = yychar < 0;
741 #endif
742 			if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) )
743 				yychar = 0;		/* reached EOF */
744 #if YYDEBUG
745 			if ( yydebug && yytmp )
746 			{
747 				register int yy_i;
748 
749 				printf( "Received token " );
750 				if ( yychar == 0 )
751 					printf( "end-of-file\n" );
752 				else if ( yychar < 0 )
753 					printf( "-none-\n" );
754 				else
755 				{
756 					for ( yy_i = 0;
757 						yytoks[yy_i].t_val >= 0;
758 						yy_i++ )
759 					{
760 						if ( yytoks[yy_i].t_val
761 							== yychar )
762 						{
763 							break;
764 						}
765 					}
766 					printf( "%s\n", yytoks[yy_i].t_name );
767 				}
768 			}
769 #endif /* YYDEBUG */
770 			/*
771 			** look through exception table
772 			*/
773 			{
774 				register YYCONST int *yyxi = yyexca;
775 
776 				while ( ( *yyxi != -1 ) ||
777 					( yyxi[1] != yy_state ) )
778 				{
779 					yyxi += 2;
780 				}
781 				while ( ( *(yyxi += 2) >= 0 ) &&
782 					( *yyxi != yychar ) )
783 					;
784 				if ( ( yy_n = yyxi[1] ) < 0 )
785 					YYACCEPT;
786 			}
787 		}
788 
789 		/*
790 		** check for syntax error
791 		*/
792 		if ( yy_n == 0 )	/* have an error */
793 		{
794 			/* no worry about speed here! */
795 			switch ( yyerrflag )
796 			{
797 			case 0:		/* new error */
798 				yyerror( "syntax error" );
799 				goto skip_init;
800 			yyerrlab:
801 				/*
802 				** get globals into registers.
803 				** we have a user generated syntax type error
804 				*/
805 				yy_pv = yypv;
806 				yy_ps = yyps;
807 				yy_state = yystate;
808 			skip_init:
809 				yynerrs++;
810 				/* FALLTHRU */
811 			case 1:
812 			case 2:		/* incompletely recovered error */
813 					/* try again... */
814 				yyerrflag = 3;
815 				/*
816 				** find state where "error" is a legal
817 				** shift action
818 				*/
819 				while ( yy_ps >= yys )
820 				{
821 					yy_n = yypact[ *yy_ps ] + YYERRCODE;
822 					if ( yy_n >= 0 && yy_n < YYLAST &&
823 						yychk[yyact[yy_n]] == YYERRCODE)					{
824 						/*
825 						** simulate shift of "error"
826 						*/
827 						yy_state = yyact[ yy_n ];
828 						goto yy_stack;
829 					}
830 					/*
831 					** current state has no shift on
832 					** "error", pop stack
833 					*/
834 #if YYDEBUG
835 #	define _POP_ "Error recovery pops state %d, uncovers state %d\n"
836 					if ( yydebug )
837 						printf( _POP_, *yy_ps,
838 							yy_ps[-1] );
839 #	undef _POP_
840 #endif
841 					yy_ps--;
842 					yy_pv--;
843 				}
844 				/*
845 				** there is no state on stack with "error" as
846 				** a valid shift.  give up.
847 				*/
848 				YYABORT;
849 			case 3:		/* no shift yet; eat a token */
850 #if YYDEBUG
851 				/*
852 				** if debugging, look up token in list of
853 				** pairs.  0 and negative shouldn't occur,
854 				** but since timing doesn't matter when
855 				** debugging, it doesn't hurt to leave the
856 				** tests here.
857 				*/
858 				if ( yydebug )
859 				{
860 					register int yy_i;
861 
862 					printf( "Error recovery discards " );
863 					if ( yychar == 0 )
864 						printf( "token end-of-file\n" );
865 					else if ( yychar < 0 )
866 						printf( "token -none-\n" );
867 					else
868 					{
869 						for ( yy_i = 0;
870 							yytoks[yy_i].t_val >= 0;
871 							yy_i++ )
872 						{
873 							if ( yytoks[yy_i].t_val
874 								== yychar )
875 							{
876 								break;
877 							}
878 						}
879 						printf( "token %s\n",
880 							yytoks[yy_i].t_name );
881 					}
882 				}
883 #endif /* YYDEBUG */
884 				if ( yychar == 0 )	/* reached EOF. quit */
885 					YYABORT;
886 				yychar = -1;
887 				goto yy_newstate;
888 			}
889 		}/* end if ( yy_n == 0 ) */
890 		/*
891 		** reduction by production yy_n
892 		** put stack tops, etc. so things right after switch
893 		*/
894 #if YYDEBUG
895 		/*
896 		** if debugging, print the string that is the user's
897 		** specification of the reduction which is just about
898 		** to be done.
899 		*/
900 		if ( yydebug )
901 			printf( "Reduce by (%d) \"%s\"\n",
902 				yy_n, yyreds[ yy_n ] );
903 #endif
904 		yytmp = yy_n;			/* value to switch over */
905 		yypvt = yy_pv;			/* $vars top of value stack */
906 		/*
907 		** Look in goto table for next state
908 		** Sorry about using yy_state here as temporary
909 		** register variable, but why not, if it works...
910 		** If yyr2[ yy_n ] doesn't have the low order bit
911 		** set, then there is no action to be done for
912 		** this reduction.  So, no saving & unsaving of
913 		** registers done.  The only difference between the
914 		** code just after the if and the body of the if is
915 		** the goto yy_stack in the body.  This way the test
916 		** can be made before the choice of what to do is needed.
917 		*/
918 		{
919 			/* length of production doubled with extra bit */
920 			register int yy_len = yyr2[ yy_n ];
921 
922 			if ( !( yy_len & 01 ) )
923 			{
924 				yy_len >>= 1;
925 				yyval = ( yy_pv -= yy_len )[1];	/* $$ = $1 */
926 				yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
927 					*( yy_ps -= yy_len ) + 1;
928 				if ( yy_state >= YYLAST ||
929 					yychk[ yy_state =
930 					yyact[ yy_state ] ] != -yy_n )
931 				{
932 					yy_state = yyact[ yypgo[ yy_n ] ];
933 				}
934 				goto yy_stack;
935 			}
936 			yy_len >>= 1;
937 			yyval = ( yy_pv -= yy_len )[1];	/* $$ = $1 */
938 			yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
939 				*( yy_ps -= yy_len ) + 1;
940 			if ( yy_state >= YYLAST ||
941 				yychk[ yy_state = yyact[ yy_state ] ] != -yy_n )
942 			{
943 				yy_state = yyact[ yypgo[ yy_n ] ];
944 			}
945 		}
946 					/* save until reenter driver code */
947 		yystate = yy_state;
948 		yyps = yy_ps;
949 		yypv = yy_pv;
950 	}
951 	/*
952 	** code supplied by user is placed in this switch
953 	*/
954 	switch( yytmp )
955 	{
956 
957 case 1:
958 # line 72 "genmsg.y"
959 {
960 			if (!IsActiveMode(ReplaceMode)) {
961 				src_err(srcfile, (lineno - 1),
962 				    gettext("catgets not found"));
963 			}
964 		} break;
965 case 2:
966 # line 78 "genmsg.y"
967 { is_cat_found = TRUE; } break;
968 case 3:
969 # line 81 "genmsg.y"
970 { end_of_cat = TRUE; } break;
971 case 4:
972 # line 82 "genmsg.y"
973 { end_of_cat = TRUE; } break;
974 case 5:
975 # line 86 "genmsg.y"
976 {
977 			do_catgets(yypvt[-5].id, yypvt[-3].id, yypvt[-1].str); free(yypvt[-1].str);
978 		} break;
979 case 7:
980 # line 92 "genmsg.y"
981 { yyval.str = yypvt[-0].str; } break;
982 case 8:
983 # line 93 "genmsg.y"
984 { yyval.str = yypvt[-0].str; } break;
985 case 12:
986 # line 99 "genmsg.y"
987 { yyval.str = yypvt[-4].str; } break;
988 case 16:
989 # line 107 "genmsg.y"
990 { yyval.str = yypvt[-1].str; } break;
991 case 20:
992 # line 111 "genmsg.y"
993 { free(yypvt[-1].str); } break;
994 case 21:
995 # line 114 "genmsg.y"
996 { yyval.str = yypvt[-1].str; } break;
997 case 23:
998 # line 116 "genmsg.y"
999 { yyval.str = yypvt[-0].str; } break;
1000 case 24:
1001 # line 119 "genmsg.y"
1002 { yyval.str = yypvt[-1].str; } break;
1003 case 25:
1004 # line 120 "genmsg.y"
1005 { yyval.str = yypvt[-0].str; } break;
1006 case 27:
1007 # line 124 "genmsg.y"
1008 { yyval.id = yypvt[-0].id; } break;
1009 case 28:
1010 # line 125 "genmsg.y"
1011 { yyval.id = yypvt[-0].id; } break;
1012 case 30:
1013 # line 129 "genmsg.y"
1014 { yyval.id = yypvt[-2].id + yypvt[-0].id; } break;
1015 case 31:
1016 # line 130 "genmsg.y"
1017 { yyval.id = yypvt[-2].id - yypvt[-0].id; } break;
1018 case 32:
1019 # line 131 "genmsg.y"
1020 { yyval.id = yypvt[-2].id * yypvt[-0].id; } break;
1021 case 33:
1022 # line 133 "genmsg.y"
1023 {
1024 			if (yypvt[-0].id == 0) {
1025 				yyerror(gettext("zero divide"));
1026 			} else {
1027 				yyval.id = yypvt[-2].id / yypvt[-0].id;
1028 			}
1029 		} break;
1030 case 34:
1031 # line 140 "genmsg.y"
1032 { yyval.id = -yypvt[-0].id; } break;
1033 case 35:
1034 # line 141 "genmsg.y"
1035 { yyval.id = yypvt[-1].id; } break;
1036 case 37:
1037 # line 145 "genmsg.y"
1038 { yyval.id = yypvt[-0].id; } break;
1039 case 38:
1040 # line 146 "genmsg.y"
1041 { yyval.id = yypvt[-0].id; } break;
1042 case 40:
1043 # line 150 "genmsg.y"
1044 { yyval.id = yypvt[-2].id + yypvt[-0].id; } break;
1045 case 41:
1046 # line 151 "genmsg.y"
1047 { yyval.id = yypvt[-2].id - yypvt[-0].id; } break;
1048 case 42:
1049 # line 152 "genmsg.y"
1050 { yyval.id = yypvt[-2].id * yypvt[-0].id; } break;
1051 case 43:
1052 # line 154 "genmsg.y"
1053 {
1054 			if (yypvt[-0].id == 0) {
1055 				yyerror(gettext("zero devide"));
1056 			} else {
1057 				yyval.id = yypvt[-2].id / yypvt[-0].id;
1058 			}
1059 		} break;
1060 case 44:
1061 # line 161 "genmsg.y"
1062 { yyval.id = -yypvt[-0].id; } break;
1063 case 45:
1064 # line 162 "genmsg.y"
1065 { yyval.id = yypvt[-1].id; } break;
1066 case 47:
1067 # line 166 "genmsg.y"
1068 { yyval.id = yypvt[-0].id; } break;
1069 case 48:
1070 # line 167 "genmsg.y"
1071 { yyval.id = yypvt[-0].id; } break;
1072 case 50:
1073 # line 171 "genmsg.y"
1074 { yyval.id = yypvt[-2].id + yypvt[-0].id; } break;
1075 case 51:
1076 # line 172 "genmsg.y"
1077 { yyval.id = yypvt[-2].id - yypvt[-0].id; } break;
1078 case 52:
1079 # line 173 "genmsg.y"
1080 { yyval.id = yypvt[-2].id * yypvt[-0].id; } break;
1081 case 53:
1082 # line 175 "genmsg.y"
1083 {
1084 			if (yypvt[-0].id == 0) {
1085 				yyerror(gettext("zero divide"));
1086 			} else {
1087 				yyval.id = yypvt[-2].id / yypvt[-0].id;
1088 			}
1089 		} break;
1090 case 54:
1091 # line 182 "genmsg.y"
1092 { yyval.id = -yypvt[-0].id; } break;
1093 case 55:
1094 # line 183 "genmsg.y"
1095 { yyval.id = yypvt[-1].id; } break;
1096 case 57:
1097 # line 187 "genmsg.y"
1098 { yyval.str = yypvt[-0].str; } break;
1099 case 58:
1100 # line 188 "genmsg.y"
1101 { yyval.str = yypvt[-0].str; } break;
1102 case 60:
1103 # line 192 "genmsg.y"
1104 { yyval.str = yypvt[-1].str; } break;
1105 case 63:
1106 # line 197 "genmsg.y"
1107 { yyval.str = add_qstring(yypvt[-1].str, yypvt[-0].str); } break;
1108 # line	556 "/usr/share/lib/ccs/yaccpar"
1109 	}
1110 	goto yystack;		/* reset registers in driver code */
1111 }
1112 
1113