OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / protoize.c
index 937f01e..0eb6957 100644 (file)
@@ -1,12 +1,12 @@
 /* Protoize program - Original version by Ron Guilmette (rfg@segfault.us.com).
    Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
 GCC is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
+Software Foundation; either version 3, or (at your option) any later
 version.
 
 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -15,9 +15,8 @@ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 for more details.
 
 You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING.  If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.  */
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
 #include "system.h"
@@ -34,7 +33,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-#undef abort
 #include "version.h"
 
 /* Include getopt.h for the sake of getopt_long.  */
@@ -75,11 +73,9 @@ static void usage (void) ATTRIBUTE_NORETURN;
 static void aux_info_corrupted (void) ATTRIBUTE_NORETURN;
 static void declare_source_confusing (const char *) ATTRIBUTE_NORETURN;
 static const char *shortpath (const char *, const char *);
-extern void fancy_abort  (void) ATTRIBUTE_NORETURN;
 static void notice (const char *, ...) ATTRIBUTE_PRINTF_1;
 static char *savestring (const char *, unsigned int);
 static char *dupnstr (const char *, size_t);
-static const char *substr (const char *, const char * const);
 static int safe_read (int, void *, int);
 static void safe_write (int, void *, int, const char *);
 static void save_pointers (void);
@@ -364,6 +360,8 @@ static const char *pname;
 static int errors = 0;
 
 /* Option flags.  */
+/* ??? The variables are not marked static because some of them have
+   the same names as gcc variables declared in options.h.  */
 /* ??? These comments should say what the flag mean as well as the options
    that set them.  */
 
@@ -371,20 +369,20 @@ static int errors = 0;
    something other than gcc.  */
 static const char *compiler_file_name = "gcc";
 
-static int version_flag = 0;           /* Print our version number.  */
-static int quiet_flag = 0;             /* Don't print messages normally.  */
-static int nochange_flag = 0;          /* Don't convert, just say what files
-                                          we would have converted.  */
-static int nosave_flag = 0;            /* Don't save the old version.  */
-static int keep_flag = 0;              /* Don't delete the .X files.  */
+int version_flag = 0;          /* Print our version number.  */
+int quiet_flag = 0;            /* Don't print messages normally.  */
+int nochange_flag = 0;         /* Don't convert, just say what files
+                                  we would have converted.  */
+int nosave_flag = 0;           /* Don't save the old version.  */
+int keep_flag = 0;             /* Don't delete the .X files.  */
 static const char ** compile_params = 0;       /* Option string for gcc.  */
 #ifdef UNPROTOIZE
 static const char *indent_string = "     ";    /* Indentation for newly
                                                   inserted parm decls.  */
 #else /* !defined (UNPROTOIZE) */
-static int local_flag = 0;             /* Insert new local decls (when?).  */
-static int global_flag = 0;            /* set by -g option */
-static int cplusplus_flag = 0;         /* Rename converted files to *.C.  */
+int local_flag = 0;            /* Insert new local decls (when?).  */
+int global_flag = 0;           /* set by -g option */
+int cplusplus_flag = 0;                /* Rename converted files to *.C.  */
 static const char *nondefault_syscalls_dir = 0; /* Dir to look for
                                                   SYSCALLS.c.X in.  */
 #endif /* !defined (UNPROTOIZE) */
@@ -506,12 +504,12 @@ static char * saved_repl_write_ptr;
 \f
 /* Translate and output an error message.  */
 static void
-notice (const char *msgid, ...)
+notice (const char *cmsgid, ...)
 {
   va_list ap;
   
-  va_start (ap, msgid);
-  vfprintf (stderr, _(msgid), ap);
+  va_start (ap, cmsgid);
+  vfprintf (stderr, _(cmsgid), ap);
   va_end (ap);
 }
 
@@ -521,20 +519,11 @@ notice (const char *msgid, ...)
 static char *
 savestring (const char *input, unsigned int size)
 {
-  char *output = (char *) xmalloc (size + 1);
+  char *output = xmalloc (size + 1);
   strcpy (output, input);
   return output;
 }
 
-/* More 'friendly' abort that prints the line and file.
-   config.h can #define abort fancy_abort if you like that sort of thing.  */
-
-void
-fancy_abort (void)
-{
-  notice ("%s: internal abort\n", pname);
-  exit (FATAL_EXIT_CODE);
-}
 \f
 /* Make a duplicate of the first N bytes of a given string in a newly
    allocated area.  */
@@ -542,34 +531,12 @@ fancy_abort (void)
 static char *
 dupnstr (const char *s, size_t n)
 {
-  char *ret_val = (char *) xmalloc (n + 1);
+  char *ret_val = xmalloc (n + 1);
 
   strncpy (ret_val, s, n);
   ret_val[n] = '\0';
   return ret_val;
 }
-
-/* Return a pointer to the first occurrence of s2 within s1 or NULL if s2
-   does not occur within s1.  Assume neither s1 nor s2 are null pointers.  */
-
-static const char *
-substr (const char *s1, const char *const s2)
-{
-  for (; *s1 ; s1++)
-    {
-      const char *p1;
-      const char *p2;
-      int c;
-
-      for (p1 = s1, p2 = s2; (c = *p2); p1++, p2++)
-       if (*p1 != c)
-         goto outer;
-      return s1;
-outer:
-      ;
-    }
-  return 0;
-}
 \f
 /* Read LEN bytes at PTR from descriptor DESC, for file FILENAME,
    retrying if necessary.  Return the actual number of bytes read.  */
