OSDN Git Service

* typeck.c (build_x_function_call): Resolve an OFFSET_REF.
[pf3gnuchains/gcc-fork.git] / gcc / cppinit.c
1 /* CPP Library.
2    Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3    1999, 2000 Free Software Foundation, Inc.
4    Contributed by Per Bothner, 1994-95.
5    Based on CCCP program by Paul Rubin, June 1986
6    Adapted to ANSI C, Richard Stallman, Jan 1987
7
8 This program is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 2, or (at your option) any
11 later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
21
22 #include "config.h"
23 #include "system.h"
24 #include "hashtab.h"
25 #include "cpplib.h"
26 #include "cpphash.h"
27 #include "output.h"
28 #include "prefix.h"
29 #include "intl.h"
30 #include "version.h"
31 #include "mkdeps.h"
32
33 /* Predefined symbols, built-in macros, and the default include path. */
34
35 #ifndef GET_ENV_PATH_LIST
36 #define GET_ENV_PATH_LIST(VAR,NAME)     do { (VAR) = getenv (NAME); } while (0)
37 #endif
38
39 /* Windows does not natively support inodes, and neither does MSDOS.
40    Cygwin's emulation can generate non-unique inodes, so don't use it.
41    VMS has non-numeric inodes. */
42 #ifdef VMS
43 #define INO_T_EQ(a, b) (!memcmp (&(a), &(b), sizeof (a)))
44 #elif (defined _WIN32 && ! defined (_UWIN)) || defined __MSDOS__
45 #define INO_T_EQ(a, b) 0
46 #else
47 #define INO_T_EQ(a, b) ((a) == (b))
48 #endif
49
50 #ifndef STANDARD_INCLUDE_DIR
51 #define STANDARD_INCLUDE_DIR "/usr/include"
52 #endif
53
54 /* We let tm.h override the types used here, to handle trivial differences
55    such as the choice of unsigned int or long unsigned int for size_t.
56    When machines start needing nontrivial differences in the size type,
57    it would be best to do something here to figure out automatically
58    from other information what type to use.  */
59
60 /* The string value for __SIZE_TYPE__.  */
61
62 #ifndef SIZE_TYPE
63 #define SIZE_TYPE "long unsigned int"
64 #endif
65
66 /* The string value for __PTRDIFF_TYPE__.  */
67
68 #ifndef PTRDIFF_TYPE
69 #define PTRDIFF_TYPE "long int"
70 #endif
71
72 /* The string value for __WCHAR_TYPE__.  */
73
74 #ifndef WCHAR_TYPE
75 #define WCHAR_TYPE "int"
76 #endif
77
78 /* The string value for __USER_LABEL_PREFIX__ */
79
80 #ifndef USER_LABEL_PREFIX
81 #define USER_LABEL_PREFIX ""
82 #endif
83
84 /* The string value for __REGISTER_PREFIX__ */
85
86 #ifndef REGISTER_PREFIX
87 #define REGISTER_PREFIX ""
88 #endif
89
90 /* This is the default list of directories to search for include files.
91    It may be overridden by the various -I and -ixxx options.
92
93    #include "file" looks in the same directory as the current file,
94    then this list.
95    #include <file> just looks in this list.
96
97    All these directories are treated as `system' include directories
98    (they are not subject to pedantic warnings in some cases).  */
99
100 struct default_include
101 {
102   const char *fname;            /* The name of the directory.  */
103   const char *component;        /* The component containing the directory
104                                    (see update_path in prefix.c) */
105   int cplusplus;                /* Only look here if we're compiling C++.  */
106   int cxx_aware;                /* Includes in this directory don't need to
107                                    be wrapped in extern "C" when compiling
108                                    C++.  */
109 };
110
111 #ifndef STANDARD_INCLUDE_COMPONENT
112 #define STANDARD_INCLUDE_COMPONENT 0
113 #endif
114
115 #ifdef CROSS_COMPILE
116 #undef LOCAL_INCLUDE_DIR
117 #undef SYSTEM_INCLUDE_DIR
118 #undef STANDARD_INCLUDE_DIR
119 #else
120 #undef CROSS_INCLUDE_DIR
121 #endif
122
123 static const struct default_include include_defaults_array[]
124 #ifdef INCLUDE_DEFAULTS
125 = INCLUDE_DEFAULTS;
126 #else
127 = {
128 #ifdef GPLUSPLUS_INCLUDE_DIR
129     /* Pick up GNU C++ specific include files.  */
130     { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 },
131 #endif
132 #ifdef LOCAL_INCLUDE_DIR
133     /* /usr/local/include comes before the fixincluded header files.  */
134     { LOCAL_INCLUDE_DIR, 0, 0, 1 },
135 #endif
136 #ifdef GCC_INCLUDE_DIR
137     /* This is the dir for fixincludes and for gcc's private headers.  */
138     { GCC_INCLUDE_DIR, "GCC", 0, 0 },
139 #endif
140 #ifdef CROSS_INCLUDE_DIR
141     /* One place the target system's headers might be.  */
142     { CROSS_INCLUDE_DIR, "GCC", 0, 0 },
143 #endif
144 #ifdef TOOL_INCLUDE_DIR
145     /* Another place the target system's headers might be.  */
146     { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1 },
147 #endif
148 #ifdef SYSTEM_INCLUDE_DIR
149     /* Some systems have an extra dir of include files.  */
150     { SYSTEM_INCLUDE_DIR, 0, 0, 0 },
151 #endif
152 #ifdef STANDARD_INCLUDE_DIR
153     /* /usr/include comes dead last.  */
154     { STANDARD_INCLUDE_DIR, STANDARD_INCLUDE_COMPONENT, 0, 0 },
155 #endif
156     { 0, 0, 0, 0 }
157   };
158 #endif /* no INCLUDE_DEFAULTS */
159
160 /* Internal structures and prototypes. */
161
162 /* A `struct pending_option' remembers one -D, -A, -U, -include, or -imacros
163    switch.  There are four lists: one for -D and -U, one for -A, one
164    for -include, one for -imacros.  `undef' is set for -U, clear for
165    -D, ignored for the others.
166    (Future: add an equivalent of -U for -A) */
167
168 typedef void (* cl_directive_handler) PARAMS ((cpp_reader *, const char *));
169 struct pending_option
170 {
171   struct pending_option *next;
172   const char *arg;
173   cl_directive_handler handler;
174 };
175
176 /* The `pending' structure accumulates all the options that are not
177    actually processed until we hit cpp_start_read.  It consists of
178    several lists, one for each type of option.  We keep both head and
179    tail pointers for quick insertion. */
180 struct cpp_pending
181 {
182   struct pending_option *directive_head, *directive_tail;
183
184   struct file_name_list *quote_head, *quote_tail;
185   struct file_name_list *brack_head, *brack_tail;
186   struct file_name_list *systm_head, *systm_tail;
187   struct file_name_list *after_head, *after_tail;
188
189   struct pending_option *imacros_head, *imacros_tail;
190   struct pending_option *include_head, *include_tail;
191 };
192
193 #ifdef __STDC__
194 #define APPEND(pend, list, elt) \
195   do {  if (!(pend)->list##_head) (pend)->list##_head = (elt); \
196         else (pend)->list##_tail->next = (elt); \
197         (pend)->list##_tail = (elt); \
198   } while (0)
199 #else
200 #define APPEND(pend, list, elt) \
201   do {  if (!(pend)->list/**/_head) (pend)->list/**/_head = (elt); \
202         else (pend)->list/**/_tail->next = (elt); \
203         (pend)->list/**/_tail = (elt); \
204   } while (0)
205 #endif
206
207 static void print_help                  PARAMS ((void));
208 static void path_include                PARAMS ((cpp_reader *,
209                                                  struct cpp_pending *,
210                                                  char *, int));
211 static void initialize_builtins         PARAMS ((cpp_reader *));
212 static void append_include_chain        PARAMS ((cpp_reader *,
213                                                  struct cpp_pending *,
214                                                  char *, int, int));
215 static void merge_include_chains        PARAMS ((cpp_reader *));
216
217 static void dump_special_to_buffer      PARAMS ((cpp_reader *, const char *));
218 static void initialize_dependency_output PARAMS ((cpp_reader *));
219 static void initialize_standard_includes PARAMS ((cpp_reader *));
220 static void new_pending_directive               PARAMS ((struct cpp_pending *,
221                                                  const char *,
222                                                  cl_directive_handler));
223 #ifdef HOST_EBCDIC
224 static int opt_comp                     PARAMS ((const void *, const void *));
225 #endif
226 static int parse_option                 PARAMS ((const char *));
227 static int handle_option                PARAMS ((cpp_reader *, int, char **));
228
229 /* Fourth argument to append_include_chain: chain to use */
230 enum { QUOTE = 0, BRACKET, SYSTEM, AFTER };
231
232 /* If we have designated initializers (GCC >2.7, or C99) this table
233    can be initialized, constant data.  Otherwise, it has to be filled
234    in at runtime.  */
235
236 #if (GCC_VERSION >= 2007) || (__STDC_VERSION__ >= 199901L)
237 #define init_IStable()  /* nothing */
238 #define ISTABLE const unsigned char _cpp_IStable[256] = {
239 #define END };
240 #define s(p, v) [p] = v,
241 #else
242 #define ISTABLE unsigned char _cpp_IStable[256] = { 0 }; \
243  static void init_IStable PARAMS ((void)) { \
244  unsigned char *x = _cpp_IStable;
245 #define END }
246 #define s(p, v) x[p] = v;
247 #endif
248
249 #define A(x) s(x, ISidnum|ISidstart)
250 #define N(x) s(x, ISidnum|ISnumstart)
251 #define H(x) s(x, IShspace|ISspace)
252 #define S(x) s(x, ISspace)
253
254 ISTABLE
255   A('_')
256
257   A('a') A('b') A('c') A('d') A('e') A('f') A('g') A('h') A('i')
258   A('j') A('k') A('l') A('m') A('n') A('o') A('p') A('q') A('r')
259   A('s') A('t') A('u') A('v') A('w') A('x') A('y') A('z')
260
261   A('A') A('B') A('C') A('D') A('E') A('F') A('G') A('H') A('I')
262   A('J') A('K') A('L') A('M') A('N') A('O') A('P') A('Q') A('R')
263   A('S') A('T') A('U') A('V') A('W') A('X') A('Y') A('Z')
264
265   N('1') N('2') N('3') N('4') N('5') N('6') N('7') N('8') N('9') N('0')
266
267   H('\0') H(' ') H('\t') H('\v') H('\f')
268
269   S('\n')
270 END
271
272 #undef A
273 #undef N
274 #undef H
275 #undef S
276 #undef s
277 #undef ISTABLE
278 #undef END
279
280 /* Given a colon-separated list of file names PATH,
281    add all the names to the search path for include files.  */
282
283 static void
284 path_include (pfile, pend, list, path)
285      cpp_reader *pfile;
286      struct cpp_pending *pend;
287      char *list;
288      int path;
289 {
290   char *p, *q, *name;
291
292   p = list;
293
294   do
295     {
296       /* Find the end of this name.  */
297       q = p;
298       while (*q != 0 && *q != PATH_SEPARATOR) q++;
299       if (q == p)
300         {
301           /* An empty name in the path stands for the current directory.  */
302           name = (char *) xmalloc (2);
303           name[0] = '.';
304           name[1] = 0;
305         }
306       else
307         {
308           /* Otherwise use the directory that is named.  */
309           name = (char *) xmalloc (q - p + 1);
310           memcpy (name, p, q - p);
311           name[q - p] = 0;
312         }
313
314       append_include_chain (pfile, pend, name, path, 0);
315
316       /* Advance past this name.  */
317       if (*q == 0)
318         break;
319       p = q + 1;
320     }
321   while (1);
322 }
323
324 /* Append DIR to include path PATH.  DIR must be permanently allocated
325    and writable. */
326 static void
327 append_include_chain (pfile, pend, dir, path, cxx_aware)
328      cpp_reader *pfile;
329      struct cpp_pending *pend;
330      char *dir;
331      int path;
332      int cxx_aware;
333 {
334   struct file_name_list *new;
335   struct stat st;
336   unsigned int len;
337
338   _cpp_simplify_pathname (dir);
339   if (stat (dir, &st))
340     {
341       /* Dirs that don't exist are silently ignored. */
342       if (errno != ENOENT)
343         cpp_notice_from_errno (pfile, dir);
344       else if (CPP_OPTION (pfile, verbose))
345         fprintf (stderr, _("ignoring nonexistent directory `%s'\n"), dir);
346       return;
347     }
348
349   if (!S_ISDIR (st.st_mode))
350     {
351       cpp_notice (pfile, "%s: Not a directory", dir);
352       return;
353     }
354
355   len = strlen (dir);
356   if (len > pfile->max_include_len)
357     pfile->max_include_len = len;
358
359   new = (struct file_name_list *) xmalloc (sizeof (struct file_name_list));
360   new->name = dir;
361   new->nlen = len;
362   new->ino  = st.st_ino;
363   new->dev  = st.st_dev;
364   if (path == SYSTEM)
365     new->sysp = cxx_aware ? 1 : 2;
366   else
367     new->sysp = 0;
368   new->name_map = NULL;
369   new->next = NULL;
370   new->alloc = NULL;
371
372   switch (path)
373     {
374     case QUOTE:         APPEND (pend, quote, new); break;
375     case BRACKET:       APPEND (pend, brack, new); break;
376     case SYSTEM:        APPEND (pend, systm, new); break;
377     case AFTER:         APPEND (pend, after, new); break;
378     }
379 }
380
381 /* Merge the four include chains together in the order quote, bracket,
382    system, after.  Remove duplicate dirs (as determined by
383    INO_T_EQ()).  The system_include and after_include chains are never
384    referred to again after this function; all access is through the
385    bracket_include path.
386
387    For the future: Check if the directory is empty (but
388    how?) and possibly preload the include hash. */
389
390 static void
391 merge_include_chains (pfile)
392      cpp_reader *pfile;
393 {
394   struct file_name_list *prev, *cur, *other;
395   struct file_name_list *quote, *brack, *systm, *after;
396   struct file_name_list *qtail, *btail, *stail, *atail;
397
398   struct cpp_pending *pend = CPP_OPTION (pfile, pending);
399
400   qtail = pend->quote_tail;
401   btail = pend->brack_tail;
402   stail = pend->systm_tail;
403   atail = pend->after_tail;
404
405   quote = pend->quote_head;
406   brack = pend->brack_head;
407   systm = pend->systm_head;
408   after = pend->after_head;
409
410   /* Paste together bracket, system, and after include chains. */
411   if (stail)
412     stail->next = after;
413   else
414     systm = after;
415   if (btail)
416     btail->next = systm;
417   else
418     brack = systm;
419
420   /* This is a bit tricky.
421      First we drop dupes from the quote-include list.
422      Then we drop dupes from the bracket-include list.
423      Finally, if qtail and brack are the same directory,
424      we cut out qtail.
425
426      We can't just merge the lists and then uniquify them because
427      then we may lose directories from the <> search path that should
428      be there; consider -Ifoo -Ibar -I- -Ifoo -Iquux. It is however
429      safe to treat -Ibar -Ifoo -I- -Ifoo -Iquux as if written
430      -Ibar -I- -Ifoo -Iquux.
431
432      Note that this algorithm is quadratic in the number of -I switches,
433      which is acceptable since there aren't usually that many of them.  */
434
435   for (cur = quote, prev = NULL; cur; cur = cur->next)
436     {
437       for (other = quote; other != cur; other = other->next)
438         if (INO_T_EQ (cur->ino, other->ino)
439             && cur->dev == other->dev)
440           {
441             if (CPP_OPTION (pfile, verbose))
442               fprintf (stderr, _("ignoring duplicate directory `%s'\n"),
443                        cur->name);
444
445             prev->next = cur->next;
446             free (cur->name);
447             free (cur);
448             cur = prev;
449             break;
450           }
451       prev = cur;
452     }
453   qtail = prev;
454
455   for (cur = brack; cur; cur = cur->next)
456     {
457       for (other = brack; other != cur; other = other->next)
458         if (INO_T_EQ (cur->ino, other->ino)
459             && cur->dev == other->dev)
460           {
461             if (CPP_OPTION (pfile, verbose))
462               fprintf (stderr, _("ignoring duplicate directory `%s'\n"),
463                        cur->name);
464
465             prev->next = cur->next;
466             free (cur->name);
467             free (cur);
468             cur = prev;
469             break;
470           }
471       prev = cur;
472     }
473
474   if (quote)
475     {
476       if (INO_T_EQ (qtail->ino, brack->ino) && qtail->dev == brack->dev)
477         {
478           if (quote == qtail)
479             {
480               if (CPP_OPTION (pfile, verbose))
481                 fprintf (stderr, _("ignoring duplicate directory `%s'\n"),
482                          quote->name);
483
484               free (quote->name);
485               free (quote);
486               quote = brack;
487             }
488           else
489             {
490               cur = quote;
491               while (cur->next != qtail)
492                   cur = cur->next;
493               cur->next = brack;
494               if (CPP_OPTION (pfile, verbose))
495                 fprintf (stderr, _("ignoring duplicate directory `%s'\n"),
496                          qtail->name);
497
498               free (qtail->name);
499               free (qtail);
500             }
501         }
502       else
503           qtail->next = brack;
504     }
505   else
506       quote = brack;
507
508   CPP_OPTION (pfile, quote_include) = quote;
509   CPP_OPTION (pfile, bracket_include) = brack;
510 }
511
512
513 /* Write out a #define command for the special named MACRO_NAME
514    to PFILE's token_buffer.  */
515
516 static void
517 dump_special_to_buffer (pfile, macro_name)
518      cpp_reader *pfile;
519      const char *macro_name;
520 {
521   static const char define_directive[] = "#define ";
522   int macro_name_length = strlen (macro_name);
523   CPP_RESERVE (pfile, sizeof(define_directive) + macro_name_length);
524   CPP_PUTS_Q (pfile, define_directive, sizeof(define_directive)-1);
525   CPP_PUTS_Q (pfile, macro_name, macro_name_length);
526   CPP_PUTC_Q (pfile, ' ');
527   _cpp_expand_to_buffer (pfile, macro_name, macro_name_length);
528   CPP_PUTC (pfile, '\n');
529 }
530
531 /* Initialize a cpp_reader structure. */
532 void
533 cpp_reader_init (pfile)
534      cpp_reader *pfile;
535 {
536   memset ((char *) pfile, 0, sizeof (cpp_reader));
537
538   pfile->token_buffer_size = 200;
539   pfile->token_buffer = (U_CHAR *) xmalloc (pfile->token_buffer_size);
540   CPP_SET_WRITTEN (pfile, 0);
541
542   CPP_OPTION (pfile, dollars_in_ident) = 1;
543   CPP_OPTION (pfile, cplusplus_comments) = 1;
544   CPP_OPTION (pfile, warn_import) = 1;
545   CPP_OPTION (pfile, discard_comments) = 1;
546   CPP_OPTION (pfile, show_column) = 1;
547
548   CPP_OPTION (pfile, pending) =
549     (struct cpp_pending *) xcalloc (1, sizeof (struct cpp_pending));
550
551   _cpp_init_macro_hash (pfile);
552   _cpp_init_include_hash (pfile);
553 }
554
555 /* Initialize a cpp_printer structure.  As a side effect, open the
556    output file.  */
557 cpp_printer *
558 cpp_printer_init (pfile, print)
559      cpp_reader *pfile;
560      cpp_printer *print;
561 {
562   memset (print, '\0', sizeof (cpp_printer));
563   if (CPP_OPTION (pfile, out_fname) == NULL)
564     CPP_OPTION (pfile, out_fname) = "";
565   
566   if (CPP_OPTION (pfile, out_fname)[0] == '\0')
567     print->outf = stdout;
568   else
569     {
570       print->outf = fopen (CPP_OPTION (pfile, out_fname), "w");
571       if (! print->outf)
572         {
573           cpp_notice_from_errno (pfile, CPP_OPTION (pfile, out_fname));
574           return NULL;
575         }
576     }
577   return print;
578 }
579
580 /* Free resources used by PFILE.
581    This is the cpp_reader 'finalizer' or 'destructor' (in C++ terminology).  */
582 void
583 cpp_cleanup (pfile)
584      cpp_reader *pfile;
585 {
586   while (CPP_BUFFER (pfile) != NULL)
587     cpp_pop_buffer (pfile);
588
589   if (pfile->token_buffer)
590     {
591       free (pfile->token_buffer);
592       pfile->token_buffer = NULL;
593     }
594
595   if (pfile->input_buffer)
596     {
597       free (pfile->input_buffer);
598       pfile->input_buffer = NULL;
599       pfile->input_buffer_len = 0;
600     }
601
602   if (pfile->deps)
603     deps_free (pfile->deps);
604
605   htab_delete (pfile->hashtab);
606   htab_delete (pfile->all_include_files);
607 }
608
609
610 /* This structure defines one built-in macro.  A node of type TYPE will
611    be entered in the macro hash table under the name NAME, with value
612    VALUE (if any).  FLAGS tweaks the behavior a little:
613    DUMP         write debug info for this macro
614    VERS         value is the global version_string, quoted
615    ULP          value is the global user_label_prefix
616  */
617
618 struct builtin
619 {
620   const char *name;
621   const char *value;
622   unsigned short type;
623   unsigned short flags;
624 };
625 #define DUMP 0x01
626 #define VERS 0x02
627 #define ULP  0x04
628
629 static const struct builtin builtin_array[] =
630 {
631   { "__TIME__",                 0, T_TIME,              0 },
632   { "__DATE__",                 0, T_DATE,              0 },
633   { "__FILE__",                 0, T_FILE,              0 },
634   { "__BASE_FILE__",            0, T_BASE_FILE,         0 },
635   { "__LINE__",                 0, T_SPECLINE,          0 },
636   { "__INCLUDE_LEVEL__",        0, T_INCLUDE_LEVEL,     0 },
637
638   { "__VERSION__",              0,               T_MCONST, DUMP|VERS },
639   { "__USER_LABEL_PREFIX__",    0,               T_CONST,  DUMP|ULP  },
640   { "__STDC__",                 "1",             T_STDC,   DUMP },
641   { "__REGISTER_PREFIX__",      REGISTER_PREFIX, T_CONST,  DUMP },
642   { "__HAVE_BUILTIN_SETJMP__",  "1",             T_CONST,  DUMP },
643 #ifndef NO_BUILTIN_SIZE_TYPE
644   { "__SIZE_TYPE__",            SIZE_TYPE,       T_CONST,  DUMP },
645 #endif
646 #ifndef NO_BUILTIN_PTRDIFF_TYPE
647   { "__PTRDIFF_TYPE__",         PTRDIFF_TYPE,    T_CONST,  DUMP },
648 #endif
649 #ifndef NO_BUILTIN_WCHAR_TYPE
650   { "__WCHAR_TYPE__",           WCHAR_TYPE,      T_CONST,  DUMP },
651 #endif
652 };
653 #define builtin_array_end \
654  builtin_array + sizeof(builtin_array)/sizeof(struct builtin)
655
656 /* Subroutine of cpp_start_read; reads the builtins table above and
657    enters the macros into the hash table.  */
658 static void
659 initialize_builtins (pfile)
660      cpp_reader *pfile;
661 {
662   int len;
663   const struct builtin *b;
664   const char *val;
665   HASHNODE *hp;
666   for(b = builtin_array; b < builtin_array_end; b++)
667     {
668       if (b->type == T_STDC && CPP_TRADITIONAL (pfile))
669         continue;
670
671       if (b->flags & ULP)
672         val = user_label_prefix;
673       else if (b->flags & VERS)
674         {
675           val = xmalloc (strlen (version_string) + 3);
676           sprintf ((char *)val, "\"%s\"", version_string);
677         }
678       else
679         val = b->value;
680
681       len = strlen (b->name);
682       hp = _cpp_make_hashnode (b->name, len, b->type,
683                                _cpp_calc_hash (b->name, len));
684       hp->value.cpval = val;
685       *(htab_find_slot (pfile->hashtab, (void *) hp, INSERT)) = hp;
686
687       if ((b->flags & DUMP) && CPP_OPTION (pfile, debug_output))
688         dump_special_to_buffer (pfile, b->name);
689     }
690 }
691 #undef DUMP
692 #undef STDC
693 #undef VERS
694 #undef ULP
695
696 /* Another subroutine of cpp_start_read.  This one sets up to do
697    dependency-file output. */
698 static void
699 initialize_dependency_output (pfile)
700      cpp_reader *pfile;
701 {
702   char *spec, *s, *output_file;
703
704   /* Either of two environment variables can specify output of deps.
705      Its value is either "OUTPUT_FILE" or "OUTPUT_FILE DEPS_TARGET",
706      where OUTPUT_FILE is the file to write deps info to
707      and DEPS_TARGET is the target to mention in the deps.  */
708
709   if (CPP_OPTION (pfile, print_deps) == 0)
710     {
711       spec = getenv ("DEPENDENCIES_OUTPUT");
712       if (spec)
713         CPP_OPTION (pfile, print_deps) = 1;
714       else
715         {
716           spec = getenv ("SUNPRO_DEPENDENCIES");
717           if (spec)
718             CPP_OPTION (pfile, print_deps) = 2;
719           else
720             return;
721         }
722
723       /* Find the space before the DEPS_TARGET, if there is one.  */
724       s = strchr (spec, ' ');
725       if (s)
726         {
727           CPP_OPTION (pfile, deps_target) = s + 1;
728           output_file = (char *) xmalloc (s - spec + 1);
729           memcpy (output_file, spec, s - spec);
730           output_file[s - spec] = 0;
731         }
732       else
733         {
734           CPP_OPTION (pfile, deps_target) = 0;
735           output_file = spec;
736         }
737
738       CPP_OPTION (pfile, deps_file) = output_file;
739       CPP_OPTION (pfile, print_deps_append) = 1;
740     }
741
742   pfile->deps = deps_init ();
743
744   /* Print the expected object file name as the target of this Make-rule.  */
745   if (CPP_OPTION (pfile, deps_target))
746     deps_add_target (pfile->deps, CPP_OPTION (pfile, deps_target));
747   else if (*CPP_OPTION (pfile, in_fname) == 0)
748     deps_add_target (pfile->deps, "-");
749   else
750     deps_calc_target (pfile->deps, CPP_OPTION (pfile, in_fname));
751
752   if (CPP_OPTION (pfile, in_fname))
753     deps_add_dep (pfile->deps, CPP_OPTION (pfile, in_fname));
754 }
755
756 /* And another subroutine.  This one sets up the standard include path.  */
757 static void
758 initialize_standard_includes (pfile)
759      cpp_reader *pfile;
760 {
761   char *path;
762   const struct default_include *p;
763   const char *specd_prefix = CPP_OPTION (pfile, include_prefix);
764
765   /* Several environment variables may add to the include search path.
766      CPATH specifies an additional list of directories to be searched
767      as if specified with -I, while C_INCLUDE_PATH, CPLUS_INCLUDE_PATH,
768      etc. specify an additional list of directories to be searched as
769      if specified with -isystem, for the language indicated.  */
770
771   GET_ENV_PATH_LIST (path, "CPATH");
772   if (path != 0 && *path != 0)
773     path_include (pfile, CPP_OPTION (pfile, pending), path, BRACKET);
774
775   switch ((CPP_OPTION (pfile, objc) << 1) + CPP_OPTION (pfile, cplusplus))
776     {
777     case 0:
778       GET_ENV_PATH_LIST (path, "C_INCLUDE_PATH");
779       break;
780     case 1:
781       GET_ENV_PATH_LIST (path, "CPLUS_INCLUDE_PATH");
782       break;
783     case 2:
784       GET_ENV_PATH_LIST (path, "OBJC_INCLUDE_PATH");
785       break;
786     case 3:
787       GET_ENV_PATH_LIST (path, "OBJCPLUS_INCLUDE_PATH");
788       break;
789     }
790   if (path != 0 && *path != 0)
791     path_include (pfile, CPP_OPTION (pfile, pending), path, SYSTEM);
792
793   /* Search "translated" versions of GNU directories.
794      These have /usr/local/lib/gcc... replaced by specd_prefix.  */
795   if (specd_prefix != 0)
796     {
797       char *default_prefix = (char *) alloca (sizeof GCC_INCLUDE_DIR - 7);
798       /* Remove the `include' from /usr/local/lib/gcc.../include.
799          GCC_INCLUDE_DIR will always end in /include. */
800       int default_len = sizeof GCC_INCLUDE_DIR - 8;
801       int specd_len = strlen (specd_prefix);
802
803       memcpy (default_prefix, GCC_INCLUDE_DIR, default_len);
804       default_prefix[default_len] = '\0';
805
806       for (p = include_defaults_array; p->fname; p++)
807         {
808           /* Some standard dirs are only for C++.  */
809           if (!p->cplusplus
810               || (CPP_OPTION (pfile, cplusplus)
811                   && !CPP_OPTION (pfile, no_standard_cplusplus_includes)))
812             {
813               /* Does this dir start with the prefix?  */
814               if (!strncmp (p->fname, default_prefix, default_len))
815                 {
816                   /* Yes; change prefix and add to search list.  */
817                   int flen = strlen (p->fname);
818                   int this_len = specd_len + flen - default_len;
819                   char *str = (char *) xmalloc (this_len + 1);
820                   memcpy (str, specd_prefix, specd_len);
821                   memcpy (str + specd_len,
822                           p->fname + default_len,
823                           flen - default_len + 1);
824
825                   append_include_chain (pfile, CPP_OPTION (pfile, pending),
826                                         str, SYSTEM, p->cxx_aware);
827                 }
828             }
829         }
830     }
831
832   /* Search ordinary names for GNU include directories.  */
833   for (p = include_defaults_array; p->fname; p++)
834     {
835       /* Some standard dirs are only for C++.  */
836       if (!p->cplusplus
837           || (CPP_OPTION (pfile, cplusplus)
838               && !CPP_OPTION (pfile, no_standard_cplusplus_includes)))
839         {
840           /* XXX Potential memory leak! */
841           char *str = xstrdup (update_path (p->fname, p->component));
842           append_include_chain (pfile, CPP_OPTION (pfile, pending),
843                                 str, SYSTEM, p->cxx_aware);
844         }
845     }
846 }
847
848 /* This is called after options have been processed.
849  * Check options for consistency, and setup for processing input
850  * from the file named FNAME.  (Use standard input if FNAME==NULL.)
851  * Return 1 on success, 0 on failure.
852  */
853
854 int
855 cpp_start_read (pfile, print, fname)
856      cpp_reader *pfile;
857      cpp_printer *print;
858      const char *fname;
859 {
860   struct pending_option *p, *q;
861
862   /* -MG doesn't select the form of output and must be specified with one of
863      -M or -MM.  -MG doesn't make sense with -MD or -MMD since they don't
864      inhibit compilation.  */
865   if (CPP_OPTION (pfile, print_deps_missing_files)
866       && (CPP_OPTION (pfile, print_deps) == 0
867           || !CPP_OPTION (pfile, no_output)))
868     {
869       cpp_fatal (pfile, "-MG must be specified with one of -M or -MM");
870       return 0;
871     }
872
873   /* Chill should not be used with -trigraphs. */
874   if (CPP_OPTION (pfile, chill) && CPP_OPTION (pfile, trigraphs))
875     {
876       cpp_warning (pfile, "-lang-chill and -trigraphs are mutually exclusive");
877       CPP_OPTION (pfile, trigraphs) = 0;
878     }
879
880   /* -Wtraditional is not useful in C++ mode.  */
881   if (CPP_OPTION (pfile, cplusplus))
882     CPP_OPTION (pfile, warn_traditional) = 0;
883
884   /* Set this if it hasn't been set already. */
885   if (user_label_prefix == NULL)
886     user_label_prefix = USER_LABEL_PREFIX;
887
888   /* Don't bother trying to do macro expansion if we've already done
889      preprocessing.  */
890   if (CPP_OPTION (pfile, preprocessed))
891     pfile->no_macro_expand++;
892
893   /* Set up the IStable.  This doesn't do anything if we were compiled
894      with a compiler that supports C99 designated initializers.  */
895   init_IStable ();
896
897   /* Set up the tables used by read_and_prescan.  */
898   _cpp_init_input_buffer (pfile);
899
900   /* Set up the include search path now.  */
901   if (! CPP_OPTION (pfile, no_standard_includes))
902     initialize_standard_includes (pfile);
903
904   merge_include_chains (pfile);
905
906   /* With -v, print the list of dirs to search.  */
907   if (CPP_OPTION (pfile, verbose))
908     {
909       struct file_name_list *l;
910       fprintf (stderr, _("#include \"...\" search starts here:\n"));
911       for (l = CPP_OPTION (pfile, quote_include); l; l = l->next)
912         {
913           if (l == CPP_OPTION (pfile, bracket_include))
914             fprintf (stderr, _("#include <...> search starts here:\n"));
915           fprintf (stderr, " %s\n", l->name);
916         }
917       fprintf (stderr, _("End of search list.\n"));
918     }
919
920   /* Open the main input file.  This must be done early, so we have a
921      buffer to stand on.  */
922   if (CPP_OPTION (pfile, in_fname) == NULL
923       || *CPP_OPTION (pfile, in_fname) == 0)
924     {
925       CPP_OPTION (pfile, in_fname) = fname;
926       if (CPP_OPTION (pfile, in_fname) == NULL)
927         CPP_OPTION (pfile, in_fname) = "";
928     }
929   if (CPP_OPTION (pfile, out_fname) == NULL)
930     CPP_OPTION (pfile, out_fname) = "";
931
932   if (!cpp_read_file (pfile, fname))
933     return 0;
934
935   initialize_dependency_output (pfile);
936
937   /* -D and friends may produce output, which should be identified
938      as line 0.  */
939
940   CPP_BUFFER (pfile)->lineno = 0;
941
942   if (print)
943     {
944       print->lineno = 0;
945       print->last_fname = CPP_BUFFER (pfile)->nominal_fname;
946       print->last_bsd = pfile->buffer_stack_depth;
947       print->written = CPP_WRITTEN (pfile);
948     }
949
950   /* Install __LINE__, etc.  */
951   initialize_builtins (pfile);
952
953   /* Do -U's, -D's and -A's in the order they were seen.  */
954   p = CPP_OPTION (pfile, pending)->directive_head;
955   while (p)
956     {
957       (*p->handler) (pfile, p->arg);
958       q = p->next;
959       free (p);
960       p = q;
961     }
962   pfile->done_initializing = 1;
963   pfile->only_seen_white = 2;
964   CPP_BUFFER (pfile)->lineno = 1;
965   if (print && ! CPP_OPTION (pfile, no_output))
966     cpp_output_tokens (pfile, print);
967
968   /* The -imacros files can be scanned now, but the -include files
969      have to be pushed onto the include stack and processed later,
970      in the main loop calling cpp_get_token.  */
971
972   p = CPP_OPTION (pfile, pending)->imacros_head;
973   while (p)
974     {
975       if (cpp_read_file (pfile, p->arg))
976         cpp_scan_buffer_nooutput (pfile);
977       q = p->next;
978       free (p);
979       p = q;
980     }
981
982   p = CPP_OPTION (pfile, pending)->include_head;
983   while (p)
984     {
985       if (cpp_read_file (pfile, p->arg)
986           && print && ! CPP_OPTION (pfile, no_output))
987         cpp_output_tokens (pfile, print);
988       q = p->next;
989       free (p);
990       p = q;
991     }
992
993   free (CPP_OPTION (pfile, pending));
994   CPP_OPTION (pfile, pending) = NULL;
995
996   return 1;
997 }
998
999 /* This is called at the end of preprocessing.  It pops the
1000    last buffer and writes dependency output.  It should also
1001    clear macro definitions, such that you could call cpp_start_read
1002    with a new filename to restart processing. */
1003 void
1004 cpp_finish (pfile, print)
1005      cpp_reader *pfile;
1006      cpp_printer *print;
1007 {
1008   if (CPP_BUFFER (pfile))
1009     {
1010       cpp_ice (pfile, "buffers still stacked in cpp_finish");
1011       while (CPP_BUFFER (pfile))
1012         cpp_pop_buffer (pfile);
1013     }
1014
1015   /* Don't write the deps file if preprocessing has failed.  */
1016   if (CPP_OPTION (pfile, print_deps) && pfile->errors == 0)
1017     {
1018       /* Stream on which to print the dependency information.  */
1019       FILE *deps_stream = 0;
1020       const char *deps_mode
1021         = CPP_OPTION (pfile, print_deps_append) ? "a" : "w";
1022       if (CPP_OPTION (pfile, deps_file) == 0)
1023         deps_stream = stdout;
1024       else
1025         {
1026           deps_stream = fopen (CPP_OPTION (pfile, deps_file), deps_mode);
1027           if (deps_stream == 0)
1028             cpp_notice_from_errno (pfile, CPP_OPTION (pfile, deps_file));
1029         }
1030       if (deps_stream)
1031         {
1032           deps_write (pfile->deps, deps_stream, 72);
1033           if (CPP_OPTION (pfile, deps_file))
1034             {
1035               if (ferror (deps_stream) || fclose (deps_stream) != 0)
1036                 cpp_fatal (pfile, "I/O error on output");
1037             }
1038         }
1039     }
1040
1041   if (CPP_OPTION (pfile, dump_macros) == dump_only)
1042     _cpp_dump_macro_hash (pfile);
1043
1044   /* Flush any pending output.  */
1045   if (print)
1046     {
1047       cpp_output_tokens (pfile, print);
1048       if (ferror (print->outf) || fclose (print->outf))
1049         cpp_notice_from_errno (pfile, CPP_OPTION (pfile, out_fname));
1050     }
1051 }
1052
1053 static void
1054 new_pending_directive (pend, text, handler)
1055      struct cpp_pending *pend;
1056      const char *text;
1057      cl_directive_handler handler;
1058 {
1059   struct pending_option *o = (struct pending_option *)
1060     xmalloc (sizeof (struct pending_option));
1061
1062   o->arg = text;
1063   o->next = NULL;
1064   o->handler = handler;
1065   APPEND (pend, directive, o);
1066 }
1067
1068 /* Irix6 "cc -n32" and OSF4 cc have problems with char foo[] = ("string");
1069    I.e. a const string initializer with parens around it.  That is
1070    what N_("string") resolves to, so we make no_* be macros instead.  */
1071 #define no_arg N_("Argument missing after %s")
1072 #define no_ass N_("Assertion missing after %s")
1073 #define no_dir N_("Directory name missing after %s")
1074 #define no_fil N_("File name missing after %s")
1075 #define no_mac N_("Macro name missing after %s")
1076 #define no_pth N_("Path name missing after %s")
1077
1078 /* This is the list of all command line options, with the leading
1079    "-" removed.  It must be sorted in ASCII collating order.  */
1080 #define COMMAND_LINE_OPTIONS                                                  \
1081   DEF_OPT("",                         0,      OPT_stdin_stdout)               \
1082   DEF_OPT("$",                        0,      OPT_dollar)                     \
1083   DEF_OPT("+",                        0,      OPT_plus)                       \
1084   DEF_OPT("-help",                    0,      OPT__help)                      \
1085   DEF_OPT("-version",                 0,      OPT__version)                   \
1086   DEF_OPT("A",                        no_ass, OPT_A)                          \
1087   DEF_OPT("C",                        0,      OPT_C)                          \
1088   DEF_OPT("D",                        no_mac, OPT_D)                          \
1089   DEF_OPT("H",                        0,      OPT_H)                          \
1090   DEF_OPT("I",                        no_dir, OPT_I)                          \
1091   DEF_OPT("M",                        0,      OPT_M)                          \
1092   DEF_OPT("MD",                       no_fil, OPT_MD)                         \
1093   DEF_OPT("MG",                       0,      OPT_MG)                         \
1094   DEF_OPT("MM",                       0,      OPT_MM)                         \
1095   DEF_OPT("MMD",                      no_fil, OPT_MMD)                        \
1096   DEF_OPT("P",                        0,      OPT_P)                          \
1097   DEF_OPT("U",                        no_mac, OPT_U)                          \
1098   DEF_OPT("W",                        no_arg, OPT_W)  /* arg optional */      \
1099   DEF_OPT("d",                        no_arg, OPT_d)                          \
1100   DEF_OPT("fleading-underscore",      0,      OPT_fleading_underscore)        \
1101   DEF_OPT("fno-leading-underscore",   0,      OPT_fno_leading_underscore)     \
1102   DEF_OPT("fno-preprocessed",         0,      OPT_fno_preprocessed)           \
1103   DEF_OPT("fno-show-column",          0,      OPT_fno_show_column)            \
1104   DEF_OPT("fpreprocessed",            0,      OPT_fpreprocessed)              \
1105   DEF_OPT("fshow-column",             0,      OPT_fshow_column)               \
1106   DEF_OPT("g",                        no_arg, OPT_g)  /* arg optional */      \
1107   DEF_OPT("h",                        0,      OPT_h)                          \
1108   DEF_OPT("idirafter",                no_dir, OPT_idirafter)                  \
1109   DEF_OPT("imacros",                  no_fil, OPT_imacros)                    \
1110   DEF_OPT("include",                  no_fil, OPT_include)                    \
1111   DEF_OPT("iprefix",                  no_pth, OPT_iprefix)                    \
1112   DEF_OPT("isystem",                  no_dir, OPT_isystem)                    \
1113   DEF_OPT("iwithprefix",              no_dir, OPT_iwithprefix)                \
1114   DEF_OPT("iwithprefixbefore",        no_dir, OPT_iwithprefixbefore)          \
1115   DEF_OPT("lang-asm",                 0,      OPT_lang_asm)                   \
1116   DEF_OPT("lang-c",                   0,      OPT_lang_c)                     \
1117   DEF_OPT("lang-c++",                 0,      OPT_lang_cplusplus)             \
1118   DEF_OPT("lang-c89",                 0,      OPT_lang_c89)                   \
1119   DEF_OPT("lang-chill",               0,      OPT_lang_chill)                 \
1120   DEF_OPT("lang-fortran",             0,      OPT_lang_fortran)               \
1121   DEF_OPT("lang-objc",                0,      OPT_lang_objc)                  \
1122   DEF_OPT("lang-objc++",              0,      OPT_lang_objcplusplus)          \
1123   DEF_OPT("nostdinc",                 0,      OPT_nostdinc)                   \
1124   DEF_OPT("nostdinc++",               0,      OPT_nostdincplusplus)           \
1125   DEF_OPT("o",                        no_fil, OPT_o)                          \
1126   DEF_OPT("pedantic",                 0,      OPT_pedantic)                   \
1127   DEF_OPT("pedantic-errors",          0,      OPT_pedantic_errors)            \
1128   DEF_OPT("remap",                    0,      OPT_remap)                      \
1129   DEF_OPT("std=c89",                  0,      OPT_std_c89)                    \
1130   DEF_OPT("std=c99",                  0,      OPT_std_c99)                    \
1131   DEF_OPT("std=c9x",                  0,      OPT_std_c9x)                    \
1132   DEF_OPT("std=gnu89",                0,      OPT_std_gnu89)                  \
1133   DEF_OPT("std=gnu99",                0,      OPT_std_gnu99)                  \
1134   DEF_OPT("std=gnu9x",                0,      OPT_std_gnu9x)                  \
1135   DEF_OPT("std=iso9899:1990",         0,      OPT_std_iso9899_1990)           \
1136   DEF_OPT("std=iso9899:199409",       0,      OPT_std_iso9899_199409)         \
1137   DEF_OPT("std=iso9899:1999",         0,      OPT_std_iso9899_1999)           \
1138   DEF_OPT("std=iso9899:199x",         0,      OPT_std_iso9899_199x)           \
1139   DEF_OPT("traditional",              0,      OPT_traditional)                \
1140   DEF_OPT("trigraphs",                0,      OPT_trigraphs)                  \
1141   DEF_OPT("v",                        0,      OPT_v)                          \
1142   DEF_OPT("w",                        0,      OPT_w)
1143
1144 #define DEF_OPT(text, msg, code) code,
1145 enum opt_code
1146 {
1147   COMMAND_LINE_OPTIONS
1148   N_OPTS
1149 };
1150 #undef DEF_OPT
1151
1152 struct cl_option
1153 {
1154   const char *opt_text;
1155   const char *msg;
1156   size_t opt_len;
1157   enum opt_code opt_code;
1158 };
1159
1160 #define DEF_OPT(text, msg, code) { text, msg, sizeof(text) - 1, code },
1161 #ifdef HOST_EBCDIC
1162 static struct cl_option cl_options[] =
1163 #else
1164 static const struct cl_option cl_options[] =
1165 #endif
1166 {
1167   COMMAND_LINE_OPTIONS
1168 };
1169 #undef DEF_OPT
1170 #undef COMMAND_LINE_OPTIONS
1171
1172 /* Perform a binary search to find which, if any, option the given
1173    command-line matches.  Returns its index in the option array,
1174    negative on failure.  Complications arise since some options can be
1175    suffixed with an argument, and multiple complete matches can occur,
1176    e.g. -iwithprefix and -iwithprefixbefore.  Moreover, we want to
1177    accept options beginning with -g and -W that we do not recognise,
1178    but not to swallow any subsequent command line argument; these are
1179    handled as special cases in cpp_handle_option */
1180 static int
1181 parse_option (input)
1182      const char *input;
1183 {
1184   unsigned int md, mn, mx;
1185   size_t opt_len;
1186   int comp;
1187
1188   mn = 0;
1189   mx = N_OPTS;
1190
1191   while (mx > mn)
1192     {
1193       md = (mn + mx) / 2;
1194
1195       opt_len = cl_options[md].opt_len;
1196       comp = strncmp (input, cl_options[md].opt_text, opt_len);
1197
1198       if (comp > 0)
1199         mn = md + 1;
1200       else if (comp < 0)
1201         mx = md;
1202       else
1203         {
1204           if (input[opt_len] == '\0')
1205             return md;
1206           /* We were passed more text.  If the option takes an argument,
1207              we may match a later option or we may have been passed the
1208              argument.  The longest possible option match succeeds.
1209              If the option takes no arguments we have not matched and
1210              continue the search (e.g. input="stdc++" match was "stdc") */
1211           mn = md + 1;
1212           if (cl_options[md].msg)
1213             {
1214               /* Scan forwards.  If we get an exact match, return it.
1215                  Otherwise, return the longest option-accepting match.
1216                  This loops no more than twice with current options */
1217               mx = md;
1218               for (; mn < N_OPTS; mn++)
1219                 {
1220                   opt_len = cl_options[mn].opt_len;
1221                   if (strncmp (input, cl_options[mn].opt_text, opt_len))
1222                     break;
1223                   if (input[opt_len] == '\0')
1224                     return mn;
1225                   if (cl_options[mn].msg)
1226                     mx = mn;
1227                 }
1228               return mx;
1229             }
1230         }
1231     }
1232
1233   return -1;
1234 }
1235
1236 /* Handle one command-line option in (argc, argv).
1237    Can be called multiple times, to handle multiple sets of options.
1238    Returns number of strings consumed.  */
1239
1240 static int
1241 handle_option (pfile, argc, argv)
1242      cpp_reader *pfile;
1243      int argc;
1244      char **argv;
1245 {
1246   int i = 0;
1247
1248   if (argv[i][0] != '-')
1249     {
1250       if (CPP_OPTION (pfile, out_fname) != NULL)
1251         cpp_fatal (pfile, "Too many arguments. Type %s --help for usage info",
1252                    progname);
1253       else if (CPP_OPTION (pfile, in_fname) != NULL)
1254         CPP_OPTION (pfile, out_fname) = argv[i];
1255       else
1256         CPP_OPTION (pfile, in_fname) = argv[i];
1257     }
1258   else
1259     {
1260       enum opt_code opt_code;
1261       int opt_index;
1262       const char *arg = 0;
1263
1264       /* Skip over '-' */
1265       opt_index = parse_option (&argv[i][1]);
1266       if (opt_index < 0)
1267         return i;
1268
1269       opt_code = cl_options[opt_index].opt_code;
1270       if (cl_options[opt_index].msg)
1271         {
1272           arg = &argv[i][cl_options[opt_index].opt_len + 1];
1273
1274           /* Yuk. Special case for -g and -W as they must not swallow
1275              up any following argument.  If this becomes common, add
1276              another field to the cl_options table */
1277           if (arg[0] == '\0' && !(opt_code == OPT_g || opt_code == OPT_W))
1278             {
1279               arg = argv[++i];
1280               if (!arg)
1281                 {
1282                   cpp_fatal (pfile, cl_options[opt_index].msg, argv[i - 1]);
1283                   return argc;
1284                 }
1285             }
1286         }
1287
1288       switch (opt_code)
1289         {
1290         case N_OPTS: /* shut GCC up */
1291           break;
1292         case OPT_fleading_underscore:
1293           user_label_prefix = "_";
1294           break;
1295         case OPT_fno_leading_underscore:
1296           user_label_prefix = "";
1297           break;
1298         case OPT_fpreprocessed:
1299           CPP_OPTION (pfile, preprocessed) = 1;
1300           break;
1301         case OPT_fno_preprocessed:
1302           CPP_OPTION (pfile, preprocessed) = 0;
1303           break;
1304         case OPT_fshow_column:
1305           CPP_OPTION (pfile, show_column) = 1;
1306           break;
1307         case OPT_fno_show_column:
1308           CPP_OPTION (pfile, show_column) = 0;
1309           break;
1310         case OPT_w:
1311           CPP_OPTION (pfile, inhibit_warnings) = 1;
1312           break;
1313         case OPT_g:  /* Silently ignore anything but -g3 */
1314           if (!strcmp(&argv[i][2], "3"))
1315             CPP_OPTION (pfile, debug_output) = 1;
1316           break;
1317         case OPT_h:
1318         case OPT__help:
1319           print_help ();
1320           exit (0);  /* XXX */
1321           break;
1322         case OPT__version:
1323           fprintf (stderr, _("GNU CPP version %s (cpplib)\n"), version_string);
1324           exit (0);  /* XXX */
1325           break;
1326         case OPT_C:
1327           CPP_OPTION (pfile, discard_comments) = 0;
1328           break;
1329         case OPT_P:
1330           CPP_OPTION (pfile, no_line_commands) = 1;
1331           break;
1332         case OPT_dollar:                /* Don't include $ in identifiers.  */
1333           CPP_OPTION (pfile, dollars_in_ident) = 0;
1334           break;
1335         case OPT_H:
1336           CPP_OPTION (pfile, print_include_names) = 1;
1337           break;
1338         case OPT_D:
1339           new_pending_directive (CPP_OPTION (pfile, pending), arg, cpp_define);
1340           break;
1341         case OPT_pedantic_errors:
1342           CPP_OPTION (pfile, pedantic_errors) = 1;
1343           /* fall through */
1344         case OPT_pedantic:
1345           CPP_OPTION (pfile, pedantic) = 1;
1346           break;
1347         case OPT_traditional:
1348           CPP_OPTION (pfile, traditional) = 1;
1349           CPP_OPTION (pfile, cplusplus_comments) = 0;
1350           CPP_OPTION (pfile, trigraphs) = 0;
1351           CPP_OPTION (pfile, warn_trigraphs) = 0;
1352           break;
1353         case OPT_trigraphs:
1354           CPP_OPTION (pfile, trigraphs) = 1;
1355           break;
1356         case OPT_plus:
1357           CPP_OPTION (pfile, cplusplus) = 1;
1358           CPP_OPTION (pfile, cplusplus_comments) = 1;
1359           break;
1360         case OPT_remap:
1361           CPP_OPTION (pfile, remap) = 1;
1362           break;
1363         case OPT_iprefix:
1364           CPP_OPTION (pfile, include_prefix) = arg;
1365           CPP_OPTION (pfile, include_prefix_len) = strlen (arg);
1366           break;
1367         case OPT_lang_c:
1368           CPP_OPTION (pfile, cplusplus) = 0;
1369           CPP_OPTION (pfile, cplusplus_comments) = 1;
1370           CPP_OPTION (pfile, c89) = 0;
1371           CPP_OPTION (pfile, c99) = 1;
1372           CPP_OPTION (pfile, objc) = 0;
1373           break;
1374         case OPT_lang_c89:
1375           CPP_OPTION (pfile, cplusplus) = 0;
1376           CPP_OPTION (pfile, cplusplus_comments) = 0;
1377           CPP_OPTION (pfile, c89) = 1;
1378           CPP_OPTION (pfile, c99) = 0;
1379           CPP_OPTION (pfile, objc) = 0;
1380           CPP_OPTION (pfile, trigraphs) = 1;
1381           new_pending_directive (CPP_OPTION (pfile, pending),
1382                                  "__STRICT_ANSI__", cpp_define);
1383           break;
1384         case OPT_lang_cplusplus:
1385           CPP_OPTION (pfile, cplusplus) = 1;
1386           CPP_OPTION (pfile, cplusplus_comments) = 1;
1387           CPP_OPTION (pfile, c89) = 0;
1388           CPP_OPTION (pfile, c99) = 0;
1389           CPP_OPTION (pfile, objc) = 0;
1390           break;
1391         case OPT_lang_objc:
1392         case OPT_lang_objcplusplus:
1393           CPP_OPTION (pfile, cplusplus) = opt_code == OPT_lang_objcplusplus;
1394           CPP_OPTION (pfile, cplusplus_comments) = 1;
1395           CPP_OPTION (pfile, c89) = 0;
1396           CPP_OPTION (pfile, c99) = 0;
1397           CPP_OPTION (pfile, objc) = 1;
1398           break;
1399         case OPT_lang_asm:
1400           CPP_OPTION (pfile, lang_asm) = 1;
1401           break;
1402         case OPT_lang_fortran:
1403           CPP_OPTION (pfile, lang_fortran) = 1;
1404           CPP_OPTION (pfile, cplusplus_comments) = 0;
1405           break;
1406         case OPT_lang_chill:
1407           CPP_OPTION (pfile, objc) = 0;
1408           CPP_OPTION (pfile, cplusplus) = 0;
1409           CPP_OPTION (pfile, chill) = 1;
1410           CPP_OPTION (pfile, traditional) = 1;
1411           break;
1412         case OPT_nostdinc:
1413           /* -nostdinc causes no default include directories.
1414              You must specify all include-file directories with -I.  */
1415           CPP_OPTION (pfile, no_standard_includes) = 1;
1416           break;
1417         case OPT_nostdincplusplus:
1418           /* -nostdinc++ causes no default C++-specific include directories. */
1419           CPP_OPTION (pfile, no_standard_cplusplus_includes) = 1;
1420           break;
1421         case OPT_std_gnu89:
1422           CPP_OPTION (pfile, cplusplus) = 0;
1423           CPP_OPTION (pfile, cplusplus_comments) = 1;
1424           CPP_OPTION (pfile, c89) = 1;
1425           CPP_OPTION (pfile, c99) = 0;
1426           CPP_OPTION (pfile, objc) = 0;
1427           break;
1428         case OPT_std_gnu9x:
1429         case OPT_std_gnu99:
1430           CPP_OPTION (pfile, cplusplus) = 0;
1431           CPP_OPTION (pfile, cplusplus_comments) = 1;
1432           CPP_OPTION (pfile, c89) = 0;
1433           CPP_OPTION (pfile, c99) = 1;
1434           CPP_OPTION (pfile, objc) = 0;
1435           new_pending_directive (CPP_OPTION (pfile, pending),
1436                                  "__STDC_VERSION__=199901L", cpp_define);
1437           break;
1438         case OPT_std_iso9899_199409:
1439           new_pending_directive (CPP_OPTION (pfile, pending),
1440                                  "__STDC_VERSION__=199409L", cpp_define);
1441           /* Fall through */
1442         case OPT_std_iso9899_1990:
1443         case OPT_std_c89:
1444           CPP_OPTION (pfile, cplusplus) = 0;
1445           CPP_OPTION (pfile, cplusplus_comments) = 0;
1446           CPP_OPTION (pfile, c89) = 1;
1447           CPP_OPTION (pfile, c99) = 0;
1448           CPP_OPTION (pfile, objc) = 0;
1449           CPP_OPTION (pfile, trigraphs) = 1;
1450           new_pending_directive (CPP_OPTION (pfile, pending),
1451                                  "__STRICT_ANSI__", cpp_define);
1452           break;
1453         case OPT_std_iso9899_199x:
1454         case OPT_std_iso9899_1999:
1455         case OPT_std_c9x:
1456         case OPT_std_c99:
1457           CPP_OPTION (pfile, cplusplus) = 0;
1458           CPP_OPTION (pfile, cplusplus_comments) = 1;
1459           CPP_OPTION (pfile, c89) = 0;
1460           CPP_OPTION (pfile, c99) = 1;
1461           CPP_OPTION (pfile, objc) = 0;
1462           CPP_OPTION (pfile, trigraphs) = 1;
1463           new_pending_directive (CPP_OPTION (pfile, pending),
1464                                  "__STRICT_ANSI__", cpp_define);
1465           new_pending_directive (CPP_OPTION (pfile, pending),
1466                                  "__STDC_VERSION__=199901L", cpp_define);
1467           break;
1468         case OPT_o:
1469           if (CPP_OPTION (pfile, out_fname) != NULL)
1470             {
1471               cpp_fatal (pfile, "Output filename specified twice");
1472               return argc;
1473             }
1474           CPP_OPTION (pfile, out_fname) = arg;
1475           if (!strcmp (CPP_OPTION (pfile, out_fname), "-"))
1476             CPP_OPTION (pfile, out_fname) = "";
1477           break;
1478         case OPT_v:
1479           fprintf (stderr, _("GNU CPP version %s (cpplib)\n"), version_string);
1480 #ifdef TARGET_VERSION
1481           TARGET_VERSION;
1482 #endif
1483           fputc ('\n', stderr);
1484           CPP_OPTION (pfile, verbose) = 1;
1485           break;
1486         case OPT_stdin_stdout:
1487           /* JF handle '-' as file name meaning stdin or stdout */
1488           if (CPP_OPTION (pfile, in_fname) == NULL)
1489             CPP_OPTION (pfile, in_fname) = "";
1490           else if (CPP_OPTION (pfile, out_fname) == NULL)
1491             CPP_OPTION (pfile, out_fname) = "";
1492           break;
1493         case OPT_d:
1494           /* Args to -d specify what parts of macros to dump.
1495              Silently ignore unrecognised options; they may
1496              be aimed at the compiler proper. */
1497           {
1498             char c;
1499
1500             while ((c = *arg++) != '\0')
1501               switch (c)
1502                 {
1503                 case 'M':
1504                   CPP_OPTION (pfile, dump_macros) = dump_only;
1505                   CPP_OPTION (pfile, no_output) = 1;
1506                   break;
1507                 case 'N':
1508                   CPP_OPTION (pfile, dump_macros) = dump_names;
1509                   break;
1510                 case 'D':
1511                   CPP_OPTION (pfile, dump_macros) = dump_definitions;
1512                   break;
1513                 case 'I':
1514                   CPP_OPTION (pfile, dump_includes) = 1;
1515                   break;
1516                 }
1517           }
1518           break;
1519           /* The style of the choices here is a bit mixed.
1520              The chosen scheme is a hybrid of keeping all options in one string
1521              and specifying each option in a separate argument:
1522              -M|-MM|-MD file|-MMD file [-MG].  An alternative is:
1523              -M|-MM|-MD file|-MMD file|-MG|-MMG; or more concisely:
1524              -M[M][G][D file].  This is awkward to handle in specs, and is not
1525              as extensible.  */
1526           /* ??? -MG must be specified in addition to one of -M or -MM.
1527              This can be relaxed in the future without breaking anything.
1528              The converse isn't true.  */
1529
1530           /* -MG isn't valid with -MD or -MMD.  This is checked for later.  */
1531         case OPT_MG:
1532           CPP_OPTION (pfile, print_deps_missing_files) = 1;
1533           break;
1534         case OPT_M:
1535         case OPT_MD:
1536         case OPT_MM:
1537         case OPT_MMD:
1538           if (opt_code == OPT_M || opt_code == OPT_MD)
1539             CPP_OPTION (pfile, print_deps) = 2;
1540           else
1541             CPP_OPTION (pfile, print_deps) = 1;
1542
1543           /* For -MD and -MMD options, write deps on file named by next arg */
1544           /* For -M and -MM, write deps on standard output
1545              and suppress the usual output.  */
1546           if (opt_code == OPT_MD || opt_code == OPT_MMD)
1547               CPP_OPTION (pfile, deps_file) = arg;
1548           else
1549               CPP_OPTION (pfile, no_output) = 1;
1550           break;
1551         case OPT_A:
1552           if (arg[0] == '-')
1553             {
1554               /* -A with an argument beginning with '-' acts as
1555                  #unassert on whatever immediately follows the '-'.
1556                  If "-" is the whole argument, we eliminate all
1557                  predefined macros and assertions, including those
1558                  that were specified earlier on the command line.
1559                  That way we can get rid of any that were passed
1560                  automatically in from GCC.  */
1561
1562               if (arg[1] == '\0')
1563                 {
1564                   struct pending_option *o1, *o2;
1565
1566                   o1 = CPP_OPTION (pfile, pending)->directive_head;
1567                   while (o1)
1568                     {
1569                       o2 = o1->next;
1570                       free (o1);
1571                       o1 = o2;
1572                     }
1573                   CPP_OPTION (pfile, pending)->directive_head = NULL;
1574                   CPP_OPTION (pfile, pending)->directive_tail = NULL;
1575                 }
1576               else
1577                 new_pending_directive (CPP_OPTION (pfile, pending),
1578                                        arg + 1, cpp_unassert);
1579             }
1580           else
1581             new_pending_directive (CPP_OPTION (pfile, pending),
1582                                    arg, cpp_assert);
1583           break;
1584         case OPT_U:
1585           new_pending_directive (CPP_OPTION (pfile, pending), arg, cpp_undef);
1586           break;
1587         case OPT_I:           /* Add directory to path for includes.  */
1588           if (!strcmp (arg, "-"))
1589             {
1590               /* -I- means:
1591                  Use the preceding -I directories for #include "..."
1592                  but not #include <...>.
1593                  Don't search the directory of the present file
1594                  for #include "...".  (Note that -I. -I- is not the same as
1595                  the default setup; -I. uses the compiler's working dir.)  */
1596               if (! CPP_OPTION (pfile, ignore_srcdir))
1597                 {
1598                   struct cpp_pending *pend = CPP_OPTION (pfile, pending);
1599                   pend->quote_head = pend->brack_head;
1600                   pend->quote_tail = pend->brack_tail;
1601                   pend->brack_head = 0;
1602                   pend->brack_tail = 0;
1603                   CPP_OPTION (pfile, ignore_srcdir) = 1;
1604                 }
1605               else
1606                 {
1607                   cpp_fatal (pfile, "-I- specified twice");
1608                   return argc;
1609                 }
1610             }
1611           else
1612             append_include_chain (pfile, CPP_OPTION (pfile, pending),
1613                                   xstrdup (arg), BRACKET, 0);
1614           break;
1615         case OPT_isystem:
1616           /* Add directory to beginning of system include path, as a system
1617              include directory. */
1618           append_include_chain (pfile, CPP_OPTION (pfile, pending),
1619                                 xstrdup (arg), SYSTEM, 0);
1620           break;
1621         case OPT_include:
1622           {
1623             struct pending_option *o = (struct pending_option *)
1624               xmalloc (sizeof (struct pending_option));
1625             o->arg = arg;
1626
1627             /* This list has to be built in reverse order so that
1628                when cpp_start_read pushes all the -include files onto
1629                the buffer stack, they will be scanned in forward order.  */
1630             o->next = CPP_OPTION (pfile, pending)->include_head;
1631             CPP_OPTION (pfile, pending)->include_head = o;
1632           }
1633           break;
1634         case OPT_imacros:
1635           {
1636             struct pending_option *o = (struct pending_option *)
1637               xmalloc (sizeof (struct pending_option));
1638             o->arg = arg;
1639             o->next = NULL;
1640
1641             APPEND (CPP_OPTION (pfile, pending), imacros, o);
1642           }
1643           break;
1644         case OPT_iwithprefix:
1645           /* Add directory to end of path for includes,
1646              with the default prefix at the front of its name.  */
1647           /* fall through */
1648         case OPT_iwithprefixbefore:
1649           /* Add directory to main path for includes,
1650              with the default prefix at the front of its name.  */
1651           {
1652             char *fname;
1653             int len;
1654
1655             len = strlen (arg);
1656
1657             if (CPP_OPTION (pfile, include_prefix) != 0)
1658               {
1659                 size_t ipl = CPP_OPTION (pfile, include_prefix_len);
1660                 fname = xmalloc (ipl + len + 1);
1661                 memcpy (fname, CPP_OPTION (pfile, include_prefix), ipl);
1662                 memcpy (fname + ipl, arg, len + 1);
1663               }
1664             else
1665               {
1666                 fname = xmalloc (sizeof GCC_INCLUDE_DIR - 8 + len);
1667                 memcpy (fname, GCC_INCLUDE_DIR, sizeof GCC_INCLUDE_DIR - 9);
1668                 memcpy (fname + sizeof GCC_INCLUDE_DIR - 9, arg, len + 1);
1669               }
1670
1671             append_include_chain (pfile, CPP_OPTION (pfile, pending), fname,
1672                           opt_code == OPT_iwithprefix ? SYSTEM: BRACKET, 0);
1673           }
1674           break;
1675         case OPT_idirafter:
1676           /* Add directory to end of path for includes.  */
1677           append_include_chain (pfile, CPP_OPTION (pfile, pending),
1678                                 xstrdup (arg), AFTER, 0);
1679           break;
1680         case OPT_W:
1681           /* Silently ignore unrecognised options */
1682           if (!strcmp (argv[i], "-Wall"))
1683             {
1684               CPP_OPTION (pfile, warn_trigraphs) = 1;
1685               CPP_OPTION (pfile, warn_comments) = 1;
1686             }
1687           else if (!strcmp (argv[i], "-Wtraditional"))
1688             CPP_OPTION (pfile, warn_traditional) = 1;
1689           else if (!strcmp (argv[i], "-Wtrigraphs"))
1690             CPP_OPTION (pfile, warn_trigraphs) = 1;
1691           else if (!strcmp (argv[i], "-Wcomment"))
1692             CPP_OPTION (pfile, warn_comments) = 1;
1693           else if (!strcmp (argv[i], "-Wcomments"))
1694             CPP_OPTION (pfile, warn_comments) = 1;
1695           else if (!strcmp (argv[i], "-Wundef"))
1696             CPP_OPTION (pfile, warn_undef) = 1;
1697           else if (!strcmp (argv[i], "-Wimport"))
1698             CPP_OPTION (pfile, warn_import) = 1;
1699           else if (!strcmp (argv[i], "-Werror"))
1700             CPP_OPTION (pfile, warnings_are_errors) = 1;
1701           else if (!strcmp (argv[i], "-Wno-traditional"))
1702             CPP_OPTION (pfile, warn_traditional) = 0;
1703           else if (!strcmp (argv[i], "-Wno-trigraphs"))
1704             CPP_OPTION (pfile, warn_trigraphs) = 0;
1705           else if (!strcmp (argv[i], "-Wno-comment"))
1706             CPP_OPTION (pfile, warn_comments) = 0;
1707           else if (!strcmp (argv[i], "-Wno-comments"))
1708             CPP_OPTION (pfile, warn_comments) = 0;
1709           else if (!strcmp (argv[i], "-Wno-undef"))
1710             CPP_OPTION (pfile, warn_undef) = 0;
1711           else if (!strcmp (argv[i], "-Wno-import"))
1712             CPP_OPTION (pfile, warn_import) = 0;
1713           else if (!strcmp (argv[i], "-Wno-error"))
1714             CPP_OPTION (pfile, warnings_are_errors) = 0;
1715           break;
1716         }
1717     }
1718   return i + 1;
1719 }
1720
1721 #ifdef HOST_EBCDIC
1722 static int
1723 opt_comp (const void *p1, const void *p2)
1724 {
1725   return strcmp (((struct cl_option *)p1)->opt_text,
1726                  ((struct cl_option *)p2)->opt_text);
1727 }
1728 #endif
1729
1730 /* Handle command-line options in (argc, argv).
1731    Can be called multiple times, to handle multiple sets of options.
1732    Returns if an unrecognized option is seen.
1733    Returns number of strings consumed.  */
1734 int
1735 cpp_handle_options (pfile, argc, argv)
1736      cpp_reader *pfile;
1737      int argc;
1738      char **argv;
1739 {
1740   int i;
1741   int strings_processed;
1742
1743 #ifdef HOST_EBCDIC
1744   static int opts_sorted = 0;
1745
1746   if (!opts_sorted)
1747     {
1748       opts_sorted = 1;
1749       /* For non-ASCII hosts, the array needs to be sorted at runtime */
1750       qsort (cl_options, N_OPTS, sizeof (struct cl_option), opt_comp);
1751     }
1752 #endif
1753
1754   for (i = 0; i < argc; i += strings_processed)
1755     {
1756       strings_processed = handle_option (pfile, argc - i, argv + i);
1757       if (strings_processed == 0)
1758         break;
1759     }
1760   return i;
1761 }
1762
1763 static void
1764 print_help ()
1765 {
1766   fprintf (stderr, _("Usage: %s [switches] input output\n"), progname);
1767   fputs (_("\
1768 Switches:\n\
1769   -include <file>           Include the contents of <file> before other files\n\
1770   -imacros <file>           Accept definition of macros in <file>\n\
1771   -iprefix <path>           Specify <path> as a prefix for next two options\n\
1772   -iwithprefix <dir>        Add <dir> to the end of the system include path\n\
1773   -iwithprefixbefore <dir>  Add <dir> to the end of the main include path\n\
1774   -isystem <dir>            Add <dir> to the start of the system include path\n\
1775   -idirafter <dir>          Add <dir> to the end of the system include path\n\
1776   -I <dir>                  Add <dir> to the end of the main include path\n\
1777   -I-                       Fine-grained include path control; see info docs\n\
1778   -nostdinc                 Do not search system include directories\n\
1779                              (dirs specified with -isystem will still be used)\n\
1780   -nostdinc++               Do not search system include directories for C++\n\
1781   -o <file>                 Put output into <file>\n\
1782   -pedantic                 Issue all warnings demanded by strict ANSI C\n\
1783   -pedantic-errors          Issue -pedantic warnings as errors instead\n\
1784   -traditional              Follow K&R pre-processor behaviour\n\
1785   -trigraphs                Support ANSI C trigraphs\n\
1786   -lang-c                   Assume that the input sources are in C\n\
1787   -lang-c89                 Assume that the input sources are in C89\n\
1788   -lang-c++                 Assume that the input sources are in C++\n\
1789   -lang-objc                Assume that the input sources are in ObjectiveC\n\
1790   -lang-objc++              Assume that the input sources are in ObjectiveC++\n\
1791   -lang-asm                 Assume that the input sources are in assembler\n\
1792   -lang-fortran             Assume that the input sources are in Fortran\n\
1793   -lang-chill               Assume that the input sources are in Chill\n\
1794   -std=<std name>           Specify the conformance standard; one of:\n\
1795                             gnu89, gnu99, c89, c99, iso9899:1990,\n\
1796                             iso9899:199409, iso9899:1999\n\
1797   -+                        Allow parsing of C++ style features\n\
1798   -w                        Inhibit warning messages\n\
1799   -Wtrigraphs               Warn if trigraphs are encountered\n\
1800   -Wno-trigraphs            Do not warn about trigraphs\n\
1801   -Wcomment{s}              Warn if one comment starts inside another\n\
1802   -Wno-comment{s}           Do not warn about comments\n\
1803   -Wtraditional             Warn if a macro argument is/would be turned into\n\
1804                              a string if -traditional is specified\n\
1805   -Wno-traditional          Do not warn about stringification\n\
1806   -Wundef                   Warn if an undefined macro is used by #if\n\
1807   -Wno-undef                Do not warn about testing undefined macros\n\
1808   -Wimport                  Warn about the use of the #import directive\n\
1809   -Wno-import               Do not warn about the use of #import\n\
1810   -Werror                   Treat all warnings as errors\n\
1811   -Wno-error                Do not treat warnings as errors\n\
1812   -Wall                     Enable all preprocessor warnings\n\
1813   -M                        Generate make dependencies\n\
1814   -MM                       As -M, but ignore system header files\n\
1815   -MD                       As -M, but put output in a .d file\n\
1816   -MMD                      As -MD, but ignore system header files\n\
1817   -MG                       Treat missing header file as generated files\n\
1818   -g3                       Include #define and #undef directives in the output\n\
1819   -D<macro>                 Define a <macro> with string '1' as its value\n\
1820   -D<macro>=<val>           Define a <macro> with <val> as its value\n\
1821   -A<question> (<answer>)   Assert the <answer> to <question>\n\
1822   -A-<question> (<answer>)  Disable the <answer> to <question>\n\
1823   -U<macro>                 Undefine <macro> \n\
1824   -v                        Display the version number\n\
1825   -H                        Print the name of header files as they are used\n\
1826   -C                        Do not discard comments\n\
1827   -dM                       Display a list of macro definitions active at end\n\
1828   -dD                       Preserve macro definitions in output\n\
1829   -dN                       As -dD except that only the names are preserved\n\
1830   -dI                       Include #include directives in the output\n\
1831   -P                        Do not generate #line directives\n\
1832   -$                        Do not allow '$' in identifiers\n\
1833   -remap                    Remap file names when including files.\n\
1834   --version                 Display version information\n\
1835   -h or --help              Display this information\n\
1836 "), stdout);
1837 }