OSDN Git Service

(gen_lowpart_common): When converting a floating point value into an
[pf3gnuchains/gcc-fork.git] / gcc / cpplib.c
index 65d6112..24ac342 100644 (file)
@@ -1,5 +1,5 @@
 /* CPP Library.
-   Copyright (C) 1986, 87, 89, 92, 93, 94, 1995 Free Software Foundation, Inc.
+   Copyright (C) 1986, 87, 89, 92-5, 1996 Free Software Foundation, Inc.
    Written by Per Bothner, 1994-95.
    Based on CCCP program by by Paul Rubin, June 1986
    Adapted to ANSI C, Richard Stallman, Jan 1987
@@ -78,14 +78,13 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 #include <sys/time.h>          /* for __DATE__ and __TIME__ */
 #include <sys/resource.h>
 #else
-#include <sys/param.h>                 /* CYGNUS LOCAL: shebs -noquiet */
 #include <sys/times.h>
 #include <time.h>
 #include <fcntl.h>
 #endif /* USG */
 #endif /* not VMS */
 
-/* This defines "errno" properly for VMS, and gives us EACCES. */
+/* This defines "errno" properly for VMS, and gives us EACCES.  */
 #include <errno.h>
 
 extern char *index ();
@@ -137,7 +136,7 @@ extern char *rindex ();
 #endif
 
 #ifndef NULL_PTR
-#define NULL_PTR ((GENERIC_PTR)0)
+#define NULL_PTR ((GENERIC_PTR) 0)
 #endif
 
 #ifndef INCLUDE_LEN_FUDGE
@@ -205,7 +204,7 @@ struct assertion_hashnode {
   struct assertion_hashnode *prev;
   /* also, a back pointer to this node's hash
      chain is kept, in case the node is the head
-     of the chain and gets deleted. */
+     of the chain and gets deleted.  */
   struct assertion_hashnode **bucket_hdr;
   int length;                  /* length of token, for quick comparison */
   U_CHAR *name;                        /* the actual name */
@@ -234,15 +233,11 @@ struct assertion_hashnode {
 #define NEWLINE_FIX \
   do {while (PEEKC() == '\\' && PEEKN(1) == '\n') FORWARD(2); } while(0)
 
-/* Same, but assume we've already read the potential '\\' into C. */
+/* Same, but assume we've already read the potential '\\' into C.  */
 #define NEWLINE_FIX1(C) do { \
     while ((C) == '\\' && PEEKC() == '\n') { FORWARD(1); (C) = GETC(); }\
   } while(0)
 
-/* Name under which this program was invoked.  */
-
-char *progname;
-
 struct cpp_pending {
   struct cpp_pending *next;
   char *cmd;
@@ -267,7 +262,9 @@ static void trigraph_pcp ();
 static int finclude ();
 static void validate_else ();
 static int comp_def_part ();
+#ifdef abort
 extern void fancy_abort ();
+#endif
 static void pipe_closed ();
 static void print_containing_files ();
 static int lookup_import ();
@@ -290,10 +287,10 @@ static struct arglist *read_token_list ();
 static void free_token_list ();
 static int safe_read ();
 static void push_macro_expansion PARAMS ((cpp_reader *,
-                                         U_CHAR*, int, HASHNODE*));
-static struct cpp_pending *nreverse_pending PARAMS ((struct cpp_pending*));
+                                         U_CHAR *, int, HASHNODE *));
+static struct cpp_pending *nreverse_pending PARAMS ((struct cpp_pending *));
 extern char *xrealloc ();
-extern char *xcalloc ();
+static char *xcalloc ();
 static char *savestring ();
 
 static void conditional_skip ();
@@ -304,7 +301,7 @@ enum file_change_code {same_file, enter_file, leave_file};
 
 /* External declarations.  */
 
-extern HOST_WIDE_INT cpp_parse_expr PARAMS ((cpp_reader*));
+extern HOST_WIDE_INT cpp_parse_expr PARAMS ((cpp_reader *));
 
 extern char *getenv ();
 extern FILE *fdopen ();
@@ -350,12 +347,12 @@ struct file_name_list
   };
 
 /* If a buffer's dir field is SELF_DIR_DUMMY, it means the file was found
-   via the same directory as the file that #included it. */
-#define SELF_DIR_DUMMY ((struct file_name_list*)(~0))
+   via the same directory as the file that #included it.  */
+#define SELF_DIR_DUMMY ((struct file_name_list *) (~0))
 
-/* #include "file" looks in source file dir, then stack. */
-/* #include <file> just looks in the stack. */
-/* -I directories are added to the end, then the defaults are added. */
+/* #include "file" looks in source file dir, then stack.  */
+/* #include <file> just looks in the stack.  */
+/* -I directories are added to the end, then the defaults are added.  */
 /* The */
 static struct default_include {
   char *fname;                 /* The name of the directory.  */
@@ -370,6 +367,7 @@ static struct default_include {
   = {
     /* Pick up GNU C++ specific include files.  */
     { GPLUSPLUS_INCLUDE_DIR, 1, 1 },
+    { OLD_GPLUSPLUS_INCLUDE_DIR, 1, 1 },
 #ifdef CROSS_COMPILE
     /* This is the dir for fixincludes.  Put it just before
        the files that we fix.  */
@@ -405,8 +403,8 @@ struct directive {
   int length;                  /* Length of name */
   int (*func)();               /* Function to handle directive */
   char *name;                  /* Name of directive */
-  enum node_type type;         /* Code which describes which directive. */
-  char command_reads_line;      /* One if rest of line is read by func. */
+  enum node_type type;         /* Code which describes which directive.  */
+  char command_reads_line;      /* One if rest of line is read by func.  */
   char traditional_comments;   /* Nonzero: keep comments if -traditional.  */
   char pass_thru;              /* Copy preprocessed directive to output file.*/
 };
@@ -439,9 +437,9 @@ static struct directive directive_table[] = {
   {  -1, 0, "", T_UNUSED},
 };
 \f
-/* table to tell if char can be part of a C identifier. */
+/* table to tell if char can be part of a C identifier.  */
 U_CHAR is_idchar[256];
-/* table to tell if char can be first char of a c identifier. */
+/* table to tell if char can be first char of a c identifier.  */
 U_CHAR is_idstart[256];
 /* table to tell if c is horizontal space.  */
 U_CHAR is_hor_space[256];
@@ -492,7 +490,8 @@ initialize_char_syntax (opts)
 
 
 /* Place into PFILE a quoted string representing the string SRC.
-   Caller must reserve enough space in pfile->token_buffer. */
+   Caller must reserve enough space in pfile->token_buffer.  */
+
 static void
 quote_string (pfile, src)
      cpp_reader *pfile;
@@ -527,7 +526,7 @@ quote_string (pfile, src)
       }
 }
 
-/* Make sure PFILE->token_buffer will hold at least N more chars. */
+/* Re-allocates PFILE->token_buffer so it will hold at least N more chars.  */
 
 void
 cpp_grow_buffer (pfile, n)
@@ -536,7 +535,7 @@ cpp_grow_buffer (pfile, n)
 {
   long old_written = CPP_WRITTEN (pfile);
   pfile->token_buffer_size = n + 2 * pfile->token_buffer_size;
-  pfile->token_buffer = (U_CHAR*)
+  pfile->token_buffer = (U_CHAR *)
     xrealloc(pfile->token_buffer, pfile->token_buffer_size);
   CPP_SET_WRITTEN (pfile, old_written);
 }
@@ -609,7 +608,6 @@ make_assertion (pfile, option, str)
      char *option;
      U_CHAR *str;
 {
-  cpp_buffer *ip;
   struct directive *kt;
   U_CHAR *buf, *p, *q;
 
@@ -641,9 +639,11 @@ make_assertion (pfile, option, str)
     return;
   }
   
-  ip = cpp_push_buffer (pfile, buf, strlen (buf));
-  do_assert (pfile, NULL, NULL, NULL);
-  cpp_pop_buffer (pfile);
+  if (cpp_push_buffer (pfile, buf, strlen (buf)) != NULL)
+    {
+      do_assert (pfile, NULL, NULL, NULL);
+      cpp_pop_buffer (pfile);
+    }
 }
 \f
 /* Append a chain of `struct file_name_list's
@@ -775,8 +775,8 @@ path_include (pfile, path)
 }
 \f
 void
-init_parse_options (opts)
-     struct cpp_options *opts;
+cpp_options_init (opts)
+     cpp_options *opts;
 {
   bzero ((char *) opts, sizeof *opts);
   opts->in_fname = NULL;
@@ -785,7 +785,6 @@ init_parse_options (opts)
   /* Initialize is_idchar to allow $.  */
   opts->dollars_in_ident = 1;
   initialize_char_syntax (opts);
