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 (c) 1997-1999 by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate  * All rights reserved.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #include <stdio.h>
28*7c478bd9Sstevel@tonic-gate #include <string.h>
29*7c478bd9Sstevel@tonic-gate #include <ctype.h>
30*7c478bd9Sstevel@tonic-gate #include "xlator.h"
31*7c478bd9Sstevel@tonic-gate #include "util.h"
32*7c478bd9Sstevel@tonic-gate #include "bucket.h"
33*7c478bd9Sstevel@tonic-gate #include "errlog.h"
34*7c478bd9Sstevel@tonic-gate 
35*7c478bd9Sstevel@tonic-gate /* Types: */
36*7c478bd9Sstevel@tonic-gate #define	TRUE	1
37*7c478bd9Sstevel@tonic-gate #define	FALSE	0
38*7c478bd9Sstevel@tonic-gate #define	MAXLINE 1024
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate typedef enum {
42*7c478bd9Sstevel@tonic-gate 	PARENT, UNCLE
43*7c478bd9Sstevel@tonic-gate } RELATION;
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate /* Statics: */
47*7c478bd9Sstevel@tonic-gate /* The parser is a dfa, driven by the following: */
48*7c478bd9Sstevel@tonic-gate static FILE *Fp;
49*7c478bd9Sstevel@tonic-gate static const char *Filename;
50*7c478bd9Sstevel@tonic-gate static char Previous[MAXLINE];
51*7c478bd9Sstevel@tonic-gate static char LeftMostChild[MAXLINE];
52*7c478bd9Sstevel@tonic-gate static int Selected = FALSE;
53*7c478bd9Sstevel@tonic-gate static int Line;
54*7c478bd9Sstevel@tonic-gate static int Errors;
55*7c478bd9Sstevel@tonic-gate 
56*7c478bd9Sstevel@tonic-gate 
57*7c478bd9Sstevel@tonic-gate /* The grammar is: */
58*7c478bd9Sstevel@tonic-gate static int arch(void);
59*7c478bd9Sstevel@tonic-gate static int comment(void);
60*7c478bd9Sstevel@tonic-gate static int arch_name(void);
61*7c478bd9Sstevel@tonic-gate static int set_list(void);
62*7c478bd9Sstevel@tonic-gate static int set(void);
63*7c478bd9Sstevel@tonic-gate 
64*7c478bd9Sstevel@tonic-gate /* The supporting code is: */
65*7c478bd9Sstevel@tonic-gate static int accept_token(char *);
66*7c478bd9Sstevel@tonic-gate static void skip_to(char *);
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate /* And the tokenizer is: */
69*7c478bd9Sstevel@tonic-gate static char *tokenize(char *);
70*7c478bd9Sstevel@tonic-gate static char *currtok(void);
71*7c478bd9Sstevel@tonic-gate static char *nexttok(void);
72*7c478bd9Sstevel@tonic-gate static char *skipb(char *);
73*7c478bd9Sstevel@tonic-gate static char *skipover(char *);
74*7c478bd9Sstevel@tonic-gate static char *CurrTok = NULL;
75*7c478bd9Sstevel@tonic-gate 
76*7c478bd9Sstevel@tonic-gate static int set_parents(void);
77*7c478bd9Sstevel@tonic-gate 
78*7c478bd9Sstevel@tonic-gate static table_t *Vers;
79*7c478bd9Sstevel@tonic-gate static table_t *Varch;
80*7c478bd9Sstevel@tonic-gate 
81*7c478bd9Sstevel@tonic-gate static void init_tables(void);
82*7c478bd9Sstevel@tonic-gate 
83*7c478bd9Sstevel@tonic-gate static void add_valid_arch(char *);
84*7c478bd9Sstevel@tonic-gate static void add_valid_version(char *vers_name);
85*7c478bd9Sstevel@tonic-gate 
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate #define	in_specials(c)  ((c) == '{' || (c) == '}' || (c) == '+' || \
88*7c478bd9Sstevel@tonic-gate 	(c) == '-' || (c) == ';' || (c) == ':' || (c) == ',' || \
89*7c478bd9Sstevel@tonic-gate 	(c) == '[' || (c) == ']')
90*7c478bd9Sstevel@tonic-gate 
91*7c478bd9Sstevel@tonic-gate #define	eq(s1, s2)	(strcmp((s1), (s2)) == 0)
92*7c478bd9Sstevel@tonic-gate 
93*7c478bd9Sstevel@tonic-gate 
94*7c478bd9Sstevel@tonic-gate /*
95*7c478bd9Sstevel@tonic-gate  * parse_versions -- parse the file whose name is passed, return
96*7c478bd9Sstevel@tonic-gate  *	the number of (fatal) errors encountered. Currently only
97*7c478bd9Sstevel@tonic-gate  *	knows about reading set files and writing vers files.
98*7c478bd9Sstevel@tonic-gate  */
99*7c478bd9Sstevel@tonic-gate int
parse_versions(const char * fileName)100*7c478bd9Sstevel@tonic-gate parse_versions(const char *fileName)
101*7c478bd9Sstevel@tonic-gate {
102*7c478bd9Sstevel@tonic-gate 
103*7c478bd9Sstevel@tonic-gate 	/* Prime the set-file parser dfa: */
104*7c478bd9Sstevel@tonic-gate 	assert(fileName != NULL, "passed null filename to parse_versions");
105*7c478bd9Sstevel@tonic-gate 	errlog(BEGIN, "parse_versions(%s) {", fileName);
106*7c478bd9Sstevel@tonic-gate 
107*7c478bd9Sstevel@tonic-gate 
108*7c478bd9Sstevel@tonic-gate 	if ((Fp = fopen(fileName, "r")) == NULL) {
109*7c478bd9Sstevel@tonic-gate 		(void) fprintf(stderr, "Cannot open version file \"%s\"\n",
110*7c478bd9Sstevel@tonic-gate 		    fileName);
111*7c478bd9Sstevel@tonic-gate 		errlog(END, "} /* parse_versions */");
112*7c478bd9Sstevel@tonic-gate 		return (1);
113*7c478bd9Sstevel@tonic-gate 	}
114*7c478bd9Sstevel@tonic-gate 	Filename = fileName;
115*7c478bd9Sstevel@tonic-gate 	Line = 0;
116*7c478bd9Sstevel@tonic-gate 
117*7c478bd9Sstevel@tonic-gate 	errlog(VERBOSE, "reading set file %s looking for architecture %s",
118*7c478bd9Sstevel@tonic-gate 	    Filename, TargetArchStr);
119*7c478bd9Sstevel@tonic-gate 
120*7c478bd9Sstevel@tonic-gate 	/* Run the dfa. */
121*7c478bd9Sstevel@tonic-gate 	while (arch())
122*7c478bd9Sstevel@tonic-gate 		continue;
123*7c478bd9Sstevel@tonic-gate 
124*7c478bd9Sstevel@tonic-gate 	(void) fclose(Fp);
125*7c478bd9Sstevel@tonic-gate 	/* print_all_buckets(); */
126*7c478bd9Sstevel@tonic-gate 	errlog(END, "} /* parse_versions */");
127*7c478bd9Sstevel@tonic-gate 	return (Errors);
128*7c478bd9Sstevel@tonic-gate }
129*7c478bd9Sstevel@tonic-gate 
130*7c478bd9Sstevel@tonic-gate 
131*7c478bd9Sstevel@tonic-gate /*
132*7c478bd9Sstevel@tonic-gate  * The parser. This implements the grammar:
133*7c478bd9Sstevel@tonic-gate  *    setfile::= (arch())+ <EOF>
134*7c478bd9Sstevel@tonic-gate  *             | <EOF>
135*7c478bd9Sstevel@tonic-gate  *    arch::= <ARCHITECTURE> "{" (set_list())* "}"
136*7c478bd9Sstevel@tonic-gate  *    set_list::= (set())+ ";"
137*7c478bd9Sstevel@tonic-gate  *    set::= <IDENTIFIER> ["[" "WEAK" "]"] ":" "{" (ancestors) "}" ";"
138*7c478bd9Sstevel@tonic-gate  *    ancestors::= <IDENTIFIER> | <ancestors> "," <IDENTIFIER>
139*7c478bd9Sstevel@tonic-gate  *    where <ARCHITECTURE> and <IDENTIFIER> are tokens.
140*7c478bd9Sstevel@tonic-gate  */
141*7c478bd9Sstevel@tonic-gate static int
arch(void)142*7c478bd9Sstevel@tonic-gate arch(void)
143*7c478bd9Sstevel@tonic-gate {
144*7c478bd9Sstevel@tonic-gate 	int olderrors;
145*7c478bd9Sstevel@tonic-gate 
146*7c478bd9Sstevel@tonic-gate 	errlog(BEGIN, "arch() {");
147*7c478bd9Sstevel@tonic-gate 	if (comment()) {
148*7c478bd9Sstevel@tonic-gate 		errlog(END, "} /* arch */");
149*7c478bd9Sstevel@tonic-gate 		return (TRUE);
150*7c478bd9Sstevel@tonic-gate 	}
151*7c478bd9Sstevel@tonic-gate 	if (arch_name() == FALSE) {
152*7c478bd9Sstevel@tonic-gate 		errlog(END, "} /* arch */");
153*7c478bd9Sstevel@tonic-gate 		return (FALSE);
154*7c478bd9Sstevel@tonic-gate 	}
155*7c478bd9Sstevel@tonic-gate 	if (accept_token("{") == FALSE) {
156*7c478bd9Sstevel@tonic-gate 		errlog(END, "} /* arch */");
157*7c478bd9Sstevel@tonic-gate 		return (FALSE);
158*7c478bd9Sstevel@tonic-gate 	}
159*7c478bd9Sstevel@tonic-gate 
160*7c478bd9Sstevel@tonic-gate 	olderrors = Errors;
161*7c478bd9Sstevel@tonic-gate 	if (set_list() == FALSE) {
162*7c478bd9Sstevel@tonic-gate 		if (olderrors != Errors) {
163*7c478bd9Sstevel@tonic-gate 			errlog(END, "} /* arch */");
164*7c478bd9Sstevel@tonic-gate 			return (FALSE);
165*7c478bd9Sstevel@tonic-gate 		}
166*7c478bd9Sstevel@tonic-gate 	}
167*7c478bd9Sstevel@tonic-gate 
168*7c478bd9Sstevel@tonic-gate 	errlog(END, "} /* arch */");
169*7c478bd9Sstevel@tonic-gate 	return (TRUE);
170*7c478bd9Sstevel@tonic-gate }
171*7c478bd9Sstevel@tonic-gate 
172*7c478bd9Sstevel@tonic-gate static int
comment(void)173*7c478bd9Sstevel@tonic-gate comment(void)
174*7c478bd9Sstevel@tonic-gate {
175*7c478bd9Sstevel@tonic-gate 	char *token = currtok();
176*7c478bd9Sstevel@tonic-gate 
177*7c478bd9Sstevel@tonic-gate 	if (token == NULL || *token != '#') {
178*7c478bd9Sstevel@tonic-gate 		return (FALSE);
179*7c478bd9Sstevel@tonic-gate 	} else {
180*7c478bd9Sstevel@tonic-gate 		/* Swallow token. */
181*7c478bd9Sstevel@tonic-gate 		token =  nexttok();
182*7c478bd9Sstevel@tonic-gate 		return (TRUE);
183*7c478bd9Sstevel@tonic-gate 	}
184*7c478bd9Sstevel@tonic-gate }
185*7c478bd9Sstevel@tonic-gate 
186*7c478bd9Sstevel@tonic-gate static int
arch_name(void)187*7c478bd9Sstevel@tonic-gate arch_name(void)
188*7c478bd9Sstevel@tonic-gate {
189*7c478bd9Sstevel@tonic-gate 	char *token = currtok();
190*7c478bd9Sstevel@tonic-gate 
191*7c478bd9Sstevel@tonic-gate 	errlog(BEGIN, "arch_name() {");
192*7c478bd9Sstevel@tonic-gate 	errlog(VERBOSE, "token = '%s';",
193*7c478bd9Sstevel@tonic-gate 		token ? token : "<NULL>");
194*7c478bd9Sstevel@tonic-gate 
195*7c478bd9Sstevel@tonic-gate 	if (token == NULL) {
196*7c478bd9Sstevel@tonic-gate 		errlog(END, "} /* arch_name */");
197*7c478bd9Sstevel@tonic-gate 		return (FALSE);
198*7c478bd9Sstevel@tonic-gate 
199*7c478bd9Sstevel@tonic-gate 	} else if (in_specials(*token)) {
200*7c478bd9Sstevel@tonic-gate 		/* It's not an architecture */
201*7c478bd9Sstevel@tonic-gate 		Selected = FALSE;
202*7c478bd9Sstevel@tonic-gate 
203*7c478bd9Sstevel@tonic-gate 		/* Report a syntax error: TBD */
204*7c478bd9Sstevel@tonic-gate 		errlog(INPUT | ERROR, "found special char. %c "
205*7c478bd9Sstevel@tonic-gate 		    "while looking for an architecture name",
206*7c478bd9Sstevel@tonic-gate 		    *token);
207*7c478bd9Sstevel@tonic-gate 
208*7c478bd9Sstevel@tonic-gate 		skip_to("}");	/* The follower set for arch_name. */
209*7c478bd9Sstevel@tonic-gate 		errlog(END, "} /* arch name */");
210*7c478bd9Sstevel@tonic-gate 
211*7c478bd9Sstevel@tonic-gate 		Errors++;
212*7c478bd9Sstevel@tonic-gate 		return (FALSE);
213*7c478bd9Sstevel@tonic-gate 
214*7c478bd9Sstevel@tonic-gate 	} else if (!eq(token, TargetArchStr)) {
215*7c478bd9Sstevel@tonic-gate 		/* It's an architecture ... */
216*7c478bd9Sstevel@tonic-gate 		errlog(VERBOSE, "Begin unselected architecture: %s", token);
217*7c478bd9Sstevel@tonic-gate 		add_valid_arch(token);
218*7c478bd9Sstevel@tonic-gate 		(void) nexttok();
219*7c478bd9Sstevel@tonic-gate 
220*7c478bd9Sstevel@tonic-gate 		/* ... but the the wrong one. */
221*7c478bd9Sstevel@tonic-gate 		Selected = FALSE;
222*7c478bd9Sstevel@tonic-gate 		errlog(END, "} /* arch name */");
223*7c478bd9Sstevel@tonic-gate 		return (TRUE);
224*7c478bd9Sstevel@tonic-gate 	} else {
225*7c478bd9Sstevel@tonic-gate 		/* Found the right architecture. */
226*7c478bd9Sstevel@tonic-gate 		errlog(VERBOSE, "Begin selected architecture: %s", token);
227*7c478bd9Sstevel@tonic-gate 		add_valid_arch(token);
228*7c478bd9Sstevel@tonic-gate 		(void) nexttok();
229*7c478bd9Sstevel@tonic-gate 		Selected = TRUE;
230*7c478bd9Sstevel@tonic-gate 		errlog(END, "} /* arch name */");
231*7c478bd9Sstevel@tonic-gate 		return (TRUE);
232*7c478bd9Sstevel@tonic-gate 	}
233*7c478bd9Sstevel@tonic-gate }
234*7c478bd9Sstevel@tonic-gate 
235*7c478bd9Sstevel@tonic-gate 
236*7c478bd9Sstevel@tonic-gate static int
set_list(void)237*7c478bd9Sstevel@tonic-gate set_list(void)
238*7c478bd9Sstevel@tonic-gate {
239*7c478bd9Sstevel@tonic-gate 	int olderrors;
240*7c478bd9Sstevel@tonic-gate 	char *token = currtok();
241*7c478bd9Sstevel@tonic-gate 
242*7c478bd9Sstevel@tonic-gate 	errlog(BEGIN, "set_list() {");
243*7c478bd9Sstevel@tonic-gate 	errlog(VERBOSE, "token = '%s'",
244*7c478bd9Sstevel@tonic-gate 	    (token) ? token : "<NULL>");
245*7c478bd9Sstevel@tonic-gate 	if (set() == FALSE) {
246*7c478bd9Sstevel@tonic-gate 		errlog(END, "} /* set_list */");
247*7c478bd9Sstevel@tonic-gate 		return (FALSE);
248*7c478bd9Sstevel@tonic-gate 	}
249*7c478bd9Sstevel@tonic-gate 
250*7c478bd9Sstevel@tonic-gate 	olderrors = Errors;
251*7c478bd9Sstevel@tonic-gate 	while (set()) {
252*7c478bd9Sstevel@tonic-gate 		continue;
253*7c478bd9Sstevel@tonic-gate 	}
254*7c478bd9Sstevel@tonic-gate 	if (olderrors != Errors) {
255*7c478bd9Sstevel@tonic-gate 		errlog(END, "} /* set_list */");
256*7c478bd9Sstevel@tonic-gate 		return (FALSE);
257*7c478bd9Sstevel@tonic-gate 	}
258*7c478bd9Sstevel@tonic-gate 
259*7c478bd9Sstevel@tonic-gate 	errlog(END, "} /* set_list */");
260*7c478bd9Sstevel@tonic-gate 	return (TRUE);
261*7c478bd9Sstevel@tonic-gate }
262*7c478bd9Sstevel@tonic-gate 
263*7c478bd9Sstevel@tonic-gate 
264*7c478bd9Sstevel@tonic-gate static int
set(void)265*7c478bd9Sstevel@tonic-gate set(void)
266*7c478bd9Sstevel@tonic-gate {
267*7c478bd9Sstevel@tonic-gate 	char *token = currtok();
268*7c478bd9Sstevel@tonic-gate 	int has_parent = 0;
269*7c478bd9Sstevel@tonic-gate 
270*7c478bd9Sstevel@tonic-gate 	errlog(BEGIN, "set() {");
271*7c478bd9Sstevel@tonic-gate 	errlog(VERBOSE, "token = '%s'",
272*7c478bd9Sstevel@tonic-gate 	    (token) ? token : "<NULL>");
273*7c478bd9Sstevel@tonic-gate 
274*7c478bd9Sstevel@tonic-gate 	if (in_specials(*token)) {
275*7c478bd9Sstevel@tonic-gate 		errlog(INPUT|ERROR, "unexpected token \"%s\" found. "
276*7c478bd9Sstevel@tonic-gate 		    "Version name expected", token);
277*7c478bd9Sstevel@tonic-gate 		Errors++;
278*7c478bd9Sstevel@tonic-gate 		errlog(END, "} /* set */");
279*7c478bd9Sstevel@tonic-gate 		return (FALSE);
280*7c478bd9Sstevel@tonic-gate 	}
281*7c478bd9Sstevel@tonic-gate 
282*7c478bd9Sstevel@tonic-gate 	errlog(VERBOSE, "Begin Version: %s", token);
283*7c478bd9Sstevel@tonic-gate 	*Previous = '\0';
284*7c478bd9Sstevel@tonic-gate 	if (Selected) {
285*7c478bd9Sstevel@tonic-gate 		if (add_parent(token, Previous, 0) == FALSE) {
286*7c478bd9Sstevel@tonic-gate 			errlog(INPUT | ERROR, "unable to add a parent version "
287*7c478bd9Sstevel@tonic-gate 			    "from the set file");
288*7c478bd9Sstevel@tonic-gate 			Errors++;
289*7c478bd9Sstevel@tonic-gate 			errlog(END, "} /* set */");
290*7c478bd9Sstevel@tonic-gate 			return (FALSE);
291*7c478bd9Sstevel@tonic-gate 		}
292*7c478bd9Sstevel@tonic-gate 	}
293*7c478bd9Sstevel@tonic-gate 
294*7c478bd9Sstevel@tonic-gate 	add_valid_version(token);
295*7c478bd9Sstevel@tonic-gate 	(void) strncpy(LeftMostChild, token, MAXLINE);
296*7c478bd9Sstevel@tonic-gate 	LeftMostChild[MAXLINE-1] = '\0';
297*7c478bd9Sstevel@tonic-gate 	(void) strncpy(Previous, token, MAXLINE);
298*7c478bd9Sstevel@tonic-gate 	Previous[MAXLINE-1] = '\0';
299*7c478bd9Sstevel@tonic-gate 
300*7c478bd9Sstevel@tonic-gate 	token = nexttok();
301*7c478bd9Sstevel@tonic-gate 
302*7c478bd9Sstevel@tonic-gate 	switch (*token) {
303*7c478bd9Sstevel@tonic-gate 		case ':':
304*7c478bd9Sstevel@tonic-gate 			errlog(VERBOSE, "token ':' found");
305*7c478bd9Sstevel@tonic-gate 			(void) accept_token(":");
306*7c478bd9Sstevel@tonic-gate 			if (set_parents() == FALSE) {
307*7c478bd9Sstevel@tonic-gate 				errlog(END, "} /* set */");
308*7c478bd9Sstevel@tonic-gate 				return (FALSE);
309*7c478bd9Sstevel@tonic-gate 			}
310*7c478bd9Sstevel@tonic-gate 			if (accept_token(";") == FALSE) {
311*7c478bd9Sstevel@tonic-gate 				errlog(END, "} /* set */");
312*7c478bd9Sstevel@tonic-gate 				return (FALSE);
313*7c478bd9Sstevel@tonic-gate 			}
314*7c478bd9Sstevel@tonic-gate 			errlog(VERBOSE, "End Version");
315*7c478bd9Sstevel@tonic-gate 			break;
316*7c478bd9Sstevel@tonic-gate 
317*7c478bd9Sstevel@tonic-gate 		case ';':
318*7c478bd9Sstevel@tonic-gate 			errlog(VERBOSE, "token ';' found");
319*7c478bd9Sstevel@tonic-gate 			(void) accept_token(";");
320*7c478bd9Sstevel@tonic-gate 			errlog(VERBOSE, "End version ':'");
321*7c478bd9Sstevel@tonic-gate 			break;
322*7c478bd9Sstevel@tonic-gate 
323*7c478bd9Sstevel@tonic-gate 		case '[':
324*7c478bd9Sstevel@tonic-gate 			(void) accept_token("[");
325*7c478bd9Sstevel@tonic-gate 			if (accept_token("WEAK") == FALSE) {
326*7c478bd9Sstevel@tonic-gate 				errlog(END, "} /* set */");
327*7c478bd9Sstevel@tonic-gate 				return (FALSE);
328*7c478bd9Sstevel@tonic-gate 			}
329*7c478bd9Sstevel@tonic-gate 			if (accept_token("]") == FALSE) {
330*7c478bd9Sstevel@tonic-gate 				errlog(END, "} /* set */");
331*7c478bd9Sstevel@tonic-gate 				return (FALSE);
332*7c478bd9Sstevel@tonic-gate 			}
333*7c478bd9Sstevel@tonic-gate 			token = currtok();
334*7c478bd9Sstevel@tonic-gate 			if (eq(token, ":")) {
335*7c478bd9Sstevel@tonic-gate 				(void) accept_token(":");
336*7c478bd9Sstevel@tonic-gate 				has_parent = 1;
337*7c478bd9Sstevel@tonic-gate 			} else if (eq(token, ";")) {
338*7c478bd9Sstevel@tonic-gate 				(void) accept_token(";");
339*7c478bd9Sstevel@tonic-gate 			} else {
340*7c478bd9Sstevel@tonic-gate 				errlog(ERROR|INPUT,
341*7c478bd9Sstevel@tonic-gate 				    "Unexpected token \"%s\" found. ':'"
342*7c478bd9Sstevel@tonic-gate 				    "or ';' expected.", token);
343*7c478bd9Sstevel@tonic-gate 				Errors++;
344*7c478bd9Sstevel@tonic-gate 				errlog(END, "} /* set */");
345*7c478bd9Sstevel@tonic-gate 				return (FALSE);
346*7c478bd9Sstevel@tonic-gate 			}
347*7c478bd9Sstevel@tonic-gate 			errlog(VERBOSE, "WEAK version detected\n");
348*7c478bd9Sstevel@tonic-gate 			if (Selected)
349*7c478bd9Sstevel@tonic-gate 				set_weak(LeftMostChild, TRUE);
350*7c478bd9Sstevel@tonic-gate 
351*7c478bd9Sstevel@tonic-gate 			if (has_parent) {
352*7c478bd9Sstevel@tonic-gate 				if (set_parents() == FALSE) {
353*7c478bd9Sstevel@tonic-gate 					errlog(END, "} /* set */");
354*7c478bd9Sstevel@tonic-gate 					return (FALSE);
355*7c478bd9Sstevel@tonic-gate 				}
356*7c478bd9Sstevel@tonic-gate 				if (accept_token(";") == FALSE) {
357*7c478bd9Sstevel@tonic-gate 					errlog(END, "} /* set */");
358*7c478bd9Sstevel@tonic-gate 					return (FALSE);
359*7c478bd9Sstevel@tonic-gate 				}
360*7c478bd9Sstevel@tonic-gate 			}
361*7c478bd9Sstevel@tonic-gate 			errlog(VERBOSE, "End Version");
362*7c478bd9Sstevel@tonic-gate 			break;
363*7c478bd9Sstevel@tonic-gate 		default:
364*7c478bd9Sstevel@tonic-gate 			/* CSTYLED */
365*7c478bd9Sstevel@tonic-gate 			errlog(ERROR|INPUT,
366*7c478bd9Sstevel@tonic-gate 			    "Unexpected token \"%s\" found. ';' expected.",
367*7c478bd9Sstevel@tonic-gate 			    token);
368*7c478bd9Sstevel@tonic-gate 			Errors++;
369*7c478bd9Sstevel@tonic-gate 			errlog(END, "} /* set */");
370*7c478bd9Sstevel@tonic-gate 			return (FALSE);
371*7c478bd9Sstevel@tonic-gate 	}
372*7c478bd9Sstevel@tonic-gate 
373*7c478bd9Sstevel@tonic-gate 	token = currtok();
374*7c478bd9Sstevel@tonic-gate 	if (eq(token, "}")) {
375*7c478bd9Sstevel@tonic-gate 		(void) accept_token("}");
376*7c478bd9Sstevel@tonic-gate 		errlog(VERBOSE, "End architecture");
377*7c478bd9Sstevel@tonic-gate 		errlog(END, "} /* set */");
378*7c478bd9Sstevel@tonic-gate 		return (FALSE);
379*7c478bd9Sstevel@tonic-gate 	}
380*7c478bd9Sstevel@tonic-gate 
381*7c478bd9Sstevel@tonic-gate 	errlog(END, "} /* set */");
382*7c478bd9Sstevel@tonic-gate 	return (TRUE);
383*7c478bd9Sstevel@tonic-gate }
384*7c478bd9Sstevel@tonic-gate 
385*7c478bd9Sstevel@tonic-gate static int
set_parents(void)386*7c478bd9Sstevel@tonic-gate set_parents(void)
387*7c478bd9Sstevel@tonic-gate {
388*7c478bd9Sstevel@tonic-gate 	char *token = currtok();
389*7c478bd9Sstevel@tonic-gate 	int uncle;
390*7c478bd9Sstevel@tonic-gate 
391*7c478bd9Sstevel@tonic-gate 	errlog(BEGIN, "set_parents() {");
392*7c478bd9Sstevel@tonic-gate 	errlog(VERBOSE, "token = '%s'",
393*7c478bd9Sstevel@tonic-gate 	    (token) ? token : "<NULL>");
394*7c478bd9Sstevel@tonic-gate 
395*7c478bd9Sstevel@tonic-gate 	if (accept_token("{") == FALSE) {
396*7c478bd9Sstevel@tonic-gate 		errlog(INPUT|ERROR, "set_parents(): Unexpected token: %s\n",
397*7c478bd9Sstevel@tonic-gate 		    token);
398*7c478bd9Sstevel@tonic-gate 		Errors++;
399*7c478bd9Sstevel@tonic-gate 		errlog(END, "} /* set_parents */");
400*7c478bd9Sstevel@tonic-gate 		return (FALSE);
401*7c478bd9Sstevel@tonic-gate 	}
402*7c478bd9Sstevel@tonic-gate 
403*7c478bd9Sstevel@tonic-gate 	token = currtok();
404*7c478bd9Sstevel@tonic-gate 
405*7c478bd9Sstevel@tonic-gate 	if (in_specials(*token)) {
406*7c478bd9Sstevel@tonic-gate 		errlog(INPUT|ERROR, "set_parents(): Unexpected token: %c "
407*7c478bd9Sstevel@tonic-gate 		    "found. Version token expected", *token);
408*7c478bd9Sstevel@tonic-gate 		Errors++;
409*7c478bd9Sstevel@tonic-gate 		errlog(END, "} /* set_parents */");
410*7c478bd9Sstevel@tonic-gate 		return (FALSE);
411*7c478bd9Sstevel@tonic-gate 	}
412*7c478bd9Sstevel@tonic-gate 
413*7c478bd9Sstevel@tonic-gate 	uncle = 0;
414*7c478bd9Sstevel@tonic-gate 	while (token && *token != '}') {
415*7c478bd9Sstevel@tonic-gate 		errlog(VERBOSE, "Begin parent list: %s\n", token);
416*7c478bd9Sstevel@tonic-gate 		if (Selected) {
417*7c478bd9Sstevel@tonic-gate 			if (uncle)
418*7c478bd9Sstevel@tonic-gate 				(void) add_uncle(token, LeftMostChild, 0);
419*7c478bd9Sstevel@tonic-gate 			else
420*7c478bd9Sstevel@tonic-gate 				(void) add_parent(token, Previous, 0);
421*7c478bd9Sstevel@tonic-gate 		}
422*7c478bd9Sstevel@tonic-gate 		(void) strncpy(Previous, token, MAXLINE);
423*7c478bd9Sstevel@tonic-gate 		add_valid_version(token);
424*7c478bd9Sstevel@tonic-gate 		Previous[MAXLINE-1] = '\0';
425*7c478bd9Sstevel@tonic-gate 
426*7c478bd9Sstevel@tonic-gate 		token = nexttok();
427*7c478bd9Sstevel@tonic-gate 
428*7c478bd9Sstevel@tonic-gate 		if (*token == ',') {
429*7c478bd9Sstevel@tonic-gate 			token = nexttok();
430*7c478bd9Sstevel@tonic-gate 			/* following identifiers are all uncles */
431*7c478bd9Sstevel@tonic-gate 			uncle = 1;
432*7c478bd9Sstevel@tonic-gate 			continue;
433*7c478bd9Sstevel@tonic-gate 		}
434*7c478bd9Sstevel@tonic-gate 
435*7c478bd9Sstevel@tonic-gate 		if (*token == '}') {
436*7c478bd9Sstevel@tonic-gate 			if (accept_token("}") == FALSE) {
437*7c478bd9Sstevel@tonic-gate 				errlog(END, "} /* set_parents */");
438*7c478bd9Sstevel@tonic-gate 				return (FALSE);
439*7c478bd9Sstevel@tonic-gate 			}
440*7c478bd9Sstevel@tonic-gate 			errlog(VERBOSE, "set_parent: End of parent list");
441*7c478bd9Sstevel@tonic-gate 			errlog(END, "} /* set_parents */");
442*7c478bd9Sstevel@tonic-gate 			return (TRUE);
443*7c478bd9Sstevel@tonic-gate 		}
444*7c478bd9Sstevel@tonic-gate 
445*7c478bd9Sstevel@tonic-gate 		errlog(INPUT|ERROR,
446*7c478bd9Sstevel@tonic-gate 		    "set_parents(): Unexpected token \"%s\" "
447*7c478bd9Sstevel@tonic-gate 		    "found. ',' or '}' were expected", token);
448*7c478bd9Sstevel@tonic-gate 		Errors++;
449*7c478bd9Sstevel@tonic-gate 		errlog(END, "} /* set_parents */");
450*7c478bd9Sstevel@tonic-gate 		return (FALSE);
451*7c478bd9Sstevel@tonic-gate 	}
452*7c478bd9Sstevel@tonic-gate 	errlog(END, "} /* set_parents */");
453*7c478bd9Sstevel@tonic-gate 	return (TRUE);
454*7c478bd9Sstevel@tonic-gate }
455*7c478bd9Sstevel@tonic-gate 
456*7c478bd9Sstevel@tonic-gate 
457*7c478bd9Sstevel@tonic-gate /*
458*7c478bd9Sstevel@tonic-gate  * parser support routines
459*7c478bd9Sstevel@tonic-gate  */
460*7c478bd9Sstevel@tonic-gate 
461*7c478bd9Sstevel@tonic-gate 
462*7c478bd9Sstevel@tonic-gate /*
463*7c478bd9Sstevel@tonic-gate  * accept_token -- get a specified token or complain loudly.
464*7c478bd9Sstevel@tonic-gate  */
465*7c478bd9Sstevel@tonic-gate static int
accept_token(char * expected)466*7c478bd9Sstevel@tonic-gate accept_token(char *expected)
467*7c478bd9Sstevel@tonic-gate {
468*7c478bd9Sstevel@tonic-gate 	char *token = currtok();
469*7c478bd9Sstevel@tonic-gate 
470*7c478bd9Sstevel@tonic-gate 	assert(expected != NULL, "null token passed to accept_token");
471*7c478bd9Sstevel@tonic-gate 	errlog(OTHER | TRACING, "accept_token, at %s expecting %s",
472*7c478bd9Sstevel@tonic-gate 		(token) ? token : "<NULL>", expected);
473*7c478bd9Sstevel@tonic-gate 
474*7c478bd9Sstevel@tonic-gate 	if (token == NULL) {
475*7c478bd9Sstevel@tonic-gate 		/* We're at EOF */
476*7c478bd9Sstevel@tonic-gate 		return (TRUE);
477*7c478bd9Sstevel@tonic-gate 	}
478*7c478bd9Sstevel@tonic-gate 	if (eq(token, expected)) {
479*7c478bd9Sstevel@tonic-gate 		(void) nexttok();
480*7c478bd9Sstevel@tonic-gate 		return (TRUE);
481*7c478bd9Sstevel@tonic-gate 	} else {
482*7c478bd9Sstevel@tonic-gate 		errlog(INPUT | ERROR,
483*7c478bd9Sstevel@tonic-gate 			"accept_token, found %s while looking for %s",
484*7c478bd9Sstevel@tonic-gate 			(token) ? token : "<NULL>", expected);
485*7c478bd9Sstevel@tonic-gate 		++Errors;
486*7c478bd9Sstevel@tonic-gate 		return (FALSE);
487*7c478bd9Sstevel@tonic-gate 	}
488*7c478bd9Sstevel@tonic-gate }
489*7c478bd9Sstevel@tonic-gate 
490*7c478bd9Sstevel@tonic-gate static void
skip_to(char * target)491*7c478bd9Sstevel@tonic-gate skip_to(char *target)
492*7c478bd9Sstevel@tonic-gate {
493*7c478bd9Sstevel@tonic-gate 	char *token = currtok();
494*7c478bd9Sstevel@tonic-gate 
495*7c478bd9Sstevel@tonic-gate 	assert(target != NULL, "null target passed to skip_to");
496*7c478bd9Sstevel@tonic-gate 	while (token && !eq(token, target)) {
497*7c478bd9Sstevel@tonic-gate 		errlog(VERBOSE, "skipping over %s",
498*7c478bd9Sstevel@tonic-gate 			(token) ? token : "<NULL>");
499*7c478bd9Sstevel@tonic-gate 		token = nexttok();
500*7c478bd9Sstevel@tonic-gate 	}
501*7c478bd9Sstevel@tonic-gate }
502*7c478bd9Sstevel@tonic-gate 
503*7c478bd9Sstevel@tonic-gate 
504*7c478bd9Sstevel@tonic-gate /*
505*7c478bd9Sstevel@tonic-gate  * tokenizer -- below the grammar lives this, like a troll
506*7c478bd9Sstevel@tonic-gate  *	under a bridge.
507*7c478bd9Sstevel@tonic-gate  */
508*7c478bd9Sstevel@tonic-gate 
509*7c478bd9Sstevel@tonic-gate 
510*7c478bd9Sstevel@tonic-gate /*
511*7c478bd9Sstevel@tonic-gate  * skipb -- skip over blanks (whitespace, actually), stopping
512*7c478bd9Sstevel@tonic-gate  *      on first non-blank.
513*7c478bd9Sstevel@tonic-gate  */
514*7c478bd9Sstevel@tonic-gate static char *
skipb(char * p)515*7c478bd9Sstevel@tonic-gate skipb(char *p)
516*7c478bd9Sstevel@tonic-gate {
517*7c478bd9Sstevel@tonic-gate 
518*7c478bd9Sstevel@tonic-gate 	while (*p && isspace(*p))
519*7c478bd9Sstevel@tonic-gate 		++p;
520*7c478bd9Sstevel@tonic-gate 	return (p);
521*7c478bd9Sstevel@tonic-gate }
522*7c478bd9Sstevel@tonic-gate 
523*7c478bd9Sstevel@tonic-gate /*
524*7c478bd9Sstevel@tonic-gate  * skipover -- skip over non-separators (alnum, . and _, actually),
525*7c478bd9Sstevel@tonic-gate  *      stopping on first separator.
526*7c478bd9Sstevel@tonic-gate  */
527*7c478bd9Sstevel@tonic-gate static char *
skipover(char * p)528*7c478bd9Sstevel@tonic-gate skipover(char *p)
529*7c478bd9Sstevel@tonic-gate {
530*7c478bd9Sstevel@tonic-gate 
531*7c478bd9Sstevel@tonic-gate 	while (*p && (isalnum(*p) || (*p == '_' || *p == '.')))
532*7c478bd9Sstevel@tonic-gate 		++p;
533*7c478bd9Sstevel@tonic-gate 	return (p);
534*7c478bd9Sstevel@tonic-gate }
535*7c478bd9Sstevel@tonic-gate 
536*7c478bd9Sstevel@tonic-gate 
537*7c478bd9Sstevel@tonic-gate /*
538*7c478bd9Sstevel@tonic-gate  * currtok/nexttok -- get the current/next token
539*7c478bd9Sstevel@tonic-gate  */
540*7c478bd9Sstevel@tonic-gate static char *
currtok(void)541*7c478bd9Sstevel@tonic-gate currtok(void)
542*7c478bd9Sstevel@tonic-gate {
543*7c478bd9Sstevel@tonic-gate 
544*7c478bd9Sstevel@tonic-gate 	if (CurrTok == NULL) {
545*7c478bd9Sstevel@tonic-gate 		(void) nexttok();
546*7c478bd9Sstevel@tonic-gate 	}
547*7c478bd9Sstevel@tonic-gate 	return (CurrTok);
548*7c478bd9Sstevel@tonic-gate }
549*7c478bd9Sstevel@tonic-gate 
550*7c478bd9Sstevel@tonic-gate static char *
nexttok(void)551*7c478bd9Sstevel@tonic-gate nexttok(void)
552*7c478bd9Sstevel@tonic-gate {
553*7c478bd9Sstevel@tonic-gate 	static char line[MAXLINE];
554*7c478bd9Sstevel@tonic-gate 	char *p;
555*7c478bd9Sstevel@tonic-gate 
556*7c478bd9Sstevel@tonic-gate 	if ((p = tokenize(NULL)) == NULL) {
557*7c478bd9Sstevel@tonic-gate 		/* We're at an end of line. */
558*7c478bd9Sstevel@tonic-gate 		do {
559*7c478bd9Sstevel@tonic-gate 			if (fgets(line, sizeof (line), Fp) == NULL) {
560*7c478bd9Sstevel@tonic-gate 				/* Which is also end of file. */
561*7c478bd9Sstevel@tonic-gate 				CurrTok = NULL;
562*7c478bd9Sstevel@tonic-gate 				return (NULL);
563*7c478bd9Sstevel@tonic-gate 			}
564*7c478bd9Sstevel@tonic-gate 			++Line;
565*7c478bd9Sstevel@tonic-gate 			seterrline(Line, Filename, "", line);
566*7c478bd9Sstevel@tonic-gate 		} while ((p = tokenize(line)) == NULL);
567*7c478bd9Sstevel@tonic-gate 	}
568*7c478bd9Sstevel@tonic-gate 	CurrTok = p;
569*7c478bd9Sstevel@tonic-gate 	return (p);
570*7c478bd9Sstevel@tonic-gate }
571*7c478bd9Sstevel@tonic-gate 
572*7c478bd9Sstevel@tonic-gate 
573*7c478bd9Sstevel@tonic-gate 
574*7c478bd9Sstevel@tonic-gate /*
575*7c478bd9Sstevel@tonic-gate  * tokenize -- a version of the standard strtok with specific behavior.
576*7c478bd9Sstevel@tonic-gate  */
577*7c478bd9Sstevel@tonic-gate static char *
tokenize(char * line)578*7c478bd9Sstevel@tonic-gate tokenize(char *line)
579*7c478bd9Sstevel@tonic-gate {
580*7c478bd9Sstevel@tonic-gate 	static char *p = NULL;
581*7c478bd9Sstevel@tonic-gate 	static char saved = 0;
582*7c478bd9Sstevel@tonic-gate 	char *q;
583*7c478bd9Sstevel@tonic-gate 
584*7c478bd9Sstevel@tonic-gate 	if (line == NULL && p == NULL) {
585*7c478bd9Sstevel@tonic-gate 		/* It's the very first time */
586*7c478bd9Sstevel@tonic-gate 		return (NULL);
587*7c478bd9Sstevel@tonic-gate 	} else if (line != NULL) {
588*7c478bd9Sstevel@tonic-gate 		/* Initialize with a new line */
589*7c478bd9Sstevel@tonic-gate 		q = skipb(line);
590*7c478bd9Sstevel@tonic-gate 	} else {
591*7c478bd9Sstevel@tonic-gate 		/* Restore previous line. */
592*7c478bd9Sstevel@tonic-gate 		*p = saved;
593*7c478bd9Sstevel@tonic-gate 		q = skipb(p);
594*7c478bd9Sstevel@tonic-gate 	}
595*7c478bd9Sstevel@tonic-gate 	/* q is at the beginning of a token or at EOL, p is irrelevant. */
596*7c478bd9Sstevel@tonic-gate 
597*7c478bd9Sstevel@tonic-gate 	if (*q == '\0') {
598*7c478bd9Sstevel@tonic-gate 		/* It's at EOL. */
599*7c478bd9Sstevel@tonic-gate 		p = q;
600*7c478bd9Sstevel@tonic-gate 	} else if (in_specials(*q)) {
601*7c478bd9Sstevel@tonic-gate 		/* We have a special-character token. */
602*7c478bd9Sstevel@tonic-gate 		p = q + 1;
603*7c478bd9Sstevel@tonic-gate 	} else if (*q == '#') {
604*7c478bd9Sstevel@tonic-gate 		/* The whole rest of the line is a comment token. */
605*7c478bd9Sstevel@tonic-gate 		return (NULL);
606*7c478bd9Sstevel@tonic-gate 	} else {
607*7c478bd9Sstevel@tonic-gate 		/* We have a word token. */
608*7c478bd9Sstevel@tonic-gate 		p = skipover(q);
609*7c478bd9Sstevel@tonic-gate 	}
610*7c478bd9Sstevel@tonic-gate 	saved = *p;
611*7c478bd9Sstevel@tonic-gate 	*p = '\0';
612*7c478bd9Sstevel@tonic-gate 
613*7c478bd9Sstevel@tonic-gate 	if (p == q) {
614*7c478bd9Sstevel@tonic-gate 		/* End of line */
615*7c478bd9Sstevel@tonic-gate 		return (NULL);
616*7c478bd9Sstevel@tonic-gate 	} else {
617*7c478bd9Sstevel@tonic-gate 		return (q);
618*7c478bd9Sstevel@tonic-gate 	}
619*7c478bd9Sstevel@tonic-gate }
620*7c478bd9Sstevel@tonic-gate 
621*7c478bd9Sstevel@tonic-gate 
622*7c478bd9Sstevel@tonic-gate /*
623*7c478bd9Sstevel@tonic-gate  * valid_version -- see if a version string was mentioned in the set file.
624*7c478bd9Sstevel@tonic-gate  */
625*7c478bd9Sstevel@tonic-gate int
valid_version(const char * vers_name)626*7c478bd9Sstevel@tonic-gate valid_version(const char *vers_name)
627*7c478bd9Sstevel@tonic-gate {
628*7c478bd9Sstevel@tonic-gate 
629*7c478bd9Sstevel@tonic-gate 	if (Vers == NULL) {
630*7c478bd9Sstevel@tonic-gate 		init_tables();
631*7c478bd9Sstevel@tonic-gate 	}
632*7c478bd9Sstevel@tonic-gate 	return (in_stringtable(Vers, vers_name));
633*7c478bd9Sstevel@tonic-gate }
634*7c478bd9Sstevel@tonic-gate 
635*7c478bd9Sstevel@tonic-gate /*
636*7c478bd9Sstevel@tonic-gate  * valid_arch -- see if the arch was mentioned in the set file.
637*7c478bd9Sstevel@tonic-gate  */
638*7c478bd9Sstevel@tonic-gate int
valid_arch(const char * arch_name)639*7c478bd9Sstevel@tonic-gate valid_arch(const char *arch_name)
640*7c478bd9Sstevel@tonic-gate {
641*7c478bd9Sstevel@tonic-gate 
642*7c478bd9Sstevel@tonic-gate 	if (Vers == NULL) {
643*7c478bd9Sstevel@tonic-gate 		init_tables();
644*7c478bd9Sstevel@tonic-gate 	}
645*7c478bd9Sstevel@tonic-gate 	return (in_stringtable(Varch, arch_name));
646*7c478bd9Sstevel@tonic-gate }
647*7c478bd9Sstevel@tonic-gate 
648*7c478bd9Sstevel@tonic-gate /*
649*7c478bd9Sstevel@tonic-gate  * add_valid_version and _arch -- add a name to the table.
650*7c478bd9Sstevel@tonic-gate  */
651*7c478bd9Sstevel@tonic-gate static void
add_valid_version(char * vers_name)652*7c478bd9Sstevel@tonic-gate add_valid_version(char *vers_name)
653*7c478bd9Sstevel@tonic-gate {
654*7c478bd9Sstevel@tonic-gate 	errlog(BEGIN, "add_valid_version(\"%s\") {", vers_name);
655*7c478bd9Sstevel@tonic-gate 	if (Vers == NULL) {
656*7c478bd9Sstevel@tonic-gate 		init_tables();
657*7c478bd9Sstevel@tonic-gate 	}
658*7c478bd9Sstevel@tonic-gate 	Vers = add_to_stringtable(Vers, vers_name);
659*7c478bd9Sstevel@tonic-gate 	errlog(END, "}");
660*7c478bd9Sstevel@tonic-gate }
661*7c478bd9Sstevel@tonic-gate 
662*7c478bd9Sstevel@tonic-gate static void
add_valid_arch(char * arch_name)663*7c478bd9Sstevel@tonic-gate add_valid_arch(char *arch_name)
664*7c478bd9Sstevel@tonic-gate {
665*7c478bd9Sstevel@tonic-gate 
666*7c478bd9Sstevel@tonic-gate 	errlog(BEGIN, "add_valid_arch(\"%s\") {", arch_name);
667*7c478bd9Sstevel@tonic-gate 	if (Vers == NULL) {
668*7c478bd9Sstevel@tonic-gate 		init_tables();
669*7c478bd9Sstevel@tonic-gate 	}
670*7c478bd9Sstevel@tonic-gate 	Varch = add_to_stringtable(Varch, arch_name);
671*7c478bd9Sstevel@tonic-gate 	errlog(END, "}");
672*7c478bd9Sstevel@tonic-gate }
673*7c478bd9Sstevel@tonic-gate 
674*7c478bd9Sstevel@tonic-gate /*
675*7c478bd9Sstevel@tonic-gate  * init_tables -- creat them when first used.
676*7c478bd9Sstevel@tonic-gate  */
677*7c478bd9Sstevel@tonic-gate static void
init_tables(void)678*7c478bd9Sstevel@tonic-gate init_tables(void)
679*7c478bd9Sstevel@tonic-gate {
680*7c478bd9Sstevel@tonic-gate 	Vers = create_stringtable(TABLE_INITIAL);
681*7c478bd9Sstevel@tonic-gate 	Varch = create_stringtable(TABLE_INITIAL);
682*7c478bd9Sstevel@tonic-gate }
683