xref: /openbsd-src/gnu/usr.bin/binutils/binutils/nlmheader.c (revision 007c2a4539b8b8aaa95c5e73e77620090abe113b)
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-1.35/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 #   define yystpcpy stpcpy
650 #  else
651 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
652    YYDEST.  */
653 static char *
654 #   if defined (__STDC__) || defined (__cplusplus)
yystpcpy(char * yydest,const char * yysrc)655 yystpcpy (char *yydest, const char *yysrc)
656 #   else
657 yystpcpy (yydest, yysrc)
658      char *yydest;
659      const char *yysrc;
660 #   endif
661 {
662   register char *yyd = yydest;
663   register const char *yys = yysrc;
664 
665   while ((*yyd++ = *yys++) != '\0')
666     continue;
667 
668   return yyd - 1;
669 }
670 #  endif
671 # endif
672 #endif
673 
674 #line 315 "/usr/share/bison-1.35/bison.simple"
675 
676 
677 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
678    into yyparse.  The argument should have type void *.
679    It should actually point to an object.
680    Grammar actions can access the variable by casting it
681    to the proper pointer type.  */
682 
683 #ifdef YYPARSE_PARAM
684 # if defined (__STDC__) || defined (__cplusplus)
685 #  define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
686 #  define YYPARSE_PARAM_DECL
687 # else
688 #  define YYPARSE_PARAM_ARG YYPARSE_PARAM
689 #  define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
690 # endif
691 #else /* !YYPARSE_PARAM */
692 # define YYPARSE_PARAM_ARG
693 # define YYPARSE_PARAM_DECL
694 #endif /* !YYPARSE_PARAM */
695 
696 /* Prevent warning if -Wstrict-prototypes.  */
697 #ifdef __GNUC__
698 # ifdef YYPARSE_PARAM
699 int yyparse (void *);
700 # else
701 int yyparse (void);
702 # endif
703 #endif
704 
705 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
706    variables are global, or local to YYPARSE.  */
707 
708 #define YY_DECL_NON_LSP_VARIABLES			\
709 /* The lookahead symbol.  */				\
710 int yychar;						\
711 							\
712 /* The semantic value of the lookahead symbol. */	\
713 YYSTYPE yylval;						\
714 							\
715 /* Number of parse errors so far.  */			\
716 int yynerrs;
717 
718 #if YYLSP_NEEDED
719 # define YY_DECL_VARIABLES			\
720 YY_DECL_NON_LSP_VARIABLES			\
721 						\
722 /* Location data for the lookahead symbol.  */	\
723 YYLTYPE yylloc;
724 #else
725 # define YY_DECL_VARIABLES			\
726 YY_DECL_NON_LSP_VARIABLES
727 #endif
728 
729 
730 /* If nonreentrant, generate the variables here. */
731 
732 #if !YYPURE
733 YY_DECL_VARIABLES
734 #endif  /* !YYPURE */
735 
736 int
yyparse(YYPARSE_PARAM_ARG)737 yyparse (YYPARSE_PARAM_ARG)
738      YYPARSE_PARAM_DECL
739 {
740   /* If reentrant, generate the variables here. */
741 #if YYPURE
742   YY_DECL_VARIABLES
743 #endif  /* !YYPURE */
744 
745   register int yystate;
746   register int yyn;
747   int yyresult;
748   /* Number of tokens to shift before error messages enabled.  */
749   int yyerrstatus;
750   /* Lookahead token as an internal (translated) token number.  */
751   int yychar1 = 0;
752 
753   /* Three stacks and their tools:
754      `yyss': related to states,
755      `yyvs': related to semantic values,
756      `yyls': related to locations.
757 
758      Refer to the stacks thru separate pointers, to allow yyoverflow
759      to reallocate them elsewhere.  */
760 
761   /* The state stack. */
762   short	yyssa[YYINITDEPTH];
763   short *yyss = yyssa;
764   register short *yyssp;
765 
766   /* The semantic value stack.  */
767   YYSTYPE yyvsa[YYINITDEPTH];
768   YYSTYPE *yyvs = yyvsa;
769   register YYSTYPE *yyvsp;
770 
771 #if YYLSP_NEEDED
772   /* The location stack.  */
773   YYLTYPE yylsa[YYINITDEPTH];
774   YYLTYPE *yyls = yylsa;
775   YYLTYPE *yylsp;
776 #endif
777 
778 #if YYLSP_NEEDED
779 # define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
780 #else
781 # define YYPOPSTACK   (yyvsp--, yyssp--)
782 #endif
783 
784   YYSIZE_T yystacksize = YYINITDEPTH;
785 
786 
787   /* The variables used to return semantic value and location from the
788      action routines.  */
789   YYSTYPE yyval;
790 #if YYLSP_NEEDED
791   YYLTYPE yyloc;
792 #endif
793 
794   /* When reducing, the number of symbols on the RHS of the reduced
795      rule. */
796   int yylen;
797 
798   YYDPRINTF ((stderr, "Starting parse\n"));
799 
800   yystate = 0;
801   yyerrstatus = 0;
802   yynerrs = 0;
803   yychar = YYEMPTY;		/* Cause a token to be read.  */
804 
805   /* Initialize stack pointers.
806      Waste one element of value and location stack
807      so that they stay on the same level as the state stack.
808      The wasted elements are never initialized.  */
809 
810   yyssp = yyss;
811   yyvsp = yyvs;
812 #if YYLSP_NEEDED
813   yylsp = yyls;
814 #endif
815   goto yysetstate;
816 
817 /*------------------------------------------------------------.
818 | yynewstate -- Push a new state, which is found in yystate.  |
819 `------------------------------------------------------------*/
820  yynewstate:
821   /* In all cases, when you get here, the value and location stacks
822      have just been pushed. so pushing a state here evens the stacks.
823      */
824   yyssp++;
825 
826  yysetstate:
827   *yyssp = yystate;
828 
829   if (yyssp >= yyss + yystacksize - 1)
830     {
831       /* Get the current used size of the three stacks, in elements.  */
832       YYSIZE_T yysize = yyssp - yyss + 1;
833 
834 #ifdef yyoverflow
835       {
836 	/* Give user a chance to reallocate the stack. Use copies of
837 	   these so that the &'s don't force the real ones into
838 	   memory.  */
839 	YYSTYPE *yyvs1 = yyvs;
840 	short *yyss1 = yyss;
841 
842 	/* Each stack pointer address is followed by the size of the
843 	   data in use in that stack, in bytes.  */
844 # if YYLSP_NEEDED
845 	YYLTYPE *yyls1 = yyls;
846 	/* This used to be a conditional around just the two extra args,
847 	   but that might be undefined if yyoverflow is a macro.  */
848 	yyoverflow ("parser stack overflow",
849 		    &yyss1, yysize * sizeof (*yyssp),
850 		    &yyvs1, yysize * sizeof (*yyvsp),
851 		    &yyls1, yysize * sizeof (*yylsp),
852 		    &yystacksize);
853 	yyls = yyls1;
854 # else
855 	yyoverflow ("parser stack overflow",
856 		    &yyss1, yysize * sizeof (*yyssp),
857 		    &yyvs1, yysize * sizeof (*yyvsp),
858 		    &yystacksize);
859 # endif
860 	yyss = yyss1;
861 	yyvs = yyvs1;
862       }
863 #else /* no yyoverflow */
864 # ifndef YYSTACK_RELOCATE
865       goto yyoverflowlab;
866 # else
867       /* Extend the stack our own way.  */
868       if (yystacksize >= YYMAXDEPTH)
869 	goto yyoverflowlab;
870       yystacksize *= 2;
871       if (yystacksize > YYMAXDEPTH)
872 	yystacksize = YYMAXDEPTH;
873 
874       {
875 	short *yyss1 = yyss;
876 	union yyalloc *yyptr =
877 	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
878 	if (! yyptr)
879 	  goto yyoverflowlab;
880 	YYSTACK_RELOCATE (yyss);
881 	YYSTACK_RELOCATE (yyvs);
882 # if YYLSP_NEEDED
883 	YYSTACK_RELOCATE (yyls);
884 # endif
885 # undef YYSTACK_RELOCATE
886 	if (yyss1 != yyssa)
887 	  YYSTACK_FREE (yyss1);
888       }
889 # endif
890 #endif /* no yyoverflow */
891 
892       yyssp = yyss + yysize - 1;
893       yyvsp = yyvs + yysize - 1;
894 #if YYLSP_NEEDED
895       yylsp = yyls + yysize - 1;
896 #endif
897 
898       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
899 		  (unsigned long int) yystacksize));
900 
901       if (yyssp >= yyss + yystacksize - 1)
902 	YYABORT;
903     }
904 
905   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
906 
907   goto yybackup;
908 
909 
910 /*-----------.
911 | yybackup.  |
912 `-----------*/
913 yybackup:
914 
915 /* Do appropriate processing given the current state.  */
916 /* Read a lookahead token if we need one and don't already have one.  */
917 /* yyresume: */
918 
919   /* First try to decide what to do without reference to lookahead token.  */
920 
921   yyn = yypact[yystate];
922   if (yyn == YYFLAG)
923     goto yydefault;
924 
925   /* Not known => get a lookahead token if don't already have one.  */
926 
927   /* yychar is either YYEMPTY or YYEOF
928      or a valid token in external form.  */
929 
930   if (yychar == YYEMPTY)
931     {
932       YYDPRINTF ((stderr, "Reading a token: "));
933       yychar = YYLEX;
934     }
935 
936   /* Convert token to internal form (in yychar1) for indexing tables with */
937 
938   if (yychar <= 0)		/* This means end of input. */
939     {
940       yychar1 = 0;
941       yychar = YYEOF;		/* Don't call YYLEX any more */
942 
943       YYDPRINTF ((stderr, "Now at end of input.\n"));
944     }
945   else
946     {
947       yychar1 = YYTRANSLATE (yychar);
948 
949 #if YYDEBUG
950      /* We have to keep this `#if YYDEBUG', since we use variables
951 	which are defined only if `YYDEBUG' is set.  */
952       if (yydebug)
953 	{
954 	  YYFPRINTF (stderr, "Next token is %d (%s",
955 		     yychar, yytname[yychar1]);
956 	  /* Give the individual parser a way to print the precise
957 	     meaning of a token, for further debugging info.  */
958 # ifdef YYPRINT
959 	  YYPRINT (stderr, yychar, yylval);
960 # endif
961 	  YYFPRINTF (stderr, ")\n");
962 	}
963 #endif
964     }
965 
966   yyn += yychar1;
967   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
968     goto yydefault;
969 
970   yyn = yytable[yyn];
971 
972   /* yyn is what to do for this token type in this state.
973      Negative => reduce, -yyn is rule number.
974      Positive => shift, yyn is new state.
975        New state is final state => don't bother to shift,
976        just return success.
977      0, or most negative number => error.  */
978 
979   if (yyn < 0)
980     {
981       if (yyn == YYFLAG)
982 	goto yyerrlab;
983       yyn = -yyn;
984       goto yyreduce;
985     }
986   else if (yyn == 0)
987     goto yyerrlab;
988 
989   if (yyn == YYFINAL)
990     YYACCEPT;
991 
992   /* Shift the lookahead token.  */
993   YYDPRINTF ((stderr, "Shifting token %d (%s), ",
994 	      yychar, yytname[yychar1]));
995 
996   /* Discard the token being shifted unless it is eof.  */
997   if (yychar != YYEOF)
998     yychar = YYEMPTY;
999 
1000   *++yyvsp = yylval;
1001 #if YYLSP_NEEDED
1002   *++yylsp = yylloc;
1003 #endif
1004 
1005   /* Count tokens shifted since error; after three, turn off error
1006      status.  */
1007   if (yyerrstatus)
1008     yyerrstatus--;
1009 
1010   yystate = yyn;
1011   goto yynewstate;
1012 
1013 
1014 /*-----------------------------------------------------------.
1015 | yydefault -- do the default action for the current state.  |
1016 `-----------------------------------------------------------*/
1017 yydefault:
1018   yyn = yydefact[yystate];
1019   if (yyn == 0)
1020     goto yyerrlab;
1021   goto yyreduce;
1022 
1023 
1024 /*-----------------------------.
1025 | yyreduce -- Do a reduction.  |
1026 `-----------------------------*/
1027 yyreduce:
1028   /* yyn is the number of a rule to reduce with.  */
1029   yylen = yyr2[yyn];
1030 
1031   /* If YYLEN is nonzero, implement the default value of the action:
1032      `$$ = $1'.
1033 
1034      Otherwise, the following line sets YYVAL to the semantic value of
1035      the lookahead token.  This behavior is undocumented and Bison
1036      users should not rely upon it.  Assigning to YYVAL
1037      unconditionally makes the parser a bit smaller, and it avoids a
1038      GCC warning that YYVAL may be used uninitialized.  */
1039   yyval = yyvsp[1-yylen];
1040 
1041 #if YYLSP_NEEDED
1042   /* Similarly for the default location.  Let the user run additional
1043      commands if for instance locations are ranges.  */
1044   yyloc = yylsp[1-yylen];
1045   YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1046 #endif
1047 
1048 #if YYDEBUG
1049   /* We have to keep this `#if YYDEBUG', since we use variables which
1050      are defined only if `YYDEBUG' is set.  */
1051   if (yydebug)
1052     {
1053       int yyi;
1054 
1055       YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
1056 		 yyn, yyrline[yyn]);
1057 
1058       /* Print the symbols being reduced, and their result.  */
1059       for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
1060 	YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
1061       YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1062     }
1063 #endif
1064 
1065   switch (yyn) {
1066 
1067 case 4:
1068 #line 158 "nlmheader.y"
1069 {
1070 	    check_procedure = yyvsp[0].string;
1071 	  }
1072     break;
1073 case 5:
1074 #line 162 "nlmheader.y"
1075 {
1076 	    nlmheader_warn (_("CODESTART is not implemented; sorry"), -1);
1077 	    free (yyvsp[0].string);
1078 	  }
1079     break;
1080 case 6:
1081 #line 167 "nlmheader.y"
1082 {
1083 	    int len;
1084 
1085 	    strncpy (copyright_hdr->stamp, "CoPyRiGhT=", 10);
1086 	    len = strlen (yyvsp[0].string);
1087 	    if (len >= NLM_MAX_COPYRIGHT_MESSAGE_LENGTH)
1088 	      {
1089 		nlmheader_warn (_("copyright string is too long"),
1090 				NLM_MAX_COPYRIGHT_MESSAGE_LENGTH - 1);
1091 		len = NLM_MAX_COPYRIGHT_MESSAGE_LENGTH - 1;
1092 	      }
1093 	    copyright_hdr->copyrightMessageLength = len;
1094 	    strncpy (copyright_hdr->copyrightMessage, yyvsp[0].string, len);
1095 	    copyright_hdr->copyrightMessage[len] = '\0';
1096 	    free (yyvsp[0].string);
1097 	  }
1098     break;
1099 case 7:
1100 #line 184 "nlmheader.y"
1101 {
1102 	    custom_file = yyvsp[0].string;
1103 	  }
1104     break;
1105 case 8:
1106 #line 188 "nlmheader.y"
1107 {
1108 	    /* We don't set the version stamp here, because we use the
1109 	       version stamp to detect whether the required VERSION
1110 	       keyword was given.  */
1111 	    version_hdr->month = nlmlex_get_number (yyvsp[-2].string);
1112 	    version_hdr->day = nlmlex_get_number (yyvsp[-1].string);
1113 	    version_hdr->year = nlmlex_get_number (yyvsp[0].string);
1114 	    free (yyvsp[-2].string);
1115 	    free (yyvsp[-1].string);
1116 	    free (yyvsp[0].string);
1117 	    if (version_hdr->month < 1 || version_hdr->month > 12)
1118 	      nlmheader_warn (_("illegal month"), -1);
1119 	    if (version_hdr->day < 1 || version_hdr->day > 31)
1120 	      nlmheader_warn (_("illegal day"), -1);
1121 	    if (version_hdr->year < 1900 || version_hdr->year > 3000)
1122 	      nlmheader_warn (_("illegal year"), -1);
1123 	  }
1124     break;
1125 case 9:
1126 #line 206 "nlmheader.y"
1127 {
1128 	    debug_info = TRUE;
1129 	  }
1130     break;
1131 case 10:
1132 #line 210 "nlmheader.y"
1133 {
1134 	    int len;
1135 
1136 	    len = strlen (yyvsp[0].string);
1137 	    if (len > NLM_MAX_DESCRIPTION_LENGTH)
1138 	      {
1139 		nlmheader_warn (_("description string is too long"),
1140 				NLM_MAX_DESCRIPTION_LENGTH);
1141 		len = NLM_MAX_DESCRIPTION_LENGTH;
1142 	      }
1143 	    var_hdr->descriptionLength = len;
1144 	    strncpy (var_hdr->descriptionText, yyvsp[0].string, len);
1145 	    var_hdr->descriptionText[len] = '\0';
1146 	    free (yyvsp[0].string);
1147 	  }
1148     break;
1149 case 11:
1150 #line 226 "nlmheader.y"
1151 {
1152 	    exit_procedure = yyvsp[0].string;
1153 	  }
1154     break;
1155 case 12:
1156 #line 230 "nlmheader.y"
1157 {
1158 	    symbol_prefix = NULL;
1159 	  }
1160     break;
1161 case 13:
1162 #line 234 "nlmheader.y"
1163 {
1164 	    export_symbols = string_list_append (export_symbols, yyvsp[0].list);
1165 	  }
1166     break;
1167 case 14:
1168 #line 238 "nlmheader.y"
1169 {
1170 	    fixed_hdr->flags |= nlmlex_get_number (yyvsp[0].string);
1171 	    free (yyvsp[0].string);
1172 	  }
1173     break;
1174 case 15:
1175 #line 243 "nlmheader.y"
1176 {
1177 	    fixed_hdr->flags &=~ nlmlex_get_number (yyvsp[0].string);
1178 	    free (yyvsp[0].string);
1179 	  }
1180     break;
1181 case 16:
1182 #line 248 "nlmheader.y"
1183 {
1184 	    map_file = "";
1185 	    full_map = TRUE;
1186 	  }
1187     break;
1188 case 17:
1189 #line 253 "nlmheader.y"
1190 {
1191 	    map_file = yyvsp[0].string;
1192 	    full_map = TRUE;
1193 	  }
1194     break;
1195 case 18:
1196 #line 258 "nlmheader.y"
1197 {
1198 	    help_file = yyvsp[0].string;
1199 	  }
1200     break;
1201 case 19:
1202 #line 262 "nlmheader.y"
1203 {
1204 	    symbol_prefix = NULL;
1205 	  }
1206     break;
1207 case 20:
1208 #line 266 "nlmheader.y"
1209 {
1210 	    import_symbols = string_list_append (import_symbols, yyvsp[0].list);
1211 	  }
1212     break;
1213 case 21:
1214 #line 270 "nlmheader.y"
1215 {
1216 	    input_files = string_list_append (input_files, yyvsp[0].list);
1217 	  }
1218     break;
1219 case 22:
1220 #line 274 "nlmheader.y"
1221 {
1222 	    map_file = "";
1223 	  }
1224     break;
1225 case 23:
1226 #line 278 "nlmheader.y"
1227 {
1228 	    map_file = yyvsp[0].string;
1229 	  }
1230     break;
1231 case 24:
1232 #line 282 "nlmheader.y"
1233 {
1234 	    message_file = yyvsp[0].string;
1235 	  }
1236     break;
1237 case 25:
1238 #line 286 "nlmheader.y"
1239 {
1240 	    modules = string_list_append (modules, yyvsp[0].list);
1241 	  }
1242     break;
1243 case 26:
1244 #line 290 "nlmheader.y"
1245 {
1246 	    fixed_hdr->flags |= 0x2;
1247 	  }
1248     break;
1249 case 27:
1250 #line 294 "nlmheader.y"
1251 {
1252 	    fixed_hdr->flags |= 0x10;
1253 	  }
1254     break;
1255 case 28:
1256 #line 298 "nlmheader.y"
1257 {
1258 	    if (output_file == NULL)
1259 	      output_file = yyvsp[0].string;
1260 	    else
1261 	      nlmheader_warn (_("ignoring duplicate OUTPUT statement"), -1);
1262 	  }
1263     break;
1264 case 29:
1265 #line 305 "nlmheader.y"
1266 {
1267 	    fixed_hdr->flags |= 0x8;
1268 	  }
1269     break;
1270 case 30:
1271 #line 309 "nlmheader.y"
1272 {
1273 	    fixed_hdr->flags |= 0x1;
1274 	  }
1275     break;
1276 case 31:
1277 #line 313 "nlmheader.y"
1278 {
1279 	    int len;
1280 
1281 	    len = strlen (yyvsp[0].string);
1282 	    if (len >= NLM_MAX_SCREEN_NAME_LENGTH)
1283 	      {
1284 		nlmheader_warn (_("screen name is too long"),
1285 				NLM_MAX_SCREEN_NAME_LENGTH);
1286 		len = NLM_MAX_SCREEN_NAME_LENGTH;
1287 	      }
1288 	    var_hdr->screenNameLength = len;
1289 	    strncpy (var_hdr->screenName, yyvsp[0].string, len);
1290 	    var_hdr->screenName[NLM_MAX_SCREEN_NAME_LENGTH] = '\0';
1291 	    free (yyvsp[0].string);
1292 	  }
1293     break;
1294 case 32:
1295 #line 329 "nlmheader.y"
1296 {
1297 	    sharelib_file = yyvsp[0].string;
1298 	  }
1299     break;
1300 case 33:
1301 #line 333 "nlmheader.y"
1302 {
1303 	    var_hdr->stackSize = nlmlex_get_number (yyvsp[0].string);
1304 	    free (yyvsp[0].string);
1305 	  }
1306     break;
1307 case 34:
1308 #line 338 "nlmheader.y"
1309 {
1310 	    start_procedure = yyvsp[0].string;
1311 	  }
1312     break;
1313 case 35:
1314 #line 342 "nlmheader.y"
1315 {
1316 	    fixed_hdr->flags |= 0x4;
1317 	  }
1318     break;
1319 case 36:
1320 #line 346 "nlmheader.y"
1321 {
1322 	    int len;
1323 
1324 	    len = strlen (yyvsp[0].string);
1325 	    if (len >= NLM_MAX_THREAD_NAME_LENGTH)
1326 	      {
1327 		nlmheader_warn (_("thread name is too long"),
1328 				NLM_MAX_THREAD_NAME_LENGTH);
1329 		len = NLM_MAX_THREAD_NAME_LENGTH;
1330 	      }
1331 	    var_hdr->threadNameLength = len;
1332 	    strncpy (var_hdr->threadName, yyvsp[0].string, len);
1333 	    var_hdr->threadName[len] = '\0';
1334 	    free (yyvsp[0].string);
1335 	  }
1336     break;
1337 case 37:
1338 #line 362 "nlmheader.y"
1339 {
1340 	    fixed_hdr->moduleType = nlmlex_get_number (yyvsp[0].string);
1341 	    free (yyvsp[0].string);
1342 	  }
1343     break;
1344 case 38:
1345 #line 367 "nlmheader.y"
1346 {
1347 	    verbose = TRUE;
1348 	  }
1349     break;
1350 case 39:
1351 #line 371 "nlmheader.y"
1352 {
1353 	    long val;
1354 
1355 	    strncpy (version_hdr->stamp, "VeRsIoN#", 8);
1356 	    version_hdr->majorVersion = nlmlex_get_number (yyvsp[-2].string);
1357 	    val = nlmlex_get_number (yyvsp[-1].string);
1358 	    if (val < 0 || val > 99)
1359 	      nlmheader_warn (_("illegal minor version number (must be between 0 and 99)"),
1360 			      -1);
1361 	    else
1362 	      version_hdr->minorVersion = val;
1363 	    val = nlmlex_get_number (yyvsp[0].string);
1364 	    if (val < 0)
1365 	      nlmheader_warn (_("illegal revision number (must be between 0 and 26)"),
1366 			      -1);
1367 	    else if (val > 26)
1368 	      version_hdr->revision = 0;
1369 	    else
1370 	      version_hdr->revision = val;
1371 	    free (yyvsp[-2].string);
1372 	    free (yyvsp[-1].string);
1373 	    free (yyvsp[0].string);
1374 	  }
1375     break;
1376 case 40:
1377 #line 395 "nlmheader.y"
1378 {
1379 	    long val;
1380 
1381 	    strncpy (version_hdr->stamp, "VeRsIoN#", 8);
1382 	    version_hdr->majorVersion = nlmlex_get_number (yyvsp[-1].string);
1383 	    val = nlmlex_get_number (yyvsp[0].string);
1384 	    if (val < 0 || val > 99)
1385 	      nlmheader_warn (_("illegal minor version number (must be between 0 and 99)"),
1386 			      -1);
1387 	    else
1388 	      version_hdr->minorVersion = val;
1389 	    version_hdr->revision = 0;
1390 	    free (yyvsp[-1].string);
1391 	    free (yyvsp[0].string);
1392 	  }
1393     break;
1394 case 41:
1395 #line 411 "nlmheader.y"
1396 {
1397 	    rpc_file = yyvsp[0].string;
1398 	  }
1399     break;
1400 case 42:
1401 #line 420 "nlmheader.y"
1402 {
1403 	    yyval.list = NULL;
1404 	  }
1405     break;
1406 case 43:
1407 #line 424 "nlmheader.y"
1408 {
1409 	    yyval.list = yyvsp[0].list;
1410 	  }
1411     break;
1412 case 44:
1413 #line 435 "nlmheader.y"
1414 {
1415 	    yyval.list = string_list_cons (yyvsp[0].string, NULL);
1416 	  }
1417     break;
1418 case 45:
1419 #line 439 "nlmheader.y"
1420 {
1421 	    yyval.list = NULL;
1422 	  }
1423     break;
1424 case 46:
1425 #line 443 "nlmheader.y"
1426 {
1427 	    yyval.list = string_list_append1 (yyvsp[-1].list, yyvsp[0].string);
1428 	  }
1429     break;
1430 case 47:
1431 #line 447 "nlmheader.y"
1432 {
1433 	    yyval.list = yyvsp[-1].list;
1434 	  }
1435     break;
1436 case 48:
1437 #line 456 "nlmheader.y"
1438 {
1439 	    if (symbol_prefix != NULL)
1440 	      free (symbol_prefix);
1441 	    symbol_prefix = yyvsp[-1].string;
1442 	  }
1443     break;
1444 case 49:
1445 #line 467 "nlmheader.y"
1446 {
1447 	    if (symbol_prefix == NULL)
1448 	      yyval.string = yyvsp[0].string;
1449 	    else
1450 	      {
1451 		yyval.string = xmalloc (strlen (symbol_prefix) + strlen (yyvsp[0].string) + 2);
1452 		sprintf (yyval.string, "%s@%s", symbol_prefix, yyvsp[0].string);
1453 		free (yyvsp[0].string);
1454 	      }
1455 	  }
1456     break;
1457 case 50:
1458 #line 483 "nlmheader.y"
1459 {
1460 	    yyval.list = NULL;
1461 	  }
1462     break;
1463 case 51:
1464 #line 487 "nlmheader.y"
1465 {
1466 	    yyval.list = string_list_cons (yyvsp[-1].string, yyvsp[0].list);
1467 	  }
1468     break;
1469 }
1470 
1471 #line 705 "/usr/share/bison-1.35/bison.simple"
1472 
1473 
1474   yyvsp -= yylen;
1475   yyssp -= yylen;
1476 #if YYLSP_NEEDED
1477   yylsp -= yylen;
1478 #endif
1479 
1480 #if YYDEBUG
1481   if (yydebug)
1482     {
1483       short *yyssp1 = yyss - 1;
1484       YYFPRINTF (stderr, "state stack now");
1485       while (yyssp1 != yyssp)
1486 	YYFPRINTF (stderr, " %d", *++yyssp1);
1487       YYFPRINTF (stderr, "\n");
1488     }
1489 #endif
1490 
1491   *++yyvsp = yyval;
1492 #if YYLSP_NEEDED
1493   *++yylsp = yyloc;
1494 #endif
1495 
1496   /* Now `shift' the result of the reduction.  Determine what state
1497      that goes to, based on the state we popped back to and the rule
1498      number reduced by.  */
1499 
1500   yyn = yyr1[yyn];
1501 
1502   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1503   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1504     yystate = yytable[yystate];
1505   else
1506     yystate = yydefgoto[yyn - YYNTBASE];
1507 
1508   goto yynewstate;
1509 
1510 
1511 /*------------------------------------.
1512 | yyerrlab -- here on detecting error |
1513 `------------------------------------*/
1514 yyerrlab:
1515   /* If not already recovering from an error, report this error.  */
1516   if (!yyerrstatus)
1517     {
1518       ++yynerrs;
1519 
1520 #ifdef YYERROR_VERBOSE
1521       yyn = yypact[yystate];
1522 
1523       if (yyn > YYFLAG && yyn < YYLAST)
1524 	{
1525 	  YYSIZE_T yysize = 0;
1526 	  char *yymsg;
1527 	  int yyx, yycount;
1528 
1529 	  yycount = 0;
1530 	  /* Start YYX at -YYN if negative to avoid negative indexes in
1531 	     YYCHECK.  */
1532 	  for (yyx = yyn < 0 ? -yyn : 0;
1533 	       yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
1534 	    if (yycheck[yyx + yyn] == yyx)
1535 	      yysize += yystrlen (yytname[yyx]) + 15, yycount++;
1536 	  yysize += yystrlen ("parse error, unexpected ") + 1;
1537 	  yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
1538 	  yymsg = (char *) YYSTACK_ALLOC (yysize);
1539 	  if (yymsg != 0)
1540 	    {
1541 	      char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
1542 	      yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
1543 
1544 	      if (yycount < 5)
1545 		{
1546 		  yycount = 0;
1547 		  for (yyx = yyn < 0 ? -yyn : 0;
1548 		       yyx < (int) (sizeof (yytname) / sizeof (char *));
1549 		       yyx++)
1550 		    if (yycheck[yyx + yyn] == yyx)
1551 		      {
1552 			const char *yyq = ! yycount ? ", expecting " : " or ";
1553 			yyp = yystpcpy (yyp, yyq);
1554 			yyp = yystpcpy (yyp, yytname[yyx]);
1555 			yycount++;
1556 		      }
1557 		}
1558 	      yyerror (yymsg);
1559 	      YYSTACK_FREE (yymsg);
1560 	    }
1561 	  else
1562 	    yyerror ("parse error; also virtual memory exhausted");
1563 	}
1564       else
1565 #endif /* defined (YYERROR_VERBOSE) */
1566 	yyerror ("parse error");
1567     }
1568   goto yyerrlab1;
1569 
1570 
1571 /*--------------------------------------------------.
1572 | yyerrlab1 -- error raised explicitly by an action |
1573 `--------------------------------------------------*/
1574 yyerrlab1:
1575   if (yyerrstatus == 3)
1576     {
1577       /* If just tried and failed to reuse lookahead token after an
1578 	 error, discard it.  */
1579 
1580       /* return failure if at end of input */
1581       if (yychar == YYEOF)
1582 	YYABORT;
1583       YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
1584 		  yychar, yytname[yychar1]));
1585       yychar = YYEMPTY;
1586     }
1587 
1588   /* Else will try to reuse lookahead token after shifting the error
1589      token.  */
1590 
1591   yyerrstatus = 3;		/* Each real token shifted decrements this */
1592 
1593   goto yyerrhandle;
1594 
1595 
1596 /*-------------------------------------------------------------------.
1597 | yyerrdefault -- current state does not do anything special for the |
1598 | error token.                                                       |
1599 `-------------------------------------------------------------------*/
1600 yyerrdefault:
1601 #if 0
1602   /* This is wrong; only states that explicitly want error tokens
1603      should shift them.  */
1604 
1605   /* If its default is to accept any token, ok.  Otherwise pop it.  */
1606   yyn = yydefact[yystate];
1607   if (yyn)
1608     goto yydefault;
1609 #endif
1610 
1611 
1612 /*---------------------------------------------------------------.
1613 | yyerrpop -- pop the current state because it cannot handle the |
1614 | error token                                                    |
1615 `---------------------------------------------------------------*/
1616 yyerrpop:
1617   if (yyssp == yyss)
1618     YYABORT;
1619   yyvsp--;
1620   yystate = *--yyssp;
1621 #if YYLSP_NEEDED
1622   yylsp--;
1623 #endif
1624 
1625 #if YYDEBUG
1626   if (yydebug)
1627     {
1628       short *yyssp1 = yyss - 1;
1629       YYFPRINTF (stderr, "Error: state stack now");
1630       while (yyssp1 != yyssp)
1631 	YYFPRINTF (stderr, " %d", *++yyssp1);
1632       YYFPRINTF (stderr, "\n");
1633     }
1634 #endif
1635 
1636 /*--------------.
1637 | yyerrhandle.  |
1638 `--------------*/
1639 yyerrhandle:
1640   yyn = yypact[yystate];
1641   if (yyn == YYFLAG)
1642     goto yyerrdefault;
1643 
1644   yyn += YYTERROR;
1645   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1646     goto yyerrdefault;
1647 
1648   yyn = yytable[yyn];
1649   if (yyn < 0)
1650     {
1651       if (yyn == YYFLAG)
1652 	goto yyerrpop;
1653       yyn = -yyn;
1654       goto yyreduce;
1655     }
1656   else if (yyn == 0)
1657     goto yyerrpop;
1658 
1659   if (yyn == YYFINAL)
1660     YYACCEPT;
1661 
1662   YYDPRINTF ((stderr, "Shifting error token, "));
1663 
1664   *++yyvsp = yylval;
1665 #if YYLSP_NEEDED
1666   *++yylsp = yylloc;
1667 #endif
1668 
1669   yystate = yyn;
1670   goto yynewstate;
1671 
1672 
1673 /*-------------------------------------.
1674 | yyacceptlab -- YYACCEPT comes here.  |
1675 `-------------------------------------*/
1676 yyacceptlab:
1677   yyresult = 0;
1678   goto yyreturn;
1679 
1680 /*-----------------------------------.
1681 | yyabortlab -- YYABORT comes here.  |
1682 `-----------------------------------*/
1683 yyabortlab:
1684   yyresult = 1;
1685   goto yyreturn;
1686 
1687 /*---------------------------------------------.
1688 | yyoverflowab -- parser overflow comes here.  |
1689 `---------------------------------------------*/
1690 yyoverflowlab:
1691   yyerror ("parser stack overflow");
1692   yyresult = 2;
1693   /* Fall through.  */
1694 
1695 yyreturn:
1696 #ifndef yyoverflow
1697   if (yyss != yyssa)
1698     YYSTACK_FREE (yyss);
1699 #endif
1700   return yyresult;
1701 }
1702 #line 492 "nlmheader.y"
1703 
1704 
1705 /* If strerror is just a macro, we want to use the one from libiberty
1706    since it will handle undefined values.  */
1707 #undef strerror
1708 extern char *strerror PARAMS ((int));
1709 
1710 /* The lexer is simple, too simple for flex.  Keywords are only
1711    recognized at the start of lines.  Everything else must be an
1712    argument.  A comma is treated as whitespace.  */
1713 
1714 /* The states the lexer can be in.  */
1715 
1716 enum lex_state
1717 {
1718   /* At the beginning of a line.  */
1719   BEGINNING_OF_LINE,
1720   /* In the middle of a line.  */
1721   IN_LINE
1722 };
1723 
1724 /* We need to keep a stack of files to handle file inclusion.  */
1725 
1726 struct input
1727 {
1728   /* The file to read from.  */
1729   FILE *file;
1730   /* The name of the file.  */
1731   char *name;
1732   /* The current line number.  */
1733   int lineno;
1734   /* The current state.  */
1735   enum lex_state state;
1736   /* The next file on the stack.  */
1737   struct input *next;
1738 };
1739 
1740 /* The current input file.  */
1741 
1742 static struct input current;
1743 
1744 /* The character which introduces comments.  */
1745 #define COMMENT_CHAR '#'
1746 
1747 /* Start the lexer going on the main input file.  */
1748 
1749 bfd_boolean
nlmlex_file(const char * name)1750 nlmlex_file (const char *name)
1751 {
1752   current.next = NULL;
1753   return nlmlex_file_open (name);
1754 }
1755 
1756 /* Start the lexer going on a subsidiary input file.  */
1757 
1758 static void
nlmlex_file_push(const char * name)1759 nlmlex_file_push (const char *name)
1760 {
1761   struct input *push;
1762 
1763   push = (struct input *) xmalloc (sizeof (struct input));
1764   *push = current;
1765   if (nlmlex_file_open (name))
1766     current.next = push;
1767   else
1768     {
1769       current = *push;
1770       free (push);
1771     }
1772 }
1773 
1774 /* Start lexing from a file.  */
1775 
1776 static bfd_boolean
nlmlex_file_open(const char * name)1777 nlmlex_file_open (const char *name)
1778 {
1779   current.file = fopen (name, "r");
1780   if (current.file == NULL)
1781     {
1782       fprintf (stderr, "%s:%s: %s\n", program_name, name, strerror (errno));
1783       ++parse_errors;
1784       return FALSE;
1785     }
1786   current.name = xstrdup (name);
1787   current.lineno = 1;
1788   current.state = BEGINNING_OF_LINE;
1789   return TRUE;
1790 }
1791 
1792 /* Table used to turn keywords into tokens.  */
1793 
1794 struct keyword_tokens_struct
1795 {
1796   const char *keyword;
1797   int token;
1798 };
1799 
1800 struct keyword_tokens_struct keyword_tokens[] =
1801 {
1802   { "CHECK", CHECK },
1803   { "CODESTART", CODESTART },
1804   { "COPYRIGHT", COPYRIGHT },
1805   { "CUSTOM", CUSTOM },
1806   { "DATE", DATE },
1807   { "DEBUG", DEBUG },
1808   { "DESCRIPTION", DESCRIPTION },
1809   { "EXIT", EXIT },
1810   { "EXPORT", EXPORT },
1811   { "FLAG_ON", FLAG_ON },
1812   { "FLAG_OFF", FLAG_OFF },
1813   { "FULLMAP", FULLMAP },
1814   { "HELP", HELP },
1815   { "IMPORT", IMPORT },
1816   { "INPUT", INPUT },
1817   { "MAP", MAP },
1818   { "MESSAGES", MESSAGES },
1819   { "MODULE", MODULE },
1820   { "MULTIPLE", MULTIPLE },
1821   { "OS_DOMAIN", OS_DOMAIN },
1822   { "OUTPUT", OUTPUT },
1823   { "PSEUDOPREEMPTION", PSEUDOPREEMPTION },
1824   { "REENTRANT", REENTRANT },
1825   { "SCREENNAME", SCREENNAME },
1826   { "SHARELIB", SHARELIB },
1827   { "STACK", STACK },
1828   { "STACKSIZE", STACK },
1829   { "START", START },
1830   { "SYNCHRONIZE", SYNCHRONIZE },
1831   { "THREADNAME", THREADNAME },
1832   { "TYPE", TYPE },
1833   { "VERBOSE", VERBOSE },
1834   { "VERSION", VERSIONK },
1835   { "XDCDATA", XDCDATA }
1836 };
1837 
1838 #define KEYWORD_COUNT (sizeof (keyword_tokens) / sizeof (keyword_tokens[0]))
1839 
1840 /* The lexer accumulates strings in these variables.  */
1841 static char *lex_buf;
1842 static int lex_size;
1843 static int lex_pos;
1844 
1845 /* Start accumulating strings into the buffer.  */
1846 #define BUF_INIT() \
1847   ((void) (lex_buf != NULL ? lex_pos = 0 : nlmlex_buf_init ()))
1848 
1849 static int
nlmlex_buf_init(void)1850 nlmlex_buf_init (void)
1851 {
1852   lex_size = 10;
1853   lex_buf = xmalloc (lex_size + 1);
1854   lex_pos = 0;
1855   return 0;
1856 }
1857 
1858 /* Finish a string in the buffer.  */
1859 #define BUF_FINISH() ((void) (lex_buf[lex_pos] = '\0'))
1860 
1861 /* Accumulate a character into the buffer.  */
1862 #define BUF_ADD(c) \
1863   ((void) (lex_pos < lex_size \
1864 	   ? lex_buf[lex_pos++] = (c) \
1865 	   : nlmlex_buf_add (c)))
1866 
1867 static char
nlmlex_buf_add(int c)1868 nlmlex_buf_add (int c)
1869 {
1870   if (lex_pos >= lex_size)
1871     {
1872       lex_size *= 2;
1873       lex_buf = xrealloc (lex_buf, lex_size + 1);
1874     }
1875 
1876   return lex_buf[lex_pos++] = c;
1877 }
1878 
1879 /* The lexer proper.  This is called by the bison generated parsing
1880    code.  */
1881 
1882 static int
yylex(void)1883 yylex (void)
1884 {
1885   int c;
1886 
1887 tail_recurse:
1888 
1889   c = getc (current.file);
1890 
1891   /* Commas are treated as whitespace characters.  */
1892   while (ISSPACE (c) || c == ',')
1893     {
1894       current.state = IN_LINE;
1895       if (c == '\n')
1896 	{
1897 	  ++current.lineno;
1898 	  current.state = BEGINNING_OF_LINE;
1899 	}
1900       c = getc (current.file);
1901     }
1902 
1903   /* At the end of the file we either pop to the previous file or
1904      finish up.  */
1905   if (c == EOF)
1906     {
1907       fclose (current.file);
1908       free (current.name);
1909       if (current.next == NULL)
1910 	return 0;
1911       else
1912 	{
1913 	  struct input *next;
1914 
1915 	  next = current.next;
1916 	  current = *next;
1917 	  free (next);
1918 	  goto tail_recurse;
1919 	}
1920     }
1921 
1922   /* A comment character always means to drop everything until the
1923      next newline.  */
1924   if (c == COMMENT_CHAR)
1925     {
1926       do
1927 	{
1928 	  c = getc (current.file);
1929 	}
1930       while (c != '\n');
1931       ++current.lineno;
1932       current.state = BEGINNING_OF_LINE;
1933       goto tail_recurse;
1934     }
1935 
1936   /* An '@' introduces an include file.  */
1937   if (c == '@')
1938     {
1939       do
1940 	{
1941 	  c = getc (current.file);
1942 	  if (c == '\n')
1943 	    ++current.lineno;
1944 	}
1945       while (ISSPACE (c));
1946       BUF_INIT ();
1947       while (! ISSPACE (c) && c != EOF)
1948 	{
1949 	  BUF_ADD (c);
1950 	  c = getc (current.file);
1951 	}
1952       BUF_FINISH ();
1953 
1954       ungetc (c, current.file);
1955 
1956       nlmlex_file_push (lex_buf);
1957       goto tail_recurse;
1958     }
1959 
1960   /* A non-space character at the start of a line must be the start of
1961      a keyword.  */
1962   if (current.state == BEGINNING_OF_LINE)
1963     {
1964       BUF_INIT ();
1965       while (ISALNUM (c) || c == '_')
1966 	{
1967 	  BUF_ADD (TOUPPER (c));
1968 	  c = getc (current.file);
1969 	}
1970       BUF_FINISH ();
1971 
1972       if (c != EOF && ! ISSPACE (c) && c != ',')
1973 	{
1974 	  nlmheader_identify ();
1975 	  fprintf (stderr, _("%s:%d: illegal character in keyword: %c\n"),
1976 		   current.name, current.lineno, c);
1977 	}
1978       else
1979 	{
1980 	  unsigned int i;
1981 
1982 	  for (i = 0; i < KEYWORD_COUNT; i++)
1983 	    {
1984 	      if (lex_buf[0] == keyword_tokens[i].keyword[0]
1985 		  && strcmp (lex_buf, keyword_tokens[i].keyword) == 0)
1986 		{
1987 		  /* Pushing back the final whitespace avoids worrying
1988 		     about \n here.  */
1989 		  ungetc (c, current.file);
1990 		  current.state = IN_LINE;
1991 		  return keyword_tokens[i].token;
1992 		}
1993 	    }
1994 
1995 	  nlmheader_identify ();
1996 	  fprintf (stderr, _("%s:%d: unrecognized keyword: %s\n"),
1997 		   current.name, current.lineno, lex_buf);
1998 	}
1999 
2000       ++parse_errors;
2001       /* Treat the rest of this line as a comment.  */
2002       ungetc (COMMENT_CHAR, current.file);
2003       goto tail_recurse;
2004     }
2005 
2006   /* Parentheses just represent themselves.  */
2007   if (c == '(' || c == ')')
2008     return c;
2009 
2010   /* Handle quoted strings.  */
2011   if (c == '"' || c == '\'')
2012     {
2013       int quote;
2014       int start_lineno;
2015 
2016       quote = c;
2017       start_lineno = current.lineno;
2018 
2019       c = getc (current.file);
2020       BUF_INIT ();
2021       while (c != quote && c != EOF)
2022 	{
2023 	  BUF_ADD (c);
2024 	  if (c == '\n')
2025 	    ++current.lineno;
2026 	  c = getc (current.file);
2027 	}
2028       BUF_FINISH ();
2029 
2030       if (c == EOF)
2031 	{
2032 	  nlmheader_identify ();
2033 	  fprintf (stderr, _("%s:%d: end of file in quoted string\n"),
2034 		   current.name, start_lineno);
2035 	  ++parse_errors;
2036 	}
2037 
2038       /* FIXME: Possible memory leak.  */
2039       yylval.string = xstrdup (lex_buf);
2040       return QUOTED_STRING;
2041     }
2042 
2043   /* Gather a generic argument.  */
2044   BUF_INIT ();
2045   while (! ISSPACE (c)
2046 	 && c != ','
2047 	 && c != COMMENT_CHAR
2048 	 && c != '('
2049 	 && c != ')')
2050     {
2051       BUF_ADD (c);
2052       c = getc (current.file);
2053     }
2054   BUF_FINISH ();
2055 
2056   ungetc (c, current.file);
2057 
2058   /* FIXME: Possible memory leak.  */
2059   yylval.string = xstrdup (lex_buf);
2060   return STRING;
2061 }
2062 
2063 /* Get a number from a string.  */
2064 
2065 static long
nlmlex_get_number(const char * s)2066 nlmlex_get_number (const char *s)
2067 {
2068   long ret;
2069   char *send;
2070 
2071   ret = strtol (s, &send, 10);
2072   if (*send != '\0')
2073     nlmheader_warn (_("bad number"), -1);
2074   return ret;
2075 }
2076 
2077 /* Prefix the nlmconv warnings with a note as to where they come from.
2078    We don't use program_name on every warning, because then some
2079    versions of the emacs next-error function can't recognize the line
2080    number.  */
2081 
2082 static void
nlmheader_identify(void)2083 nlmheader_identify (void)
2084 {
2085   static int done;
2086 
2087   if (! done)
2088     {
2089       fprintf (stderr, _("%s: problems in NLM command language input:\n"),
2090 	       program_name);
2091       done = 1;
2092     }
2093 }
2094 
2095 /* Issue a warning.  */
2096 
2097 static void
nlmheader_warn(const char * s,int imax)2098 nlmheader_warn (const char *s, int imax)
2099 {
2100   nlmheader_identify ();
2101   fprintf (stderr, "%s:%d: %s", current.name, current.lineno, s);
2102   if (imax != -1)
2103     fprintf (stderr, " (max %d)", imax);
2104   fprintf (stderr, "\n");
2105 }
2106 
2107 /* Report an error.  */
2108 
2109 static void
nlmheader_error(const char * s)2110 nlmheader_error (const char *s)
2111 {
2112   nlmheader_warn (s, -1);
2113   ++parse_errors;
2114 }
2115 
2116 /* Add a string to a string list.  */
2117 
2118 static struct string_list *
string_list_cons(char * s,struct string_list * l)2119 string_list_cons (char *s, struct string_list *l)
2120 {
2121   struct string_list *ret;
2122 
2123   ret = (struct string_list *) xmalloc (sizeof (struct string_list));
2124   ret->next = l;
2125   ret->string = s;
2126   return ret;
2127 }
2128 
2129 /* Append a string list to another string list.  */
2130 
2131 static struct string_list *
string_list_append(struct string_list * l1,struct string_list * l2)2132 string_list_append (struct string_list *l1, struct string_list *l2)
2133 {
2134   register struct string_list **pp;
2135 
2136   for (pp = &l1; *pp != NULL; pp = &(*pp)->next)
2137     ;
2138   *pp = l2;
2139   return l1;
2140 }
2141 
2142 /* Append a string to a string list.  */
2143 
2144 static struct string_list *
string_list_append1(struct string_list * l,char * s)2145 string_list_append1 (struct string_list *l, char *s)
2146 {
2147   struct string_list *n;
2148   register struct string_list **pp;
2149 
2150   n = (struct string_list *) xmalloc (sizeof (struct string_list));
2151   n->next = NULL;
2152   n->string = s;
2153   for (pp = &l; *pp != NULL; pp = &(*pp)->next)
2154     ;
2155   *pp = n;
2156   return l;
2157 }
2158 
2159 /* Duplicate a string in memory.  */
2160 
2161 static char *
xstrdup(const char * s)2162 xstrdup (const char *s)
2163 {
2164   unsigned long len;
2165   char *ret;
2166 
2167   len = strlen (s);
2168   ret = xmalloc (len + 1);
2169   strcpy (ret, s);
2170   return ret;
2171 }
2172