2 /* A Bison parser, made from ./mcy.y
3 by GNU Bison version 1.25
6 #define YYBISON 1 /* Identify Bison output. */
42 static const char err_syntax
[] = "Syntax error";
43 static const char err_number
[] = "Number expected";
44 static const char err_ident
[] = "Identifier expected";
45 static const char err_assign
[] = "'=' expected";
46 static const char err_popen
[] = "'(' expected";
47 static const char err_pclose
[] = "')' expected";
48 static const char err_colon
[] = "':' expected";
49 static const char err_msg
[] = "Message expected";
51 /* Scanner switches */
52 int want_nl
= 0; /* Request next newlinw */
53 int want_line
= 0; /* Request next complete line */
54 int want_file
= 0; /* Request next ident as filename */
56 node_t
*nodehead
= NULL
; /* The list of all parsed elements */
57 static node_t
*nodetail
= NULL
;
58 lan_blk_t
*lanblockhead
; /* List of parsed elements transposed */
60 static int base
= 16; /* Current printout base to use (8, 10 or 16) */
61 static WCHAR
*cast
= NULL
; /* Current typecast to use */
63 static int last_id
= 0; /* The last message ID parsed */
64 static int last_sev
= 0; /* Last severity code parsed */
65 static int last_fac
= 0; /* Last facility code parsed */
66 static WCHAR
*last_sym
= NULL
;/* Last alias symbol parsed */
67 static int have_sev
; /* Set if severity parsed for current message */
68 static int have_fac
; /* Set if facility parsed for current message */
69 static int have_sym
; /* Set is symbol parsed for current message */
71 static cp_xlat_t
*cpxlattab
= NULL
; /* Codepage translation table */
72 static int ncpxlattab
= 0;
75 static WCHAR
*merge(WCHAR
*s1
, WCHAR
*s2
);
76 static lanmsg_t
*new_lanmsg(lan_cp_t
*lcp
, WCHAR
*msg
);
77 static msg_t
*add_lanmsg(msg_t
*msg
, lanmsg_t
*lanmsg
);
78 static msg_t
*complete_msg(msg_t
*msg
, int id
);
79 static void add_node(node_e type
, void *p
);
80 static void do_add_token(tok_e type
, token_t
*tok
, const char *code
);
81 static void test_id(int id
);
82 static int check_languages(node_t
*head
);
83 static lan_blk_t
*block_messages(node_t
*head
);
84 static void add_cpxlat(int lan
, int cpin
, int cpout
);
85 static cp_xlat_t
*find_cpxlat(int lan
);
112 #define YYFLAG -32768
115 #define YYTRANSLATE(x) ((unsigned)(x) <= 276 ? yytranslate[x] : 58)
117 static const char yytranslate
[] = { 0,
118 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
119 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
120 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
121 2, 2, 2, 2, 2, 2, 2, 2, 2, 23,
122 24, 2, 26, 2, 2, 2, 2, 2, 2, 2,
123 2, 2, 2, 2, 2, 2, 2, 25, 2, 2,
124 22, 2, 2, 2, 2, 2, 2, 2, 2, 2,
125 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
126 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
127 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
128 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
129 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
130 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
131 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
132 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
133 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
134 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
135 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
136 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
137 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
138 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
139 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
140 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
141 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
142 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
143 2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
144 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
145 16, 17, 18, 19, 20, 21
149 static const short yyprhs
[] = { 0,
150 0, 2, 4, 7, 9, 11, 13, 15, 21, 27,
151 31, 34, 40, 46, 50, 53, 59, 65, 69, 72,
152 78, 84, 88, 91, 95, 99, 102, 106, 110, 113,
153 115, 118, 120, 125, 129, 132, 134, 137, 139, 144,
154 148, 151, 152, 155, 158, 160, 163, 165, 173, 180,
155 185, 189, 192, 193, 196, 199, 201, 204, 206, 212,
156 218, 223, 227, 230, 232, 234, 235, 240, 244, 247,
157 248, 250, 253, 256, 257, 260, 263, 266, 270, 274,
158 277, 281, 285, 288, 292, 296, 299, 301, 304, 306,
159 311, 317, 323, 328, 331, 333, 336, 338, 341, 343,
163 static const short yyrhs
[] = { 28,
164 0, 29, 0, 28, 29, 0, 30, 0, 42, 0,
165 19, 0, 1, 0, 3, 22, 23, 31, 24, 0,
166 3, 22, 23, 31, 1, 0, 3, 22, 1, 0,
167 3, 1, 0, 4, 22, 23, 33, 24, 0, 4,
168 22, 23, 33, 1, 0, 4, 22, 1, 0, 4,
169 1, 0, 5, 22, 23, 36, 24, 0, 5, 22,
170 23, 36, 1, 0, 5, 22, 1, 0, 5, 1,
171 0, 7, 22, 23, 39, 24, 0, 7, 22, 23,
172 39, 1, 0, 7, 22, 1, 0, 7, 1, 0,
173 8, 22, 16, 0, 8, 22, 1, 0, 8, 1,
174 0, 6, 22, 20, 0, 6, 22, 1, 0, 6,
175 1, 0, 32, 0, 31, 32, 0, 1, 0, 54,
176 22, 20, 35, 0, 54, 22, 1, 0, 54, 1,
177 0, 34, 0, 33, 34, 0, 1, 0, 54, 22,
178 20, 35, 0, 54, 22, 1, 0, 54, 1, 0,
179 0, 25, 16, 0, 25, 1, 0, 37, 0, 36,
180 37, 0, 1, 0, 54, 22, 20, 57, 25, 18,
181 38, 0, 54, 22, 20, 57, 25, 1, 0, 54,
182 22, 20, 1, 0, 54, 22, 1, 0, 54, 1,
183 0, 0, 25, 20, 0, 25, 1, 0, 40, 0,
184 39, 40, 0, 1, 0, 41, 22, 20, 25, 20,
185 0, 41, 22, 20, 25, 1, 0, 41, 22, 20,
186 1, 0, 41, 22, 1, 0, 41, 1, 0, 20,
187 0, 21, 0, 0, 44, 46, 43, 50, 0, 15,
188 22, 45, 0, 15, 1, 0, 0, 20, 0, 26,
189 20, 0, 26, 1, 0, 0, 46, 48, 0, 46,
190 49, 0, 46, 47, 0, 10, 22, 16, 0, 10,
191 22, 1, 0, 10, 1, 0, 12, 22, 54, 0,
192 12, 22, 1, 0, 12, 1, 0, 13, 22, 54,
193 0, 13, 22, 1, 0, 13, 1, 0, 51, 0,
194 50, 51, 0, 1, 0, 52, 56, 53, 11, 0,
195 14, 55, 22, 54, 9, 0, 14, 55, 22, 54,
196 1, 0, 14, 55, 22, 1, 0, 14, 1, 0,
197 17, 0, 53, 17, 0, 1, 0, 53, 1, 0,
198 16, 0, 21, 0, 0, 0, 0
204 static const short yyrline
[] = { 0,
205 108, 115, 116, 119, 120, 121, 122, 125, 126, 127,
206 128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
207 138, 139, 140, 141, 142, 143, 144, 156, 157, 163,
208 164, 165, 168, 175, 176, 182, 183, 184, 187, 194,
209 195, 198, 199, 200, 206, 207, 208, 211, 219, 220,
210 221, 222, 225, 226, 227, 233, 234, 235, 238, 248,
211 249, 250, 251, 254, 255, 265, 265, 268, 273, 276,
212 277, 278, 279, 282, 283, 284, 285, 288, 289, 290,
213 293, 301, 302, 305, 313, 314, 320, 321, 322, 325,
214 333, 362, 363, 364, 367, 368, 369, 370, 376, 377,
220 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
222 static const char * const yytname
[] = { "$","error","$undefined.","tSEVNAMES",
223 "tFACNAMES","tLANNAMES","tBASE","tCODEPAGE","tTYPEDEF","tNL","tSYMNAME","tMSGEND",
224 "tSEVERITY","tFACILITY","tLANGUAGE","tMSGID","tIDENT","tLINE","tFILE","tCOMMENT",
225 "tNUMBER","tTOKEN","'='","'('","')'","':'","'+'","file","items","decl","global",
226 "smaps","smap","fmaps","fmap","alias","lmaps","lmap","optcp","cmaps","cmap",
227 "clan","msg","@1","msgid","id","sevfacsym","sym","sev","fac","bodies","body",
228 "lang","lines","token","setnl","setline","setfile", NULL
232 static const short yyr1
[] = { 0,
233 27, 28, 28, 29, 29, 29, 29, 30, 30, 30,
234 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
235 30, 30, 30, 30, 30, 30, 30, 30, 30, 31,
236 31, 31, 32, 32, 32, 33, 33, 33, 34, 34,
237 34, 35, 35, 35, 36, 36, 36, 37, 37, 37,
238 37, 37, 38, 38, 38, 39, 39, 39, 40, 40,
239 40, 40, 40, 41, 41, 43, 42, 44, 44, 45,
240 45, 45, 45, 46, 46, 46, 46, 47, 47, 47,
241 48, 48, 48, 49, 49, 49, 50, 50, 50, 51,
242 52, 52, 52, 52, 53, 53, 53, 53, 54, 54,
246 static const short yyr2
[] = { 0,
247 1, 1, 2, 1, 1, 1, 1, 5, 5, 3,
248 2, 5, 5, 3, 2, 5, 5, 3, 2, 5,
249 5, 3, 2, 3, 3, 2, 3, 3, 2, 1,
250 2, 1, 4, 3, 2, 1, 2, 1, 4, 3,
251 2, 0, 2, 2, 1, 2, 1, 7, 6, 4,
252 3, 2, 0, 2, 2, 1, 2, 1, 5, 5,
253 4, 3, 2, 1, 1, 0, 4, 3, 2, 0,
254 1, 2, 2, 0, 2, 2, 2, 3, 3, 2,
255 3, 3, 2, 3, 3, 2, 1, 2, 1, 4,
256 5, 5, 4, 2, 1, 2, 1, 2, 1, 1,
260 static const short yydefact
[] = { 0,
261 7, 0, 0, 0, 0, 0, 0, 0, 6, 0,
262 2, 4, 5, 74, 11, 0, 15, 0, 19, 0,
263 29, 0, 23, 0, 26, 0, 69, 70, 3, 66,
264 10, 0, 14, 0, 18, 0, 28, 27, 22, 0,
265 25, 24, 71, 0, 68, 0, 0, 0, 0, 77,
266 75, 76, 32, 99, 100, 0, 30, 0, 38, 0,
267 36, 0, 47, 0, 45, 0, 58, 64, 65, 0,
268 56, 0, 73, 72, 80, 0, 83, 0, 86, 0,
269 89, 0, 67, 87, 102, 9, 8, 31, 35, 0,
270 13, 12, 37, 41, 0, 17, 16, 46, 52, 0,
271 21, 20, 57, 63, 0, 79, 78, 82, 81, 85,
272 84, 94, 0, 88, 0, 34, 42, 40, 42, 51,
273 0, 62, 0, 0, 97, 95, 0, 0, 33, 39,
274 50, 0, 61, 0, 93, 0, 98, 90, 96, 44,
275 43, 0, 60, 59, 92, 91, 49, 53, 0, 48,
279 static const short yydefgoto
[] = { 153,
280 10, 11, 12, 56, 57, 60, 61, 129, 64, 65,
281 150, 70, 71, 72, 13, 49, 14, 45, 30, 50,
282 51, 52, 83, 84, 85, 127, 58, 113, 115, 132
285 static const short yypact
[] = { 132,
286 -32768, 18, 44, 46, 47, 48, 49, 50,-32768, 113,
287 -32768,-32768,-32768,-32768,-32768, 11,-32768, 14,-32768, 19,
288 -32768, 85,-32768, 20,-32768, 147,-32768, -13,-32768, 87,
289 -32768, 66,-32768, 80,-32768, 82,-32768,-32768,-32768, 64,
290 -32768,-32768,-32768, 107,-32768, 51, 52, 53, 3,-32768,
291 -32768,-32768,-32768,-32768,-32768, 7,-32768, 54,-32768, 8,
292 -32768, 55,-32768, 17,-32768, 56,-32768,-32768,-32768, 15,
293 -32768, 57,-32768,-32768,-32768, 148,-32768, 88,-32768, 90,
294 -32768, 58, -4,-32768,-32768,-32768,-32768,-32768,-32768, 109,
295 -32768,-32768,-32768,-32768, 114,-32768,-32768,-32768,-32768, 121,
296 -32768,-32768,-32768,-32768, 122,-32768,-32768,-32768,-32768,-32768,
297 -32768,-32768, -11,-32768, 129,-32768, 35,-32768, 35,-32768,
298 0,-32768, 2, 91,-32768,-32768, 144, 149,-32768,-32768,
299 -32768, 36,-32768, 123,-32768, 5,-32768,-32768,-32768,-32768,
300 -32768, 4,-32768,-32768,-32768,-32768,-32768, 37, 124,-32768,
301 -32768,-32768, 63, 93,-32768
304 static const short yypgoto
[] = {-32768,
305 -32768, 78,-32768,-32768, 38,-32768, 42, -55,-32768, 31,
306 -32768,-32768, 61,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
307 -32768,-32768,-32768, 43,-32768,-32768, -34,-32768,-32768,-32768
314 static const short yytable
[] = { 62,
315 131, 66, 133, 81, 147, 145, 43, 86, 91, 82,
316 124, 31, 44, 146, 33, 101, 82, 96, 15, 35,
317 39, 148, 54, 54, -103, 62, 134, 55, 55, 66,
318 87, 92, 54, 32, 68, 69, 34, 55, 102, 16,
319 97, 36, 40, 109, 17, 111, 19, 21, 23, 25,
320 27, 75, 77, 79, 89, 94, 99, 104, 112, 128,
321 142, 149, 154, 130, 67, 18, 53, 20, 22, 24,
322 26, 28, 76, 78, 80, 90, 95, 100, 105, -101,
323 59, 54, 63, 68, 69, 37, 55, 29, 108, 136,
324 110, 135, 155, 88, 98, 54, 46, 54, 47, 48,
325 55, 93, 55, 54, 38, 54, 54, 73, 55, 116,
326 55, 55, -1, 1, 118, 2, 3, 4, 5, 6,
327 7, 120, 122, 143, 151, 114, 74, 8, 117, 125,
328 103, 9, 1, 119, 2, 3, 4, 5, 6, 7,
329 121, 123, 144, 152, 137, 126, 8, 41, 106, 140,
330 9, 0, 0, 0, 138, 0, 0, 0, 0, 0,
334 static const short yycheck
[] = { 34,
335 1, 36, 1, 1, 1, 1, 20, 1, 1, 14,
336 22, 1, 26, 9, 1, 1, 14, 1, 1, 1,
337 1, 18, 16, 16, 25, 60, 25, 21, 21, 64,
338 24, 24, 16, 23, 20, 21, 23, 21, 24, 22,
339 24, 23, 23, 78, 1, 80, 1, 1, 1, 1,
340 1, 1, 1, 1, 1, 1, 1, 1, 1, 25,
341 25, 25, 0, 119, 1, 22, 1, 22, 22, 22,
342 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
343 1, 16, 1, 20, 21, 1, 21, 10, 1, 124,
344 1, 1, 0, 56, 64, 16, 10, 16, 12, 13,
345 21, 60, 21, 16, 20, 16, 16, 1, 21, 1,
346 21, 21, 0, 1, 1, 3, 4, 5, 6, 7,
347 8, 1, 1, 1, 1, 83, 20, 15, 20, 1,
348 70, 19, 1, 20, 3, 4, 5, 6, 7, 8,
349 20, 20, 20, 20, 1, 17, 15, 1, 1, 1,
350 19, -1, -1, -1, 11, -1, -1, -1, -1, -1,
353 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
354 #line 3 "/usr/share/bison.simple"
356 /* Skeleton output parser for bison,
357 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
359 This program is free software; you can redistribute it and/or modify
360 it under the terms of the GNU General Public License as published by
361 the Free Software Foundation; either version 2, or (at your option)
364 This program is distributed in the hope that it will be useful,
365 but WITHOUT ANY WARRANTY; without even the implied warranty of
366 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
367 GNU General Public License for more details.
369 You should have received a copy of the GNU General Public License
370 along with this program; if not, write to the Free Software
371 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
373 /* As a special exception, when this file is copied by Bison into a
374 Bison output file, you may use that output file without restriction.
375 This special exception was added by the Free Software Foundation
376 in version 1.24 of Bison. */
380 #define alloca __builtin_alloca
381 #else /* not GNU C. */
382 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
384 #else /* not sparc */
385 #if defined (MSDOS) && !defined (__TURBOC__)
387 #else /* not MSDOS, or __TURBOC__ */
391 #else /* not MSDOS, __TURBOC__, or _AIX */
395 void *alloca (unsigned int);
397 #else /* not __cplusplus */
399 #endif /* not __cplusplus */
401 #endif /* not _AIX */
402 #endif /* not MSDOS, or __TURBOC__ */
403 #endif /* not sparc. */
404 #endif /* not GNU C. */
405 #endif /* alloca not defined. */
407 /* This is the parser code that is written into each bison parser
408 when the %semantic_parser declaration is not specified in the grammar.
409 It was written by Richard Stallman by simplifying the hairy parser
410 used when %semantic_parser is specified. */
412 /* Note: there must be only one dollar sign in this file.
413 It is replaced by the list of actions, each action
414 as one case of the switch. */
416 #define yyerrok (yyerrstatus = 0)
417 #define yyclearin (yychar = YYEMPTY)
420 #define YYACCEPT return(0)
421 #define YYABORT return(1)
422 #define YYERROR goto yyerrlab1
423 /* Like YYERROR except do call yyerror.
424 This remains here temporarily to ease the
425 transition to the new meaning of YYERROR, for GCC.
426 Once GCC version 2 has supplanted version 1, this can go. */
427 #define YYFAIL goto yyerrlab
428 #define YYRECOVERING() (!!yyerrstatus)
429 #define YYBACKUP(token, value) \
431 if (yychar == YYEMPTY && yylen == 1) \
432 { yychar = (token), yylval = (value); \
433 yychar1 = YYTRANSLATE (yychar); \
438 { yyerror ("syntax error: cannot back up"); YYERROR; } \
442 #define YYERRCODE 256
445 #define YYLEX yylex()
451 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
453 #define YYLEX yylex(&yylval, &yylloc)
455 #else /* not YYLSP_NEEDED */
457 #define YYLEX yylex(&yylval, YYLEX_PARAM)
459 #define YYLEX yylex(&yylval)
461 #endif /* not YYLSP_NEEDED */
464 /* If nonreentrant, generate the variables here */
468 int yychar
; /* the lookahead symbol */
469 YYSTYPE yylval
; /* the semantic value of the */
470 /* lookahead symbol */
473 YYLTYPE yylloc
; /* location data for the lookahead */
477 int yynerrs
; /* number of parse errors so far */
478 #endif /* not YYPURE */
481 int yydebug
; /* nonzero means print parse trace */
482 /* Since this is uninitialized, it does not stop multiple parsers
486 /* YYINITDEPTH indicates the initial size of the parser's stacks */
489 #define YYINITDEPTH 200
492 /* YYMAXDEPTH is the maximum size the stacks can grow to
493 (effective only if the built-in stack extension method is used). */
500 #define YYMAXDEPTH 10000
503 #ifndef YYPARSE_RETURN_TYPE
504 #define YYPARSE_RETURN_TYPE int
507 /* Prevent warning if -Wstrict-prototypes. */
509 YYPARSE_RETURN_TYPE
yyparse (void);
512 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
513 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
514 #else /* not GNU C or C++ */
517 /* This is the most reliable way to avoid incompatibilities
518 in available built-in functions on various systems. */
520 __yy_memcpy (to
, from
, count
)
525 register char *f
= from
;
526 register char *t
= to
;
527 register int i
= count
;
533 #else /* __cplusplus */
535 /* This is the most reliable way to avoid incompatibilities
536 in available built-in functions on various systems. */
538 __yy_memcpy (char *to
, char *from
, int count
)
540 register char *f
= from
;
541 register char *t
= to
;
542 register int i
= count
;
551 #line 196 "/usr/share/bison.simple"
553 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
554 into yyparse. The argument should have type void *.
555 It should actually point to an object.
556 Grammar actions can access the variable by casting it
557 to the proper pointer type. */
561 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
562 #define YYPARSE_PARAM_DECL
563 #else /* not __cplusplus */
564 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
565 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
566 #endif /* not __cplusplus */
567 #else /* not YYPARSE_PARAM */
568 #define YYPARSE_PARAM_ARG
569 #define YYPARSE_PARAM_DECL
570 #endif /* not YYPARSE_PARAM */
573 yyparse(YYPARSE_PARAM_ARG
)
576 register int yystate
;
578 register short *yyssp
;
579 register YYSTYPE
*yyvsp
;
580 int yyerrstatus
; /* number of tokens to shift before error messages enabled */
581 int yychar1
= 0; /* lookahead token as an internal (translated) token number */
583 short yyssa
[YYINITDEPTH
]; /* the state stack */
584 YYSTYPE yyvsa
[YYINITDEPTH
]; /* the semantic value stack */
586 short *yyss
= yyssa
; /* refer to the stacks thru separate pointers */
587 YYSTYPE
*yyvs
= yyvsa
; /* to allow yyoverflow to reallocate them elsewhere */
590 YYLTYPE yylsa
[YYINITDEPTH
]; /* the location stack */
591 YYLTYPE
*yyls
= yylsa
;
594 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
596 #define YYPOPSTACK (yyvsp--, yyssp--)
599 int yystacksize
= YYINITDEPTH
;
610 YYSTYPE yyval
; /* the variable used to return */
611 /* semantic values from the action */
618 fprintf(stderr
, "Starting parse\n");
624 yychar
= YYEMPTY
; /* Cause a token to be read. */
626 /* Initialize stack pointers.
627 Waste one element of value and location stack
628 so that they stay on the same level as the state stack.
629 The wasted elements are never initialized. */
637 /* Push a new state, which is found in yystate . */
638 /* In all cases, when you get here, the value and location stacks
639 have just been pushed. so pushing a state here evens the stacks. */
644 if (yyssp
>= yyss
+ yystacksize
- 1)
646 /* Give user a chance to reallocate the stack */
647 /* Use copies of these so that the &'s don't force the real ones into memory. */
648 YYSTYPE
*yyvs1
= yyvs
;
651 YYLTYPE
*yyls1
= yyls
;
654 /* Get the current used size of the three stacks, in elements. */
655 int size
= yyssp
- yyss
+ 1;
658 /* Each stack pointer address is followed by the size of
659 the data in use in that stack, in bytes. */
661 /* This used to be a conditional around just the two extra args,
662 but that might be undefined if yyoverflow is a macro. */
663 yyoverflow("parser stack overflow",
664 &yyss1
, size
* sizeof (*yyssp
),
665 &yyvs1
, size
* sizeof (*yyvsp
),
666 &yyls1
, size
* sizeof (*yylsp
),
669 yyoverflow("parser stack overflow",
670 &yyss1
, size
* sizeof (*yyssp
),
671 &yyvs1
, size
* sizeof (*yyvsp
),
675 yyss
= yyss1
; yyvs
= yyvs1
;
679 #else /* no yyoverflow */
680 /* Extend the stack our own way. */
681 if (yystacksize
>= YYMAXDEPTH
)
683 yyerror("parser stack overflow");
687 if (yystacksize
> YYMAXDEPTH
)
688 yystacksize
= YYMAXDEPTH
;
689 yyss
= (short *) _alloca (yystacksize
* sizeof (*yyssp
));
690 __yy_memcpy ((char *)yyss
, (char *)yyss1
, size
* sizeof (*yyssp
));
691 yyvs
= (YYSTYPE
*) _alloca (yystacksize
* sizeof (*yyvsp
));
692 __yy_memcpy ((char *)yyvs
, (char *)yyvs1
, size
* sizeof (*yyvsp
));
694 yyls
= (YYLTYPE
*) _alloca (yystacksize
* sizeof (*yylsp
));
695 __yy_memcpy ((char *)yyls
, (char *)yyls1
, size
* sizeof (*yylsp
));
697 #endif /* no yyoverflow */
699 yyssp
= yyss
+ size
- 1;
700 yyvsp
= yyvs
+ size
- 1;
702 yylsp
= yyls
+ size
- 1;
707 fprintf(stderr
, "Stack size increased to %d\n", yystacksize
);
710 if (yyssp
>= yyss
+ yystacksize
- 1)
716 fprintf(stderr
, "Entering state %d\n", yystate
);
722 /* Do appropriate processing given the current state. */
723 /* Read a lookahead token if we need one and don't already have one. */
726 /* First try to decide what to do without reference to lookahead token. */
728 yyn
= yypact
[yystate
];
732 /* Not known => get a lookahead token if don't already have one. */
734 /* yychar is either YYEMPTY or YYEOF
735 or a valid token in external form. */
737 if (yychar
== YYEMPTY
)
741 fprintf(stderr
, "Reading a token: ");
746 /* Convert token to internal form (in yychar1) for indexing tables with */
748 if (yychar
<= 0) /* This means end of input. */
751 yychar
= YYEOF
; /* Don't call YYLEX any more */
755 fprintf(stderr
, "Now at end of input.\n");
760 yychar1
= YYTRANSLATE(yychar
);
765 fprintf (stderr
, "Next token is %d (%s", yychar
, yytname
[yychar1
]);
766 /* Give the individual parser a way to print the precise meaning
767 of a token, for further debugging info. */
769 YYPRINT (stderr
, yychar
, yylval
);
771 fprintf (stderr
, ")\n");
777 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != yychar1
)
782 /* yyn is what to do for this token type in this state.
783 Negative => reduce, -yyn is rule number.
784 Positive => shift, yyn is new state.
785 New state is final state => don't bother to shift,
787 0, or most negative number => error. */
802 /* Shift the lookahead token. */
806 fprintf(stderr
, "Shifting token %d (%s), ", yychar
, yytname
[yychar1
]);
809 /* Discard the token being shifted unless it is eof. */
818 /* count tokens shifted since error; after three, turn off error status. */
819 if (yyerrstatus
) yyerrstatus
--;
824 /* Do the default action for the current state. */
827 yyn
= yydefact
[yystate
];
831 /* Do a reduction. yyn is the number of a rule to reduce with. */
835 yyval
= yyvsp
[1-yylen
]; /* implement default value of the action */
842 fprintf (stderr
, "Reducing via rule %d (line %d), ",
845 /* Print the symbols being reduced, and their result. */
846 for (i
= yyprhs
[yyn
]; yyrhs
[i
] > 0; i
++)
847 fprintf (stderr
, "%s ", yytname
[yyrhs
[i
]]);
848 fprintf (stderr
, " -> %s\n", yytname
[yyr1
[yyn
]]);
858 if(!check_languages(nodehead
))
859 xyyerror("No messages defined");
860 lanblockhead
= block_messages(nodehead
);
865 { add_node(nd_msg
, yyvsp
[0].msg
); ;
869 { add_node(nd_comment
, yyvsp
[0].str
); ;
873 { xyyerror(err_syntax
); /* `Catch all' error */ ;
877 { xyyerror(err_pclose
); ;
881 { xyyerror(err_popen
); ;
885 { xyyerror(err_assign
); ;
889 { xyyerror(err_pclose
); ;
893 { xyyerror(err_popen
); ;
897 { xyyerror(err_assign
); ;
901 { xyyerror(err_pclose
); ;
905 { xyyerror(err_popen
); ;
909 { xyyerror(err_assign
); ;
913 { xyyerror(err_pclose
); ;
917 { xyyerror(err_popen
); ;
921 { xyyerror(err_assign
); ;
925 { cast
= yyvsp
[0].str
; ;
929 { xyyerror(err_number
); ;
933 { xyyerror(err_assign
); ;
946 xyyerror("Numberbase must be 8, 10 or 16");
952 { xyyerror(err_number
); ;
956 { xyyerror(err_assign
); ;
960 { xyyerror(err_ident
); ;
965 yyvsp
[-3].tok
->token
= yyvsp
[-1].num
;
966 yyvsp
[-3].tok
->alias
= yyvsp
[0].str
;
967 if(yyvsp
[-1].num
& (~0x3))
968 xyyerror("Severity value out of range (0x%08x > 0x3)", yyvsp
[-1].num
);
969 do_add_token(tok_severity
, yyvsp
[-3].tok
, "severity");
974 { xyyerror(err_number
); ;
978 { xyyerror(err_assign
); ;
982 { xyyerror(err_ident
); ;
987 yyvsp
[-3].tok
->token
= yyvsp
[-1].num
;
988 yyvsp
[-3].tok
->alias
= yyvsp
[0].str
;
989 if(yyvsp
[-1].num
& (~0xfff))
990 xyyerror("Facility value out of range (0x%08x > 0xfff)", yyvsp
[-1].num
);
991 do_add_token(tok_facility
, yyvsp
[-3].tok
, "facility");
996 { xyyerror(err_number
); ;
1000 { xyyerror(err_assign
); ;
1004 { yyval
.str
= NULL
; ;
1008 { yyval
.str
= yyvsp
[0].str
; ;
1012 { xyyerror(err_ident
); ;
1016 { xyyerror(err_ident
); ;
1021 yyvsp
[-6].tok
->token
= yyvsp
[-4].num
;
1022 yyvsp
[-6].tok
->alias
= yyvsp
[-1].str
;
1023 yyvsp
[-6].tok
->codepage
= yyvsp
[0].num
;
1024 do_add_token(tok_language
, yyvsp
[-6].tok
, "language");
1025 if(!find_language(yyvsp
[-6].tok
->token
) && !find_cpxlat(yyvsp
[-6].tok
->token
))
1026 yywarning("Language 0x%x not built-in, using codepage %d; use explicit codepage to override", yyvsp
[-6].tok
->token
, WMC_DEFAULT_CODEPAGE
);
1031 { xyyerror("Filename expected"); ;
1035 { xyyerror(err_colon
); ;
1039 { xyyerror(err_number
); ;
1043 { xyyerror(err_assign
); ;
1051 { yyval
.num
= yyvsp
[0].num
; ;
1055 { xyyerror("Codepage-number expected"); ;
1059 { xyyerror(err_ident
); ;
1064 static const char err_nocp
[] = "Codepage %d not builtin; cannot convert";
1065 if(find_cpxlat(yyvsp
[-4].num
))
1066 xyyerror("Codepage translation already defined for language 0x%x", yyvsp
[-4].num
);
1067 // if(yyvsp[-2].num && !find_codepage(yyvsp[-2].num))
1069 xyyerror(err_nocp
, yyvsp
[-2].num
);
1070 // if(yyvsp[0].num && !find_codepage(yyvsp[0].num))
1072 xyyerror(err_nocp
, yyvsp
[0].num
);
1073 add_cpxlat(yyvsp
[-4].num
, yyvsp
[-2].num
, yyvsp
[0].num
);
1078 { xyyerror(err_number
); ;
1082 { xyyerror(err_colon
); ;
1086 { xyyerror(err_number
); ;
1090 { xyyerror(err_assign
); ;
1094 { yyval
.num
= yyvsp
[0].num
; ;
1099 if(yyvsp
[0].tok
->type
!= tok_language
)
1100 xyyerror("Language name or code expected");
1101 yyval
.num
= yyvsp
[0].tok
->token
;
1106 { test_id(yyvsp
[-1].num
); ;
1110 { yyval
.msg
= complete_msg(yyvsp
[0].msg
, yyvsp
[-3].num
); ;
1115 if(yyvsp
[0].num
& (~0xffff))
1116 xyyerror("Message ID value out of range (0x%08x > 0xffff)", yyvsp
[0].num
);
1117 yyval
.num
= yyvsp
[0].num
;
1122 { xyyerror(err_assign
); ;
1126 { yyval
.num
= ++last_id
; ;
1130 { yyval
.num
= last_id
= yyvsp
[0].num
; ;
1134 { yyval
.num
= last_id
+= yyvsp
[0].num
; ;
1138 { xyyerror(err_number
); ;
1142 { have_sev
= have_fac
= have_sym
= 0; ;
1146 { if(have_sev
) xyyerror("Severity already defined"); have_sev
= 1; ;
1150 { if(have_fac
) xyyerror("Facility already defined"); have_fac
= 1; ;
1154 { if(have_sym
) xyyerror("Symbolname already defined"); have_sym
= 1; ;
1158 { last_sym
= yyvsp
[0].str
; ;
1162 { xyyerror(err_ident
); ;
1166 { xyyerror(err_assign
); ;
1171 token_t
*tok
= lookup_token(yyvsp
[0].tok
->name
);
1173 xyyerror("Undefined severityname");
1174 if(tok
->type
!= tok_severity
)
1175 xyyerror("Identifier is not of class 'severity'");
1176 last_sev
= tok
->token
;
1181 { xyyerror(err_ident
); ;
1185 { xyyerror(err_assign
); ;
1190 token_t
*tok
= lookup_token(yyvsp
[0].tok
->name
);
1192 xyyerror("Undefined facilityname");
1193 if(tok
->type
!= tok_facility
)
1194 xyyerror("Identifier is not of class 'facility'");
1195 last_fac
= tok
->token
;
1200 { xyyerror(err_ident
); ;
1204 { xyyerror(err_assign
); ;
1208 { yyval
.msg
= add_lanmsg(NULL
, yyvsp
[0].lmp
); ;
1212 { yyval
.msg
= add_lanmsg(yyvsp
[-1].msg
, yyvsp
[0].lmp
); ;
1216 { xyyerror("'Language=...' (start of message text-definition) expected"); ;
1220 { yyval
.lmp
= new_lanmsg(&yyvsp
[-3].lcp
, yyvsp
[-1].str
); ;
1225 token_t
*tok
= lookup_token(yyvsp
[-1].tok
->name
);
1228 xyyerror("Undefined language");
1229 if(tok
->type
!= tok_language
)
1230 xyyerror("Identifier is not of class 'language'");
1231 if((cpx
= find_cpxlat(tok
->token
)))
1233 set_codepage(yyval
.lcp
.codepage
= cpx
->cpin
);
1235 else if(!tok
->codepage
)
1237 const language_t
*lan
= find_language(tok
->token
);
1240 /* Just set default; warning was given while parsing languagenames */
1241 set_codepage(yyval
.lcp
.codepage
= WMC_DEFAULT_CODEPAGE
);
1245 /* The default seems to be to use the DOS codepage... */
1246 set_codepage(yyval
.lcp
.codepage
= lan
->doscp
);
1250 set_codepage(yyval
.lcp
.codepage
= tok
->codepage
);
1251 yyval
.lcp
.language
= tok
->token
;
1256 { xyyerror("Missing newline"); ;
1260 { xyyerror(err_ident
); ;
1264 { xyyerror(err_assign
); ;
1268 { yyval
.str
= yyvsp
[0].str
; ;
1272 { yyval
.str
= merge(yyvsp
[-1].str
, yyvsp
[0].str
); ;
1276 { xyyerror(err_msg
); ;
1280 { xyyerror(err_msg
); ;
1284 { yyval
.tok
= xmalloc(sizeof(token_t
)); yyval
.tok
->name
= yyvsp
[0].str
; ;
1288 { yyval
.tok
= yyvsp
[0].tok
; ;
1303 /* the action file gets copied in in place of this dollarsign */
1304 #line 498 "/usr/share/bison.simple"
1315 short *ssp1
= yyss
- 1;
1316 fprintf (stderr
, "state stack now");
1317 while (ssp1
!= yyssp
)
1318 fprintf (stderr
, " %d", *++ssp1
);
1319 fprintf (stderr
, "\n");
1329 yylsp
->first_line
= yylloc
.first_line
;
1330 yylsp
->first_column
= yylloc
.first_column
;
1331 yylsp
->last_line
= (yylsp
-1)->last_line
;
1332 yylsp
->last_column
= (yylsp
-1)->last_column
;
1337 yylsp
->last_line
= (yylsp
+yylen
-1)->last_line
;
1338 yylsp
->last_column
= (yylsp
+yylen
-1)->last_column
;
1342 /* Now "shift" the result of the reduction.
1343 Determine what state that goes to,
1344 based on the state we popped back to
1345 and the rule number reduced by. */
1349 yystate
= yypgoto
[yyn
- YYNTBASE
] + *yyssp
;
1350 if (yystate
>= 0 && yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1351 yystate
= yytable
[yystate
];
1353 yystate
= yydefgoto
[yyn
- YYNTBASE
];
1357 yyerrlab
: /* here on detecting error */
1360 /* If not already recovering from an error, report this error. */
1364 #ifdef YYERROR_VERBOSE
1365 yyn
= yypact
[yystate
];
1367 if (yyn
> YYFLAG
&& yyn
< YYLAST
)
1374 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1375 for (x
= (yyn
< 0 ? -yyn
: 0);
1376 x
< (sizeof(yytname
) / sizeof(char *)); x
++)
1377 if (yycheck
[x
+ yyn
] == x
)
1378 size
+= strlen(yytname
[x
]) + 15, count
++;
1379 msg
= (char *) malloc(size
+ 15);
1382 strcpy(msg
, "parse error");
1387 for (x
= (yyn
< 0 ? -yyn
: 0);
1388 x
< (sizeof(yytname
) / sizeof(char *)); x
++)
1389 if (yycheck
[x
+ yyn
] == x
)
1391 strcat(msg
, count
== 0 ? ", expecting `" : " or `");
1392 strcat(msg
, yytname
[x
]);
1401 yyerror ("parse error; also virtual memory exceeded");
1404 #endif /* YYERROR_VERBOSE */
1405 yyerror("parse error");
1409 yyerrlab1
: /* here on error raised explicitly by an action */
1411 if (yyerrstatus
== 3)
1413 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1415 /* return failure if at end of input */
1416 if (yychar
== YYEOF
)
1421 fprintf(stderr
, "Discarding token %d (%s).\n", yychar
, yytname
[yychar1
]);
1427 /* Else will try to reuse lookahead token
1428 after shifting the error token. */
1430 yyerrstatus
= 3; /* Each real token shifted decrements this */
1434 yyerrdefault
: /* current state does not do anything special for the error token. */
1437 /* This is wrong; only states that explicitly want error tokens
1438 should shift them. */
1439 yyn
= yydefact
[yystate
]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1440 if (yyn
) goto yydefault
;
1443 yyerrpop
: /* pop the current state because it cannot handle the error token */
1445 if (yyssp
== yyss
) YYABORT
;
1455 short *ssp1
= yyss
- 1;
1456 fprintf (stderr
, "Error: state stack now");
1457 while (ssp1
!= yyssp
)
1458 fprintf (stderr
, " %d", *++ssp1
);
1459 fprintf (stderr
, "\n");
1465 yyn
= yypact
[yystate
];
1470 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != YYTERROR
)
1489 fprintf(stderr
, "Shifting error token, ");
1503 static WCHAR
*merge(WCHAR
*s1
, WCHAR
*s2
)
1505 int l1
= unistrlen(s1
);
1506 int l2
= unistrlen(s2
);
1507 s1
= xrealloc(s1
, (l1
+ l2
+ 1) * sizeof(*s1
));
1508 unistrcpy(s1
+l1
, s2
);
1513 static void do_add_token(tok_e type
, token_t
*tok
, const char *code
)
1515 token_t
*tp
= lookup_token(tok
->name
);
1518 if(tok
->type
!= type
)
1519 yywarning("Type change in token");
1521 xyyerror("Overlapping token not the same");
1522 /* else its already defined and changed */
1524 xyyerror("Redefinition of %s", code
);
1529 add_token(type
, tok
->name
, tok
->token
, tok
->codepage
, tok
->alias
, 1);
1534 static lanmsg_t
*new_lanmsg(lan_cp_t
*lcp
, WCHAR
*msg
)
1536 lanmsg_t
*lmp
= (lanmsg_t
*)xmalloc(sizeof(lanmsg_t
));
1537 lmp
->lan
= lcp
->language
;
1538 lmp
->cp
= lcp
->codepage
;
1540 lmp
->len
= unistrlen(msg
) + 1; /* Include termination */
1542 yywarning("Message exceptionally long; might be a missing termination");
1546 static msg_t
*add_lanmsg(msg_t
*msg
, lanmsg_t
*lanmsg
)
1550 msg
= xmalloc(sizeof(msg_t
));
1551 msg
->msgs
= xrealloc(msg
->msgs
, (msg
->nmsgs
+1) * sizeof(*(msg
->msgs
)));
1552 msg
->msgs
[msg
->nmsgs
] = lanmsg
;
1554 for(i
= 0; i
< msg
->nmsgs
-1; i
++)
1556 if(msg
->msgs
[i
]->lan
== lanmsg
->lan
)
1557 xyyerror("Message for language 0x%x already defined", lanmsg
->lan
);
1562 static int sort_lanmsg(const void *p1
, const void *p2
)
1564 return (*(lanmsg_t
**)p1
)->lan
- (*(lanmsg_t
**)p2
)->lan
;
1567 static msg_t
*complete_msg(msg_t
*mp
, int id
)
1574 xyyerror("No symbolic name defined for message id %d", id
);
1577 qsort(mp
->msgs
, mp
->nmsgs
, sizeof(*(mp
->msgs
)), sort_lanmsg
);
1578 mp
->realid
= id
| (last_sev
<< 30) | (last_fac
<< 16);
1580 mp
->realid
|= 1 << 29;
1586 static void add_node(node_e type
, void *p
)
1588 node_t
*ndp
= (node_t
*)xmalloc(sizeof(node_t
));
1594 ndp
->prev
= nodetail
;
1595 nodetail
->next
= ndp
;
1600 nodehead
= nodetail
= ndp
;
1604 static void test_id(int id
)
1607 for(ndp
= nodehead
; ndp
; ndp
= ndp
->next
)
1609 if(ndp
->type
!= nd_msg
)
1611 if(ndp
->u
.msg
->id
== id
&& ndp
->u
.msg
->sev
== last_sev
&& ndp
->u
.msg
->fac
== last_fac
)
1612 xyyerror("MessageId %d with facility 0x%x and severity 0x%x already defined", id
, last_fac
, last_sev
);
1616 static int check_languages(node_t
*head
)
1618 static char err_missing
[] = "Missing definition for language 0x%x; MessageID %d, facility 0x%x, severity 0x%x";
1623 for(ndp
= head
; ndp
; ndp
= ndp
->next
)
1625 if(ndp
->type
!= nd_msg
)
1636 if(ndp
->u
.msg
->nmsgs
> msg
->nmsgs
)
1647 for(i
= 0; i
< m1
->nmsgs
; i
++)
1650 error(err_missing
, m1
->msgs
[i
]->lan
, m2
->id
, m2
->fac
, m2
->sev
);
1651 else if(m1
->msgs
[i
]->lan
< m2
->msgs
[i
]->lan
)
1652 error(err_missing
, m1
->msgs
[i
]->lan
, m2
->id
, m2
->fac
, m2
->sev
);
1653 else if(m1
->msgs
[i
]->lan
> m2
->msgs
[i
]->lan
)
1654 error(err_missing
, m2
->msgs
[i
]->lan
, m1
->id
, m1
->fac
, m1
->sev
);
1662 #define MSGRID(x) ((*(msg_t **)(x))->realid)
1663 static int sort_msg(const void *p1
, const void *p2
)
1665 return MSGRID(p1
) > MSGRID(p2
) ? 1 : (MSGRID(p1
) == MSGRID(p2
) ? 0 : -1);
1666 /* return (*(msg_t **)p1)->realid - (*(msg_t **)p1)->realid; */
1670 * block_messages() basically transposes the messages
1671 * from ID/language based list to a language/ID
1674 static lan_blk_t
*block_messages(node_t
*head
)
1677 lan_blk_t
*lblktail
= NULL
;
1678 lan_blk_t
*lblkhead
= NULL
;
1679 msg_t
**msgtab
= NULL
;
1684 int factor
= unicodeout
? 2 : 1;
1686 for(ndp
= head
; ndp
; ndp
= ndp
->next
)
1688 if(ndp
->type
!= nd_msg
)
1690 msgtab
= xrealloc(msgtab
, (nmsg
+1) * sizeof(*msgtab
));
1691 msgtab
[nmsg
++] = ndp
->u
.msg
;
1695 qsort(msgtab
, nmsg
, sizeof(*msgtab
), sort_msg
);
1697 for(nl
= 0; nl
< msgtab
[0]->nmsgs
; nl
++) /* This should be equal for all after check_languages() */
1699 lbp
= xmalloc(sizeof(lan_blk_t
));
1703 lblkhead
= lblktail
= lbp
;
1707 lblktail
->next
= lbp
;
1708 lbp
->prev
= lblktail
;
1712 lbp
->blks
= xmalloc(sizeof(*lbp
->blks
));
1713 lbp
->blks
[0].idlo
= msgtab
[0]->realid
;
1714 lbp
->blks
[0].idhi
= msgtab
[0]->realid
;
1715 /* The plus 4 is the entry header; (+3)&~3 is DWORD alignment */
1716 lbp
->blks
[0].size
= ((factor
* msgtab
[0]->msgs
[nl
]->len
+ 3) & ~3) + 4;
1717 lbp
->blks
[0].msgs
= xmalloc(sizeof(*lbp
->blks
[0].msgs
));
1718 lbp
->blks
[0].nmsg
= 1;
1719 lbp
->blks
[0].msgs
[0] = msgtab
[0]->msgs
[nl
];
1720 lbp
->lan
= msgtab
[0]->msgs
[nl
]->lan
;
1722 for(i
= 1; i
< nmsg
; i
++)
1724 block_t
*blk
= &(lbp
->blks
[lbp
->nblk
-1]);
1725 if(msgtab
[i
]->realid
== blk
->idhi
+1)
1727 blk
->size
+= ((factor
* msgtab
[i
]->msgs
[nl
]->len
+ 3) & ~3) + 4;
1729 blk
->msgs
= xrealloc(blk
->msgs
, (blk
->nmsg
+1) * sizeof(*blk
->msgs
));
1730 blk
->msgs
[blk
->nmsg
++] = msgtab
[i
]->msgs
[nl
];
1735 lbp
->blks
= xrealloc(lbp
->blks
, lbp
->nblk
* sizeof(*lbp
->blks
));
1736 blk
= &(lbp
->blks
[lbp
->nblk
-1]);
1737 blk
->idlo
= msgtab
[i
]->realid
;
1738 blk
->idhi
= msgtab
[i
]->realid
;
1739 blk
->size
= ((factor
* msgtab
[i
]->msgs
[nl
]->len
+ 3) & ~3) + 4;
1740 blk
->msgs
= xmalloc(sizeof(*blk
->msgs
));
1742 blk
->msgs
[0] = msgtab
[i
]->msgs
[nl
];
1750 static int sc_xlat(const void *p1
, const void *p2
)
1752 return ((cp_xlat_t
*)p1
)->lan
- ((cp_xlat_t
*)p2
)->lan
;
1755 static void add_cpxlat(int lan
, int cpin
, int cpout
)
1757 cpxlattab
= xrealloc(cpxlattab
, (ncpxlattab
+1) * sizeof(*cpxlattab
));
1758 cpxlattab
[ncpxlattab
].lan
= lan
;
1759 cpxlattab
[ncpxlattab
].cpin
= cpin
;
1760 cpxlattab
[ncpxlattab
].cpout
= cpout
;
1762 qsort(cpxlattab
, ncpxlattab
, sizeof(*cpxlattab
), sc_xlat
);
1765 static cp_xlat_t
*find_cpxlat(int lan
)
1769 if(!cpxlattab
) return NULL
;
1772 return (cp_xlat_t
*)bsearch(&t
, cpxlattab
, ncpxlattab
, sizeof(*cpxlattab
), sc_xlat
);