-  opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS > 0;
 
   opts->no_line_commands = 0;
   opts->no_trigraphs = 1;
@@ -828,7 +827,7 @@ macro_cleanup (pbuf, pfile)
      cpp_buffer *pbuf;
      cpp_reader *pfile;
 {
-  HASHNODE *macro = (HASHNODE*)pbuf->data;
+  HASHNODE *macro = (HASHNODE *) pbuf->data;
   if (macro->type == T_DISABLED)
     macro->type = T_MACRO;
   if (macro->type != T_MACRO || pbuf->buf != macro->value.defn->expansion)
@@ -849,52 +848,18 @@ file_cleanup (pbuf, pfile)
   return 0;
 }
 
-static void
-newline_fix (pfile)
-     cpp_reader *pfile;
-{
-#if 1
-  NEWLINE_FIX;
-#else
-  register U_CHAR *p = bp;
-
-  /* First count the backslash-newline pairs here.  */
-
-  while (p[0] == '\\' && p[1] == '\n')
-    p += 2;
-
-  /* What follows the backslash-newlines is not embarrassing.  */
-
-  if (*p != '/' && *p != '*')
-    return;
-
-  /* Copy all potentially embarrassing characters
-     that follow the backslash-newline pairs
-     down to where the pairs originally started.  */
-
-  while (*p == '*' || *p == '/')
-    *bp++ = *p++;
-
-  /* Now write the same number of pairs after the embarrassing chars.  */
-  while (bp < p) {
-    *bp++ = '\\';
-    *bp++ = '\n';
-  }
-#endif
-}
-
 /* Assuming we have read '/'.
    If this is the start of a comment (followed by '*' or '/'),
    skip to the end of the comment, and return ' '.
    Return EOF if we reached the end of file before the end of the comment.
-   If not the start of a comment, return '/'. */
+   If not the start of a comment, return '/'.  */
 
 static int
 skip_comment (pfile, linep)
      cpp_reader *pfile;
      long *linep;
 {
-  int c;
+  int c = 0;
   while (PEEKC() == '\\' && PEEKN(1) == '\n')
     {
       if (linep)
@@ -929,7 +894,7 @@ skip_comment (pfile, linep)
        {
          c = GETC ();
          if (c == EOF)
-           return ' '; /* Allow // to be terminated by EOF. */
+           return ' '; /* Allow // to be terminated by EOF.  */
          while (c == '\\' && PEEKC() == '\n')
            {
              FORWARD(1);
@@ -939,7 +904,7 @@ skip_comment (pfile, linep)
            }
          if (c == '\n')
            {
-             /* Don't consider final '\n' to be part of comment. */
+             /* Don't consider final '\n' to be part of comment.  */
              FORWARD(-1);
              return ' ';
            }
@@ -950,6 +915,7 @@ skip_comment (pfile, linep)
 }     
 
 /* Skip whitespace \-newline and comments.  Does not macro-expand.  */
+
 void
 cpp_skip_hspace (pfile)
      cpp_reader *pfile;
@@ -986,9 +952,9 @@ cpp_skip_hspace (pfile)
 }
 
 /* Read the rest of the current line.
-   The line is appended to PFILE's output buffer. */
+   The line is appended to PFILE's output buffer.  */
 
-void
+static void
 copy_rest_of_line (pfile)
      cpp_reader *pfile;
 {
@@ -1071,7 +1037,7 @@ handle_directive (pfile)
       goto done_a_directive;
     }
 
-  /* Now find the directive name. */
+  /* Now find the directive name.  */
   CPP_PUTC (pfile, '#');
   parse_name (pfile, GETC());
   ident = pfile->token_buffer + old_written + 1;
@@ -1117,7 +1083,9 @@ handle_directive (pfile)
       break;
   }
 
-  if (! kt->command_reads_line)
+  if (kt->command_reads_line)
+    after_ident = 0;
+  else
     {
       /* Nonzero means do not delete comments within the directive.
          #define needs this when -traditional.  */
@@ -1147,7 +1115,7 @@ handle_directive (pfile)
       || (kt->type == T_DEFINE
          && CPP_OPTIONS (pfile)->dump_macros == dump_definitions))
     {
-      /* Just leave the entire #define in the output stack. */
+      /* Just leave the entire #define in the output stack.  */
     }
   else if (kt->type == T_DEFINE
           && CPP_OPTIONS (pfile)->dump_macros == dump_names)
@@ -1203,7 +1171,7 @@ pass_thru_directive (buf, limit, pfile, keyword)
    appeared.  So the arglist is just convenience data passed
    between these two routines.  It is not kept around after
    the current #define has been processed and entered into the
-   hash table. */
+   hash table.  */
 
 struct arglist {
   struct arglist *next;
@@ -1245,7 +1213,7 @@ collect_expansion (pfile, buf, limit, nargs, arglist)
   /* Scan thru the replacement list, ignoring comments and quoted
      strings, picking up on the macro calls.  It does a linear search
      thru the arg list on every potential symbol.  Profiling might say
-     that something smarter should happen. */
+     that something smarter should happen.  */
 
   if (limit < buf)
     abort ();
@@ -1261,7 +1229,7 @@ collect_expansion (pfile, buf, limit, nargs, arglist)
      leading and trailing newline-marker and final null.  */
   maxsize = (sizeof (DEFINITION)
             + (limit - p) + 5);
-  /* Occurrences of '@' get doubled, so allocate extra space for them. */
+  /* Occurrences of '@' get doubled, so allocate extra space for them.  */
   while (p < limit)
     if (*p++ == '@')
       maxsize++;
@@ -1274,7 +1242,7 @@ collect_expansion (pfile, buf, limit, nargs, arglist)
   p = buf;
 
   /* Add one initial space escape-marker to prevent accidental
-     token-pasting (often removed by macroexpand). */
+     token-pasting (often removed by macroexpand).  */
   *exp_p++ = '@';
   *exp_p++ = ' ';
 
@@ -1311,7 +1279,7 @@ collect_expansion (pfile, buf, limit, nargs, arglist)
 
       case '@':
        /* An '@' in a string or character constant stands for itself,
-          and does not need to be escaped. */
+          and does not need to be escaped.  */
        if (!expected_delimiter)
          *exp_p++ = c;
        break;
@@ -1508,7 +1476,8 @@ static char rest_extension[] = "...";
 #define REST_EXTENSION_LENGTH  (sizeof (rest_extension) - 1)
 
 /* Create a DEFINITION node from a #define directive.  Arguments are 
-   as for do_define. */
+   as for do_define.  */
+
 static MACRODEF
 create_definition (buf, limit, pfile, predefinition)
      U_CHAR *buf, *limit;
@@ -1539,7 +1508,7 @@ create_definition (buf, limit, pfile, predefinition)
 
   /* Lossage will occur if identifiers or control keywords are broken
      across lines using backslash.  This is not the right place to take
-     care of that. */
+     care of that.  */
 
   if (*bp == '(') {
     struct arglist *arg_ptrs = NULL;
@@ -1613,7 +1582,7 @@ create_definition (buf, limit, pfile, predefinition)
 
     ++bp;                      /* skip paren */
     SKIP_WHITE_SPACE (bp);
-    /* now everything from bp before limit is the definition. */
+    /* now everything from bp before limit is the definition.  */
     defn = collect_expansion (pfile, bp, limit, argno, arg_ptrs);
     defn->rest_args = rest_args;
 
@@ -1660,7 +1629,7 @@ create_definition (buf, limit, pfile, predefinition)
          }
        }
       }
