1 /* A Bison parser, made from nlmheader.y
2 by GNU bison 1.35. */
3
4 #define YYBISON 1 /* Identify Bison output. */
5
6 # define CHECK 257
7 # define CODESTART 258
8 # define COPYRIGHT 259
9 # define CUSTOM 260
10 # define DATE 261
11 # define DEBUG 262
12 # define DESCRIPTION 263
13 # define EXIT 264
14 # define EXPORT 265
15 # define FLAG_ON 266
16 # define FLAG_OFF 267
17 # define FULLMAP 268
18 # define HELP 269
19 # define IMPORT 270
20 # define INPUT 271
21 # define MAP 272
22 # define MESSAGES 273
23 # define MODULE 274
24 # define MULTIPLE 275
25 # define OS_DOMAIN 276
26 # define OUTPUT 277
27 # define PSEUDOPREEMPTION 278
28 # define REENTRANT 279
29 # define SCREENNAME 280
30 # define SHARELIB 281
31 # define STACK 282
32 # define START 283
33 # define SYNCHRONIZE 284
34 # define THREADNAME 285
35 # define TYPE 286
36 # define VERBOSE 287
37 # define VERSIONK 288
38 # define XDCDATA 289
39 # define STRING 290
40 # define QUOTED_STRING 291
41
42 #line 1 "nlmheader.y"
43 /* nlmheader.y - parse NLM header specification keywords.
44 Copyright 1993, 1994, 1995, 1997, 1998, 2001, 2002, 2003
45 Free Software Foundation, Inc.
46
47 This file is part of GNU Binutils.
48
49 This program is free software; you can redistribute it and/or modify
50 it under the terms of the GNU General Public License as published by
51 the Free Software Foundation; either version 2 of the License, or
52 (at your option) any later version.
53
54 This program is distributed in the hope that it will be useful,
55 but WITHOUT ANY WARRANTY; without even the implied warranty of
56 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 GNU General Public License for more details.
58
59 You should have received a copy of the GNU General Public License
60 along with this program; if not, write to the Free Software
61 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
62
63 /* Written by Ian Lance Taylor <ian@cygnus.com>.
64
65 This bison file parses the commands recognized by the NetWare NLM
66 linker, except for lists of object files. It stores the
67 information in global variables.
68
69 This implementation is based on the description in the NetWare Tool
70 Maker Specification manual, edition 1.0. */
71
72 #include "ansidecl.h"
73 #include <stdio.h>
74 #include "safe-ctype.h"
75 #include "bfd.h"
76 #include "bucomm.h"
77 #include "nlm/common.h"
78 #include "nlm/internal.h"
79 #include "nlmconv.h"
80
81 /* Information is stored in the structures pointed to by these
82 variables. */
83
84 Nlm_Internal_Fixed_Header *fixed_hdr;
85 Nlm_Internal_Variable_Header *var_hdr;
86 Nlm_Internal_Version_Header *version_hdr;
87 Nlm_Internal_Copyright_Header *copyright_hdr;
88 Nlm_Internal_Extended_Header *extended_hdr;
89
90 /* Procedure named by CHECK. */
91 char *check_procedure;
92 /* File named by CUSTOM. */
93 char *custom_file;
94 /* Whether to generate debugging information (DEBUG). */
95 bfd_boolean debug_info;
96 /* Procedure named by EXIT. */
97 char *exit_procedure;
98 /* Exported symbols (EXPORT). */
99 struct string_list *export_symbols;
100 /* List of files from INPUT. */
101 struct string_list *input_files;
102 /* Map file name (MAP, FULLMAP). */
103 char *map_file;
104 /* Whether a full map has been requested (FULLMAP). */
105 bfd_boolean full_map;
106 /* File named by HELP. */
107 char *help_file;
108 /* Imported symbols (IMPORT). */
109 struct string_list *import_symbols;
110 /* File named by MESSAGES. */
111 char *message_file;
112 /* Autoload module list (MODULE). */
113 struct string_list *modules;
114 /* File named by OUTPUT. */
115 char *output_file;
116 /* File named by SHARELIB. */
117 char *sharelib_file;
118 /* Start procedure name (START). */
119 char *start_procedure;
120 /* VERBOSE. */
121 bfd_boolean verbose;
122 /* RPC description file (XDCDATA). */
123 char *rpc_file;
124
125 /* The number of serious errors that have occurred. */
126 int parse_errors;
127
128 /* The current symbol prefix when reading a list of import or export
129 symbols. */
130 static char *symbol_prefix;
131
132 /* Parser error message handler. */
133 #define yyerror(msg) nlmheader_error (msg);
134
135 /* Local functions. */
136 static int yylex (void);
137 static void nlmlex_file_push (const char *);
138 static bfd_boolean nlmlex_file_open (const char *);
139 static int nlmlex_buf_init (void);
140 static char nlmlex_buf_add (int);
141 static long nlmlex_get_number (const char *);
142 static void nlmheader_identify (void);
143 static void nlmheader_warn (const char *, int);
144 static void nlmheader_error (const char *);
145 static struct string_list * string_list_cons (char *, struct string_list *);
146 static struct string_list * string_list_append (struct string_list *,
147 struct string_list *);
148 static struct string_list * string_list_append1 (struct string_list *,
149 char *);
150 static char *xstrdup (const char *);
151
152
153 #line 112 "nlmheader.y"
154 #ifndef YYSTYPE
155 typedef union
156 {
157 char *string;
158 struct string_list *list;
159 } yystype;
160 # define YYSTYPE yystype
161 # define YYSTYPE_IS_TRIVIAL 1
162 #endif
163 #ifndef YYDEBUG
164 # define YYDEBUG 0
165 #endif
166
167
168
169 #define YYFINAL 82
170 #define YYFLAG -32768
171 #define YYNTBASE 40
172
173 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
174 #define YYTRANSLATE(x) ((unsigned)(x) <= 291 ? yytranslate[x] : 50)
175
176 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
177 static const char yytranslate[] =
178 {
179 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
180 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
181 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
182 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
183 38, 39, 2, 2, 2, 2, 2, 2, 2, 2,
184 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
185 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
186 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
187 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
188 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
189 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
190 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
191 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
192 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
193 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
194 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
195 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
196 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
197 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
198 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
199 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
200 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
201 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
202 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
203 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
204 2, 2, 2, 2, 2, 2, 1, 3, 4, 5,
205 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
206 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
207 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
208 36, 37
209 };
210
211 #if YYDEBUG
212 static const short yyprhs[] =
213 {
214 0, 0, 2, 3, 6, 9, 12, 15, 18, 23,
215 25, 28, 31, 32, 36, 39, 42, 44, 47, 50,
216 51, 55, 58, 60, 63, 66, 69, 71, 73, 76,
217 78, 80, 83, 86, 89, 92, 94, 97, 100, 102,
218 107, 111, 114, 115, 117, 119, 121, 124, 127, 131,
219 133, 134
220 };
221 static const short yyrhs[] =
222 {
223 41, 0, 0, 42, 41, 0, 3, 36, 0, 4,
224 36, 0, 5, 37, 0, 6, 36, 0, 7, 36,
225 36, 36, 0, 8, 0, 9, 37, 0, 10, 36,
226 0, 0, 11, 43, 45, 0, 12, 36, 0, 13,
227 36, 0, 14, 0, 14, 36, 0, 15, 36, 0,
228 0, 16, 44, 45, 0, 17, 49, 0, 18, 0,
229 18, 36, 0, 19, 36, 0, 20, 49, 0, 21,
230 0, 22, 0, 23, 36, 0, 24, 0, 25, 0,
231 26, 37, 0, 27, 36, 0, 28, 36, 0, 29,
232 36, 0, 30, 0, 31, 37, 0, 32, 36, 0,
233 33, 0, 34, 36, 36, 36, 0, 34, 36, 36,
234 0, 35, 36, 0, 0, 46, 0, 48, 0, 47,
235 0, 46, 48, 0, 46, 47, 0, 38, 36, 39,
236 0, 36, 0, 0, 36, 49, 0
237 };
238
239 #endif
240
241 #if YYDEBUG
242 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
243 static const short yyrline[] =
244 {
245 0, 143, 149, 151, 156, 161, 166, 183, 187, 205,
246 209, 225, 229, 229, 237, 242, 247, 252, 257, 261,
247 261, 269, 273, 277, 281, 285, 289, 293, 297, 304,
248 308, 312, 328, 332, 337, 341, 345, 361, 366, 370,
249 394, 410, 418, 423, 433, 438, 442, 446, 454, 465,
250 481, 486
251 };
252 #endif
253
254
255 #if (YYDEBUG) || defined YYERROR_VERBOSE
256
257 /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
258 static const char *const yytname[] =
259 {
260 "$", "error", "$undefined.", "CHECK", "CODESTART", "COPYRIGHT", "CUSTOM",
261 "DATE", "DEBUG", "DESCRIPTION", "EXIT", "EXPORT", "FLAG_ON", "FLAG_OFF",
262 "FULLMAP", "HELP", "IMPORT", "INPUT", "MAP", "MESSAGES", "MODULE",
263 "MULTIPLE", "OS_DOMAIN", "OUTPUT", "PSEUDOPREEMPTION", "REENTRANT",
264 "SCREENNAME", "SHARELIB", "STACK", "START", "SYNCHRONIZE", "THREADNAME",
265 "TYPE", "VERBOSE", "VERSIONK", "XDCDATA", "STRING", "QUOTED_STRING",
266 "'('", "')'", "file", "commands", "command", "@1", "@2",
267 "symbol_list_opt", "symbol_list", "symbol_prefix", "symbol",
268 "string_list", 0
269 };
270 #endif
271
272 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
273 static const short yyr1[] =
274 {
275 0, 40, 41, 41, 42, 42, 42, 42, 42, 42,
276 42, 42, 43, 42, 42, 42, 42, 42, 42, 44,
277 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
278 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
279 42, 42, 45, 45, 46, 46, 46, 46, 47, 48,
280 49, 49
281 };
282
283 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
284 static const short yyr2[] =
285 {
286 0, 1, 0, 2, 2, 2, 2, 2, 4, 1,
287 2, 2, 0, 3, 2, 2, 1, 2, 2, 0,
288 3, 2, 1, 2, 2, 2, 1, 1, 2, 1,
289 1, 2, 2, 2, 2, 1, 2, 2, 1, 4,
290 3, 2, 0, 1, 1, 1, 2, 2, 3, 1,
291 0, 2
292 };
293
294 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
295 doesn't specify something else to do. Zero means the default is an
296 error. */
297 static const short yydefact[] =
298 {
299 2, 0, 0, 0, 0, 0, 9, 0, 0, 12,
300 0, 0, 16, 0, 19, 50, 22, 0, 50, 26,
301 27, 0, 29, 30, 0, 0, 0, 0, 35, 0,
302 0, 38, 0, 0, 1, 2, 4, 5, 6, 7,
303 0, 10, 11, 42, 14, 15, 17, 18, 42, 50,
304 21, 23, 24, 25, 28, 31, 32, 33, 34, 36,
305 37, 0, 41, 3, 0, 49, 0, 13, 43, 45,
306 44, 20, 51, 40, 8, 0, 47, 46, 39, 48,
307 0, 0, 0
308 };
309
310 static const short yydefgoto[] =
311 {
312 80, 34, 35, 43, 48, 67, 68, 69, 70, 50
313 };
314
315 static const short yypact[] =
316 {
317 -3, -1, 1, 2, 4, 5,-32768, 6, 8,-32768,
318 9, 10, 11, 12,-32768, 13, 14, 16, 13,-32768,
319 -32768, 17,-32768,-32768, 18, 20, 21, 22,-32768, 23,
320 25,-32768, 26, 27,-32768, -3,-32768,-32768,-32768,-32768,
321 29,-32768,-32768, -2,-32768,-32768,-32768,-32768, -2, 13,
322 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
323 -32768, 30,-32768,-32768, 31,-32768, 32,-32768, -2,-32768,
324 -32768,-32768,-32768, 33,-32768, 3,-32768,-32768,-32768,-32768,
325 38, 51,-32768
326 };
327
328 static const short yypgoto[] =
329 {
330 -32768, 19,-32768,-32768,-32768, 24,-32768, -9, 7, 15
331 };
332
333
334 #define YYLAST 75
335
336
337 static const short yytable[] =
338 {
339 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
340 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
341 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
342 31, 32, 33, 53, 65, 36, 66, 37, 81, 38,
343 39, 40, 79, 41, 42, 44, 45, 46, 47, 49,
344 51, 82, 52, 54, 63, 55, 56, 57, 58, 76,
345 59, 60, 61, 62, 72, 64, 73, 74, 75, 78,
346 0, 0, 71, 0, 0, 77
347 };
348
349 static const short yycheck[] =
350 {
351 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
352 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
353 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
354 33, 34, 35, 18, 36, 36, 38, 36, 0, 37,
355 36, 36, 39, 37, 36, 36, 36, 36, 36, 36,
356 36, 0, 36, 36, 35, 37, 36, 36, 36, 68,
357 37, 36, 36, 36, 49, 36, 36, 36, 36, 36,
358 -1, -1, 48, -1, -1, 68
359 };
360 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
361 #line 3 "/usr/share/bison/bison.simple"
362
363 /* Skeleton output parser for bison,
364
365 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
366 Foundation, Inc.
367
368 This program is free software; you can redistribute it and/or modify
369 it under the terms of the GNU General Public License as published by
370 the Free Software Foundation; either version 2, or (at your option)
371 any later version.
372
373 This program is distributed in the hope that it will be useful,
374 but WITHOUT ANY WARRANTY; without even the implied warranty of
375 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376 GNU General Public License for more details.
377
378 You should have received a copy of the GNU General Public License
379 along with this program; if not, write to the Free Software
380 Foundation, Inc., 59 Temple Place - Suite 330,
381 Boston, MA 02111-1307, USA. */
382
383 /* As a special exception, when this file is copied by Bison into a
384 Bison output file, you may use that output file without restriction.
385 This special exception was added by the Free Software Foundation
386 in version 1.24 of Bison. */
387
388 /* This is the parser code that is written into each bison parser when
389 the %semantic_parser declaration is not specified in the grammar.
390 It was written by Richard Stallman by simplifying the hairy parser
391 used when %semantic_parser is specified. */
392
393 /* All symbols defined below should begin with yy or YY, to avoid
394 infringing on user name space. This should be done even for local
395 variables, as they might otherwise be expanded by user macros.
396 There are some unavoidable exceptions within include files to
397 define necessary library symbols; they are noted "INFRINGES ON
398 USER NAME SPACE" below. */
399
400 #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
401
402 /* The parser invokes alloca or malloc; define the necessary symbols. */
403
404 # if YYSTACK_USE_ALLOCA
405 # define YYSTACK_ALLOC alloca
406 # else
407 # ifndef YYSTACK_USE_ALLOCA
408 # if defined (alloca) || defined (_ALLOCA_H)
409 # define YYSTACK_ALLOC alloca
410 # else
411 # ifdef __GNUC__
412 # define YYSTACK_ALLOC __builtin_alloca
413 # endif
414 # endif
415 # endif
416 # endif
417
418 # ifdef YYSTACK_ALLOC
419 /* Pacify GCC's `empty if-body' warning. */
420 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
421 # else
422 # if defined (__STDC__) || defined (__cplusplus)
423 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
424 # define YYSIZE_T size_t
425 # endif
426 # define YYSTACK_ALLOC malloc
427 # define YYSTACK_FREE free
428 # endif
429 #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
430
431
432 #if (! defined (yyoverflow) \
433 && (! defined (__cplusplus) \
434 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
435
436 /* A type that is properly aligned for any stack member. */
437 union yyalloc
438 {
439 short yyss;
440 YYSTYPE yyvs;
441 # if YYLSP_NEEDED
442 YYLTYPE yyls;
443 # endif
444 };
445
446 /* The size of the maximum gap between one aligned stack and the next. */
447 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
448
449 /* The size of an array large to enough to hold all stacks, each with
450 N elements. */
451 # if YYLSP_NEEDED
452 # define YYSTACK_BYTES(N) \
453 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
454 + 2 * YYSTACK_GAP_MAX)
455 # else
456 # define YYSTACK_BYTES(N) \
457 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
458 + YYSTACK_GAP_MAX)
459 # endif
460
461 /* Copy COUNT objects from FROM to TO. The source and destination do
462 not overlap. */
463 # ifndef YYCOPY
464 # if 1 < __GNUC__
465 # define YYCOPY(To, From, Count) \
466 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
467 # else
468 # define YYCOPY(To, From, Count) \
469 do \
470 { \
471 register YYSIZE_T yyi; \
472 for (yyi = 0; yyi < (Count); yyi++) \
473 (To)[yyi] = (From)[yyi]; \
474 } \
475 while (0)
476 # endif
477 # endif
478
479 /* Relocate STACK from its old location to the new one. The
480 local variables YYSIZE and YYSTACKSIZE give the old and new number of
481 elements in the stack, and YYPTR gives the new location of the
482 stack. Advance YYPTR to a properly aligned location for the next
483 stack. */
484 # define YYSTACK_RELOCATE(Stack) \
485 do \
486 { \
487 YYSIZE_T yynewbytes; \
488 YYCOPY (&yyptr->Stack, Stack, yysize); \
489 Stack = &yyptr->Stack; \
490 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \
491 yyptr += yynewbytes / sizeof (*yyptr); \
492 } \
493 while (0)
494
495 #endif
496
497
498 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
499 # define YYSIZE_T __SIZE_TYPE__
500 #endif
501 #if ! defined (YYSIZE_T) && defined (size_t)
502 # define YYSIZE_T size_t
503 #endif
504 #if ! defined (YYSIZE_T)
505 # if defined (__STDC__) || defined (__cplusplus)
506 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
507 # define YYSIZE_T size_t
508 # endif
509 #endif
510 #if ! defined (YYSIZE_T)
511 # define YYSIZE_T unsigned int
512 #endif
513
514 #define yyerrok (yyerrstatus = 0)
515 #define yyclearin (yychar = YYEMPTY)
516 #define YYEMPTY -2
517 #define YYEOF 0
518 #define YYACCEPT goto yyacceptlab
519 #define YYABORT goto yyabortlab
520 #define YYERROR goto yyerrlab1
521 /* Like YYERROR except do call yyerror. This remains here temporarily
522 to ease the transition to the new meaning of YYERROR, for GCC.
523 Once GCC version 2 has supplanted version 1, this can go. */
524 #define YYFAIL goto yyerrlab
525 #define YYRECOVERING() (!!yyerrstatus)
526 #define YYBACKUP(Token, Value) \
527 do \
528 if (yychar == YYEMPTY && yylen == 1) \
529 { \
530 yychar = (Token); \
531 yylval = (Value); \
532 yychar1 = YYTRANSLATE (yychar); \
533 YYPOPSTACK; \
534 goto yybackup; \
535 } \
536 else \
537 { \
538 yyerror ("syntax error: cannot back up"); \
539 YYERROR; \
540 } \
541 while (0)
542
543 #define YYTERROR 1
544 #define YYERRCODE 256
545
546
547 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
548 are run).
549
550 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
551 first token. By default, to implement support for ranges, extend
552 its range to the last symbol. */
553
554 #ifndef YYLLOC_DEFAULT
555 # define YYLLOC_DEFAULT(Current, Rhs, N) \
556 Current.last_line = Rhs[N].last_line; \
557 Current.last_column = Rhs[N].last_column;
558 #endif
559
560
561 /* YYLEX -- calling `yylex' with the right arguments. */
562
563 #if YYPURE
564 # if YYLSP_NEEDED
565 # ifdef YYLEX_PARAM
566 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
567 # else
568 # define YYLEX yylex (&yylval, &yylloc)
569 # endif
570 # else /* !YYLSP_NEEDED */
571 # ifdef YYLEX_PARAM
572 # define YYLEX yylex (&yylval, YYLEX_PARAM)
573 # else
574 # define YYLEX yylex (&yylval)
575 # endif
576 # endif /* !YYLSP_NEEDED */
577 #else /* !YYPURE */
578 # define YYLEX yylex ()
579 #endif /* !YYPURE */
580
581
582 /* Enable debugging if requested. */
583 #if YYDEBUG
584
585 # ifndef YYFPRINTF
586 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
587 # define YYFPRINTF fprintf
588 # endif
589
590 # define YYDPRINTF(Args) \
591 do { \
592 if (yydebug) \
593 YYFPRINTF Args; \
594 } while (0)
595 /* Nonzero means print parse trace. It is left uninitialized so that
596 multiple parsers can coexist. */
597 int yydebug;
598 #else /* !YYDEBUG */
599 # define YYDPRINTF(Args)
600 #endif /* !YYDEBUG */
601
602 /* YYINITDEPTH -- initial size of the parser's stacks. */
603 #ifndef YYINITDEPTH
604 # define YYINITDEPTH 200
605 #endif
606
607 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
608 if the built-in stack extension method is used).
609
610 Do not make this value too large; the results are undefined if
611 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
612 evaluated with infinite-precision integer arithmetic. */
613
614 #if YYMAXDEPTH == 0
615 # undef YYMAXDEPTH
616 #endif
617
618 #ifndef YYMAXDEPTH
619 # define YYMAXDEPTH 10000
620 #endif
621
622 #ifdef YYERROR_VERBOSE
623
624 # ifndef yystrlen
625 # if defined (__GLIBC__) && defined (_STRING_H)
626 # define yystrlen strlen
627 # else
628 /* Return the length of YYSTR. */
629 static YYSIZE_T
630 # if defined (__STDC__) || defined (__cplusplus)
yystrlen(const char * yystr)631 yystrlen (const char *yystr)
632 # else
633 yystrlen (yystr)
634 const char *yystr;
635 # endif
636 {
637 register const char *yys = yystr;
638
639 while (*yys++ != '\0')
640 continue;
641
642 return yys - yystr - 1;
643 }
644 # endif
645 # endif
646
647 # ifndef yystpcpy
648 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
649 # include <string.h>
650 # define yystpcpy stpcpy
651 # else
652 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
653 YYDEST. */
654 static char *
655 # if defined (__STDC__) || defined (__cplusplus)
yystpcpy(char * yydest,const char * yysrc)656 yystpcpy (char *yydest, const char *yysrc)
657 # else
658 yystpcpy (yydest, yysrc)
659 char *yydest;
660 const char *yysrc;
661 # endif
662 {
663 register char *yyd = yydest;
664 register const char *yys = yysrc;
665
666 while ((*yyd++ = *yys++) != '\0')
667 continue;
668
669 return yyd - 1;
670 }
671 # endif
672 # endif
673 #endif
674
675 #line 316 "/usr/share/bison/bison.simple"
676
677
678 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
679 into yyparse. The argument should have type void *.
680 It should actually point to an object.
681 Grammar actions can access the variable by casting it
682 to the proper pointer type. */
683
684 #ifdef YYPARSE_PARAM
685 # if defined (__STDC__) || defined (__cplusplus)
686 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
687 # define YYPARSE_PARAM_DECL
688 # else
689 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
690 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
691 # endif
692 #else /* !YYPARSE_PARAM */
693 # define YYPARSE_PARAM_ARG
694 # define YYPARSE_PARAM_DECL
695 #endif /* !YYPARSE_PARAM */
696
697 /* Prevent warning if -Wstrict-prototypes. */
698 #ifdef __GNUC__
699 # ifdef YYPARSE_PARAM
700 int yyparse (void *);
701 # else
702 int yyparse (void);
703 # endif
704 #endif
705
706 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
707 variables are global, or local to YYPARSE. */
708
709 #define YY_DECL_NON_LSP_VARIABLES \
710 /* The lookahead symbol. */ \
711 int yychar; \
712 \
713 /* The semantic value of the lookahead symbol. */ \
714 YYSTYPE yylval; \
715 \
716 /* Number of parse errors so far. */ \
717 int yynerrs;
718
719 #if YYLSP_NEEDED
720 # define YY_DECL_VARIABLES \
721 YY_DECL_NON_LSP_VARIABLES \
722 \
723 /* Location data for the lookahead symbol. */ \
724 YYLTYPE yylloc;
725 #else
726 # define YY_DECL_VARIABLES \
727 YY_DECL_NON_LSP_VARIABLES
728 #endif
729
730
731 /* If nonreentrant, generate the variables here. */
732
733 #if !YYPURE
734 YY_DECL_VARIABLES
735 #endif /* !YYPURE */
736
737 int
yyparse(YYPARSE_PARAM_ARG)738 yyparse (YYPARSE_PARAM_ARG)
739 YYPARSE_PARAM_DECL
740 {
741 /* If reentrant, generate the variables here. */
742 #if YYPURE
743 YY_DECL_VARIABLES
744 #endif /* !YYPURE */
745
746 register int yystate;
747 register int yyn;
748 int yyresult;
749 /* Number of tokens to shift before error messages enabled. */
750 int yyerrstatus;
751 /* Lookahead token as an internal (translated) token number. */
752 int yychar1 = 0;
753
754 /* Three stacks and their tools:
755 `yyss': related to states,
756 `yyvs': related to semantic values,
757 `yyls': related to locations.
758
759 Refer to the stacks thru separate pointers, to allow yyoverflow
760 to reallocate them elsewhere. */
761
762 /* The state stack. */
763 short yyssa[YYINITDEPTH];
764 short *yyss = yyssa;
765 register short *yyssp;
766
767 /* The semantic value stack. */
768 YYSTYPE yyvsa[YYINITDEPTH];
769 YYSTYPE *yyvs = yyvsa;
770 register YYSTYPE *yyvsp;
771
772 #if YYLSP_NEEDED
773 /* The location stack. */
774 YYLTYPE yylsa[YYINITDEPTH];
775 YYLTYPE *yyls = yylsa;
776 YYLTYPE *yylsp;
777 #endif
778
779 #if YYLSP_NEEDED
780 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
781 #else
782 # define YYPOPSTACK (yyvsp--, yyssp--)
783 #endif
784
785 YYSIZE_T yystacksize = YYINITDEPTH;
786
787
788 /* The variables used to return semantic value and location from the
789 action routines. */
790 YYSTYPE yyval;
791 #if YYLSP_NEEDED
792 YYLTYPE yyloc;
793 #endif
794
795 /* When reducing, the number of symbols on the RHS of the reduced
796 rule. */
797 int yylen;
798
799 YYDPRINTF ((stderr, "Starting parse\n"));
800
801 yystate = 0;
802 yyerrstatus = 0;
803 yynerrs = 0;
804 yychar = YYEMPTY; /* Cause a token to be read. */
805
806 /* Initialize stack pointers.
807 Waste one element of value and location stack
808 so that they stay on the same level as the state stack.
809 The wasted elements are never initialized. */
810
811 yyssp = yyss;
812 yyvsp = yyvs;
813 #if YYLSP_NEEDED
814 yylsp = yyls;
815 #endif
816 goto yysetstate;
817
818 /*------------------------------------------------------------.
819 | yynewstate -- Push a new state, which is found in yystate. |
820 `------------------------------------------------------------*/
821 yynewstate:
822 /* In all cases, when you get here, the value and location stacks
823 have just been pushed. so pushing a state here evens the stacks.
824 */
825 yyssp++;
826
827 yysetstate:
828 *yyssp = yystate;
829
830 if (yyssp >= yyss + yystacksize - 1)
831 {
832 /* Get the current used size of the three stacks, in elements. */
833 YYSIZE_T yysize = yyssp - yyss + 1;
834
835 #ifdef yyoverflow
836 {
837 /* Give user a chance to reallocate the stack. Use copies of
838 these so that the &'s don't force the real ones into
839 memory. */
840 YYSTYPE *yyvs1 = yyvs;
841 short *yyss1 = yyss;
842
843 /* Each stack pointer address is followed by the size of the
844 data in use in that stack, in bytes. */
845 # if YYLSP_NEEDED
846 YYLTYPE *yyls1 = yyls;
847 /* This used to be a conditional around just the two extra args,
848 but that might be undefined if yyoverflow is a macro. */
849 yyoverflow ("parser stack overflow",
850 &yyss1, yysize * sizeof (*yyssp),
851 &yyvs1, yysize * sizeof (*yyvsp),
852 &yyls1, yysize * sizeof (*yylsp),
853 &yystacksize);
854 yyls = yyls1;
855 # else
856 yyoverflow ("parser stack overflow",
857 &yyss1, yysize * sizeof (*yyssp),
858 &yyvs1, yysize * sizeof (*yyvsp),
859 &yystacksize);
860 # endif
861 yyss = yyss1;
862 yyvs = yyvs1;
863 }
864 #else /* no yyoverflow */
865 # ifndef YYSTACK_RELOCATE
866 goto yyoverflowlab;
867 # else
868 /* Extend the stack our own way. */
869 if (yystacksize >= YYMAXDEPTH)
870 goto yyoverflowlab;
871 yystacksize *= 2;
872 if (yystacksize > YYMAXDEPTH)
873 yystacksize = YYMAXDEPTH;
874
875 {
876 short *yyss1 = yyss;
877 union yyalloc *yyptr =
878 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
879 if (! yyptr)
880 goto yyoverflowlab;
881 YYSTACK_RELOCATE (yyss);
882 YYSTACK_RELOCATE (yyvs);
883 # if YYLSP_NEEDED
884 YYSTACK_RELOCATE (yyls);
885 # endif
886 # undef YYSTACK_RELOCATE
887 if (yyss1 != yyssa)
888 YYSTACK_FREE (yyss1);
889 }
890 # endif
891 #endif /* no yyoverflow */
892
893 yyssp = yyss + yysize - 1;
894 yyvsp = yyvs + yysize - 1;
895 #if YYLSP_NEEDED
896 yylsp = yyls + yysize - 1;
897 #endif
898
899 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
900 (unsigned long int) yystacksize));
901
902 if (yyssp >= yyss + yystacksize - 1)
903 YYABORT;
904 }
905
906 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
907
908 goto yybackup;
909
910
911 /*-----------.
912 | yybackup. |
913 `-----------*/
914 yybackup:
915
916 /* Do appropriate processing given the current state. */
917 /* Read a lookahead token if we need one and don't already have one. */
918 /* yyresume: */
919
920 /* First try to decide what to do without reference to lookahead token. */
921
922 yyn = yypact[yystate];
923 if (yyn == YYFLAG)
924 goto yydefault;
925
926 /* Not known => get a lookahead token if don't already have one. */
927
928 /* yychar is either YYEMPTY or YYEOF
929 or a valid token in external form. */
930
931 if (yychar == YYEMPTY)
932 {
933 YYDPRINTF ((stderr, "Reading a token: "));
934 yychar = YYLEX;
935 }
936
937 /* Convert token to internal form (in yychar1) for indexing tables with */
938
939 if (yychar <= 0) /* This means end of input. */
940 {
941 yychar1 = 0;
942 yychar = YYEOF; /* Don't call YYLEX any more */
943
944 YYDPRINTF ((stderr, "Now at end of input.\n"));
945 }
946 else
947 {
948 yychar1 = YYTRANSLATE (yychar);
949
950 #if YYDEBUG
951 /* We have to keep this `#if YYDEBUG', since we use variables
952 which are defined only if `YYDEBUG' is set. */
953 if (yydebug)
954 {
955 YYFPRINTF (stderr, "Next token is %d (%s",
956 yychar, yytname[yychar1]);
957 /* Give the individual parser a way to print the precise
958 meaning of a token, for further debugging info. */
959 # ifdef YYPRINT
960 YYPRINT (stderr, yychar, yylval);
961 # endif
962 YYFPRINTF (stderr, ")\n");
963 }
964 #endif
965 }
966
967 yyn += yychar1;
968 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
969 goto yydefault;
970
971 yyn = yytable[yyn];
972
973 /* yyn is what to do for this token type in this state.
974 Negative => reduce, -yyn is rule number.
975 Positive => shift, yyn is new state.
976 New state is final state => don't bother to shift,
977 just return success.
978 0, or most negative number => error. */
979
980 if (yyn < 0)
981 {
982 if (yyn == YYFLAG)
983 goto yyerrlab;
984 yyn = -yyn;
985 goto yyreduce;
986 }
987 else if (yyn == 0)
988 goto yyerrlab;
989
990 if (yyn == YYFINAL)
991 YYACCEPT;
992
993 /* Shift the lookahead token. */
994 YYDPRINTF ((stderr, "Shifting token %d (%s), ",
995 yychar, yytname[yychar1]));
996
997 /* Discard the token being shifted unless it is eof. */
998 if (yychar != YYEOF)
999 yychar = YYEMPTY;
1000
1001 *++yyvsp = yylval;
1002 #if YYLSP_NEEDED
1003 *++yylsp = yylloc;
1004 #endif
1005
1006 /* Count tokens shifted since error; after three, turn off error
1007 status. */
1008 if (yyerrstatus)
1009 yyerrstatus--;
1010
1011 yystate = yyn;
1012 goto yynewstate;
1013
1014
1015 /*-----------------------------------------------------------.
1016 | yydefault -- do the default action for the current state. |
1017 `-----------------------------------------------------------*/
1018 yydefault:
1019 yyn = yydefact[yystate];
1020 if (yyn == 0)
1021 goto yyerrlab;
1022 goto yyreduce;
1023
1024
1025 /*-----------------------------.
1026 | yyreduce -- Do a reduction. |
1027 `-----------------------------*/
1028 yyreduce:
1029 /* yyn is the number of a rule to reduce with. */
1030 yylen = yyr2[yyn];
1031
1032 /* If YYLEN is nonzero, implement the default value of the action:
1033 `$$ = $1'.
1034
1035 Otherwise, the following line sets YYVAL to the semantic value of
1036 the lookahead token. This behavior is undocumented and Bison
1037 users should not rely upon it. Assigning to YYVAL
1038 unconditionally makes the parser a bit smaller, and it avoids a
1039 GCC warning that YYVAL may be used uninitialized. */
1040 yyval = yyvsp[1-yylen];
1041
1042 #if YYLSP_NEEDED
1043 /* Similarly for the default location. Let the user run additional
1044 commands if for instance locations are ranges. */
1045 yyloc = yylsp[1-yylen];
1046 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1047 #endif
1048
1049 #if YYDEBUG
1050 /* We have to keep this `#if YYDEBUG', since we use variables which
1051 are defined only if `YYDEBUG' is set. */
1052 if (yydebug)
1053 {
1054 int yyi;
1055
1056 YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
1057 yyn, yyrline[yyn]);
1058
1059 /* Print the symbols being reduced, and their result. */
1060 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
1061 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
1062 YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1063 }
1064 #endif
1065
1066 switch (yyn) {
1067
1068 case 4:
1069 #line 158 "nlmheader.y"
1070 {
1071 check_procedure = yyvsp[0].string;
1072 }
1073 break;
1074 case 5:
1075 #line 162 "nlmheader.y"
1076 {
1077 nlmheader_warn (_("CODESTART is not implemented; sorry"), -1);
1078 free (yyvsp[0].string);
1079 }
1080 break;
1081 case 6:
1082 #line 167 "nlmheader.y"
1083 {
1084 int len;
1085
1086 strncpy (copyright_hdr->stamp, "CoPyRiGhT=", 10);
1087 len = strlen (yyvsp[0].string);
1088 if (len >= NLM_MAX_COPYRIGHT_MESSAGE_LENGTH)
1089 {
1090 nlmheader_warn (_("copyright string is too long"),
1091 NLM_MAX_COPYRIGHT_MESSAGE_LENGTH - 1);
1092 len = NLM_MAX_COPYRIGHT_MESSAGE_LENGTH - 1;
1093 }
1094 copyright_hdr->copyrightMessageLength = len;
1095 strncpy (copyright_hdr->copyrightMessage, yyvsp[0].string, len);
1096 copyright_hdr->copyrightMessage[len] = '\0';
1097 free (yyvsp[0].string);
1098 }
1099 break;
1100 case 7:
1101 #line 184 "nlmheader.y"
1102 {
1103 custom_file = yyvsp[0].string;
1104 }
1105 break;
1106 case 8:
1107 #line 188 "nlmheader.y"
1108 {
1109 /* We don't set the version stamp here, because we use the
1110 version stamp to detect whether the required VERSION
1111 keyword was given. */
1112 version_hdr->month = nlmlex_get_number (yyvsp[-2].string);
1113 version_hdr->day = nlmlex_get_number (yyvsp[-1].string);
1114 version_hdr->year = nlmlex_get_number (yyvsp[0].string);
1115 free (yyvsp[-2].string);
1116 free (yyvsp[-1].string);
1117 free (yyvsp[0].string);
1118 if (version_hdr->month < 1 || version_hdr->month > 12)
1119 nlmheader_warn (_("illegal month"), -1);
1120 if (version_hdr->day < 1 || version_hdr->day > 31)
1121 nlmheader_warn (_("illegal day"), -1);
1122 if (version_hdr->year < 1900 || version_hdr->year > 3000)
1123 nlmheader_warn (_("illegal year"), -1);
1124 }
1125 break;
1126 case 9:
1127 #line 206 "nlmheader.y"
1128 {
1129 debug_info = TRUE;
1130 }
1131 break;
1132 case 10:
1133 #line 210 "nlmheader.y"
1134 {
1135 int len;
1136
1137 len = strlen (yyvsp[0].string);
1138 if (len > NLM_MAX_DESCRIPTION_LENGTH)
1139 {
1140 nlmheader_warn (_("description string is too long"),
1141 NLM_MAX_DESCRIPTION_LENGTH);
1142 len = NLM_MAX_DESCRIPTION_LENGTH;
1143 }
1144 var_hdr->descriptionLength = len;
1145 strncpy (var_hdr->descriptionText, yyvsp[0].string, len);
1146 var_hdr->descriptionText[len] = '\0';
1147 free (yyvsp[0].string);
1148 }
1149 break;
1150 case 11:
1151 #line 226 "nlmheader.y"
1152 {
1153 exit_procedure = yyvsp[0].string;
1154 }
1155 break;
1156 case 12:
1157 #line 230 "nlmheader.y"
1158 {
1159 symbol_prefix = NULL;
1160 }
1161 break;
1162 case 13:
1163 #line 234 "nlmheader.y"
1164 {
1165 export_symbols = string_list_append (export_symbols, yyvsp[0].list);
1166 }
1167 break;
1168 case 14:
1169 #line 238 "nlmheader.y"
1170 {
1171 fixed_hdr->flags |= nlmlex_get_number (yyvsp[0].string);
1172 free (yyvsp[0].string);
1173 }
1174 break;
1175 case 15:
1176 #line 243 "nlmheader.y"
1177 {
1178 fixed_hdr->flags &=~ nlmlex_get_number (yyvsp[0].string);
1179 free (yyvsp[0].string);
1180 }
1181 break;
1182 case 16:
1183 #line 248 "nlmheader.y"
1184 {
1185 map_file = "";
1186 full_map = TRUE;
1187 }
1188 break;
1189 case 17:
1190 #line 253 "nlmheader.y"
1191 {
1192 map_file = yyvsp[0].string;
1193 full_map = TRUE;
1194 }
1195 break;
1196 case 18:
1197 #line 258 "nlmheader.y"
1198 {
1199 help_file = yyvsp[0].string;
1200 }
1201 break;
1202 case 19:
1203 #line 262 "nlmheader.y"
1204 {
1205 symbol_prefix = NULL;
1206 }
1207 break;
1208 case 20:
1209 #line 266 "nlmheader.y"
1210 {
1211 import_symbols = string_list_append (import_symbols, yyvsp[0].list);
1212 }
1213 break;
1214 case 21:
1215 #line 270 "nlmheader.y"
1216 {
1217 input_files = string_list_append (input_files, yyvsp[0].list);
1218 }
1219 break;
1220 case 22:
1221 #line 274 "nlmheader.y"
1222 {
1223 map_file = "";
1224 }
1225 break;
1226 case 23:
1227 #line 278 "nlmheader.y"
1228 {
1229 map_file = yyvsp[0].string;
1230 }
1231 break;
1232 case 24:
1233 #line 282 "nlmheader.y"
1234 {
1235 message_file = yyvsp[0].string;
1236 }
1237 break;
1238 case 25:
1239 #line 286 "nlmheader.y"
1240 {
1241 modules = string_list_append (modules, yyvsp[0].list);
1242 }
1243 break;
1244 case 26:
1245 #line 290 "nlmheader.y"
1246 {
1247 fixed_hdr->flags |= 0x2;
1248 }
1249 break;
1250 case 27:
1251 #line 294 "nlmheader.y"
1252 {
1253 fixed_hdr->flags |= 0x10;
1254 }
1255 break;
1256 case 28:
1257 #line 298 "nlmheader.y"
1258 {
1259 if (output_file == NULL)
1260 output_file = yyvsp[0].string;
1261 else
1262 nlmheader_warn (_("ignoring duplicate OUTPUT statement"), -1);
1263 }
1264 break;
1265 case 29:
1266 #line 305 "nlmheader.y"
1267 {
1268 fixed_hdr->flags |= 0x8;
1269 }
1270 break;
1271 case 30:
1272 #line 309 "nlmheader.y"
1273 {
1274 fixed_hdr->flags |= 0x1;
1275 }
1276 break;
1277 case 31:
1278 #line 313 "nlmheader.y"
1279 {
1280 int len;
1281
1282 len = strlen (yyvsp[0].string);
1283 if (len >= NLM_MAX_SCREEN_NAME_LENGTH)
1284 {
1285 nlmheader_warn (_("screen name is too long"),
1286 NLM_MAX_SCREEN_NAME_LENGTH);
1287 len = NLM_MAX_SCREEN_NAME_LENGTH;
1288 }
1289 var_hdr->screenNameLength = len;
1290 strncpy (var_hdr->screenName, yyvsp[0].string, len);
1291 var_hdr->screenName[NLM_MAX_SCREEN_NAME_LENGTH] = '\0';
1292 free (yyvsp[0].string);
1293 }
1294 break;
1295 case 32:
1296 #line 329 "nlmheader.y"
1297 {
1298 sharelib_file = yyvsp[0].string;
1299 }
1300 break;
1301 case 33:
1302 #line 333 "nlmheader.y"
1303 {
1304 var_hdr->stackSize = nlmlex_get_number (yyvsp[0].string);
1305 free (yyvsp[0].string);
1306 }
1307 break;
1308 case 34:
1309 #line 338 "nlmheader.y"
1310 {
1311 start_procedure = yyvsp[0].string;
1312 }
1313 break;
1314 case 35:
1315 #line 342 "nlmheader.y"
1316 {
1317 fixed_hdr->flags |= 0x4;
1318 }
1319 break;
1320 case 36:
1321 #line 346 "nlmheader.y"
1322 {
1323 int len;
1324
1325 len = strlen (yyvsp[0].string);
1326 if (len >= NLM_MAX_THREAD_NAME_LENGTH)
1327 {
1328 nlmheader_warn (_("thread name is too long"),
1329 NLM_MAX_THREAD_NAME_LENGTH);
1330 len = NLM_MAX_THREAD_NAME_LENGTH;
1331 }
1332 var_hdr->threadNameLength = len;
1333 strncpy (var_hdr->threadName, yyvsp[0].string, len);
1334 var_hdr->threadName[len] = '\0';
1335 free (yyvsp[0].string);
1336 }
1337 break;
1338 case 37:
1339 #line 362 "nlmheader.y"
1340 {
1341 fixed_hdr->moduleType = nlmlex_get_number (yyvsp[0].string);
1342 free (yyvsp[0].string);
1343 }
1344 break;
1345 case 38:
1346 #line 367 "nlmheader.y"
1347 {
1348 verbose = TRUE;
1349 }
1350 break;
1351 case 39:
1352 #line 371 "nlmheader.y"
1353 {
1354 long val;
1355
1356 strncpy (version_hdr->stamp, "VeRsIoN#", 8);
1357 version_hdr->majorVersion = nlmlex_get_number (yyvsp[-2].string);
1358 val = nlmlex_get_number (yyvsp[-1].string);
1359 if (val < 0 || val > 99)
1360 nlmheader_warn (_("illegal minor version number (must be between 0 and 99)"),
1361 -1);
1362 else
1363 version_hdr->minorVersion = val;
1364 val = nlmlex_get_number (yyvsp[0].string);
1365 if (val < 0)
1366 nlmheader_warn (_("illegal revision number (must be between 0 and 26)"),
1367 -1);
1368 else if (val > 26)
1369 version_hdr->revision = 0;
1370 else
1371 version_hdr->revision = val;
1372 free (yyvsp[-2].string);
1373 free (yyvsp[-1].string);
1374 free (yyvsp[0].string);
1375 }
1376 break;
1377 case 40:
1378 #line 395 "nlmheader.y"
1379 {
1380 long val;
1381
1382 strncpy (version_hdr->stamp, "VeRsIoN#", 8);
1383 version_hdr->majorVersion = nlmlex_get_number (yyvsp[-1].string);
1384 val = nlmlex_get_number (yyvsp[0].string);
1385 if (val < 0 || val > 99)
1386 nlmheader_warn (_("illegal minor version number (must be between 0 and 99)"),
1387 -1);
1388 else
1389 version_hdr->minorVersion = val;
1390 version_hdr->revision = 0;
1391 free (yyvsp[-1].string);
1392 free (yyvsp[0].string);
1393 }
1394 break;
1395 case 41:
1396 #line 411 "nlmheader.y"
1397 {
1398 rpc_file = yyvsp[0].string;
1399 }
1400 break;
1401 case 42:
1402 #line 420 "nlmheader.y"
1403 {
1404 yyval.list = NULL;
1405 }
1406 break;
1407 case 43:
1408 #line 424 "nlmheader.y"
1409 {
1410 yyval.list = yyvsp[0].list;
1411 }
1412 break;
1413 case 44:
1414 #line 435 "nlmheader.y"
1415 {
1416 yyval.list = string_list_cons (yyvsp[0].string, NULL);
1417 }
1418 break;
1419 case 45:
1420 #line 439 "nlmheader.y"
1421 {
1422 yyval.list = NULL;
1423 }
1424 break;
1425 case 46:
1426 #line 443 "nlmheader.y"
1427 {
1428 yyval.list = string_list_append1 (yyvsp[-1].list, yyvsp[0].string);
1429 }
1430 break;
1431 case 47:
1432 #line 447 "nlmheader.y"
1433 {
1434 yyval.list = yyvsp[-1].list;
1435 }
1436 break;
1437 case 48:
1438 #line 456 "nlmheader.y"
1439 {
1440 if (symbol_prefix != NULL)
1441 free (symbol_prefix);
1442 symbol_prefix = yyvsp[-1].string;
1443 }
1444 break;
1445 case 49:
1446 #line 467 "nlmheader.y"
1447 {
1448 if (symbol_prefix == NULL)
1449 yyval.string = yyvsp[0].string;
1450 else
1451 {
1452 yyval.string = xmalloc (strlen (symbol_prefix) + strlen (yyvsp[0].string) + 2);
1453 sprintf (yyval.string, "%s@%s", symbol_prefix, yyvsp[0].string);
1454 free (yyvsp[0].string);
1455 }
1456 }
1457 break;
1458 case 50:
1459 #line 483 "nlmheader.y"
1460 {
1461 yyval.list = NULL;
1462 }
1463 break;
1464 case 51:
1465 #line 487 "nlmheader.y"
1466 {
1467 yyval.list = string_list_cons (yyvsp[-1].string, yyvsp[0].list);
1468 }
1469 break;
1470 }
1471
1472 #line 706 "/usr/share/bison/bison.simple"
1473
1474
1475 yyvsp -= yylen;
1476 yyssp -= yylen;
1477 #if YYLSP_NEEDED
1478 yylsp -= yylen;
1479 #endif
1480
1481 #if YYDEBUG
1482 if (yydebug)
1483 {
1484 short *yyssp1 = yyss - 1;
1485 YYFPRINTF (stderr, "state stack now");
1486 while (yyssp1 != yyssp)
1487 YYFPRINTF (stderr, " %d", *++yyssp1);
1488 YYFPRINTF (stderr, "\n");
1489 }
1490 #endif
1491
1492 *++yyvsp = yyval;
1493 #if YYLSP_NEEDED
1494 *++yylsp = yyloc;
1495 #endif
1496
1497 /* Now `shift' the result of the reduction. Determine what state
1498 that goes to, based on the state we popped back to and the rule
1499 number reduced by. */
1500
1501 yyn = yyr1[yyn];
1502
1503 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1504 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1505 yystate = yytable[yystate];
1506 else
1507 yystate = yydefgoto[yyn - YYNTBASE];
1508
1509 goto yynewstate;
1510
1511
1512 /*------------------------------------.
1513 | yyerrlab -- here on detecting error |
1514 `------------------------------------*/
1515 yyerrlab:
1516 /* If not already recovering from an error, report this error. */
1517 if (!yyerrstatus)
1518 {
1519 ++yynerrs;
1520
1521 #ifdef YYERROR_VERBOSE
1522 yyn = yypact[yystate];
1523
1524 if (yyn > YYFLAG && yyn < YYLAST)
1525 {
1526 YYSIZE_T yysize = 0;
1527 char *yymsg;
1528 int yyx, yycount;
1529
1530 yycount = 0;
1531 /* Start YYX at -YYN if negative to avoid negative indexes in
1532 YYCHECK. */
1533 for (yyx = yyn < 0 ? -yyn : 0;
1534 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
1535 if (yycheck[yyx + yyn] == yyx)
1536 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
1537 yysize += yystrlen ("parse error, unexpected ") + 1;
1538 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
1539 yymsg = (char *) YYSTACK_ALLOC (yysize);
1540 if (yymsg != 0)
1541 {
1542 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
1543 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
1544
1545 if (yycount < 5)
1546 {
1547 yycount = 0;
1548 for (yyx = yyn < 0 ? -yyn : 0;
1549 yyx < (int) (sizeof (yytname) / sizeof (char *));
1550 yyx++)
1551 if (yycheck[yyx + yyn] == yyx)
1552 {
1553 const char *yyq = ! yycount ? ", expecting " : " or ";
1554 yyp = yystpcpy (yyp, yyq);
1555 yyp = yystpcpy (yyp, yytname[yyx]);
1556 yycount++;
1557 }
1558 }
1559 yyerror (yymsg);
1560 YYSTACK_FREE (yymsg);
1561 }
1562 else
1563 yyerror ("parse error; also virtual memory exhausted");
1564 }
1565 else
1566 #endif /* defined (YYERROR_VERBOSE) */
1567 yyerror ("parse error");
1568 }
1569 goto yyerrlab1;
1570
1571
1572 /*--------------------------------------------------.
1573 | yyerrlab1 -- error raised explicitly by an action |
1574 `--------------------------------------------------*/
1575 yyerrlab1:
1576 if (yyerrstatus == 3)
1577 {
1578 /* If just tried and failed to reuse lookahead token after an
1579 error, discard it. */
1580
1581 /* return failure if at end of input */
1582 if (yychar == YYEOF)
1583 YYABORT;
1584 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
1585 yychar, yytname[yychar1]));
1586 yychar = YYEMPTY;
1587 }
1588
1589 /* Else will try to reuse lookahead token after shifting the error
1590 token. */
1591
1592 yyerrstatus = 3; /* Each real token shifted decrements this */
1593
1594 goto yyerrhandle;
1595
1596
1597 /*-------------------------------------------------------------------.
1598 | yyerrdefault -- current state does not do anything special for the |
1599 | error token. |
1600 `-------------------------------------------------------------------*/
1601 yyerrdefault:
1602 #if 0
1603 /* This is wrong; only states that explicitly want error tokens
1604 should shift them. */
1605
1606 /* If its default is to accept any token, ok. Otherwise pop it. */
1607 yyn = yydefact[yystate];
1608 if (yyn)
1609 goto yydefault;
1610 #endif
1611
1612
1613 /*---------------------------------------------------------------.
1614 | yyerrpop -- pop the current state because it cannot handle the |
1615 | error token |
1616 `---------------------------------------------------------------*/
1617 yyerrpop:
1618 if (yyssp == yyss)
1619 YYABORT;
1620 yyvsp--;
1621 yystate = *--yyssp;
1622 #if YYLSP_NEEDED
1623 yylsp--;
1624 #endif
1625
1626 #if YYDEBUG
1627 if (yydebug)
1628 {
1629 short *yyssp1 = yyss - 1;
1630 YYFPRINTF (stderr, "Error: state stack now");
1631 while (yyssp1 != yyssp)
1632 YYFPRINTF (stderr, " %d", *++yyssp1);
1633 YYFPRINTF (stderr, "\n");
1634 }
1635 #endif
1636
1637 /*--------------.
1638 | yyerrhandle. |
1639 `--------------*/
1640 yyerrhandle:
1641 yyn = yypact[yystate];
1642 if (yyn == YYFLAG)
1643 goto yyerrdefault;
1644
1645 yyn += YYTERROR;
1646 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1647 goto yyerrdefault;
1648
1649 yyn = yytable[yyn];
1650 if (yyn < 0)
1651 {
1652 if (yyn == YYFLAG)
1653 goto yyerrpop;
1654 yyn = -yyn;
1655 goto yyreduce;
1656 }
1657 else if (yyn == 0)
1658 goto yyerrpop;
1659
1660 if (yyn == YYFINAL)
1661 YYACCEPT;
1662
1663 YYDPRINTF ((stderr, "Shifting error token, "));
1664
1665 *++yyvsp = yylval;
1666 #if YYLSP_NEEDED
1667 *++yylsp = yylloc;
1668 #endif
1669
1670 yystate = yyn;
1671 goto yynewstate;
1672
1673
1674 /*-------------------------------------.
1675 | yyacceptlab -- YYACCEPT comes here. |
1676 `-------------------------------------*/
1677 yyacceptlab:
1678 yyresult = 0;
1679 goto yyreturn;
1680
1681 /*-----------------------------------.
1682 | yyabortlab -- YYABORT comes here. |
1683 `-----------------------------------*/
1684 yyabortlab:
1685 yyresult = 1;
1686 goto yyreturn;
1687
1688 /*---------------------------------------------.
1689 | yyoverflowab -- parser overflow comes here. |
1690 `---------------------------------------------*/
1691 yyoverflowlab:
1692 yyerror ("parser stack overflow");
1693 yyresult = 2;
1694 /* Fall through. */
1695
1696 yyreturn:
1697 #ifndef yyoverflow
1698 if (yyss != yyssa)
1699 YYSTACK_FREE (yyss);
1700 #endif
1701 return yyresult;
1702 }
1703 #line 492 "nlmheader.y"
1704
1705
1706 /* If strerror is just a macro, we want to use the one from libiberty
1707 since it will handle undefined values. */
1708 #undef strerror
1709 extern char *strerror PARAMS ((int));
1710
1711 /* The lexer is simple, too simple for flex. Keywords are only
1712 recognized at the start of lines. Everything else must be an
1713 argument. A comma is treated as whitespace. */
1714
1715 /* The states the lexer can be in. */
1716
1717 enum lex_state
1718 {
1719 /* At the beginning of a line. */
1720 BEGINNING_OF_LINE,
1721 /* In the middle of a line. */
1722 IN_LINE
1723 };
1724
1725 /* We need to keep a stack of files to handle file inclusion. */
1726
1727 struct input
1728 {
1729 /* The file to read from. */
1730 FILE *file;
1731 /* The name of the file. */
1732 char *name;
1733 /* The current line number. */
1734 int lineno;
1735 /* The current state. */
1736 enum lex_state state;
1737 /* The next file on the stack. */
1738 struct input *next;
1739 };
1740
1741 /* The current input file. */
1742
1743 static struct input current;
1744
1745 /* The character which introduces comments. */
1746 #define COMMENT_CHAR '#'
1747
1748 /* Start the lexer going on the main input file. */
1749
1750 bfd_boolean
nlmlex_file(const char * name)1751 nlmlex_file (const char *name)
1752 {
1753 current.next = NULL;
1754 return nlmlex_file_open (name);
1755 }
1756
1757 /* Start the lexer going on a subsidiary input file. */
1758
1759 static void
nlmlex_file_push(const char * name)1760 nlmlex_file_push (const char *name)
1761 {
1762 struct input *push;
1763
1764 push = (struct input *) xmalloc (sizeof (struct input));
1765 *push = current;
1766 if (nlmlex_file_open (name))
1767 current.next = push;
1768 else
1769 {
1770 current = *push;
1771 free (push);
1772 }
1773 }
1774
1775 /* Start lexing from a file. */
1776
1777 static bfd_boolean
nlmlex_file_open(const char * name)1778 nlmlex_file_open (const char *name)
1779 {
1780 current.file = fopen (name, "r");
1781 if (current.file == NULL)
1782 {
1783 fprintf (stderr, "%s:%s: %s\n", program_name, name, strerror (errno));
1784 ++parse_errors;
1785 return FALSE;
1786 }
1787 current.name = xstrdup (name);
1788 current.lineno = 1;
1789 current.state = BEGINNING_OF_LINE;
1790 return TRUE;
1791 }
1792
1793 /* Table used to turn keywords into tokens. */
1794
1795 struct keyword_tokens_struct
1796 {
1797 const char *keyword;
1798 int token;
1799 };
1800
1801 struct keyword_tokens_struct keyword_tokens[] =
1802 {
1803 { "CHECK", CHECK },
1804 { "CODESTART", CODESTART },
1805 { "COPYRIGHT", COPYRIGHT },
1806 { "CUSTOM", CUSTOM },
1807 { "DATE", DATE },
1808 { "DEBUG", DEBUG },
1809 { "DESCRIPTION", DESCRIPTION },
1810 { "EXIT", EXIT },
1811 { "EXPORT", EXPORT },
1812 { "FLAG_ON", FLAG_ON },
1813 { "FLAG_OFF", FLAG_OFF },
1814 { "FULLMAP", FULLMAP },
1815 { "HELP", HELP },
1816 { "IMPORT", IMPORT },
1817 { "INPUT", INPUT },
1818 { "MAP", MAP },
1819 { "MESSAGES", MESSAGES },
1820 { "MODULE", MODULE },
1821 { "MULTIPLE", MULTIPLE },
1822 { "OS_DOMAIN", OS_DOMAIN },
1823 { "OUTPUT", OUTPUT },
1824 { "PSEUDOPREEMPTION", PSEUDOPREEMPTION },
1825 { "REENTRANT", REENTRANT },
1826 { "SCREENNAME", SCREENNAME },
1827 { "SHARELIB", SHARELIB },
1828 { "STACK", STACK },
1829 { "STACKSIZE", STACK },
1830 { "START", START },
1831 { "SYNCHRONIZE", SYNCHRONIZE },
1832 { "THREADNAME", THREADNAME },
1833 { "TYPE", TYPE },
1834 { "VERBOSE", VERBOSE },
1835 { "VERSION", VERSIONK },
1836 { "XDCDATA", XDCDATA }
1837 };
1838
1839 #define KEYWORD_COUNT (sizeof (keyword_tokens) / sizeof (keyword_tokens[0]))
1840
1841 /* The lexer accumulates strings in these variables. */
1842 static char *lex_buf;
1843 static int lex_size;
1844 static int lex_pos;
1845
1846 /* Start accumulating strings into the buffer. */
1847 #define BUF_INIT() \
1848 ((void) (lex_buf != NULL ? lex_pos = 0 : nlmlex_buf_init ()))
1849
1850 static int
nlmlex_buf_init(void)1851 nlmlex_buf_init (void)
1852 {
1853 lex_size = 10;
1854 lex_buf = xmalloc (lex_size + 1);
1855 lex_pos = 0;
1856 return 0;
1857 }
1858
1859 /* Finish a string in the buffer. */
1860 #define BUF_FINISH() ((void) (lex_buf[lex_pos] = '\0'))
1861
1862 /* Accumulate a character into the buffer. */
1863 #define BUF_ADD(c) \
1864 ((void) (lex_pos < lex_size \
1865 ? lex_buf[lex_pos++] = (c) \
1866 : nlmlex_buf_add (c)))
1867
1868 static char
nlmlex_buf_add(int c)1869 nlmlex_buf_add (int c)
1870 {
1871 if (lex_pos >= lex_size)
1872 {
1873 lex_size *= 2;
1874 lex_buf = xrealloc (lex_buf, lex_size + 1);
1875 }
1876
1877 return lex_buf[lex_pos++] = c;
1878 }
1879
1880 /* The lexer proper. This is called by the bison generated parsing
1881 code. */
1882
1883 static int
yylex(void)1884 yylex (void)
1885 {
1886 int c;
1887
1888 tail_recurse:
1889
1890 c = getc (current.file);
1891
1892 /* Commas are treated as whitespace characters. */
1893 while (ISSPACE (c) || c == ',')
1894 {
1895 current.state = IN_LINE;
1896 if (c == '\n')
1897 {
1898 ++current.lineno;
1899 current.state = BEGINNING_OF_LINE;
1900 }
1901 c = getc (current.file);
1902 }
1903
1904 /* At the end of the file we either pop to the previous file or
1905 finish up. */
1906 if (c == EOF)
1907 {
1908 fclose (current.file);
1909 free (current.name);
1910 if (current.next == NULL)
1911 return 0;
1912 else
1913 {
1914 struct input *next;
1915
1916 next = current.next;
1917 current = *next;
1918 free (next);
1919 goto tail_recurse;
1920 }
1921 }
1922
1923 /* A comment character always means to drop everything until the
1924 next newline. */
1925 if (c == COMMENT_CHAR)
1926 {
1927 do
1928 {
1929 c = getc (current.file);
1930 }
1931 while (c != '\n');
1932 ++current.lineno;
1933 current.state = BEGINNING_OF_LINE;
1934 goto tail_recurse;
1935 }
1936
1937 /* An '@' introduces an include file. */
1938 if (c == '@')
1939 {
1940 do
1941 {
1942 c = getc (current.file);
1943 if (c == '\n')
1944 ++current.lineno;
1945 }
1946 while (ISSPACE (c));
1947 BUF_INIT ();
1948 while (! ISSPACE (c) && c != EOF)
1949 {
1950 BUF_ADD (c);
1951 c = getc (current.file);
1952 }
1953 BUF_FINISH ();
1954
1955 ungetc (c, current.file);
1956
1957 nlmlex_file_push (lex_buf);
1958 goto tail_recurse;
1959 }
1960
1961 /* A non-space character at the start of a line must be the start of
1962 a keyword. */
1963 if (current.state == BEGINNING_OF_LINE)
1964 {
1965 BUF_INIT ();
1966 while (ISALNUM (c) || c == '_')
1967 {
1968 BUF_ADD (TOUPPER (c));
1969 c = getc (current.file);
1970 }
1971 BUF_FINISH ();
1972
1973 if (c != EOF && ! ISSPACE (c) && c != ',')
1974 {
1975 nlmheader_identify ();
1976 fprintf (stderr, _("%s:%d: illegal character in keyword: %c\n"),
1977 current.name, current.lineno, c);
1978 }
1979 else
1980 {
1981 unsigned int i;
1982
1983 for (i = 0; i < KEYWORD_COUNT; i++)
1984 {
1985 if (lex_buf[0] == keyword_tokens[i].keyword[0]
1986 && strcmp (lex_buf, keyword_tokens[i].keyword) == 0)
1987 {
1988 /* Pushing back the final whitespace avoids worrying
1989 about \n here. */
1990 ungetc (c, current.file);
1991 current.state = IN_LINE;
1992 return keyword_tokens[i].token;
1993 }
1994 }
1995
1996 nlmheader_identify ();
1997 fprintf (stderr, _("%s:%d: unrecognized keyword: %s\n"),
1998 current.name, current.lineno, lex_buf);
1999 }
2000
2001 ++parse_errors;
2002 /* Treat the rest of this line as a comment. */
2003 ungetc (COMMENT_CHAR, current.file);
2004 goto tail_recurse;
2005 }
2006
2007 /* Parentheses just represent themselves. */
2008 if (c == '(' || c == ')')
2009 return c;
2010
2011 /* Handle quoted strings. */
2012 if (c == '"' || c == '\'')
2013 {
2014 int quote;
2015 int start_lineno;
2016
2017 quote = c;
2018 start_lineno = current.lineno;
2019
2020 c = getc (current.file);
2021 BUF_INIT ();
2022 while (c != quote && c != EOF)
2023 {
2024 BUF_ADD (c);
2025 if (c == '\n')
2026 ++current.lineno;
2027 c = getc (current.file);
2028 }
2029 BUF_FINISH ();
2030
2031 if (c == EOF)
2032 {
2033 nlmheader_identify ();
2034 fprintf (stderr, _("%s:%d: end of file in quoted string\n"),
2035 current.name, start_lineno);
2036 ++parse_errors;
2037 }
2038
2039 /* FIXME: Possible memory leak. */
2040 yylval.string = xstrdup (lex_buf);
2041 return QUOTED_STRING;
2042 }
2043
2044 /* Gather a generic argument. */
2045 BUF_INIT ();
2046 while (! ISSPACE (c)
2047 && c != ','
2048 && c != COMMENT_CHAR
2049 && c != '('
2050 && c != ')')
2051 {
2052 BUF_ADD (c);
2053 c = getc (current.file);
2054 }
2055 BUF_FINISH ();
2056
2057 ungetc (c, current.file);
2058
2059 /* FIXME: Possible memory leak. */
2060 yylval.string = xstrdup (lex_buf);
2061 return STRING;
2062 }
2063
2064 /* Get a number from a string. */
2065
2066 static long
nlmlex_get_number(const char * s)2067 nlmlex_get_number (const char *s)
2068 {
2069 long ret;
2070 char *send;
2071
2072 ret = strtol (s, &send, 10);
2073 if (*send != '\0')
2074 nlmheader_warn (_("bad number"), -1);
2075 return ret;
2076 }
2077
2078 /* Prefix the nlmconv warnings with a note as to where they come from.
2079 We don't use program_name on every warning, because then some
2080 versions of the emacs next-error function can't recognize the line
2081 number. */
2082
2083 static void
nlmheader_identify(void)2084 nlmheader_identify (void)
2085 {
2086 static int done;
2087
2088 if (! done)
2089 {
2090 fprintf (stderr, _("%s: problems in NLM command language input:\n"),
2091 program_name);
2092 done = 1;
2093 }
2094 }
2095
2096 /* Issue a warning. */
2097
2098 static void
nlmheader_warn(const char * s,int imax)2099 nlmheader_warn (const char *s, int imax)
2100 {
2101 nlmheader_identify ();
2102 fprintf (stderr, "%s:%d: %s", current.name, current.lineno, s);
2103 if (imax != -1)
2104 fprintf (stderr, " (max %d)", imax);
2105 fprintf (stderr, "\n");
2106 }
2107
2108 /* Report an error. */
2109
2110 static void
nlmheader_error(const char * s)2111 nlmheader_error (const char *s)
2112 {
2113 nlmheader_warn (s, -1);
2114 ++parse_errors;
2115 }
2116
2117 /* Add a string to a string list. */
2118
2119 static struct string_list *
string_list_cons(char * s,struct string_list * l)2120 string_list_cons (char *s, struct string_list *l)
2121 {
2122 struct string_list *ret;
2123
2124 ret = (struct string_list *) xmalloc (sizeof (struct string_list));
2125 ret->next = l;
2126 ret->string = s;
2127 return ret;
2128 }
2129
2130 /* Append a string list to another string list. */
2131
2132 static struct string_list *
string_list_append(struct string_list * l1,struct string_list * l2)2133 string_list_append (struct string_list *l1, struct string_list *l2)
2134 {
2135 register struct string_list **pp;
2136
2137 for (pp = &l1; *pp != NULL; pp = &(*pp)->next)
2138 ;
2139 *pp = l2;
2140 return l1;
2141 }
2142
2143 /* Append a string to a string list. */
2144
2145 static struct string_list *
string_list_append1(struct string_list * l,char * s)2146 string_list_append1 (struct string_list *l, char *s)
2147 {
2148 struct string_list *n;
2149 register struct string_list **pp;
2150
2151 n = (struct string_list *) xmalloc (sizeof (struct string_list));
2152 n->next = NULL;
2153 n->string = s;
2154 for (pp = &l; *pp != NULL; pp = &(*pp)->next)
2155 ;
2156 *pp = n;
2157 return l;
2158 }
2159
2160 /* Duplicate a string in memory. */
2161
2162 static char *
xstrdup(const char * s)2163 xstrdup (const char *s)
2164 {
2165 unsigned long len;
2166 char *ret;
2167
2168 len = strlen (s);
2169 ret = xmalloc (len + 1);
2170 strcpy (ret, s);
2171 return ret;
2172 }
2173