@@ -612,7 +579,7 @@ safe_write (int desc, void *ptr, int len, const char *out_fname)
        if (errno_val == EINTR)
          continue;
 #endif
-       notice ("%s: error writing file `%s': %s\n",
+       notice ("%s: error writing file '%s': %s\n",
                pname, shortpath (NULL, out_fname), xstrerror (errno_val));
        return;
       }
@@ -674,8 +641,7 @@ in_system_include_dir (const char *path)
 {
   const struct default_include *p;
 
-  if (! IS_ABSOLUTE_PATH (path))
-    abort ();          /* Must be an absolutized filename.  */
+  gcc_assert (IS_ABSOLUTE_PATH (path));
 
   for (p = cpp_include_defaults; p->fname; p++)
     if (!strncmp (path, p->fname, strlen (p->fname))
@@ -692,7 +658,7 @@ in_system_include_dir (const char *path)
 static int
 file_could_be_converted (const char *path)
 {
-  char *const dir_name = (char *) alloca (strlen (path) + 1);
+  char *const dir_name = alloca (strlen (path) + 1);
 
   if (access (path, R_OK))
     return 0;
@@ -712,10 +678,8 @@ file_could_be_converted (const char *path)
        dir_last_slash = slash;
     }
 #endif
-    if (dir_last_slash)
-      *dir_last_slash = '\0';
-    else
-      abort ();  /* Should have been an absolutized filename.  */
+    gcc_assert (dir_last_slash);
+    *dir_last_slash = '\0';
   }
 
   if (access (path, W_OK))
@@ -756,16 +720,14 @@ file_normally_convertible (const char *path)
        dir_last_slash = slash;
     }
 #endif
-    if (dir_last_slash)
-      *dir_last_slash = '\0';
-    else
-      abort ();  /* Should have been an absolutized filename.  */
+    gcc_assert (dir_last_slash);
+    *dir_last_slash = '\0';
   }
 
   if (access (path, R_OK))
     {
       if (!quiet_flag)
-       notice ("%s: warning: no read access for file `%s'\n",
+       notice ("%s: warning: no read access for file '%s'\n",
                pname, shortpath (NULL, path));
       return 0;
     }
@@ -773,7 +735,7 @@ file_normally_convertible (const char *path)
   if (access (path, W_OK))
     {
       if (!quiet_flag)
-       notice ("%s: warning: no write access for file `%s'\n",
+       notice ("%s: warning: no write access for file '%s'\n",
                pname, shortpath (NULL, path));
       return 0;
     }
@@ -781,7 +743,7 @@ file_normally_convertible (const char *path)
   if (access (dir_name, W_OK))
     {
       if (!quiet_flag)
-       notice ("%s: warning: no write access for dir containing `%s'\n",
+       notice ("%s: warning: no write access for dir containing '%s'\n",
                pname, shortpath (NULL, path));
       return 0;
     }
@@ -898,8 +860,7 @@ file_excluded_p (const char *name)
 static struct string_list *
 string_list_cons (const char *string, struct string_list *rest)
 {
-  struct string_list *temp
-    = (struct string_list *) xmalloc (sizeof (struct string_list));
+  struct string_list *temp = xmalloc (sizeof (struct string_list));
 
   temp->next = rest;
   temp->name = string;
@@ -973,7 +934,7 @@ lookup (hash_table_entry *hash_tab_p, const char *search_symbol)
       if (!strcmp (p->symbol, search_symbol))
        return p;
     }
-  p->hash_next = (hash_table_entry *) xmalloc (sizeof (hash_table_entry));
+  p->hash_next = xmalloc (sizeof (hash_table_entry));
   p = p->hash_next;
   return add_symbol (p, search_symbol);
 }
@@ -1004,7 +965,7 @@ free_def_dec (def_dec_info *p)
   free (p);
 }
 
-/* Unexpand as many macro symbol as we can find.
+/* Unexpand as many macro symbols as we can find.
 
    If the given line must be unexpanded, make a copy of it in the heap and
    return a pointer to the unexpanded copy.  Otherwise return NULL.  */
@@ -1022,7 +983,7 @@ unexpand_if_needed (const char *aux_info_line)
   if (line_buf == 0)
     {
       line_buf_size = 1024;
-      line_buf = (char *) xmalloc (line_buf_size);
+      line_buf = xmalloc (line_buf_size);
     }
 
   copy_p = line_buf;
@@ -1045,7 +1006,7 @@ unexpand_if_needed (const char *aux_info_line)
                  int offset = copy_p - line_buf;
                  line_buf_size *= 2;
                  line_buf_size += size;
-                 line_buf = (char *) xrealloc (line_buf, line_buf_size);
+                 line_buf = xrealloc (line_buf, line_buf_size);
                  copy_p = line_buf + offset;
                }
              strcpy (copy_p, unexp_p->contracted);
@@ -1062,7 +1023,7 @@ unexpand_if_needed (const char *aux_info_line)
        {
          int offset = copy_p - line_buf;
          line_buf_size *= 2;
-         line_buf = (char *) xrealloc (line_buf, line_buf_size);
+         line_buf = xrealloc (line_buf, line_buf_size);
          copy_p = line_buf + offset;
        }
       *copy_p++ = *s++;