-    /* now everything from bp before limit is the definition. */
+    /* now everything from bp before limit is the definition.  */
     defn = collect_expansion (pfile, bp, limit, -1, NULL_PTR);
     defn->args.argnames = (U_CHAR *) "";
   }
@@ -1699,7 +1668,7 @@ check_macro_name (pfile, symname, usage)
   if (sym_length == 0)
     cpp_error (pfile, "invalid %s name", usage);
   else if (!is_idstart[*symname]) {
-    U_CHAR *msg;                       /* what pain... */
+    U_CHAR *msg;                       /* what pain...  */
     msg = (U_CHAR *) alloca (sym_length + 1);
     bcopy (symname, msg, sym_length);
     msg[sym_length] = 0;
@@ -1711,9 +1680,8 @@ check_macro_name (pfile, symname, usage)
   return sym_length;
 }
 
-/*
- * return zero if two DEFINITIONs are isomorphic
- */
+/* Return zero if two DEFINITIONs are isomorphic.  */
+
 static int
 compare_defs (d1, d2)
      DEFINITION *d1, *d2;
@@ -1828,7 +1796,7 @@ do_define (pfile, keyword, buf, limit)
       /* Print the warning if it's not ok.  */
       if (!ok)
        {
-         U_CHAR *msg;          /* what pain... */
+         U_CHAR *msg;          /* what pain...  */
 
          /* If we are passing through #define and #undef directives, do
             that for this re-definition now.  */
@@ -1873,7 +1841,7 @@ nope:
    if stringified.
    `use_count' is the number of times this macro arg is substituted
    into the macro.  If the actual use count exceeds 10, 
-   the value stored is 10. */
+   the value stored is 10.  */
 
 /* raw and expanded are relative to ARG_BASE */
 #define ARG_BASE ((pfile)->token_buffer)
@@ -1887,26 +1855,27 @@ struct argdata {
   char use_count;
 };
 
+/* Allocate a new cpp_buffer for PFILE, and push it on the input buffer stack.
+   If BUFFER != NULL, then use the LENGTH characters in BUFFER
+   as the new input buffer.
+   Return the new buffer, or NULL on failure.  */
 
-cpp_buffer*
+cpp_buffer *
 cpp_push_buffer (pfile, buffer, length)
      cpp_reader *pfile;
      U_CHAR *buffer;
      long length;
 {
-#ifdef STATIC_BUFFERS
   register cpp_buffer *buf = CPP_BUFFER (pfile);
   if (buf == pfile->buffer_stack)
-    fatal ("%s: macro or `#include' recursion too deep", buf->fname);
+    {
+      cpp_fatal (pfile, "%s: macro or `#include' recursion too deep",
+                buf->fname);
+      return NULL;
+    }
   buf--;
   bzero ((char *) buf, sizeof (cpp_buffer));
   CPP_BUFFER (pfile) = buf;
-#else
-  register cpp_buffer *buf = (cpp_buffer*) xmalloc (sizeof(cpp_buffer));
-  bzero ((char *) buf, sizeof (cpp_buffer));
-  CPP_PREV_BUFFER (buf) = CPP_BUFFER (pfile);
-  CPP_BUFFER (pfile) = buf;
-#endif
   buf->if_stack = pfile->if_stack;
   buf->cleanup = null_cleanup;
   buf->underflow = null_underflow;
@@ -1916,25 +1885,17 @@ cpp_push_buffer (pfile, buffer, length)
   return buf;
 }
 
-cpp_buffer*
+cpp_buffer *
 cpp_pop_buffer (pfile)
      cpp_reader *pfile;
 {
   cpp_buffer *buf = CPP_BUFFER (pfile);
-#ifdef STATIC_BUFFERS
   (*buf->cleanup) (buf, pfile);
   return ++CPP_BUFFER (pfile);
-#else
-  cpp_buffer *next_buf = CPP_PREV_BUFFER (buf);
-  (*buf->cleanup) (buf, pfile);
-  CPP_BUFFER (pfile) = next_buf;
-  free (buf);
-  return next_buf;
-#endif
 }
 
 /* Scan until CPP_BUFFER (PFILE) is exhausted into PFILE->token_buffer.
-   Pop the buffer when done. */
+   Pop the buffer when done.  */
 
 void
 cpp_scan_buffer (pfile)
@@ -1944,7 +1905,7 @@ cpp_scan_buffer (pfile)
   for (;;)
     {
       enum cpp_token token = cpp_get_token (pfile);
-      if (token == CPP_EOF) /* Should not happen ... */
+      if (token == CPP_EOF) /* Should not happen ...  */
        break;
       if (token == CPP_POP && CPP_BUFFER (pfile) == buffer)
        {
@@ -1993,6 +1954,8 @@ cpp_expand_to_buffer (pfile, buf, length)
   buf1[length] = 0;
 
   ip = cpp_push_buffer (pfile, buf1, length);
+  if (ip == NULL)
+    return;
   ip->has_escapes = 1;
 #if 0
   ip->lineno = obuf.lineno = 1;
@@ -2027,7 +1990,7 @@ adjust_position (buf, limit, linep, colp)
     }
 }
 
-/* Move line_base forward, updating lineno and colno. */
+/* Move line_base forward, updating lineno and colno.  */
 
 static void
 update_position (pbuf)
@@ -2066,9 +2029,9 @@ cpp_buf_line_and_col (pbuf, linep, colp)
     }
 }
 
-/* Return the cpp_buffer that corresponds to a file (not a macro). */
+/* Return the cpp_buffer that corresponds to a file (not a macro).  */
 