@@ -1072,7 +1033,7 @@ continue_outer: ;
     {
       int offset = copy_p - line_buf;
       line_buf_size *= 2;
-      line_buf = (char *) xrealloc (line_buf, line_buf_size);
+      line_buf = xrealloc (line_buf, line_buf_size);
       copy_p = line_buf + offset;
     }
   *copy_p++ = '\n';
@@ -1096,8 +1057,7 @@ abspath (const char *cwd, const char *rel_filename)
 {
   /* Setup the current working directory as needed.  */
   const char *const cwd2 = (cwd) ? cwd : cwd_buffer;
-  char *const abs_buffer
-    = (char *) alloca (strlen (cwd2) + strlen (rel_filename) + 2);
+  char *const abs_buffer = alloca (strlen (cwd2) + strlen (rel_filename) + 2);
   char *endp = abs_buffer;
   char *outp, *inp;
 
@@ -1219,7 +1179,7 @@ shortpath (const char *cwd, const char *filename)
   size_t filename_len = strlen (filename);
 
   path_p = abspath (cwd, filename);
-  rel_buf_p = rel_buffer = (char *) xmalloc (filename_len);
+  rel_buf_p = rel_buffer = xmalloc (filename_len);
 
   while (*cwd_p && IS_SAME_PATH_CHAR (*cwd_p, *path_p))
     {
@@ -1306,7 +1266,7 @@ find_file (const char *filename, int do_not_stat)
   else
     {
       struct stat stat_buf;
-      file_info *file_p = (file_info *) xmalloc (sizeof (file_info));
+      file_info *file_p = xmalloc (sizeof (file_info));
 
       /* If we cannot get status on any given source file, give a warning
         and then just set its time of last modification to infinity.  */
@@ -1404,7 +1364,7 @@ referenced_file_is_newer (const char *l, time_t aux_info_mtime)
 #endif
           )
       p++;
-    filename = (char *) alloca ((size_t) (p - filename_start) + 1);
+    filename = alloca ((size_t) (p - filename_start) + 1);
     strncpy (filename, filename_start, (size_t) (p - filename_start));
     filename[p-filename_start] = '\0';
   }
@@ -1439,7 +1399,7 @@ save_def_or_dec (const char *l, int is_syscalls)
 {
   const char *p;
   const char *semicolon_p;
-  def_dec_info *def_dec_p = (def_dec_info *) xmalloc (sizeof (def_dec_info));
+  def_dec_info *def_dec_p = xmalloc (sizeof (def_dec_info));
 
 #ifndef UNPROTOIZE
   def_dec_p->written = 0;
@@ -1464,7 +1424,7 @@ save_def_or_dec (const char *l, int is_syscalls)
 #endif
           )
       p++;
-    filename = (char *) alloca ((size_t) (p - filename_start) + 1);
+    filename = alloca ((size_t) (p - filename_start) + 1);
     strncpy (filename, filename_start, (size_t) (p - filename_start));
     filename[p-filename_start] = '\0';
 
@@ -1594,8 +1554,7 @@ save_def_or_dec (const char *l, int is_syscalls)
       const char *left_paren_p = find_corresponding_lparen (p);
 #ifndef UNPROTOIZE
       {
-       f_list_chain_item *cip
-         = (f_list_chain_item *) xmalloc (sizeof (f_list_chain_item));
+       f_list_chain_item *cip = xmalloc (sizeof (f_list_chain_item));
 
        cip->formals_list
          = dupnstr (left_paren_p + 1, (size_t) (p - (left_paren_p+1)));
@@ -1637,7 +1596,7 @@ save_def_or_dec (const char *l, int is_syscalls)
     /* p now points to the leftmost character of the function name.  */
 
     {
-      char *fn_string = (char *) alloca (past_fn - p + 1);
+      char *fn_string = alloca (past_fn - p + 1);
 
       strncpy (fn_string, p, (size_t) (past_fn - p));
       fn_string[past_fn-p] = '\0';
@@ -1669,7 +1628,7 @@ save_def_or_dec (const char *l, int is_syscalls)
          {
            if (strcmp (def_dec_p->ansi_decl, other->ansi_decl))
              {
-               notice ("%s:%d: declaration of function `%s' takes different forms\n",
+               notice ("%s:%d: declaration of function '%s' takes different forms\n",
                        def_dec_p->file->hash_entry->symbol,
                        def_dec_p->line,
                        def_dec_p->hash_entry->symbol);
@@ -1833,7 +1792,7 @@ munge_compile_params (const char *params_list)
   /* Build up the contents in a temporary vector
      that is so big that to has to be big enough.  */
   const char **temp_params
-    = (const char **) alloca ((strlen (params_list) + 8) * sizeof (char *));
+    = alloca ((strlen (params_list) + 8) * sizeof (char *));
   int param_count = 0;
   const char *param;
   struct stat st;
@@ -1902,8 +1861,7 @@ munge_compile_params (const char *params_list)
 
   /* Make a copy of the compile_params in heap space.  */
 
-  compile_params
-    = (const char **) xmalloc (sizeof (char *) * (param_count+1));
+  compile_params = xmalloc (sizeof (char *) * (param_count+1));
   memcpy (compile_params, temp_params, sizeof (char *) * param_count);
 }
 
@@ -1925,7 +1883,7 @@ gen_aux_info_file (const char *base_filename)
     concat (compile_params[input_file_name_index], aux_info_suffix, NULL);
 
   if (!quiet_flag)
-    notice ("%s: compiling `%s'\n",
+    notice ("%s: compiling '%s'\n",
            pname, compile_params[input_file_name_index]);
 
   {
@@ -1967,7 +1925,7 @@ gen_aux_info_file (const char *base_filename)
          }
        return 1;
       }
-    abort ();
+    gcc_unreachable ();
   }
 }
 \f
@@ -1979,8 +1937,7 @@ process_aux_info_file (const char *base_source_filename, int keep_it,
                       int is_syscalls)
 {
   size_t base_len = strlen (base_source_filename);
-  char * aux_info_filename
-    = (char *) alloca (base_len + strlen (aux_info_suffix) + 1);
+  char * aux_info_filename = alloca (base_len + strlen (aux_info_suffix) + 1);
   char *aux_info_base;
   char *aux_info_limit;
   char *aux_info_relocated_name;
@@ -2011,7 +1968,7 @@ start_over: ;
        {
          if (is_syscalls)
            {
-             notice ("%s: warning: missing SYSCALLS file `%s'\n",
+             notice ("%s: warning: missing SYSCALLS file '%s'\n",
                      pname, aux_info_filename);
              return;
            }
@@ -2020,7 +1977,7 @@ start_over: ;
       else
        {
          int errno_val = errno;
-         notice ("%s: can't read aux info file `%s': %s\n",
+         notice ("%s: can't read aux info file '%s': %s\n",
                  pname, shortpath (NULL, aux_info_filename),
                  xstrerror (errno_val));
          errors++;
@@ -2049,7 +2006,7 @@ start_over: ;
       if (access (aux_info_filename, R_OK) == -1)
        {
          int errno_val = errno;
-         notice ("%s: can't read aux info file `%s': %s\n",
+         notice ("%s: can't read aux info file '%s': %s\n",
                  pname, shortpath (NULL, aux_info_filename),
                  xstrerror (errno_val));
          errors++;
@@ -2065,7 +2022,7 @@ start_over: ;
     if (stat (aux_info_filename, &stat_buf) == -1)
       {
        int errno_val = errno;
-       notice ("%s: can't get status of aux info file `%s': %s\n",
+       notice ("%s: can't get status of aux info file '%s': %s\n",
                pname, shortpath (NULL, aux_info_filename),
                xstrerror (errno_val));
        errors++;
@@ -2093,7 +2050,7 @@ start_over: ;
        if (stat (base_source_filename, &stat_buf) == -1)
          {
            int errno_val = errno;
-           notice ("%s: can't get status of aux info file `%s': %s\n",
+           notice ("%s: can't get status of aux info file '%s': %s\n",
                    pname, shortpath (NULL, base_source_filename),
                    xstrerror (errno_val));
            errors++;
@@ -2121,7 +2078,7 @@ start_over: ;
     if ((aux_info_file = open (aux_info_filename, fd_flags, 0444 )) == -1)
       {
        int errno_val = errno;
-       notice ("%s: can't open aux info file `%s' for reading: %s\n",
+       notice ("%s: can't open aux info file '%s' for reading: %s\n",
                pname, shortpath (NULL, aux_info_filename),
                xstrerror (errno_val));
        return;
@@ -2139,7 +2096,7 @@ start_over: ;
        (int) aux_info_size)
       {
        int errno_val = errno;
-       notice ("%s: error reading aux info file `%s': %s\n",
+       notice ("%s: error reading aux info file '%s': %s\n",
                pname, shortpath (NULL, aux_info_filename),
                xstrerror (errno_val));
        free (aux_info_base);
@@ -2152,7 +2109,7 @@ start_over: ;
     if (close (aux_info_file))
       {
        int errno_val = errno;
-       notice ("%s: error closing aux info file `%s': %s\n",
+       notice ("%s: error closing aux info file '%s': %s\n",
                pname, shortpath (NULL, aux_info_filename),
                xstrerror (errno_val));
        free (aux_info_base);
@@ -2168,7 +2125,7 @@ start_over: ;
     if (unlink (aux_info_filename) == -1)
       {
        int errno_val = errno;
-       notice ("%s: can't delete aux info file `%s': %s\n",
+       notice ("%s: can't delete aux info file '%s': %s\n",
                pname, shortpath (NULL, aux_info_filename),
                xstrerror (errno_val));
       }
@@ -2250,7 +2207,7 @@ start_over: ;
                if (keep_it && unlink (aux_info_filename) == -1)
                  {
                    int errno_val = errno;
-                   notice ("%s: can't delete file `%s': %s\n",
+                   notice ("%s: can't delete file '%s': %s\n",
                            pname, shortpath (NULL, aux_info_filename),
                            xstrerror (errno_val));
                    return;
@@ -2309,8 +2266,8 @@ rename_c_file (const hash_table_entry *hp)
 {
   const char *filename = hp->symbol;
   int last_char_index = strlen (filename) - 1;
-  char *const new_filename = (char *) alloca (strlen (filename)
-                                             + strlen (cplus_suffix) + 1);
+  char *const new_filename = alloca (strlen (filename)
+                                    + strlen (cplus_suffix) + 1);
 
   /* Note that we don't care here if the given file was converted or not.  It
      is possible that the given file was *not* converted, simply because there
@@ -2328,7 +2285,7 @@ rename_c_file (const hash_table_entry *hp)
   if (rename (filename, new_filename) == -1)
     {
       int errno_val = errno;
-      notice ("%s: warning: can't rename file `%s' to `%s': %s\n",
+      notice ("%s: warning: can't rename file '%s' to '%s': %s\n",
              pname, shortpath (NULL, filename),
              shortpath (NULL, new_filename), xstrerror (errno_val));
       errors++;
@@ -2489,7 +2446,7 @@ find_extern_def (const def_dec_info *head, const def_dec_info *user)
          {
            extern_def_p = dd_p;        /* save a pointer to the definition */
            if (!quiet_flag)
-             notice ("%s: warning: using formals list from %s(%d) for function `%s'\n",
+             notice ("%s: warning: using formals list from %s(%d) for function '%s'\n",
                      pname,
                      shortpath (NULL, dd_p->file->hash_entry->symbol),
                      dd_p->line, dd_p->hash_entry->symbol);
@@ -2517,11 +2474,11 @@ find_extern_def (const def_dec_info *head, const def_dec_info *user)
              {
                /* Why copy this string into `needed' at all?
                   Why not just use user->ansi_decl without copying?  */
-               char *needed = (char *) alloca (strlen (user->ansi_decl) + 1);
+               char *needed = alloca (strlen (user->ansi_decl) + 1);
                char *p;
 
                strcpy (needed, user->ansi_decl);
-               p = (NONCONST char *) substr (needed, user->hash_entry->symbol)
+               p = strstr (needed, user->hash_entry->symbol)
                    + strlen (user->hash_entry->symbol) + 2;
                /* Avoid having ??? in the string.  */
                *p++ = '?';
@@ -2529,13 +2486,13 @@ find_extern_def (const def_dec_info *head, const def_dec_info *user)
                *p++ = '?';
                strcpy (p, ");");
 
-               notice ("%s: %d: `%s' used but missing from SYSCALLS\n",
+               notice ("%s: %d: '%s' used but missing from SYSCALLS\n",
                        shortpath (NULL, file), user->line,
                        needed+7);      /* Don't print "extern " */
              }
 #if 0
            else
-             notice ("%s: %d: warning: no extern definition for `%s'\n",
+             notice ("%s: %d: warning: no extern definition for '%s'\n",
                      shortpath (NULL, file), user->line,
                      user->hash_entry->symbol);
 #endif
@@ -2565,13 +2522,13 @@ find_static_definition (const def_dec_info *user)
   if (num_static_defs == 0)
     {
       if (!quiet_flag)
-       notice ("%s: warning: no static definition for `%s' in file `%s'\n",
+       notice ("%s: warning: no static definition for '%s' in file '%s'\n",
                pname, head->hash_entry->symbol,
                shortpath (NULL, user->file->hash_entry->symbol));
     }
   else if (num_static_defs > 1)
     {
-      notice ("%s: multiple static defs of `%s' in file `%s'\n",
+      notice ("%s: multiple static defs of '%s' in file '%s'\n",
              pname, head->hash_entry->symbol,
              shortpath (NULL, user->file->hash_entry->symbol));
       return NULL;
@@ -2780,8 +2737,7 @@ check_source (int cond, const char *clean_p)
 static const char *
 seek_to_line (int n)
 {
-  if (n < last_known_line_number)
-    abort ();
+  gcc_assert (n >= last_known_line_number);
 
   while (n > last_known_line_number)
     {
@@ -2815,7 +2771,7 @@ output_bytes (const char *str, size_t len)
   if ((repl_write_ptr + 1) + len >= repl_text_limit)
     {
       size_t new_size = (repl_text_limit - repl_text_base) << 1;
-      char *new_buf = (char *) xrealloc (repl_text_base, new_size);
+      char *new_buf = xrealloc (repl_text_base, new_size);
 
       repl_write_ptr = new_buf + (repl_write_ptr - repl_text_base);
       repl_text_base = new_buf;
@@ -2880,7 +2836,7 @@ other_variable_style_function (const char *ansi_header)
   /* See if we have a stdarg function, or a function which has stdarg style
      parameters or a stdarg style return type.  */
 
-  return substr (ansi_header, "...") != 0;
+  return strstr (ansi_header, "...") != 0;
 
 #else /* !defined (UNPROTOIZE) */
 
@@ -2894,7 +2850,7 @@ other_variable_style_function (const char *ansi_header)
     {
       const char *candidate;
 
-      if ((candidate = substr (p, varargs_style_indicator)) == 0)
+      if ((candidate = strstr (p, varargs_style_indicator)) == 0)
        return 0;
       else
        if (!is_id_char (candidate[-1]) && !is_id_char (candidate[len]))
@@ -2955,7 +2911,7 @@ edit_fn_declaration (const def_dec_info *def_dec_p,
   if (setjmp (source_confusion_recovery))
     {
       restore_pointers ();
-      notice ("%s: declaration of function `%s' not converted\n",
+      notice ("%s: declaration of function '%s' not converted\n",
              pname, function_to_edit);
       return;
     }
@@ -3078,7 +3034,7 @@ edit_fn_declaration (const def_dec_info *def_dec_p,
       else
        {
          if (!quiet_flag)
-           notice ("%s: warning: too many parameter lists in declaration of `%s'\n",
+           notice ("%s: warning: too many parameter lists in declaration of '%s'\n",
                    pname, def_dec_p->hash_entry->symbol);
          check_source (0, end_formals);  /* leave the declaration intact */
        }
@@ -3099,7 +3055,7 @@ edit_fn_declaration (const def_dec_info *def_dec_p,
            if (this_f_list_chain_item)
              {
                if (!quiet_flag)
-                 notice ("\n%s: warning: too few parameter lists in declaration of `%s'\n",
+                 notice ("\n%s: warning: too few parameter lists in declaration of '%s'\n",
                          pname, def_dec_p->hash_entry->symbol);
                check_source (0, start_formals); /* leave the decl intact */
              }
@@ -3195,7 +3151,7 @@ edit_formals_lists (const char *end_formals, unsigned int f_list_count,
       if (func_name_len != strlen (expected)
          || strncmp (func_name_start, expected, func_name_len))
        {
-         notice ("%s: %d: warning: found `%s' but expected `%s'\n",
+         notice ("%s: %d: warning: found '%s' but expected '%s'\n",
                  shortpath (NULL, def_dec_p->file->hash_entry->symbol),
                  identify_lineno (func_name_start),
                  dupnstr (func_name_start, func_name_len),
@@ -3370,7 +3326,7 @@ add_local_decl (const def_dec_info *def_dec_p, const char *clean_text_p)
   if (setjmp (source_confusion_recovery))
     {
       restore_pointers ();
-      notice ("%s: local declaration for function `%s' not inserted\n",
+      notice ("%s: local declaration for function '%s' not inserted\n",
              pname, function_to_edit);
       return;
     }
@@ -3397,7 +3353,7 @@ add_local_decl (const def_dec_info *def_dec_p, const char *clean_text_p)
   if (*start_of_block != '{')
     {
       if (!quiet_flag)
-       notice ("\n%s: %d: warning: can't add declaration of `%s' into macro call\n",
+       notice ("\n%s: %d: warning: can't add declaration of '%s' into macro call\n",
          def_dec_p->file->hash_entry->symbol, def_dec_p->line,
          def_dec_p->hash_entry->symbol);
       return;
@@ -3469,7 +3425,7 @@ add_global_decls (const file_info *file_p, const char *clean_text_p)
   if (setjmp (source_confusion_recovery))
     {
       restore_pointers ();
-      notice ("%s: global declarations for file `%s' not inserted\n",
+      notice ("%s: global declarations for file '%s' not inserted\n",
              pname, shortpath (NULL, file_p->hash_entry->symbol));
       return;
     }
@@ -3546,7 +3502,8 @@ add_global_decls (const file_info *file_p, const char *clean_text_p)
    separate routine above.  */
 
 static void
-edit_fn_definition (const def_dec_info *def_dec_p, const char *clean_text_p)
+edit_fn_definition (const def_dec_info *def_dec_p,
+                   const char *volatile clean_text_p)
 {
   const char *end_formals;
   const char *function_to_edit = def_dec_p->hash_entry->symbol;
@@ -3558,7 +3515,7 @@ edit_fn_definition (const def_dec_info *def_dec_p, const char *clean_text_p)
   if (setjmp (source_confusion_recovery))
     {
       restore_pointers ();
-      notice ("%s: definition of function `%s' not converted\n",
+      notice ("%s: definition of function '%s' not converted\n",
              pname, function_to_edit);
       return;
     }
@@ -3588,7 +3545,7 @@ edit_fn_definition (const def_dec_info *def_dec_p, const char *clean_text_p)
   if (edit_formals_lists (end_formals, def_dec_p->f_list_count, def_dec_p))
     {
       restore_pointers ();
-      notice ("%s: definition of function `%s' not converted\n",
+      notice ("%s: definition of function '%s' not converted\n",
              pname, function_to_edit);
       return;
     }
@@ -3708,8 +3665,8 @@ do_cleaning (char *new_clean_text_base, const char *new_clean_text_limit)
            {
              if (!ISSPACE ((const unsigned char)*scan_p))
                *scan_p = ' ';
-             if (++scan_p >= new_clean_text_limit)
-               abort ();
+             ++scan_p;
+             gcc_assert (scan_p < new_clean_text_limit);
            }
          *scan_p++ = ' ';
          *scan_p = ' ';
@@ -3723,8 +3680,8 @@ do_cleaning (char *new_clean_text_base, const char *new_clean_text_limit)
            {
              if (!ISSPACE ((const unsigned char)*scan_p))
                *scan_p = ' ';
-             if (++scan_p >= new_clean_text_limit)
-               abort ();
+             ++scan_p;
+             gcc_assert (scan_p < new_clean_text_limit);
            }
          *scan_p++ = ' ';
          break;
@@ -3738,8 +3695,8 @@ do_cleaning (char *new_clean_text_base, const char *new_clean_text_limit)
                scan_p[1] = ' ';
              if (!ISSPACE ((const unsigned char)*scan_p))
                *scan_p = ' ';
-             if (++scan_p >= new_clean_text_limit)
-               abort ();
+             ++scan_p;
+             gcc_assert (scan_p < new_clean_text_limit);
            }
          *scan_p++ = ' ';
          break;
@@ -3753,8 +3710,8 @@ do_cleaning (char *new_clean_text_base, const char *new_clean_text_limit)
                scan_p[1] = ' ';
              if (!ISSPACE ((const unsigned char)*scan_p))
                *scan_p = ' ';
-             if (++scan_p >= new_clean_text_limit)
-               abort ();
+             ++scan_p;
+             gcc_assert (scan_p < new_clean_text_limit);
            }
          if (!ISSPACE ((const unsigned char)*scan_p))
            *scan_p = ' ';
@@ -3887,7 +3844,7 @@ scan_for_missed_items (const file_info *file_p)
                    goto not_missed;
 
                  {
-                   char *func_name = (char *) alloca (id_length + 1);
+                   char *func_name = alloca (id_length + 1);
                    static const char * const stmt_keywords[]
                      = { "if", "else", "do", "while", "for", "switch", "case", "return", 0 };
                    const char * const *stmt_keyword;
@@ -3903,7 +3860,7 @@ scan_for_missed_items (const file_info *file_p)
                        goto not_missed;
 
 #if 0
-                   notice ("%s: found definition of `%s' at %s(%d)\n",
+                   notice ("%s: found definition of '%s' at %s(%d)\n",
                            pname,
                            func_name,
                            shortpath (NULL, file_p->hash_entry->symbol),
@@ -3919,7 +3876,7 @@ scan_for_missed_items (const file_info *file_p)
                    /* If we make it here, then we did not know about this
                       function definition.  */
 
-                   notice ("%s: %d: warning: `%s' excluded by preprocessing\n",
+                   notice ("%s: %d: warning: '%s' excluded by preprocessing\n",
                            shortpath (NULL, file_p->hash_entry->symbol),
                            identify_lineno (id_start), func_name);
                    notice ("%s: function definition not converted\n",
@@ -3980,7 +3937,7 @@ edit_file (const hash_table_entry *hp)
          && !in_system_include_dir (convert_filename)
 #endif /* defined (UNPROTOIZE) */
          )
-       notice ("%s: `%s' not converted\n",
+       notice ("%s: '%s' not converted\n",
                pname, shortpath (NULL, convert_filename));
       return;
     }
@@ -3988,10 +3945,10 @@ edit_file (const hash_table_entry *hp)
   /* Let the user know what we are up to.  */
 
   if (nochange_flag)
-    notice ("%s: would convert file `%s'\n",
+    notice ("%s: would convert file '%s'\n",
            pname, shortpath (NULL, convert_filename));
   else
-    notice ("%s: converting file `%s'\n",
+    notice ("%s: converting file '%s'\n",
            pname, shortpath (NULL, convert_filename));
   fflush (stderr);
 
@@ -4001,7 +3958,7 @@ edit_file (const hash_table_entry *hp)
   if (stat (convert_filename, &stat_buf) == -1)
     {
       int errno_val = errno;
-      notice ("%s: can't get status for file `%s': %s\n",
+      notice ("%s: can't get status for file '%s': %s\n",
              pname, shortpath (NULL, convert_filename),
              xstrerror (errno_val));
       return;
@@ -4010,12 +3967,12 @@ edit_file (const hash_table_entry *hp)
 
   /* Allocate a buffer to hold the original text.  */
 
-  orig_text_base = new_orig_text_base = (char *) xmalloc (orig_size + 2);
+  orig_text_base = new_orig_text_base = xmalloc (orig_size + 2);
   orig_text_limit = new_orig_text_limit = new_orig_text_base + orig_size;
 
   /* Allocate a buffer to hold the cleaned-up version of the original text.  */
 
-  clean_text_base = new_clean_text_base = (char *) xmalloc (orig_size + 2);
+  clean_text_base = new_clean_text_base = xmalloc (orig_size + 2);
   clean_text_limit = new_clean_text_limit = new_clean_text_base + orig_size;
   clean_read_ptr = clean_text_base - 1;
 
@@ -4025,7 +3982,7 @@ edit_file (const hash_table_entry *hp)
      buffer can be expanded later as needed.  */
 
   repl_size = orig_size + (orig_size >> 2) + 4096;
-  repl_text_base = (char *) xmalloc (repl_size + 2);
+  repl_text_base = xmalloc (repl_size + 2);
   repl_text_limit = repl_text_base + repl_size - 1;
   repl_write_ptr = repl_text_base - 1;
 
@@ -4043,7 +4000,7 @@ edit_file (const hash_table_entry *hp)
     if ((input_file = open (convert_filename, fd_flags, 0444)) == -1)
       {
        int errno_val = errno;
-       notice ("%s: can't open file `%s' for reading: %s\n",
+       notice ("%s: can't open file '%s' for reading: %s\n",
                pname, shortpath (NULL, convert_filename),
                xstrerror (errno_val));
        return;
@@ -4058,7 +4015,7 @@ edit_file (const hash_table_entry *hp)
       {
        int errno_val = errno;
        close (input_file);
-       notice ("\n%s: error reading input file `%s': %s\n",
+       notice ("\n%s: error reading input file '%s': %s\n",
                pname, shortpath (NULL, convert_filename),
                xstrerror (errno_val));
        return;
@@ -4083,7 +4040,7 @@ edit_file (const hash_table_entry *hp)
   {
     int clean_file;
     size_t clean_size = orig_text_limit - orig_text_base;
-    char *const clean_filename = (char *) alloca (strlen (convert_filename) + 6 + 1);
+    char *const clean_filename = alloca (strlen (convert_filename) + 6 + 1);
 
     /* Open (and create) the clean file.  */
 
@@ -4092,7 +4049,7 @@ edit_file (const hash_table_entry *hp)
     if ((clean_file = creat (clean_filename, 0666)) == -1)
       {
        int errno_val = errno;
-       notice ("%s: can't create/open clean file `%s': %s\n",
+       notice ("%s: can't create/open clean file '%s': %s\n",
                pname, shortpath (NULL, clean_filename),
                xstrerror (errno_val));
        return;
@@ -4183,7 +4140,7 @@ edit_file (const hash_table_entry *hp)
   if (!nosave_flag)
     {
       char *new_filename
-       = (char *) xmalloc (strlen (convert_filename) + strlen (save_suffix) + 2);
+       = xmalloc (strlen (convert_filename) + strlen (save_suffix) + 2);
 
       strcpy (new_filename, convert_filename);
 #ifdef __MSDOS__
@@ -4197,7 +4154,7 @@ edit_file (const hash_table_entry *hp)
       if (access (new_filename, F_OK) == 0)
        {
          if (!quiet_flag)
-           notice ("%s: warning: file `%s' already saved in `%s'\n",
+           notice ("%s: warning: file '%s' already saved in '%s'\n",
                    pname,
                    shortpath (NULL, convert_filename),
                    shortpath (NULL, new_filename));
@@ -4205,7 +4162,7 @@ edit_file (const hash_table_entry *hp)
       else if (rename (convert_filename, new_filename) == -1)
        {
          int errno_val = errno;
-         notice ("%s: can't link file `%s' to `%s': %s\n",
+         notice ("%s: can't link file '%s' to '%s': %s\n",
                  pname,
                  shortpath (NULL, convert_filename),
                  shortpath (NULL, new_filename),
@@ -4220,7 +4177,7 @@ edit_file (const hash_table_entry *hp)
       /* The file may have already been renamed.  */
       if (errno_val != ENOENT)
        {
-         notice ("%s: can't delete file `%s': %s\n",
+         notice ("%s: can't delete file '%s': %s\n",
                  pname, shortpath (NULL, convert_filename),
                  xstrerror (errno_val));
          return;
@@ -4235,7 +4192,7 @@ edit_file (const hash_table_entry *hp)
     if ((output_file = creat (convert_filename, 0666)) == -1)
       {
        int errno_val = errno;
-       notice ("%s: can't create/open output file `%s': %s\n",
+       notice ("%s: can't create/open output file '%s': %s\n",
                pname, shortpath (NULL, convert_filename),
                xstrerror (errno_val));
        return;
@@ -4268,7 +4225,7 @@ edit_file (const hash_table_entry *hp)
   if (chmod (convert_filename, stat_buf.st_mode) == -1)
     {
       int errno_val = errno;
-      notice ("%s: can't change mode of file `%s': %s\n",
+      notice ("%s: can't change mode of file '%s': %s\n",
              pname, shortpath (NULL, convert_filename),
              xstrerror (errno_val));
     }
@@ -4310,8 +4267,8 @@ do_processing (void)
   if (nondefault_syscalls_dir)
     {
       syscalls_absolute_filename
-       = (char *) xmalloc (strlen (nondefault_syscalls_dir) + 1
-                           + sizeof (syscalls_filename));
+       = xmalloc (strlen (nondefault_syscalls_dir) + 1
+                  + sizeof (syscalls_filename));
       strcpy (syscalls_absolute_filename, nondefault_syscalls_dir);
     }
   else
@@ -4322,10 +4279,10 @@ do_processing (void)
          default_syscalls_dir = standard_exec_prefix;
        }
       syscalls_absolute_filename
-       = (char *) xmalloc (strlen (default_syscalls_dir) + 0
-                           + strlen (target_machine) + 1
-                           + strlen (target_version) + 1
-                           + sizeof (syscalls_filename));
+       = xmalloc (strlen (default_syscalls_dir) + 0
+                  + strlen (target_machine) + 1
+                  + strlen (target_version) + 1
+                  + sizeof (syscalls_filename));
       strcpy (syscalls_absolute_filename, default_syscalls_dir);
       strcat (syscalls_absolute_filename, target_machine);
       strcat (syscalls_absolute_filename, "/");
@@ -4436,6 +4393,9 @@ main (int argc, char **const argv)
   signal (SIGCHLD, SIG_DFL);
 #endif
 
+  /* Unlock the stdio streams.  */
+  unlock_std_streams ();
+
   gcc_init_libintl ();
 
   cwd_buffer = getpwd ();
@@ -4528,7 +4488,7 @@ main (int argc, char **const argv)
   /* Now actually make a list of the base source filenames.  */
 
   base_source_filenames
-    = (const char **) xmalloc ((n_base_source_files + 1) * sizeof (char *));
+    = xmalloc ((n_base_source_files + 1) * sizeof (char *));
   n_base_source_files = 0;
   for (; optind < argc; optind++)
     {
@@ -4565,7 +4525,8 @@ main (int argc, char **const argv)
   else
     {
       if (version_flag)
-       fprintf (stderr, "%s: %s\n", pname, version_string);
+       fprintf (stderr, "%s %s%s\n", pname, pkgversion_string,
+                version_string);
       do_processing ();
     }