-cpp_buffer*
+cpp_buffer *
 cpp_file_buffer (pfile)
      cpp_reader *pfile;
 {
@@ -2114,16 +2077,22 @@ output_line_command (pfile, conditional, file_change)
   long line, col;
   cpp_buffer *ip = CPP_BUFFER (pfile);
 
-  if (CPP_OPTIONS (pfile)->no_line_commands
-      || ip->fname == NULL || CPP_OPTIONS (pfile)->no_output) {
+  if (ip->fname == NULL)
     return;
-  }
 
   update_position (ip);
+
+  if (CPP_OPTIONS (pfile)->no_line_commands
+      || CPP_OPTIONS (pfile)->no_output)
+    return;
+
   line = CPP_BUFFER (pfile)->lineno;
   col = CPP_BUFFER (pfile)->colno;
   adjust_position (CPP_LINE_BASE (ip), ip->cur, &line, &col);
 
+  if (CPP_OPTIONS (pfile)->no_line_commands)
+    return;
+
   if (conditional) {
     if (line == pfile->lineno)
       return;
@@ -2231,7 +2200,7 @@ macarg (pfile, rest_args)
            goto found;
          break;
        found:
-         /* Remove ',' or ')' from argument buffer. */
+         /* Remove ',' or ')' from argument buffer.  */
          CPP_ADJUST_WRITTEN (pfile, -1);
          goto done;
       default: ;
@@ -2293,7 +2262,7 @@ timestamp (pfile)
      cpp_reader *pfile;
 {
   if (!pfile->timebuf) {
-    time_t t = time ((time_t *)0);
+    time_t t = time ((time_t *) 0);
     pfile->timebuf = localtime (&t);
   }
   return pfile->timebuf;
@@ -2331,7 +2300,7 @@ special_symbol (hp, pfile)
     
   for (ip = CPP_BUFFER (pfile); ; ip = CPP_PREV_BUFFER (ip))
     {
-      if (ip == NULL)
+      if (ip == CPP_NULL_BUFFER (pfile))
        {
          cpp_error (pfile, "cccp error: not in any file?!");
          return;                       /* the show must go on */
@@ -2348,7 +2317,7 @@ special_symbol (hp, pfile)
        char *string;
        if (hp->type == T_BASE_FILE)
          {
-           while (CPP_PREV_BUFFER (ip))
+           while (CPP_PREV_BUFFER (ip) != CPP_NULL_BUFFER (pfile))
              ip = CPP_PREV_BUFFER (ip);
          }
        string = ip->nominal_fname;
@@ -2362,7 +2331,8 @@ special_symbol (hp, pfile)
 
     case T_INCLUDE_LEVEL:
       true_indepth = 0;
-      for (ip = CPP_BUFFER (pfile);  ip != NULL; ip = CPP_PREV_BUFFER (ip))
+      ip = CPP_BUFFER (pfile);
+      for (;  ip != CPP_NULL_BUFFER (pfile); ip = CPP_PREV_BUFFER (ip))
        if (ip->fname != NULL)
          true_indepth++;
 
@@ -2451,7 +2421,7 @@ special_symbol (hp, pfile)
          if (pcp_outfile && pcp_inside_if
              && (hp->type == T_CONST
                  || (hp->type == T_MACRO && hp->value.defn->predefined)))
-           /* Output a precondition for this macro use. */
+           /* Output a precondition for this macro use.  */
            fprintf (pcp_outfile, "#define %s\n", hp->name);
 #endif
          buf = " 1 ";
@@ -2496,6 +2466,25 @@ special_symbol (hp, pfile)
   return;
 }
 
+/* Write out a #define command for the special named MACRO_NAME
+   to PFILE's token_buffer.  */
+
+static void
+dump_special_to_buffer (pfile, macro_name)
+     cpp_reader *pfile;
+     char *macro_name;
+{
+  static char define_directive[] = "#define ";
+  int macro_name_length = strlen (macro_name);
+  output_line_command (pfile, 0, same_file);
+  CPP_RESERVE (pfile, sizeof(define_directive) + macro_name_length);
+  CPP_PUTS_Q (pfile, define_directive, sizeof(define_directive)-1);
+  CPP_PUTS_Q (pfile, macro_name, macro_name_length);
+  CPP_PUTC_Q (pfile, ' ');
+  cpp_expand_to_buffer (pfile, macro_name, macro_name_length);
+  CPP_PUTC (pfile, '\n');
+}
+
 /* Initialize the built-in macros.  */
 
 static void
@@ -2528,68 +2517,26 @@ initialize_builtins (pfile)
 
   if (CPP_OPTIONS (pfile)->debug_output)
     {
-      char directive[2048];
-      register struct directive *dp = &directive_table[0];
-      struct tm *timebuf = timestamp (pfile);
-      cpp_buffer *pbuffer = CPP_BUFFER (pfile);
-
-      while (CPP_PREV_BUFFER (pbuffer))
-       pbuffer = CPP_PREV_BUFFER (pbuffer);
-      sprintf (directive, " __BASE_FILE__ \"%s\"\n",
-              pbuffer->nominal_fname);
-      output_line_command (pfile, 0, same_file);
-      pass_thru_directive (directive, &directive[strlen (directive)], pfile, dp);
-
-      sprintf (directive, " __VERSION__ \"%s\"\n", version_string);
-      output_line_command (pfile, 0, same_file);
-      pass_thru_directive (directive, &directive[strlen (directive)], pfile, dp);
-
+      dump_special_to_buffer (pfile, "__BASE_FILE__");
+      dump_special_to_buffer (pfile, "__VERSION__");
 #ifndef NO_BUILTIN_SIZE_TYPE
-      sprintf (directive, " __SIZE_TYPE__ %s\n", SIZE_TYPE);
-      output_line_command (pfile, 0, same_file);
-      pass_thru_directive (directive, &directive[strlen (directive)], pfile, dp);
+      dump_special_to_buffer (pfile, "__SIZE_TYPE__");
 #endif
-
 #ifndef NO_BUILTIN_PTRDIFF_TYPE
-      sprintf (directive, " __PTRDIFF_TYPE__ %s\n", PTRDIFF_TYPE);
-      output_line_command (pfile, 0, same_file);
-      pass_thru_directive (directive, &directive[strlen (directive)], pfile, dp);
+      dump_special_to_buffer (pfile, "__PTRDIFF_TYPE__");
 #endif
-
-      sprintf (directive, " __WCHAR_TYPE__ %s\n", CPP_WCHAR_TYPE (pfile));
-      output_line_command (pfile, 0, same_file);
-      pass_thru_directive (directive, &directive[strlen (directive)], pfile, dp);
-
-      sprintf (directive, " __DATE__ \"%s %2d %4d\"\n",
-              monthnames[timebuf->tm_mon],
-              timebuf->tm_mday, timebuf->tm_year + 1900);
-      output_line_command (pfile, 0, same_file);
-      pass_thru_directive (directive, &directive[strlen (directive)], pfile, dp);
-
-      sprintf (directive, " __TIME__ \"%02d:%02d:%02d\"\n",
-              timebuf->tm_hour, timebuf->tm_min, timebuf->tm_sec);
-      output_line_command (pfile, 0, same_file);
-      pass_thru_directive (directive, &directive[strlen (directive)], pfile, dp);
-
+      dump_special_to_buffer (pfile, "__WCHAR_TYPE__");
+      dump_special_to_buffer (pfile, "__DATE__");
+      dump_special_to_buffer (pfile, "__TIME__");
       if (!CPP_TRADITIONAL (pfile))
-       {
-          sprintf (directive, " __STDC__ 1");
-          output_line_command (pfile, 0, same_file);
-          pass_thru_directive (directive, &directive[strlen (directive)],
-                              pfile, dp);
-       }
+       dump_special_to_buffer (pfile, "__STDC__");
       if (CPP_OPTIONS (pfile)->objc)
-       {
-          sprintf (directive, " __OBJC__ 1");
-          output_line_command (pfile, 0, same_file);
-          pass_thru_directive (directive, &directive[strlen (directive)],
-                              pfile, dp);
-       }
+       dump_special_to_buffer (pfile, "__OBJC__");
     }
 }
 \f
 /* Return 1 iff a token ending in C1 followed directly by a token C2
-   could cause mis-tokenization. */
+   could cause mis-tokenization.  */
 
 static int
 unsafe_chars (c1, c2)
@@ -2610,7 +2557,7 @@ unsafe_chars (c1, c2)
       goto letter;
     case 'L':
       if (c2 == '\'' || c2 == '\"')
-       return 1;   /* Could turn into L"xxx" or L'xxx'. */
+       return 1;   /* Could turn into L"xxx" or L'xxx'.  */
       goto letter;
     letter:
     case '_':
@@ -2624,7 +2571,7 @@ unsafe_chars (c1, c2)
     case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
     case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
     case 'Y': case 'Z':
-      /* We're in the middle of either a name or a pre-processing number. */
+      /* We're in the middle of either a name or a pre-processing number.  */
       return (is_idchar[c2] || c2 == '.');
     case '<': case '>': case '!': case '%': case '#': case ':':
     case '^': case '&': case '|': case '*': case '/': case '=':
@@ -2692,7 +2639,7 @@ macroexpand (pfile, hp)
       /* Parse all the macro args that are supplied.  I counts them.
         The first NARGS args are stored in ARGS.
         The rest are discarded.  If rest_args is set then we assume
-        macarg absorbed the rest of the args. */
+        macarg absorbed the rest of the args.  */
       i = 0;
       rest_args = 0;
       rest_args = 0;
@@ -2800,7 +2747,7 @@ macroexpand (pfile, hp)
                  int c;
                  /* Initially need_space is -1.  Otherwise, 1 means the
                     previous character was a space, but we suppressed it;
-                    0 means the previous character was a non-space. */
+                    0 means the previous character was a non-space.  */
                  int need_space = -1;
                  i = 0;
                  arg->stringified = CPP_WRITTEN (pfile);
@@ -3010,7 +2957,7 @@ macroexpand (pfile, hp)
       }
 
       /* if there is anything left of the definition
-        after handling the arg list, copy that in too. */
+        after handling the arg list, copy that in too.  */
 
       for (i = offset; i < defn->length; i++)
        {
@@ -3034,7 +2981,7 @@ macroexpand (pfile, hp)
   push_macro_expansion (pfile, xbuf, xbuf_len, hp);
   CPP_BUFFER (pfile)->has_escapes = 1;
 
-  /* Pop the space we've used in the token_buffer for argument expansion. */
+  /* Pop the space we've used in the token_buffer for argument expansion.  */
   CPP_SET_WRITTEN (pfile, old_written);
     
   /* Recursive macro use sometimes works traditionally.
@@ -3053,6 +3000,8 @@ push_macro_expansion (pfile, xbuf, xbuf_len, hp)
      HASHNODE *hp;
 {
   register cpp_buffer *mbuf = cpp_push_buffer (pfile, xbuf, xbuf_len);
+  if (mbuf == NULL)
+    return;
   mbuf->cleanup = macro_cleanup;
   mbuf->data = hp;
 
@@ -3100,7 +3049,7 @@ get_directive_token (pfile)
       case CPP_POP:
          if (! CPP_IS_MACRO_BUFFER (CPP_BUFFER (pfile)))
              return token;
-         /* ... else fall though ... */
+         /* ... else fall though ...  */
       case CPP_HSPACE:  case CPP_COMMENT:
          CPP_SET_WRITTEN (pfile, old_written);
          break;
@@ -3116,7 +3065,7 @@ get_directive_token (pfile)
    The input is normally in part of the output_buffer following
    CPP_WRITTEN, and will get overwritten by output_line_command.
    I.e. in input file specification has been popped by handle_directive.
-   This is safe. */
+   This is safe.  */
 
 static int
 do_include (pfile, keyword, unused1, unused2)
@@ -3143,7 +3092,7 @@ do_include (pfile, keyword, unused1, unused2)
   int f;                       /* file number */
 
   int retried = 0;             /* Have already tried macro
-                                  expanding the include line*/
+                                  expanding the include line */
   int angle_brackets = 0;      /* 0 for "...", 1 for <...> */
   int pcf = -1;
   char *pcfbuf;
@@ -3185,14 +3134,14 @@ do_include (pfile, keyword, unused1, unused2)
          if (CPP_OPTIONS (pfile)->first_bracket_include)
            search_start = CPP_OPTIONS (pfile)->first_bracket_include;
        }
-      /* If -I- was specified, don't search current dir, only spec'd ones. */
+      /* If -I- was specified, don't search current dir, only spec'd ones.  */
       else if (! CPP_OPTIONS (pfile)->ignore_srcdir)
        {
-         cpp_buffer *fp;
+         cpp_buffer *fp = CPP_BUFFER (pfile);
          /* We have "filename".  Figure out directory this source
-            file is coming from and put it on the front of the list. */
+            file is coming from and put it on the front of the list.  */
 
-         for (fp = CPP_BUFFER (pfile); fp != NULL; fp = CPP_PREV_BUFFER (fp))
+         for ( ; fp != CPP_NULL_BUFFER (pfile); fp = CPP_PREV_BUFFER (fp))
            {
              int n;
              char *ep,*nam;
@@ -3271,8 +3220,8 @@ do_include (pfile, keyword, unused1, unused2)
      past the dir in which the containing file was found.  */
   if (skip_dirs)
     {
-      cpp_buffer *fp;
-      for (fp = CPP_BUFFER (pfile); fp != NULL; fp = CPP_PREV_BUFFER (fp))
+      cpp_buffer *fp = CPP_BUFFER (pfile);
+      for (; fp != CPP_NULL_BUFFER (pfile); fp = CPP_PREV_BUFFER (fp))
        if (fp->fname != NULL)
          {
            /* fp->dir is null if the containing file was specified with
@@ -3431,18 +3380,18 @@ do_include (pfile, keyword, unused1, unused2)
     /* Check to see if this include file is a once-only include file.
        If so, give up.  */
 
-    struct file_name_listptr;
+    struct file_name_list *ptr;
 
     for (ptr = pfile->dont_repeat_files; ptr; ptr = ptr->next) {
       if (!strcmp (ptr->fname, fname)) {
        close (f);
-        return 0;                              /* This file was once'd. */
+        return 0;                              /* This file was once'd.  */
       }
     }
 
     for (ptr = pfile->all_include_files; ptr; ptr = ptr->next) {
       if (!strcmp (ptr->fname, fname))
-        break;                         /* This file was included before. */
+        break;                         /* This file was included before.  */
     }
 
     if (ptr == 0) {
@@ -3467,7 +3416,7 @@ do_include (pfile, keyword, unused1, unused2)
     if (CPP_OPTIONS(pfile)->print_include_names)
       {
        cpp_buffer *buf = CPP_BUFFER (pfile);
-       while ((buf = CPP_PREV_BUFFER (buf)) != NULL)
+       while ((buf = CPP_PREV_BUFFER (buf)) != CPP_NULL_BUFFER (pfile))
          putc ('.', stderr);
        fprintf (stderr, "%s\n", fname);
       }
@@ -3477,7 +3426,7 @@ do_include (pfile, keyword, unused1, unused2)
 
     /* Actually process the file.  */
 
-    /* Record file on "seen" list for #import. */
+    /* Record file on "seen" list for #import.  */
     add_import (pfile, f, fname);
 
     pcftry = (char *) alloca (strlen (fname) + 30);
@@ -3520,7 +3469,8 @@ do_include (pfile, keyword, unused1, unused2)
 #endif
     
     /* Actually process the file */
-    cpp_push_buffer (pfile, NULL, 0);
+    if (cpp_push_buffer (pfile, NULL, 0) == NULL)
+      return 0;
     if (finclude (pfile, f, fname, is_system_include (pfile, fname),
                  searchptr != dsp ? searchptr : SELF_DIR_DUMMY))
       {
@@ -3597,6 +3547,7 @@ is_system_include (pfile, filename)
  * If HASH is >= 0, it is the precomputed hash code.
  * Otherwise, compute the hash code.
  */
+
 static ASSERTION_HASHNODE *
 assertion_install (pfile, name, len, hash)
      cpp_reader *pfile;
@@ -3674,8 +3625,8 @@ delete_assertion (hp)
       tail = next;
     }
 
-  /* make sure that the bucket chain header that
-     the deleted guy was on points to the right thing afterwards. */
+  /* Make sure that the bucket chain header that
+     the deleted guy was on points to the right thing afterwards.  */
   if (hp == *hp->bucket_hdr)
     *hp->bucket_hdr = hp->next;
 
@@ -3688,7 +3639,7 @@ delete_assertion (hp)
    The value returned in the end of the string written to RESULT,
    or NULL on error.  */
 
-static U_CHAR*
+static U_CHAR *
 convert_string (pfile, result, in, limit, handle_escapes)
      cpp_reader *pfile;
      register U_CHAR *result, *in, *limit;
@@ -3958,7 +3909,7 @@ do_once (pfile)
 
   for (ip = CPP_BUFFER (pfile); ; ip = CPP_PREV_BUFFER (ip))
     {
-      if (ip == NULL)
+      if (ip == CPP_NULL_BUFFER (pfile))
        return 0;
       if (ip->fname != NULL)
        break;
@@ -3991,7 +3942,7 @@ do_ident (pfile, keyword, buf, limit)
   if (CPP_PEDANTIC (pfile) && !CPP_BUFFER (pfile)->system_header_p)
     cpp_pedwarn (pfile, "ANSI C does not allow `#ident'");
 
-  /* Leave rest of line to be read by later calls to cpp_get_token. */
+  /* Leave rest of line to be read by later calls to cpp_get_token.  */
 
   return 0;
 }
@@ -4153,6 +4104,7 @@ do_elif (pfile, keyword, buf, limit)
  * evaluate a #if expression in BUF, of length LENGTH,
  * then parse the result as a C expression and return the value as an int.
  */
+
 static HOST_WIDE_INT
 eval_if_expression (pfile, buf, length)
      cpp_reader *pfile;
@@ -4189,7 +4141,7 @@ do_xifdef (pfile, keyword, unused1, unused2)
 {
   int skip;
   cpp_buffer *ip = CPP_BUFFER (pfile);
-  U_CHARident;
+  U_CHAR *ident;
   int ident_length;
   enum cpp_token token;
   int start_of_file = 0;
@@ -4297,6 +4249,7 @@ conditional_skip (pfile, skip, type, control_macro)
  * leaves input ptr at the sharp sign found.
  * If ANY is nonzero, return at next directive of any sort.
  */
+
 static void
 skip_if_group (pfile, any)
      cpp_reader *pfile;
@@ -4414,7 +4367,7 @@ skip_if_group (pfile, any)
        }
       c = GETC ();
     }
-  /* We're in the middle of a line.  Skip the rest of it. */
+  /* We're in the middle of a line.  Skip the rest of it.  */
   for (;;) {
     switch (c)
       {
@@ -4593,9 +4546,8 @@ validate_else (pfile, directive)
 }
 
 /* Get the next token, and add it to the text in pfile->token_buffer.
-   Return the kind of token we got. */
+   Return the kind of token we got.  */
   
-
 enum cpp_token
 cpp_get_token (pfile)
      cpp_reader *pfile;
@@ -4623,11 +4575,12 @@ cpp_get_token (pfile)
          cpp_buffer *next_buf
            = CPP_PREV_BUFFER (CPP_BUFFER (pfile));
          CPP_BUFFER (pfile)->seen_eof = 1;
-         if (CPP_BUFFER (pfile)->nominal_fname && next_buf != 0)
+         if (CPP_BUFFER (pfile)->nominal_fname
+             && next_buf != CPP_NULL_BUFFER (pfile))
            {
              /* We're about to return from an #include file.
                 Emit #line information now (as part of the CPP_POP) result.
-                But the #line refers to the file we will pop to. */
+                But the #line refers to the file we will pop to.  */
              cpp_buffer *cur_buffer = CPP_BUFFER (pfile);
              CPP_BUFFER (pfile) = next_buf;
              pfile->input_stack_listing_current = 0;
@@ -4662,7 +4615,7 @@ cpp_get_token (pfile)
                                   "unterminated comment");
              goto handle_eof;
            }
-         c = '/';  /* Initial letter of comment. */
+         c = '/';  /* Initial letter of comment.  */
        return_comment:
          /* Comments are equivalent to spaces.
             For -traditional, a comment is equivalent to nothing.  */
@@ -4687,7 +4640,7 @@ cpp_get_token (pfile)
            {
 #if 0
              /* This may not work if cpp_get_token is called recursively,
-                since many places look for horizontal space. */
+                since many places look for horizontal space.  */
              if (newlines)
                {
                  /* Copy the newlines into the output buffer, in order to
@@ -4728,7 +4681,7 @@ cpp_get_token (pfile)
 
              /* OK, now bring us back to the state we were in before we entered
                 this branch.  We need #line b/c the newline for the pragma
-                could fuck things up. */
+                could fuck things up.  */
              output_line_command (pfile, 0, same_file);
              *(obp++) = ' ';   /* just in case, if comments are copied thru */
              *(obp++) = '/';
@@ -4826,7 +4779,7 @@ cpp_get_token (pfile)
                  cc = GETC();
                  if (cc == '\n')
                    {
-                     /* Backslash newline is replaced by nothing at all. */
+                     /* Backslash newline is replaced by nothing at all.  */
                      CPP_ADJUST_WRITTEN (pfile, -1);
                      pfile->lineno++;
                    }
@@ -4890,7 +4843,7 @@ cpp_get_token (pfile)
              /* Chill style comment */
              if (opts->put_out_comments)
                parse_set_mark (&start_mark, pfile);
-             FORWARD(1);  /* Skip second '-'. */
+             FORWARD(1);  /* Skip second '-'.  */
              for (;;)
                {
                  c = GETC ();
@@ -4898,7 +4851,7 @@ cpp_get_token (pfile)
                    break;
                  if (c == '\n')
                    {
-                     /* Don't consider final '\n' to be part of comment. */
+                     /* Don't consider final '\n' to be part of comment.  */
                      FORWARD(-1);
                      break;
                    }
@@ -5111,7 +5064,7 @@ cpp_get_token (pfile)
            if (hp->type == T_DISABLED)
              {
                if (pfile->output_escapes)
-                 { /* Return "@-IDENT", followed by '\0'. */
+                 { /* Return "@-IDENT", followed by '\0'.  */
                    int i;
                    CPP_RESERVE (pfile, 3);
                    ident = pfile->token_buffer + before_name_written;
@@ -5157,7 +5110,7 @@ cpp_get_token (pfile)
              if (!is_macro_call)
                return CPP_NAME;
            }
-           /* This is now known to be a macro call. */
+           /* This is now known to be a macro call.  */
 
            /* it might not actually be a macro.  */
            if (hp->type != T_MACRO) {
@@ -5181,7 +5134,7 @@ cpp_get_token (pfile)
            /* An extra "@ " is added to the end of a macro expansion
               to prevent accidental token pasting.  We prefer to avoid
               unneeded extra spaces (for the sake of cpp-using tools like
-              imake).  Here we remove the space if it is safe to do so. */
+              imake).  Here we remove the space if it is safe to do so.  */
            if (pfile->buffer->rlimit - pfile->buffer->cur >= 3
                && pfile->buffer->rlimit[-2] == '@'
                && pfile->buffer->rlimit[-1] == ' ')
@@ -5238,7 +5191,8 @@ cpp_get_token (pfile)
     }
 }
 
-/* Like cpp_get_token, but skip spaces and comments. */
+/* Like cpp_get_token, but skip spaces and comments.  */
+
 enum cpp_token
 cpp_get_non_space_token (pfile)
      cpp_reader *pfile;
@@ -5254,7 +5208,7 @@ cpp_get_non_space_token (pfile)
     }
 }
 
-/* Parse an identifier starting with C. */
+/* Parse an identifier starting with C.  */
 
 int
 parse_name (pfile, c)
@@ -5273,7 +5227,10 @@ parse_name (pfile, c)
          break;
       }
 
-      CPP_RESERVE(pfile, 2); /* One more for final NUL. */
+      if (c == '$' && CPP_PEDANTIC (pfile))
+       cpp_pedwarn ("`$' in identifier");
+
+      CPP_RESERVE(pfile, 2); /* One more for final NUL.  */
       CPP_PUTC_Q (pfile, c);
       c = GETC();
       if (c == EOF)
@@ -5418,7 +5375,8 @@ read_filename_string (ch, f)
   return alloc;
 }
 
-/* This structure holds a linked list of file name maps, one per directory. */
+/* This structure holds a linked list of file name maps, one per directory.  */
+
 struct file_name_map_list
 {
   struct file_name_map_list *map_list_next;
@@ -5641,7 +5599,7 @@ finclude (pfile, f, fname, system_header_p, dirptr)
   } else {
     /* Cannot count its file size before reading.
        First read the entire file into heap and
-       copy them into buffer on stack. */
+       copy them into buffer on stack.  */
 
     int bsize = 2000;
 
@@ -5658,6 +5616,7 @@ finclude (pfile, f, fname, system_header_p, dirptr)
       bsize *= 2;
       fp->buf = (U_CHAR *) xrealloc (fp->buf, bsize + 2);
     }
+    fp->cur = fp->buf;
     length = st_size;
   }
 
@@ -5708,8 +5667,14 @@ finclude (pfile, f, fname, system_header_p, dirptr)
   return 1;
 }
 
+/* This is called after options have been processed.
+ * Check options for consistency, and setup for processing input
+ * from the file named FNAME.  (Use standard input if FNAME==NULL.)
+ * Return 1 on succes, 0 on failure.
+ */
+
 int
-push_parse_file (pfile, fname)
+cpp_start_read (pfile, fname)
      cpp_reader *pfile;
      char *fname;
 {
@@ -5740,6 +5705,8 @@ push_parse_file (pfile, fname)
   /* Do partial setup of input buffer for the sake of generating
      early #line directives (when -g is in effect).  */
   fp = cpp_push_buffer (pfile, NULL, 0);
+  if (!fp)
+    return 0;
   if (opts->in_fname == NULL)
     opts->in_fname = "";
   fp->nominal_fname = fp->fname = opts->in_fname;
@@ -5824,7 +5791,7 @@ push_parse_file (pfile, fname)
   /* Now handle the command line options.  */
 
   /* Do -U's, -D's and -A's in the order they were seen.  */
-  /* First reverse the list. */
+  /* First reverse the list.  */
   opts->pending = nreverse_pending (opts->pending);
 
   for (pend = opts->pending;  pend;  pend = pend->next)
@@ -5852,8 +5819,8 @@ push_parse_file (pfile, fname)
 
   opts->done_initializing = 1;
 
-  { /* read the appropriate environment variable and if it exists
-       replace include_defaults with the listed path. */
+  { /* Read the appropriate environment variable and if it exists
+       replace include_defaults with the listed path.  */
     char *epath = 0;
     switch ((opts->objc << 1) + opts->cplusplus)
       {
@@ -6002,9 +5969,10 @@ push_parse_file (pfile, fname)
          if (fd < 0)
            {
              cpp_perror_with_name (pfile, pend->arg);
-             return FATAL_EXIT_CODE;
+             return 0;
            }
-         cpp_push_buffer (pfile, NULL, 0);
+         if (!cpp_push_buffer (pfile, NULL, 0))
+             return 0;
          finclude (pfile, fd, pend->arg, 0, NULL_PTR);
          cpp_scan_buffer (pfile);
        }
@@ -6024,7 +5992,10 @@ push_parse_file (pfile, fname)
      inhibit compilation.  */
   if (opts->print_deps_missing_files
       && (opts->print_deps == 0 || !opts->no_output))
-    fatal (pfile, "-MG must be specified with one of -M or -MM");
+    {
+      cpp_fatal (pfile, "-MG must be specified with one of -M or -MM");
+      return 0;
+    }
 
   /* Either of two environment variables can specify output of deps.
      Its value is either "OUTPUT_FILE" or "OUTPUT_FILE DEPS_TARGET",
@@ -6167,15 +6138,16 @@ push_parse_file (pfile, fname)
          if (fd < 0)
            {
              cpp_perror_with_name (pfile, pend->arg);
-             return FATAL_EXIT_CODE;
+             return 0;
            }
-         cpp_push_buffer (pfile, NULL, 0);
+         if (!cpp_push_buffer (pfile, NULL, 0))
+           return 0;
          finclude (pfile, fd, pend->arg, 0, NULL_PTR);
        }
     }
   pfile->no_record_file--;
 
-  /* Free the pending list. */
+  /* Free the pending list.  */
   for (pend = opts->pending;  pend; )
     {
       struct cpp_pending *next = pend->next;
@@ -6198,18 +6170,18 @@ push_parse_file (pfile, fname)
 #endif
   if (finclude (pfile, f, fname, 0, NULL_PTR))
     output_line_command (pfile, 0, same_file);
-  return SUCCESS_EXIT_CODE;
+  return 1;
 }
 
 void
-init_parse_file (pfile)
+cpp_reader_init (pfile)
      cpp_reader *pfile;
 {
   bzero ((char *) pfile, sizeof (cpp_reader));
   pfile->get_token = cpp_get_token;
 
   pfile->token_buffer_size = 200;
-  pfile->token_buffer = (U_CHAR*)xmalloc (pfile->token_buffer_size);
+  pfile->token_buffer = (U_CHAR *) xmalloc (pfile->token_buffer_size);
   CPP_SET_WRITTEN (pfile, 0);
 
   pfile->system_include_depth = 0;
@@ -6243,7 +6215,7 @@ push_pending (pfile, cmd, arg)
      char *arg;
 {
   struct cpp_pending *pend
-    = (struct cpp_pending*)xmalloc (sizeof (struct cpp_pending));
+    = (struct cpp_pending *) xmalloc (sizeof (struct cpp_pending));
   pend->cmd = cmd;
   pend->arg = arg;
   pend->next = CPP_OPTIONS (pfile)->pending;
@@ -6266,7 +6238,10 @@ cpp_handle_options (pfile, argc, argv)
   for (i = 0; i < argc; i++) {
     if (argv[i][0] != '-') {
       if (opts->out_fname != NULL)
-       fatal ("Usage: %s [switches] input output", argv[0]);
+       {
+         cpp_fatal (pfile, "Usage: %s [switches] input output", argv[0]);
+         return argc;
+       }
       else if (opts->in_fname != NULL)
        opts->out_fname = argv[i];
       else
@@ -6274,17 +6249,24 @@ cpp_handle_options (pfile, argc, argv)
     } else {
       switch (argv[i][1]) {
 
+      missing_filename:
+       cpp_fatal (pfile, "Filename missing after `%s' option", argv[i]);
+       return argc;
+      missing_dirname:
+       cpp_fatal (pfile, "Directory name missing after `%s' option", argv[i]);
+       return argc;
+
       case 'i':
        if (!strcmp (argv[i], "-include")
            || !strcmp (argv[i], "-imacros")) {
          if (i + 1 == argc)
-           fatal ("Filename missing after `%s' option", argv[i]);
+           goto missing_filename;
          else
            push_pending (pfile, argv[i], argv[i+1]), i++;
        }
        if (!strcmp (argv[i], "-iprefix")) {
          if (i + 1 == argc)
-           fatal ("Filename missing after `-iprefix' option");
+           goto missing_filename;
          else
            opts->include_prefix = argv[++i];
        }
@@ -6295,7 +6277,7 @@ cpp_handle_options (pfile, argc, argv)
          struct file_name_list *dirtmp;
 
          if (i + 1 == argc)
-           fatal ("Filename missing after `-isystem' option");
+           goto missing_filename;
 
          dirtmp = (struct file_name_list *)
            xmalloc (sizeof (struct file_name_list));
@@ -6333,7 +6315,7 @@ cpp_handle_options (pfile, argc, argv)
          dirtmp->control_macro = 0;
          dirtmp->c_system_include_path = 0;
          if (i + 1 == argc)
-           fatal ("Directory name missing after `-iwithprefix' option");
+           goto missing_dirname;
 
          dirtmp->fname = (char *) xmalloc (strlen (argv[i+1])
                                            + strlen (prefix) + 1);
@@ -6368,7 +6350,7 @@ cpp_handle_options (pfile, argc, argv)
          dirtmp->control_macro = 0;
          dirtmp->c_system_include_path = 0;
          if (i + 1 == argc)
-           fatal ("Directory name missing after `-iwithprefixbefore' option");
+           goto missing_dirname;
 
          dirtmp->fname = (char *) xmalloc (strlen (argv[i+1])
                                            + strlen (prefix) + 1);
@@ -6388,7 +6370,7 @@ cpp_handle_options (pfile, argc, argv)
          dirtmp->control_macro = 0;
          dirtmp->c_system_include_path = 0;
          if (i + 1 == argc)
-           fatal ("Directory name missing after `-idirafter' option");
+           goto missing_dirname;
          else
            dirtmp->fname = argv[++i];
          dirtmp->got_name_map = 0;
@@ -6403,9 +6385,12 @@ cpp_handle_options (pfile, argc, argv)
 
       case 'o':
        if (opts->out_fname != NULL)
-         fatal ("Output filename specified twice");
+         {
+           cpp_fatal (pfile, "Output filename specified twice");
+           return argc;
+         }
        if (i + 1 == argc)
-         fatal ("Filename missing after -o option");
+         goto missing_filename;
        opts->out_fname = argv[++i];
        if (!strcmp (opts->out_fname, "-"))
          opts->out_fname = "";
@@ -6435,8 +6420,6 @@ cpp_handle_options (pfile, argc, argv)
       case 't':
        if (!strcmp (argv[i], "-traditional")) {
          opts->traditional = 1;
-         if (opts->dollars_in_ident > 0)
-           opts->dollars_in_ident = 1;
        } else if (!strcmp (argv[i], "-trigraphs")) {
          if (!opts->chill)
            opts->no_trigraphs = 0;
@@ -6533,7 +6516,7 @@ cpp_handle_options (pfile, argc, argv)
        if (!strcmp (argv[i], "-MD") || !strcmp (argv[i], "-MMD"))
          {
            if (i+1 == argc)
-             fatal ("Filename missing after %s option", argv[i]);
+             goto missing_filename;
            opts->deps_file = argv[++i];
          }
        else
@@ -6588,7 +6571,10 @@ cpp_handle_options (pfile, argc, argv)
        if (argv[i][2] != 0)
          push_pending (pfile, "-D", argv[i] + 2);
        else if (i + 1 == argc)
-         fatal ("Macro name missing after -D option");
+         {
+           cpp_fatal (pfile, "Macro name missing after -D option");
+           return argc;
+         }
        else
          i++, push_pending (pfile, "-D", argv[i]);
        break;
@@ -6600,7 +6586,10 @@ cpp_handle_options (pfile, argc, argv)
          if (argv[i][2] != 0)
            p = argv[i] + 2;
          else if (i + 1 == argc)
-           fatal ("Assertion missing after -A option");
+           {
+             cpp_fatal (pfile, "Assertion missing after -A option");
+             return argc;
+           }
          else
            p = argv[++i];
 
@@ -6634,7 +6623,10 @@ cpp_handle_options (pfile, argc, argv)
        if (argv[i][2] != 0)
          push_pending (pfile, "-U", argv[i] + 2);
        else if (i + 1 == argc)
-         fatal ("Macro name missing after -U option");
+         {
+           cpp_fatal (pfile, "Macro name missing after -U option", NULL);
+           return argc;
+         }
        else
          push_pending (pfile, "-U", argv[i+1]), i++;
        break;
@@ -6673,7 +6665,7 @@ cpp_handle_options (pfile, argc, argv)
            if (argv[i][2] != 0)
              dirtmp->fname = argv[i] + 2;
            else if (i + 1 == argc)
-             fatal ("Directory name missing after -I option");
+             goto missing_dirname;
            else
              dirtmp->fname = argv[++i];
            dirtmp->got_name_map = 0;
@@ -6743,13 +6735,14 @@ cpp_finish (pfile)
          if (opts->deps_file)
            {
              if (ferror (deps_stream) || fclose (deps_stream) != 0)
-               fatal ("I/O error on output");
+               cpp_fatal (pfile, "I/O error on output");
            }
        }
     }
 }
 
-/* Free resources used by PFILE. */
+/* Free resources used by PFILE.
+   This is the cpp_reader 'finalizer' or 'destructor' (in C++ terminology).  */
 
 void
 cpp_cleanup (pfile)
@@ -7203,6 +7196,16 @@ safe_read (desc, ptr, len)
 }
 
 static char *
+xcalloc (number, size)
+     unsigned number, size;
+{
+  register unsigned total = number * size;
+  register char *ptr = (char *) xmalloc (total);
+  bzero (ptr, total);
+  return ptr;
+}
+
+static char *
 savestring (input)
      char *input;
 {
@@ -7212,7 +7215,8 @@ savestring (input)
   return output;
 }
 \f
-/* Initialize PMARK to remember the current position of PFILE. */
+/* Initialize PMARK to remember the current position of PFILE.  */
+
 void
 parse_set_mark (pmark, pfile)
      struct parse_marker *pmark;
@@ -7225,20 +7229,21 @@ parse_set_mark (pmark, pfile)
   pmark->position = pbuf->cur - pbuf->buf;
 }
 
-/* Cleanup PMARK - we no longer need it. */
+/* Cleanup PMARK - we no longer need it.  */
+
 void
 parse_clear_mark (pmark)
      struct parse_marker *pmark;
 {
   struct parse_marker **pp = &pmark->buf->marks;
   for (; ; pp = &(*pp)->next) {
-    if (*pp == NULL) fatal ("internal error", "in parse_set_mark");
+    if (*pp == NULL) abort ();
     if (*pp == pmark) break;
   }
   *pp = pmark->next;
 }
 
-/* Backup the current position of PFILE to that saved in PMARK. */
+/* Backup the current position of PFILE to that saved in PMARK.  */
 
 void
 parse_goto_mark (pmark, pfile)
@@ -7247,12 +7252,12 @@ parse_goto_mark (pmark, pfile)
 {
   cpp_buffer *pbuf = CPP_BUFFER (pfile);
   if (pbuf != pmark->buf)
-    fatal ("internal error %s", "parse_goto_mark");
+    cpp_fatal (pfile, "internal error %s", "parse_goto_mark");
   pbuf->cur = pbuf->buf + pmark->position;
 }
 
 /* Reset PMARK to point to the current position of PFILE.  (Same
-   as parse_clear_mark (PMARK), parse_set_mark (PMARK, PFILE) but faster. */
+   as parse_clear_mark (PMARK), parse_set_mark (PMARK, PFILE) but faster.  */
 
 void
 parse_move_mark (pmark, pfile)
@@ -7261,7 +7266,7 @@ parse_move_mark (pmark, pfile)
 {
   cpp_buffer *pbuf = CPP_BUFFER (pfile);
   if (pbuf != pmark->buf)
-    fatal ("internal error %s", "parse_move_mark");
+    cpp_fatal (pfile, "internal error %s", "parse_move_mark");
   pmark->position = pbuf->cur - pbuf->buf;
 }
 
@@ -7430,7 +7435,7 @@ cpp_pedwarn_with_file_and_line (pfile, file, line, msg, arg1, arg2, arg3)
               msg, arg1, arg2, arg3);
 }
 
-/* This defines "errno" properly for VMS, and gives us EACCES. */
+/* This defines "errno" properly for VMS, and gives us EACCES.  */
 #include <errno.h>
 #ifndef errno
 extern int errno;
@@ -7451,9 +7456,8 @@ char *strerror ();
 char *strerror (int,...);
 #endif
 
-/*
- * my_strerror - return the descriptive text associated with an `errno' code.
- */
+/* my_strerror - return the descriptive text associated with an
+   `errno' code.  */
 
 char *
 my_strerror (errnum)