OSDN Git Service

more rigorous SIGCHLD guarding
[pf3gnuchains/gcc-fork.git] / gcc / protoize.c
index f3b1307..aa03edf 100644 (file)
@@ -1,6 +1,6 @@
-/* Protoize program - Original version by Ron Guilmette at MCC.
-
-   Copyright (C) 1989, 1992 Free Software Foundation, Inc.
+/* Protoize program - Original version by Ron Guilmette (rfg@segfault.us.com).
+   Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+   1999, 2000 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -16,202 +16,134 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GNU CC; see the file COPYING.  If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
-
-/* Any reasonable C++ compiler should have all of the same features
-   as __STDC__ plus more, so make sure that __STDC__ is defined if
-   __cplusplus is defined. */
-
-#if defined(__cplusplus) && !defined(__STDC__)
-#define __STDC__ 1
-#endif /* defined(__cplusplus) && !defined(__STDC__) */
-
-#if defined(__GNUC__) || defined (__GNUG__)
-#define VOLATILE volatile
-#else
-#define VOLATILE
-#endif
-
-#ifndef __STDC__
-#define const
-#define volatile
-#endif
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
 
 #include "config.h"
+#include "system.h"
+#include "intl.h"
 
-#if 0
-/* Users are not supposed to use _POSIX_SOURCE to say the
-   system is a POSIX system.  That is not what _POSIX_SOURCE means! -- rms  */ 
-/* If the user asked for POSIX via _POSIX_SOURCE, turn on POSIX code.  */
-#if defined(_POSIX_SOURCE) && !defined(POSIX)
-#define POSIX
-#endif
-#endif /* 0 */
-
-#ifdef POSIX /* We should be able to define _POSIX_SOURCE unconditionally,
-               but some systems respond in buggy ways to it,
-               including SunOS 4.1.1.  Which we don't classify as POSIX.  */
-/* In case this is a POSIX system with an ANSI C compiler,
-   ask for definition of all POSIX facilities.  */
-#undef _POSIX_SOURCE
-#define _POSIX_SOURCE
+#include <setjmp.h>
+#include <signal.h>
+#if ! defined( SIGCHLD ) && defined( SIGCLD )
+#  define SIGCHLD SIGCLD
 #endif
-
-#include "gvarargs.h"
-/* On some systems stdio.h includes stdarg.h;
-   we must bring in gvarargs.h first.  */
-#include <stdio.h>
-#include <ctype.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#ifdef POSIX
-#include <dirent.h>
-#else
-#include <sys/dir.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
 #endif
-#include <setjmp.h>
+#undef abort
+#include "version.h"
 
-/* Include getopt.h for the sake of getopt_long.
-   We don't need the declaration of getopt, and it could conflict
-   with something from a system header file, so effectively nullify that.  */
-#define getopt getopt_loser
+/* Include getopt.h for the sake of getopt_long. */
 #include "getopt.h"
-#undef getopt
 
-extern int errno;
-#if defined(bsd4_4)
-extern const char *const sys_errlist[];
+/* Macro to see if the path elements match.  */
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+#define IS_SAME_PATH_CHAR(a,b) (TOUPPER (a) == TOUPPER (b))
 #else
-extern char *sys_errlist[];
+#define IS_SAME_PATH_CHAR(a,b) ((a) == (b))
 #endif
-extern char *version_string;
-
-/* Systems which are compatible only with POSIX 1003.1-1988 (but *not*
-   with POSIX 1003.1-1990), e.g. Ultrix 4.2, might not have
-   const qualifiers in the prototypes in the system include files.
-   Unfortunately, this can lead to GCC issuing lots of warnings for
-   calls to the following functions.  To eliminate these warnings we
-   provide the following #defines.  */
-
-#define my_access(file,flag)   access((char *)file, flag)
-#define my_stat(file,pkt)      stat((char *)file, pkt)
-#define my_execvp(prog,argv)   execvp((char *)prog, (char **)argv)
-#define my_link(file1, file2)  link((char *)file1, (char *)file2)
-#define my_unlink(file)                unlink((char *)file)
-#define my_open(file, mode, flag)      open((char *)file, mode, flag)
-#define my_chmod(file, mode)   chmod((char *)file, mode)
-
-extern char *getpwd ();
-
-/* Aliases for pointers to void.
-   These were made to facilitate compilation with old brain-dead DEC C
-   compilers which didn't properly grok `void*' types.  */
-
-#ifdef __STDC__
-typedef void * pointer_type;
-typedef const void * const_pointer_type;
+
+/* Macro to see if the paths match.  */
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+#define IS_SAME_PATH(a,b) (strcasecmp (a, b) == 0)
 #else
-typedef char * pointer_type;
-typedef char * const_pointer_type;
+#define IS_SAME_PATH(a,b) (strcmp (a, b) == 0)
 #endif
 
-#if defined(POSIX)
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <signal.h>
-#include <fcntl.h>
-
-#else /* !defined(POSIX) */
-
-#define R_OK    4       /* Test for Read permission */
-#define W_OK    2       /* Test for Write permission */
-#define X_OK    1       /* Test for eXecute permission */
-#define F_OK    0       /* Test for existence of File */
-
-#define O_RDONLY        0
-#define O_WRONLY        1
-
-/* Declaring stat or __flsbuf with a prototype
-   causes conflicts with system headers on some systems.  */
-
-#ifndef abort
-typedef void voidfn ();
-extern VOLATILE voidfn abort;
-#endif
-extern int kill ();
-extern int creat ();
-#if 0 /* These conflict with stdio.h on some systems.  */
-extern int fprintf (FILE *, const char *, ...);
-extern int printf (const char *, ...);
-extern int open (const char *, int, ...);
-#endif /* 0 */
-extern void exit ();
-extern void free ();
-extern int read ();
-extern int write ();
-extern int close ();
-extern int fflush ();
-extern int atoi ();
-extern int puts ();
-extern int fputs ();
-extern int fputc ();
-extern int link ();
-extern int unlink ();
-extern int access ();
-extern int execvp ();
-/* In 2.6, try deleting these decls entirely since setjmp.h should
-   take care of them.  */
-#ifndef __NeXT__
-#ifndef setjmp
-extern int setjmp ();
-#endif
-#ifndef longjmp
-extern void longjmp ();
+/* Suffix for aux-info files.  */
+#ifdef __MSDOS__
+#define AUX_INFO_SUFFIX "X"
+#else
+#define AUX_INFO_SUFFIX ".X"
 #endif
+
+/* Suffix for saved files.  */
+#ifdef __MSDOS__
+#define SAVE_SUFFIX "sav"
+#else
+#define SAVE_SUFFIX ".save"
 #endif
 
-#if 0 /* size_t from sys/types.h may fail to match GCC.
-        If so, we would get a warning from this.  */
-extern size_t   strlen ()
+/* Suffix for renamed C++ files.  */
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+#define CPLUS_FILE_SUFFIX "cc"
+#else
+#define CPLUS_FILE_SUFFIX "C"
 #endif
 
-/* Fork is not declared because the declaration caused a conflict
-   on the HPPA.  */
-#if !(defined (USG) || defined (VMS))
-#define fork vfork
-#endif /* (defined (USG) || defined (VMS)) */
+static void usage PARAMS ((void)) ATTRIBUTE_NORETURN;
+static void aux_info_corrupted PARAMS ((void)) ATTRIBUTE_NORETURN;
+static void declare_source_confusing PARAMS ((const char *)) ATTRIBUTE_NORETURN;
+static const char *shortpath PARAMS ((const char *, const char *));
+extern void fancy_abort PARAMS ((void)) ATTRIBUTE_NORETURN;
+static void notice PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1;
+static char *savestring PARAMS ((const char *, unsigned int));
+static char *dupnstr PARAMS ((const char *, size_t));
+static const char *substr PARAMS ((const char *, const char * const));
+static int safe_read PARAMS ((int, PTR, int));
+static void safe_write PARAMS ((int, PTR, int, const char *));
+static void save_pointers PARAMS ((void));
+static void restore_pointers PARAMS ((void));
+static int is_id_char PARAMS ((int));
+static int in_system_include_dir PARAMS ((const char *));
+static int directory_specified_p PARAMS ((const char *));
+static int file_excluded_p PARAMS ((const char *));
+static char *unexpand_if_needed PARAMS ((const char *));
+static char *abspath PARAMS ((const char *, const char *));
+static int is_abspath PARAMS ((const char *));
+static void check_aux_info PARAMS ((int));
+static const char *find_corresponding_lparen PARAMS ((const char *));
+static int referenced_file_is_newer PARAMS ((const char *, time_t));
+static void save_def_or_dec PARAMS ((const char *, int));
+static void munge_compile_params PARAMS ((const char *));
+static int gen_aux_info_file PARAMS ((const char *));
+static void process_aux_info_file PARAMS ((const char *, int, int));
+static int identify_lineno PARAMS ((const char *));
+static void check_source PARAMS ((int, const char *));
+static const char *seek_to_line PARAMS ((int));
+static const char *forward_to_next_token_char PARAMS ((const char *));
+static void output_bytes PARAMS ((const char *, size_t));
+static void output_string PARAMS ((const char *));
+static void output_up_to PARAMS ((const char *));
+static int other_variable_style_function PARAMS ((const char *));
+static const char *find_rightmost_formals_list PARAMS ((const char *));
+static void do_cleaning PARAMS ((char *, const char *));
+static const char *careful_find_l_paren PARAMS ((const char *));
+static void do_processing PARAMS ((void));
 
-#endif /* !defined (POSIX) */
+/* Look for these where the `const' qualifier is intentionally cast aside.  */
+#define NONCONST
 
-extern char *rindex ();
+/* Define a default place to find the SYSCALLS.X file.  */
 
-/* Look for these where the `const' qualifier is intentionally cast aside.  */
+#ifndef UNPROTOIZE
 
-#define NONCONST
+#ifndef STANDARD_EXEC_PREFIX
+#define STANDARD_EXEC_PREFIX "/usr/local/lib/gcc-lib/"
+#endif /* !defined STANDARD_EXEC_PREFIX */
 
-/* Define a STRINGIFY macro that's right for ANSI or traditional C.  */
+static const char * const standard_exec_prefix = STANDARD_EXEC_PREFIX;
+static const char * const target_machine = DEFAULT_TARGET_MACHINE;
+static const char * const target_version = DEFAULT_TARGET_VERSION;
 
-#ifdef __STDC__
-#define STRINGIFY(STRING) #STRING
-#else
-#define STRINGIFY(STRING) "STRING"
+#ifndef GET_ENV_PATH_LIST
+#define GET_ENV_PATH_LIST(VAR,NAME)    do { (VAR) = getenv (NAME); } while (0)
 #endif
 
-/* Define a default place to find the SYSCALLS.X file.  */
-
-#ifndef STD_PROTO_DIR
-#define STD_PROTO_DIR "/usr/local/lib"
-#endif /* !defined (STD_PROTO_DIR) */
+#endif /* !defined (UNPROTOIZE) */
 
 /* Suffix of aux_info files.  */
 
-static const char * const aux_info_suffix = ".X";
+static const char * const aux_info_suffix = AUX_INFO_SUFFIX;
 
 /* String to attach to filenames for saved versions of original files.  */
 
-static const char * const save_suffix = ".save";
+static const char * const save_suffix = SAVE_SUFFIX;
+
+/* String to attach to C filenames renamed to C++.  */
+
+static const char * const cplus_suffix = CPLUS_FILE_SUFFIX;
 
 #ifndef UNPROTOIZE
 
@@ -223,7 +155,7 @@ static const char syscalls_filename[] = "SYSCALLS.c";
 
 /* Default place to find the above file.  */
 
-static const char * const default_syscalls_dir = STD_PROTO_DIR;
+static const char * default_syscalls_dir;
 
 /* Variable to hold the complete absolutized filename of the SYSCALLS.c.X
    file.  */
@@ -232,7 +164,7 @@ static char * syscalls_absolute_filename;
 
 #endif /* !defined (UNPROTOIZE) */
 
-/* Type of the structure that holds information about macro unexpansions. */
+/* Type of the structure that holds information about macro unexpansions.  */
 
 struct unexpansion_struct {
   const char *expanded;
@@ -263,7 +195,7 @@ static const unexpansion unexpansions[] = {
 static const int hash_mask = (HASH_TABLE_SIZE - 1);
 
 /* Make a table of default system include directories
-   just as it is done in cccp.c.  */
+   just as it is done in cpp.  */
 
 #ifndef STANDARD_INCLUDE_DIR
 #define STANDARD_INCLUDE_DIR "/usr/include"
@@ -273,49 +205,54 @@ static const int hash_mask = (HASH_TABLE_SIZE - 1);
 #define LOCAL_INCLUDE_DIR "/usr/local/include"
 #endif
 
-struct default_include { const char *fname; int cplusplus; } include_defaults[]
+struct default_include { const char *fname; 
+                        const char *component;
+                        int x1, x2; } include_defaults[]
 #ifdef INCLUDE_DEFAULTS
   = INCLUDE_DEFAULTS;
 #else
   = {
     /* Pick up GNU C++ specific include files.  */
-    { GPLUSPLUS_INCLUDE_DIR, 1},
+    { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 },
 #ifdef CROSS_COMPILE
     /* This is the dir for fixincludes.  Put it just before
        the files that we fix.  */
-    { GCC_INCLUDE_DIR, 0},
+    { GCC_INCLUDE_DIR, "GCC", 0, 0 },
     /* For cross-compilation, this dir name is generated
        automatically in Makefile.in.  */
-    { CROSS_INCLUDE_DIR, 0 },
+    { CROSS_INCLUDE_DIR, 0, 0, 0 },
     /* This is another place that the target system's headers might be.  */
-    { TOOL_INCLUDE_DIR, 0},
+    { TOOL_INCLUDE_DIR, "BINUTILS", 0, 0 },
 #else /* not CROSS_COMPILE */
     /* This should be /use/local/include and should come before
        the fixincludes-fixed header files.  */
-    { LOCAL_INCLUDE_DIR, 0},
+    { LOCAL_INCLUDE_DIR, 0, 0, 1 },
     /* This is here ahead of GCC_INCLUDE_DIR because assert.h goes here.
        Likewise, behind LOCAL_INCLUDE_DIR, where glibc puts its assert.h.  */
-    { TOOL_INCLUDE_DIR, 0},
+    { TOOL_INCLUDE_DIR, "BINUTILS", 0, 0 },
     /* This is the dir for fixincludes.  Put it just before
        the files that we fix.  */
-    { GCC_INCLUDE_DIR, 0},
+    { GCC_INCLUDE_DIR, "GCC", 0, 0 },
     /* Some systems have an extra dir of include files.  */
 #ifdef SYSTEM_INCLUDE_DIR
-    { SYSTEM_INCLUDE_DIR, 0},
+    { SYSTEM_INCLUDE_DIR, 0, 0, 0 },
 #endif
-    { STANDARD_INCLUDE_DIR, 0},
+    { STANDARD_INCLUDE_DIR, 0, 0, 0},
 #endif /* not CROSS_COMPILE */
-    { 0, 0}
+    { 0, 0, 0, 0}
     };
 #endif /* no INCLUDE_DEFAULTS */
 
 /* Datatype for lists of directories or filenames.  */
 struct string_list
 {
-  char *name;
+  const char *name;
   struct string_list *next;
 };
 
+static struct string_list *string_list_cons PARAMS ((const char *,
+                                                    struct string_list *));
+
 /* List of directories in which files should be converted.  */
 
 struct string_list *directory_list;
@@ -360,6 +297,31 @@ typedef struct def_dec_info_struct def_dec_info;
 typedef struct file_info_struct file_info;
 typedef struct f_list_chain_item_struct f_list_chain_item;
 
+#ifndef UNPROTOIZE
+static int is_syscalls_file PARAMS ((const file_info *));
+static void rename_c_file PARAMS ((const hash_table_entry *));
+static const def_dec_info *find_extern_def PARAMS ((const def_dec_info *,
+                                                   const def_dec_info *));
+static const def_dec_info *find_static_definition PARAMS ((const def_dec_info *));
+static void connect_defs_and_decs PARAMS ((const hash_table_entry *));
+static void add_local_decl PARAMS ((const def_dec_info *, const char *));
+static void add_global_decls PARAMS ((const file_info *, const char *));
+#endif /* ! UNPROTOIZE */
+static int needs_to_be_converted PARAMS ((const file_info *));
+static void visit_each_hash_node PARAMS ((const hash_table_entry *,
+                                         void (*)(const hash_table_entry *)));
+static hash_table_entry *add_symbol PARAMS ((hash_table_entry *, const char *));
+static hash_table_entry *lookup PARAMS ((hash_table_entry *, const char *));
+static void free_def_dec PARAMS ((def_dec_info *));
+static file_info *find_file PARAMS ((const char *, int));
+static void reverse_def_dec_list PARAMS ((const hash_table_entry *));
+static void edit_fn_declaration PARAMS ((const def_dec_info *, const char *));
+static int edit_formals_lists PARAMS ((const char *, unsigned int,
+                                      const def_dec_info *));
+static void edit_fn_definition PARAMS ((const def_dec_info *, const char *));
+static void scan_for_missed_items PARAMS ((const file_info *));
+static void edit_file PARAMS ((const hash_table_entry *));
+
 /* In the struct below, note that the "_info" field has two different uses
    depending on the type of hash table we are in (i.e. either the filenames
    hash table or the function names hash table).  In the filenames hash table
@@ -479,7 +441,7 @@ static const char *indent_string = "     "; /* Indentation for newly
 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.  */
-static const charnondefault_syscalls_dir = 0; /* Dir to look for
+static const char *nondefault_syscalls_dir = 0; /* Dir to look for
                                                   SYSCALLS.c.X in.  */
 #endif /* !defined (UNPROTOIZE) */
 
@@ -514,7 +476,7 @@ static const char *convert_filename;
 
 /* Pointer to relative root string (taken from aux_info file) which indicates
    where directory the user was in when he did the compilation step that
-   produced the containing aux_info file. */
+   produced the containing aux_info file.  */
 
 static const char *invocation_filename;
 
@@ -597,63 +559,27 @@ static const char * saved_clean_read_ptr;
    attempt at editing will succeed.  */
 
 static char * saved_repl_write_ptr;
-
-/* Forward declaration.  */
-
-static const char *shortpath ();
 \f
-/* Allocate some space, but check that the allocation was successful.  */
-/* alloca.c uses this, so don't make it static.  */
-
-pointer_type
-xmalloc (byte_count)
-     size_t byte_count;
+/* Translate and output an error message.  */
+static void
+notice VPARAMS ((const char *msgid, ...))
 {
-  pointer_type rv;
-
-  rv = (pointer_type) malloc (byte_count);
-  if (rv == NULL)
-    {
-      fprintf (stderr, "\n%s: virtual memory exceeded\n", pname);
-      exit (1);
-      return 0;                /* avoid warnings */
-    }
-  else
-    return rv;
-}
-
-/* Reallocate some space, but check that the reallocation was successful.  */
+#ifndef ANSI_PROTOTYPES
+  const char *msgid;
+#endif
+  va_list ap;
 
-pointer_type
-xrealloc (old_space, byte_count)
-     pointer_type old_space;
-     size_t byte_count;
-{
-  pointer_type rv;
+  VA_START (ap, msgid);
 
-  rv = (pointer_type) realloc (old_space, byte_count);
-  if (rv == NULL)
-    {
-      fprintf (stderr, "\n%s: virtual memory exceeded\n", pname);
-      exit (1);
-      return 0;                /* avoid warnings */
-    }
-  else
-    return rv;
-}
-
-/* Deallocate the area pointed to by an arbitrary pointer, but first, strip
-   the `const' qualifier from it and also make sure that the pointer value
-   is non-null.  */
+#ifndef ANSI_PROTOTYPES
+  msgid = va_arg (ap, const char *);
+#endif
 
-void
-xfree (p)
-     const_pointer_type p;
-{
-  if (p)
-    free ((NONCONST pointer_type) p);
+  vfprintf (stderr, _(msgid), ap);
+  va_end (ap);
 }
 
+\f
 /* Make a copy of a string INPUT with size SIZE.  */
 
 static char *
@@ -666,29 +592,14 @@ savestring (input, size)
   return output;
 }
 
-/* Make a copy of the concatenation of INPUT1 and INPUT2.  */
-
-static char *
-savestring2 (input1, size1, input2, size2)
-     const char *input1;
-     unsigned int size1;
-     const char *input2;
-     unsigned int size2;
-{
-  char *output = (char *) xmalloc (size1 + size2 + 1);
-  strcpy (output, input1);
-  strcpy (&output[size1], input2);
-  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 ()
 {
-  fprintf (stderr, "%s: internal abort\n", pname);
-  exit (1);
+  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
@@ -720,7 +631,7 @@ substr (s1, s2)
       const char *p2;
       int c;
 
-      for (p1 = s1, p2 = s2; c = *p2; p1++, p2++)
+      for (p1 = s1, p2 = s2; (c = *p2); p1++, p2++)
         if (*p1 != c)
           goto outer;
       return s1;
@@ -736,7 +647,7 @@ outer:
 static int
 safe_read (desc, ptr, len)
      int desc;
-     char *ptr;
+     PTR ptr;
      int len;
 {
   int left = len;
@@ -752,7 +663,8 @@ safe_read (desc, ptr, len)
       }
     if (nchars == 0)
       break;
-    ptr += nchars;
+    /* Arithmetic on void pointers is a gcc extention.  */
+    ptr = (char *) ptr + nchars;
     left -= nchars;
   }
   return len - left;
@@ -764,30 +676,32 @@ safe_read (desc, ptr, len)
 static void
 safe_write (desc, ptr, len, out_fname)
      int desc;
-     char *ptr;
+     PTR ptr;
      int len;
-     char *out_fname;
+     const char *out_fname;
 {
   while (len > 0) {
     int written = write (desc, ptr, len);
     if (written < 0)
       {
+       int errno_val = errno;
 #ifdef EINTR
-       if (errno == EINTR)
+       if (errno_val == EINTR)
          continue;
 #endif
-       fprintf (stderr, "%s: error writing file `%s': %s\n",
-                pname, shortpath (NULL, out_fname), sys_errlist[errno]);
+       notice ("%s: error writing file `%s': %s\n",
+               pname, shortpath (NULL, out_fname), xstrerror (errno_val));
        return;
       }
-    ptr += written;
+    /* Arithmetic on void pointers is a gcc extention.  */
+    ptr = (char *) ptr + written;
     len -= written;
   }
 }
 \f
 /* Get setup to recover in case the edit we are about to do goes awry.  */
 
-void
+static void
 save_pointers ()
 {
   saved_clean_read_ptr = clean_read_ptr;
@@ -797,20 +711,20 @@ save_pointers ()
 /* Call this routine to recover our previous state whenever something looks
    too confusing in the source code we are trying to edit.  */
 
-void
+static void
 restore_pointers ()
 {
   clean_read_ptr = saved_clean_read_ptr;
   repl_write_ptr = saved_repl_write_ptr;
 }
 
-/* Return true if the given character is a legal identifier character.  */
+/* Return true if the given character is a valid identifier character.  */
 
 static int
 is_id_char (ch)
-     char ch;
+     int ch;
 {
-  return (isalnum (ch) || (ch == '_') || (ch == '$'));
+  return (ISALNUM (ch) || (ch == '_') || (ch == '$'));
 }
 
 /* Give a message indicating the proper way to invoke this program and then
@@ -820,13 +734,13 @@ static void
 usage ()
 {
 #ifdef UNPROTOIZE
-  fprintf (stderr, "%s: usage '%s [ -VqfnkN ] [ -i <istring> ] [ filename ... ]'\n",
-          pname, pname);
+  notice ("%s: usage '%s [ -VqfnkN ] [ -i <istring> ] [ filename ... ]'\n",
+         pname, pname);
 #else /* !defined (UNPROTOIZE) */
-  fprintf (stderr, "%s: usage '%s [ -VqfnkNlgC ] [ -B <diname> ] [ filename ... ]'\n",
-          pname, pname);
+  notice ("%s: usage '%s [ -VqfnkNlgC ] [ -B <dirname> ] [ filename ... ]'\n",
+         pname, pname);
 #endif /* !defined (UNPROTOIZE) */
-  exit (1);
+  exit (FATAL_EXIT_CODE);
 }
 
 /* Return true if the given filename (assumed to be an absolute filename)
@@ -839,12 +753,12 @@ in_system_include_dir (path)
 {
   struct default_include *p;
 
-  if (path[0] != '/')
+  if (! is_abspath (path))
     abort ();          /* Must be an absolutized filename.  */
 
   for (p = include_defaults; p->fname; p++)
     if (!strncmp (path, p->fname, strlen (p->fname))
-       && path[strlen (p->fname)] == '/')
+       && IS_DIR_SEPARATOR (path[strlen (p->fname)]))
       return 1;
   return 0;
 }
@@ -859,21 +773,31 @@ file_could_be_converted (const char *path)
 {
   char *const dir_name = (char *) alloca (strlen (path) + 1);
 
-  if (my_access (path, R_OK))
+  if (access (path, R_OK))
     return 0;
 
   {
     char *dir_last_slash;
 
     strcpy (dir_name, path);
-    dir_last_slash = rindex (dir_name, '/');
+    dir_last_slash = strrchr (dir_name, DIR_SEPARATOR);
+#ifdef DIR_SEPARATOR_2
+    {
+      char *slash;
+
+      slash = strrchr (dir_last_slash ? dir_last_slash : dir_name, 
+                       DIR_SEPARATOR_2);
+      if (slash)
+       dir_last_slash = slash;
+    }
+#endif
     if (dir_last_slash)
       *dir_last_slash = '\0';
     else
       abort ();  /* Should have been an absolutized filename.  */
   }
 
-  if (my_access (path, W_OK))
+  if (access (path, W_OK))
     return 0;
 
   return 1;
@@ -900,34 +824,44 @@ file_normally_convertible (const char *path)
     char *dir_last_slash;
 
     strcpy (dir_name, path);
-    dir_last_slash = rindex (dir_name, '/');
+    dir_last_slash = strrchr (dir_name, DIR_SEPARATOR);
+#ifdef DIR_SEPARATOR_2
+    {
+      char *slash;
+
+      slash = strrchr (dir_last_slash ? dir_last_slash : dir_name, 
+                       DIR_SEPARATOR_2);
+      if (slash)
+       dir_last_slash = slash;
+    }
+#endif
     if (dir_last_slash)
       *dir_last_slash = '\0';
     else
       abort ();  /* Should have been an absolutized filename.  */
   }
 
-  if (my_access (path, R_OK))
+  if (access (path, R_OK))
     {
       if (!quiet_flag)
-        fprintf (stderr, "%s: warning: no read access for file `%s'\n",
-                pname, shortpath (NULL, path));
+        notice ("%s: warning: no read access for file `%s'\n",
+               pname, shortpath (NULL, path));
       return 0;
     }
 
-  if (my_access (path, W_OK))
+  if (access (path, W_OK))
     {
       if (!quiet_flag)
-        fprintf (stderr, "%s: warning: no write access for file `%s'\n",
-                pname, shortpath (NULL, path));
+        notice ("%s: warning: no write access for file `%s'\n",
+               pname, shortpath (NULL, path));
       return 0;
     }
 
-  if (my_access (dir_name, W_OK))
+  if (access (dir_name, W_OK))
     {
       if (!quiet_flag)
-        fprintf (stderr, "%s: warning: no write access for dir containing `%s'\n",
-                pname, shortpath (NULL, path));
+        notice ("%s: warning: no write access for dir containing `%s'\n",
+               pname, shortpath (NULL, path));
       return 0;
     }
 
@@ -979,14 +913,14 @@ needs_to_be_converted (file_p)
 
 #ifndef UNPROTOIZE
 
-      /* ... and if we a protoizing and this function is in old style ... */
+      /* ... and if we a protoizing and this function is in old style ...  */
       !ddp->prototyped
-      /* ... and if this a definition or is a decl with an associated def ... */
+      /* ... and if this a definition or is a decl with an associated def ...  */
       && (ddp->is_func_def || (!ddp->is_func_def && ddp->definition))
 
 #else /* defined (UNPROTOIZE) */
 
-      /* ... and if we are unprotoizing and this function is in new style ... */
+      /* ... and if we are unprotoizing and this function is in new style ...  */
       ddp->prototyped
 
 #endif /* defined (UNPROTOIZE) */
@@ -1007,14 +941,14 @@ directory_specified_p (name)
 
   for (p = directory_list; p; p = p->next)
     if (!strncmp (name, p->name, strlen (p->name))
-       && name[strlen (p->name)] == '/')
+       && IS_DIR_SEPARATOR (name[strlen (p->name)]))
       {
        const char *q = name + strlen (p->name) + 1;
 
        /* If there are more slashes, it's in a subdir, so
           this match doesn't count.  */
-       while (*q)
-         if (*q++ == '/')
+       while (*q++)
+         if (IS_DIR_SEPARATOR (*(q-1)))
            goto lose;
        return 1;
 
@@ -1035,7 +969,7 @@ file_excluded_p (name)
 
   for (p = exclude_list; p; p = p->next)
     if (!strcmp (name + len - strlen (p->name), p->name)
-       && name[len - strlen (p->name) - 1] == '/')
+       && IS_DIR_SEPARATOR (name[len - strlen (p->name) - 1]))
       return 1;
 
   return 0;
@@ -1046,7 +980,7 @@ file_excluded_p (name)
 
 static struct string_list *
 string_list_cons (string, rest)
-     char *string;
+     const char *string;
      struct string_list *rest;
 {
   struct string_list *temp
@@ -1069,7 +1003,7 @@ string_list_cons (string, rest)
 static void
 visit_each_hash_node (hash_tab_p, func)
      const hash_table_entry *hash_tab_p;
-     void (*func)();
+     void (*func) PARAMS ((const hash_table_entry *));
 {
   const hash_table_entry *primary;
 
@@ -1095,7 +1029,7 @@ add_symbol (p, s)
      const char *s;
 {
   p->hash_next = NULL;
-  p->symbol = savestring (s, strlen (s));
+  p->symbol = xstrdup (s);
   p->ddip = NULL;
   p->fip = NULL;
   return p;
@@ -1143,7 +1077,7 @@ static void
 free_def_dec (p)
      def_dec_info *p;
 {
-  xfree (p->ansi_decl);
+  free ((NONCONST PTR) p->ansi_decl);
 
 #ifndef UNPROTOIZE
   {
@@ -1153,12 +1087,12 @@ free_def_dec (p)
     for (curr = p->f_list_chain; curr; curr = next)
       {
         next = curr->chain_next;
-        xfree (curr);
+        free ((NONCONST PTR) curr);
       }
   }
 #endif /* !defined (UNPROTOIZE) */
 
-  xfree (p);
+  free (p);
 }
 
 /* Unexpand as many macro symbol as we can find.
@@ -1172,7 +1106,7 @@ unexpand_if_needed (aux_info_line)
 {
   static char *line_buf = 0;
   static int line_buf_size = 0;
-  const unexpansionunexp_p;
+  const unexpansion *unexp_p;
   int got_unexpanded = 0;
   const char *s;
   char *copy_p = line_buf;
@@ -1239,6 +1173,20 @@ continue_outer: ;
   return (got_unexpanded ? savestring (line_buf, copy_p - line_buf) : 0);
 }
 \f
+/* Return 1 if pathname is absolute. */
+
+static int
+is_abspath (path)
+     const char *path;
+{
+  return (IS_DIR_SEPARATOR (path[0])
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+          /* Check for disk name on MS-DOS-based systems.  */
+          || (path[0] && path[1] == ':' && IS_DIR_SEPARATOR (path[2]))
+#endif
+          );
+}
+\f
 /* Return the absolutized filename for the given relative
    filename.  Note that if that filename is already absolute, it may
    still be returned in a modified form because this routine also
@@ -1267,15 +1215,26 @@ abspath (cwd, rel_filename)
   {
     const char *src_p;
 
-    if (rel_filename[0] != '/')
+    if (! is_abspath (rel_filename))
       {
         src_p = cwd2;
-        while (*endp++ = *src_p++)
+        while ((*endp++ = *src_p++))
           continue;
-        *(endp-1) = '/';                       /* overwrite null */
+        *(endp-1) = DIR_SEPARATOR;                     /* overwrite null */
       }
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+    else if (IS_DIR_SEPARATOR (rel_filename[0]))
+      {
+       /* A path starting with a directory separator is considered absolute 
+          for dos based filesystems, but it's really not -- it's just the 
+          convention used throughout GCC and it works. However, in this
+          case, we still need to prepend the drive spec from cwd_buffer.  */
+       *endp++ = cwd2[0];
+       *endp++ = cwd2[1];
+      }
+#endif
     src_p = rel_filename;
-    while (*endp++ = *src_p++)
+    while ((*endp++ = *src_p++))
       continue;
   }
 
@@ -1284,47 +1243,48 @@ abspath (cwd, rel_filename)
 
   outp = inp = abs_buffer;
   *outp++ = *inp++;            /* copy first slash */
-#ifdef apollo
-  if (inp[0] == '/')
+#if defined (apollo) || defined (_WIN32) || defined (__INTERIX)
+  if (IS_DIR_SEPARATOR (inp[0]))
     *outp++ = *inp++;          /* copy second slash */
 #endif
   for (;;)
     {
       if (!inp[0])
         break;
-      else if (inp[0] == '/' && outp[-1] == '/')
+      else if (IS_DIR_SEPARATOR (inp[0]) && IS_DIR_SEPARATOR (outp[-1]))
         {
           inp++;
           continue;
         }
-      else if (inp[0] == '.' && outp[-1] == '/')
+      else if (inp[0] == '.' && IS_DIR_SEPARATOR (outp[-1]))
         {
           if (!inp[1])
                   break;
-          else if (inp[1] == '/')
+          else if (IS_DIR_SEPARATOR (inp[1]))
             {
                     inp += 2;
                     continue;
             }
-          else if ((inp[1] == '.') && (inp[2] == 0 || inp[2] == '/'))
+          else if ((inp[1] == '.') && (inp[2] == 0 
+                                      || IS_DIR_SEPARATOR (inp[2])))
             {
-                    inp += (inp[2] == '/') ? 3 : 2;
+                    inp += (IS_DIR_SEPARATOR (inp[2])) ? 3 : 2;
                     outp -= 2;
-                    while (outp >= abs_buffer && *outp != '/')
+                    while (outp >= abs_buffer && ! IS_DIR_SEPARATOR (*outp))
                outp--;
                     if (outp < abs_buffer)
-                {
-                  /* Catch cases like /.. where we try to backup to a
-                     point above the absolute root of the logical file
-                     system.  */
-
-                 fprintf (stderr, "%s: invalid file name: %s\n",
-                          pname, rel_filename);
-                 exit (1);
-               }
+                     {
+                       /* Catch cases like /.. where we try to backup to a
+                          point above the absolute root of the logical file
+                          system.  */
+
+                       notice ("%s: invalid file name: %s\n",
+                               pname, rel_filename);
+                       exit (FATAL_EXIT_CODE);
+                     }
                     *++outp = '\0';
                     continue;
-            }
+                 }
         }
       *outp++ = *inp++;
     }
@@ -1333,7 +1293,7 @@ abspath (cwd, rel_filename)
      the last character of the returned string is *not* a slash.  */
 
   *outp = '\0';
-  if (outp[-1] == '/')
+  if (IS_DIR_SEPARATOR (outp[-1]))
     *--outp  = '\0';
 
   /* Make a copy (in the heap) of the stuff left in the absolutization
@@ -1371,13 +1331,14 @@ shortpath (cwd, filename)
   path_p = abspath (cwd, filename);
   rel_buf_p = rel_buffer = (char *) xmalloc (filename_len);
 
-  while (*cwd_p && (*cwd_p == *path_p))
+  while (*cwd_p && IS_SAME_PATH_CHAR (*cwd_p, *path_p))
     {
       cwd_p++;
       path_p++;
     }
-  if (!*cwd_p && (!*path_p || *path_p == '/')) /* whole pwd matched */
+  if (!*cwd_p && (!*path_p || IS_DIR_SEPARATOR (*path_p)))
     {
+      /* whole pwd matched */
       if (!*path_p)            /* input *is* the current path! */
         return ".";
       else
@@ -1389,7 +1350,7 @@ shortpath (cwd, filename)
         {
           --cwd_p;
           --path_p;
-          while (*cwd_p != '/')                /* backup to last slash */
+          while (! IS_DIR_SEPARATOR (*cwd_p))     /* backup to last slash */
             {
               --cwd_p;
               --path_p;
@@ -1400,8 +1361,8 @@ shortpath (cwd, filename)
         }
 
       /* Find out how many directory levels in cwd were *not* matched.  */
-      while (*cwd_p)
-        if (*cwd_p++ == '/')
+      while (*cwd_p++)
+        if (IS_DIR_SEPARATOR (*(cwd_p-1)))
          unmatched_slash_count++;
 
       /* Now we know how long the "short name" will be.
@@ -1418,7 +1379,7 @@ shortpath (cwd, filename)
            return filename;
           *rel_buf_p++ = '.';
           *rel_buf_p++ = '.';
-          *rel_buf_p++ = '/';
+          *rel_buf_p++ = DIR_SEPARATOR;
         }
 
       /* Then tack on the unmatched part of the desired file's name.  */
@@ -1427,10 +1388,10 @@ shortpath (cwd, filename)
          if (rel_buffer + filename_len <= rel_buf_p)
            return filename;
        }
-      while (*rel_buf_p++ = *path_p++);
+      while ((*rel_buf_p++ = *path_p++));
 
       --rel_buf_p;
-      if (*(rel_buf_p-1) == '/')
+      if (IS_DIR_SEPARATOR (*(rel_buf_p-1)))
         *--rel_buf_p = '\0';
       return rel_buffer;
     }
@@ -1446,7 +1407,7 @@ shortpath (cwd, filename)
 
 static file_info *
 find_file (filename, do_not_stat)
-     char *filename;
+     const char *filename;
      int do_not_stat;
 {
   hash_table_entry *hash_entry_p;
@@ -1466,10 +1427,12 @@ find_file (filename, do_not_stat)
         stat_buf.st_mtime = (time_t) 0;
       else
         {
-          if (my_stat (filename, &stat_buf) == -1)
+          if (stat (filename, &stat_buf) == -1)
             {
-              fprintf (stderr, "%s: %s: can't get status: %s\n",
-                      pname, shortpath (NULL, filename), sys_errlist[errno]);
+             int errno_val = errno;
+              notice ("%s: %s: can't get status: %s\n",
+                     pname, shortpath (NULL, filename),
+                     xstrerror (errno_val));
               stat_buf.st_mtime = (time_t) -1;
             }
         }
@@ -1488,9 +1451,9 @@ find_file (filename, do_not_stat)
 static void
 aux_info_corrupted ()
 {
-  fprintf (stderr, "\n%s: fatal error: aux info file corrupted at line %d\n",
-          pname, current_aux_info_lineno);
-  exit (1);
+  notice ("\n%s: fatal error: aux info file corrupted at line %d\n",
+         pname, current_aux_info_lineno);
+  exit (FATAL_EXIT_CODE);
 }
 
 /* ??? This comment is vague.  Say what the condition is for.  */
@@ -1551,7 +1514,11 @@ referenced_file_is_newer (l, aux_info_mtime)
   {
     const char *filename_start = p = l + 3;
 
-    while (*p != ':')
+    while (*p != ':'
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+           || (*p == ':' && *p && *(p+1) && IS_DIR_SEPARATOR (*(p+1)))
+#endif
+           )
       p++;
     filename = (char *) alloca ((size_t) (p - filename_start) + 1);
     strncpy (filename, filename_start, (size_t) (p - filename_start));
@@ -1609,7 +1576,11 @@ save_def_or_dec (l, is_syscalls)
     const char *filename_start = p = l + 3;
     char *filename;
 
-    while (*p != ':')
+    while (*p != ':'
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+           || (*p == ':' && *p && *(p+1) && IS_DIR_SEPARATOR (*(p+1)))
+#endif
+           )
       p++;
     filename = (char *) alloca ((size_t) (p - filename_start) + 1);
     strncpy (filename, filename_start, (size_t) (p - filename_start));
@@ -1636,7 +1607,11 @@ save_def_or_dec (l, is_syscalls)
     const char *line_number_start = ++p;
     char line_number[10];
 
-    while (*p != ':')
+    while (*p != ':'
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+           || (*p == ':' && *p && *(p+1) && IS_DIR_SEPARATOR (*(p+1)))
+#endif
+           )
       p++;
     strncpy (line_number, line_number_start, (size_t) (p - line_number_start));
     line_number[p-line_number_start] = '\0';
@@ -1646,7 +1621,7 @@ save_def_or_dec (l, is_syscalls)
   /* Check that this record describes a new-style, old-style, or implicit
      definition or declaration.  */
 
-  p++; /* Skip over the `:'. */
+  p++; /* Skip over the `:'.  */
   check_aux_info ((*p == 'N') || (*p == 'O') || (*p == 'I'));
 
   /* Is this a new style (ANSI prototyped) definition or declaration? */
@@ -1737,8 +1712,8 @@ save_def_or_dec (l, 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
+         = (f_list_chain_item *) xmalloc (sizeof (f_list_chain_item));
 
         cip->formals_list
          = dupnstr (left_paren_p + 1, (size_t) (p - (left_paren_p+1)));
@@ -1812,11 +1787,11 @@ save_def_or_dec (l, is_syscalls)
           {
             if (strcmp (def_dec_p->ansi_decl, other->ansi_decl))
               {
-                fprintf (stderr, "%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);
-                exit (1);
+                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);
+                exit (FATAL_EXIT_CODE);
               }
             free_def_dec (def_dec_p);
             return;
@@ -1852,7 +1827,7 @@ save_def_or_dec (l, is_syscalls)
       check_aux_info (*++p == '(');
 
       {
-        const char *kr_names_start = ++p;   /* Point just inside '('. */
+        const char *kr_names_start = ++p;   /* Point just inside '('.  */
 
         while (*p++ != ')')
           continue;
@@ -1894,7 +1869,7 @@ save_def_or_dec (l, is_syscalls)
         }
 
       /* Handle a special case.  If we have a function definition marked as
-         being in "old" style, and if it's formal names list is empty, then
+         being in "old" style, and if its formal names list is empty, then
          it may actually have the string "void" in its real formals list
          in the original source code.  Just to make sure, we will get setup
          to convert such things anyway.
@@ -1980,16 +1955,17 @@ munge_compile_params (params_list)
     = (const char **) alloca ((strlen (params_list) + 8) * sizeof (char *));
   int param_count = 0;
   const char *param;
+  struct stat st;
 
   temp_params[param_count++] = compiler_file_name;
   for (;;)
     {
-      while (isspace (*params_list))
+      while (ISSPACE ((const unsigned char)*params_list))
         params_list++;
       if (!*params_list)
         break;
       param = params_list;
-      while (*params_list && !isspace (*params_list))
+      while (*params_list && !ISSPACE ((const unsigned char)*params_list))
         params_list++;
       if (param[0] != '-')
         temp_params[param_count++]
@@ -2004,9 +1980,10 @@ munge_compile_params (params_list)
               case 'c':
                 break;         /* Don't copy these.  */
               case 'o':
-                while (isspace (*params_list))
+                while (ISSPACE ((const unsigned char)*params_list))
                   params_list++;
-                while (*params_list && !isspace (*params_list))
+                while (*params_list
+                      && !ISSPACE ((const unsigned char)*params_list))
                   params_list++;
                 break;
               default:
@@ -2025,7 +2002,16 @@ munge_compile_params (params_list)
 
   temp_params[param_count++] = "-S";
   temp_params[param_count++] = "-o";
-  temp_params[param_count++] = "/dev/null";
+  
+  if ((stat (HOST_BIT_BUCKET, &st) == 0)
+      && (!S_ISDIR (st.st_mode))
+      && (access (HOST_BIT_BUCKET, W_OK) == 0))
+    temp_params[param_count++] = HOST_BIT_BUCKET;
+  else
+    /* FIXME: This is hardly likely to be right, if HOST_BIT_BUCKET is not
+       writable.  But until this is rejigged to use make_temp_file(), this
+       is the best we can do.  */
+    temp_params[param_count++] = "/dev/null";
 
   /* Leave room for the input file name argument.  */
   input_file_name_index = param_count;
@@ -2041,96 +2027,68 @@ munge_compile_params (params_list)
 }
 
 /* Do a recompilation for the express purpose of generating a new aux_info
-   file to go with a specific base source file.  */
+   file to go with a specific base source file.
+
+   The result is a boolean indicating success.  */
 
 static int
 gen_aux_info_file (base_filename)
      const char *base_filename;
 {
-  int child_pid;
-
   if (!input_file_name_index)
     munge_compile_params ("");
 
   /* Store the full source file name in the argument vector.  */
   compile_params[input_file_name_index] = shortpath (NULL, base_filename);
   /* Add .X to source file name to get aux-info file name.  */
-  compile_params[aux_info_file_name_index]
-    = savestring2 (compile_params[input_file_name_index],
-                  strlen (compile_params[input_file_name_index]),
-                  ".X",
-                  2);
-
+  compile_params[aux_info_file_name_index] =
+    concat (compile_params[input_file_name_index], aux_info_suffix, NULL);
+  
   if (!quiet_flag)
-    fprintf (stderr, "%s: compiling `%s'\n",
-            pname, compile_params[input_file_name_index]);
+    notice ("%s: compiling `%s'\n",
+           pname, compile_params[input_file_name_index]);
 
-  if (child_pid = fork ())
-    {
-      if (child_pid == -1)
-        {
-          fprintf (stderr, "%s: could not fork process: %s\n",
-                  pname, sys_errlist[errno]);
-          return 0;
-        }
-
-#if 0
-      /* Print out the command line that the other process is now executing.  */
+  {
+    char *errmsg_fmt, *errmsg_arg;
+    int wait_status, pid;
 
-      if (!quiet_flag)
-        {
-          const char **arg;
-  
-          fputs ("\t", stderr);
-          for (arg = compile_params; *arg; arg++)
-            {
-              fputs (*arg, stderr);
-              fputc (' ', stderr);
-            }
-          fputc ('\n', stderr);
-          fflush (stderr);
-        }
-#endif /* 0 */
+    pid = pexecute (compile_params[0], (char * const *) compile_params,
+                   pname, NULL, &errmsg_fmt, &errmsg_arg,
+                   PEXECUTE_FIRST | PEXECUTE_LAST | PEXECUTE_SEARCH);
 
+    if (pid == -1)
       {
-        int wait_status;
+       int errno_val = errno;
+       fprintf (stderr, "%s: ", pname);
+       fprintf (stderr, errmsg_fmt, errmsg_arg);
+       fprintf (stderr, ": %s\n", xstrerror (errno_val));
+       return 0;
+      }
 
-        if (wait (&wait_status) == -1)
-          {
-            fprintf (stderr, "%s: wait failed: %s\n",
-                    pname, sys_errlist[errno]);
-            return 0;
-          }
-       if ((wait_status & 0x7F) != 0)
-         {
-           fprintf (stderr, "%s: subprocess got fatal signal %d",
-                    pname, (wait_status & 0x7F));
-           return 0;
-         }
-       if (((wait_status & 0xFF00) >> 8) != 0)
+    pid = pwait (pid, &wait_status, 0);
+    if (pid == -1)
+      {
+       notice ("%s: wait: %s\n", pname, xstrerror (errno));
+       return 0;
+      }
+    if (WIFSIGNALED (wait_status))
+      {
+       notice ("%s: subprocess got fatal signal %d\n",
+               pname, WTERMSIG (wait_status));
+       return 0;
+      }
+    if (WIFEXITED (wait_status))
+      {
+       if (WEXITSTATUS (wait_status) != 0)
          {
-           fprintf (stderr, "%s: %s exited with status %d\n",
-                    pname, base_filename, ((wait_status & 0xFF00) >> 8));
+           notice ("%s: %s exited with status %d\n",
+                   pname, compile_params[0], WEXITSTATUS (wait_status));
            return 0;
          }
        return 1;
       }
-    }
-  else
-    {
-      if (my_execvp (compile_params[0], (char *const *) compile_params))
-        {
-         int e = errno, f = fileno (stderr);
-         write (f, pname, strlen (pname));
-         write (f, ": ", 2);
-         write (f, compile_params[0], strlen (compile_params[0]));
-         write (f, ": ", 2);
-         write (f, sys_errlist[e], strlen (sys_errlist[e]));
-         write (f, "\n", 1);
-          _exit (1);
-        }
-      return 1;                /* Never executed.  */
-    }
+    abort ();
+  }
 }
 \f
 /* Read in all of the information contained in a single aux_info file.
@@ -2169,23 +2127,24 @@ process_aux_info_file (base_source_filename, keep_it, is_syscalls)
   /* Come here with must_create set to 1 if file is out of date.  */
 start_over: ;
 
-  if (my_access (aux_info_filename, R_OK) == -1)
+  if (access (aux_info_filename, R_OK) == -1)
     {
       if (errno == ENOENT)
        {
          if (is_syscalls)
            {
-             fprintf (stderr, "%s: warning: missing SYSCALLS file `%s'\n",
-                      pname, aux_info_filename);
+             notice ("%s: warning: missing SYSCALLS file `%s'\n",
+                     pname, aux_info_filename);
              return;
            }
          must_create = 1;
        }
       else
        {
-         fprintf (stderr, "%s: can't read aux info file `%s': %s\n",
-                  pname, shortpath (NULL, aux_info_filename),
-                  sys_errlist[errno]);
+         int errno_val = errno;
+         notice ("%s: can't read aux info file `%s': %s\n",
+                 pname, shortpath (NULL, aux_info_filename),
+                 xstrerror (errno_val));
          errors++;
          return;
        }
@@ -2209,11 +2168,12 @@ start_over: ;
          errors++;
          return;
        }
-      if (my_access (aux_info_filename, R_OK) == -1)
+      if (access (aux_info_filename, R_OK) == -1)
        {
-         fprintf (stderr, "%s: can't read aux info file `%s': %s\n",
-                  pname, shortpath (NULL, aux_info_filename),
-                  sys_errlist[errno]);
+         int errno_val = errno;
+         notice ("%s: can't read aux info file `%s': %s\n",
+                 pname, shortpath (NULL, aux_info_filename),
+                 xstrerror (errno_val));
          errors++;
          return;
        }
@@ -2224,11 +2184,12 @@ start_over: ;
 
     /* Get some status information about this aux_info file.  */
   
-    if (my_stat (aux_info_filename, &stat_buf) == -1)
+    if (stat (aux_info_filename, &stat_buf) == -1)
       {
-        fprintf (stderr, "%s: can't get status of aux info file `%s': %s\n",
-                pname, shortpath (NULL, aux_info_filename),
-                sys_errlist[errno]);
+       int errno_val = errno;
+        notice ("%s: can't get status of aux info file `%s': %s\n",
+               pname, shortpath (NULL, aux_info_filename),
+               xstrerror (errno_val));
         errors++;
         return;
       }
@@ -2251,11 +2212,12 @@ start_over: ;
           The code later on can fail to check the .c file
           if it did not directly define any functions.  */
 
-       if (my_stat (base_source_filename, &stat_buf) == -1)
+       if (stat (base_source_filename, &stat_buf) == -1)
          {
-           fprintf (stderr, "%s: can't get status of aux info file `%s': %s\n",
-                    pname, shortpath (NULL, base_source_filename),
-                    sys_errlist[errno]);
+           int errno_val = errno;
+           notice ("%s: can't get status of aux info file `%s': %s\n",
+                   pname, shortpath (NULL, base_source_filename),
+                   xstrerror (errno_val));
            errors++;
            return;
          }
@@ -2269,14 +2231,21 @@ start_over: ;
 
   {
     int aux_info_file;
+    int fd_flags;
 
     /* Open the aux_info file.  */
   
-    if ((aux_info_file = my_open (aux_info_filename, O_RDONLY, 0444 )) == -1)
+    fd_flags = O_RDONLY;
+#ifdef O_BINARY
+    /* Use binary mode to avoid having to deal with different EOL characters. */
+    fd_flags |= O_BINARY;
+#endif
+    if ((aux_info_file = open (aux_info_filename, fd_flags, 0444 )) == -1)
       {
-        fprintf (stderr, "%s: can't open aux info file `%s' for reading: %s\n",
-                pname, shortpath (NULL, aux_info_filename),
-                sys_errlist[errno]);
+       int errno_val = errno;
+        notice ("%s: can't open aux info file `%s' for reading: %s\n",
+               pname, shortpath (NULL, aux_info_filename),
+               xstrerror (errno_val));
         return;
       }
   
@@ -2288,11 +2257,13 @@ start_over: ;
   
     /* Read the aux_info file into memory.  */
   
-    if (safe_read (aux_info_file, aux_info_base, aux_info_size) != aux_info_size)
+    if (safe_read (aux_info_file, aux_info_base, aux_info_size) !=
+       (int) aux_info_size)
       {
-        fprintf (stderr, "%s: error reading aux info file `%s': %s\n",
-                pname, shortpath (NULL, aux_info_filename),
-                sys_errlist[errno]);
+       int errno_val = errno;
+        notice ("%s: error reading aux info file `%s': %s\n",
+               pname, shortpath (NULL, aux_info_filename),
+               xstrerror (errno_val));
         free (aux_info_base);
         close (aux_info_file);
         return;
@@ -2302,9 +2273,10 @@ start_over: ;
   
     if (close (aux_info_file))
       {
-        fprintf (stderr, "%s: error closing aux info file `%s': %s\n",
-                pname, shortpath (NULL, aux_info_filename),
-                sys_errlist[errno]);
+       int errno_val = errno;
+        notice ("%s: error closing aux info file `%s': %s\n",
+               pname, shortpath (NULL, aux_info_filename),
+               xstrerror (errno_val));
         free (aux_info_base);
         close (aux_info_file);
         return;
@@ -2315,10 +2287,13 @@ start_over: ;
      fails for some reason, don't even worry about it.  */
 
   if (must_create && !keep_it)
-    if (my_unlink (aux_info_filename) == -1)
-      fprintf (stderr, "%s: can't delete aux info file `%s': %s\n",
-              pname, shortpath (NULL, aux_info_filename),
-              sys_errlist[errno]);
+    if (unlink (aux_info_filename) == -1)
+      {
+       int errno_val = errno;
+       notice ("%s: can't delete aux info file `%s': %s\n",
+               pname, shortpath (NULL, aux_info_filename),
+               xstrerror (errno_val));
+      }
 
   /* Save a pointer into the first line of the aux_info file which
      contains the filename of the directory from which the compiler
@@ -2330,7 +2305,11 @@ start_over: ;
   {
     char *p = aux_info_base;
 
-    while (*p != ':')
+    while (*p != ':'
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+           || (*p == ':' && *p && *(p+1) && IS_DIR_SEPARATOR (*(p+1)))
+#endif
+           )
       p++;
     p++;
     while (*p == ' ')
@@ -2338,20 +2317,30 @@ start_over: ;
     invocation_filename = p;   /* Save a pointer to first byte of path.  */
     while (*p != ' ')
       p++;
-    *p++ = '/';
+    *p++ = DIR_SEPARATOR;
     *p++ = '\0';
     while (*p++ != '\n')
       continue;
     aux_info_second_line = p;
     aux_info_relocated_name = 0;
-    if (invocation_filename[0] != '/')
+    if (! is_abspath (invocation_filename))
       {
        /* INVOCATION_FILENAME is relative;
           append it to BASE_SOURCE_FILENAME's dir.  */
        char *dir_end;
        aux_info_relocated_name = xmalloc (base_len + (p-invocation_filename));
        strcpy (aux_info_relocated_name, base_source_filename);
-       dir_end = rindex (aux_info_relocated_name, '/');
+       dir_end = strrchr (aux_info_relocated_name, DIR_SEPARATOR);
+#ifdef DIR_SEPARATOR_2
+       {
+         char *slash;
+
+         slash = strrchr (dir_end ? dir_end : aux_info_relocated_name, 
+                          DIR_SEPARATOR_2);
+         if (slash)
+           dir_end = slash;
+       }
+#endif
        if (dir_end)
          dir_end++;
        else
@@ -2379,14 +2368,16 @@ start_over: ;
             if (referenced_file_is_newer (aux_info_p, aux_info_mtime))
               {
                 free (aux_info_base);
-               xfree (aux_info_relocated_name);
-                if (keep_it && my_unlink (aux_info_filename) == -1)
+               free (aux_info_relocated_name);
+                if (keep_it && unlink (aux_info_filename) == -1)
                   {
-                    fprintf (stderr, "%s: can't delete file `%s': %s\n",
-                            pname, shortpath (NULL, aux_info_filename),
-                            sys_errlist[errno]);
+                   int errno_val = errno;
+                    notice ("%s: can't delete file `%s': %s\n",
+                           pname, shortpath (NULL, aux_info_filename),
+                           xstrerror (errno_val));
                     return;
                   }
+               must_create = 1;
                 goto start_over;
               }
     
@@ -2426,7 +2417,7 @@ start_over: ;
   }
 
   free (aux_info_base);
-  xfree (aux_info_relocated_name);
+  free (aux_info_relocated_name);
 }
 \f
 #ifndef UNPROTOIZE
@@ -2441,33 +2432,28 @@ rename_c_file (hp)
 {
   const char *filename = hp->symbol;
   int last_char_index = strlen (filename) - 1;
-  char *const new_filename = (char *) alloca (strlen (filename) + 1);
+  char *const new_filename = (char *) 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
      was nothing in it which actually required conversion.  Even in this case,
      we want to do the renaming.  Note that we only rename files with the .c
-     suffix.  */
+     suffix (except for the syscalls file, which is left alone).  */
 
-  if (filename[last_char_index] != 'c' || filename[last_char_index-1] != '.')
+  if (filename[last_char_index] != 'c' || filename[last_char_index-1] != '.'
+      || IS_SAME_PATH (syscalls_absolute_filename, filename))
     return;
 
   strcpy (new_filename, filename);
-  new_filename[last_char_index] = 'C';
+  strcpy (&new_filename[last_char_index], cplus_suffix);
 
-  if (my_link (filename, new_filename) == -1)
+  if (rename (filename, new_filename) == -1)
     {
-      fprintf (stderr, "%s: warning: can't link file `%s' to `%s': %s\n",
-              pname, shortpath (NULL, filename),
-              shortpath (NULL, new_filename), sys_errlist[errno]);
-      errors++;
-      return;
-    }
-
-  if (my_unlink (filename) == -1)
-    {
-      fprintf (stderr, "%s: warning: can't delete file `%s': %s\n",
-              pname, shortpath (NULL, filename), sys_errlist[errno]);
+      int errno_val = errno;
+      notice ("%s: warning: can't rename file `%s' to `%s': %s\n",
+             pname, shortpath (NULL, filename),
+             shortpath (NULL, new_filename), xstrerror (errno_val));
       errors++;
       return;
     }
@@ -2488,23 +2474,23 @@ reverse_def_dec_list (hp)
      const hash_table_entry *hp;
 {
   file_info *file_p = hp->fip;
-  const def_dec_info *prev = NULL;
-  const def_dec_info *current = file_p->defs_decs;
+  def_dec_info *prev = NULL;
+  def_dec_info *current = (def_dec_info *)file_p->defs_decs;
 
-  if (!( current = file_p->defs_decs))
+  if (!current)
     return;                    /* no list to reverse */
 
   prev = current;
-  if (! (current = current->next_in_file))
+  if (! (current = (def_dec_info *)current->next_in_file))
     return;                    /* can't reverse a single list element */
 
-  ((NONCONST def_dec_info *) prev)->next_in_file = NULL;
+  prev->next_in_file = NULL;
 
   while (current)
     {
-      const def_dec_info *next = current->next_in_file;
+      def_dec_info *next = (def_dec_info *)current->next_in_file;
 
-      ((NONCONST def_dec_info *) current)->next_in_file = prev;
+      current->next_in_file = prev;
       prev = current;
       current = next;
     }
@@ -2566,7 +2552,7 @@ find_extern_def (head, user)
     if (dd_p->is_func_def && !dd_p->is_static)
       {
         if (!extern_def_p)     /* Previous definition? */
-          extern_def_p = dd_p; /* Remember the first definition found. */
+          extern_def_p = dd_p; /* Remember the first definition found.  */
         else
           {
             /* Ignore definition just found if it came from SYSCALLS.c.X.  */
@@ -2590,14 +2576,14 @@ find_extern_def (head, user)
             if (!conflict_noted)       /* first time we noticed? */
               {
                 conflict_noted = 1;
-                fprintf (stderr, "%s: conflicting extern definitions of '%s'\n",
-                        pname, head->hash_entry->symbol);
+                notice ("%s: conflicting extern definitions of '%s'\n",
+                       pname, head->hash_entry->symbol);
                 if (!quiet_flag)
                   {
-                    fprintf (stderr, "%s: declarations of '%s' will not be converted\n",
-                            pname, head->hash_entry->symbol);
-                    fprintf (stderr, "%s: conflict list for '%s' follows:\n",
-                            pname, head->hash_entry->symbol);
+                    notice ("%s: declarations of '%s' will not be converted\n",
+                           pname, head->hash_entry->symbol);
+                    notice ("%s: conflict list for '%s' follows:\n",
+                           pname, head->hash_entry->symbol);
                     fprintf (stderr, "%s:     %s(%d): %s\n",
                             pname,
                             shortpath (NULL, extern_def_p->file->hash_entry->symbol),
@@ -2629,10 +2615,10 @@ find_extern_def (head, user)
           {
             extern_def_p = dd_p;       /* save a pointer to the definition */
             if (!quiet_flag)
-              fprintf (stderr, "%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);
+              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);
             break;
           }
 
@@ -2669,15 +2655,15 @@ find_extern_def (head, user)
                *p++ = '?';
                 strcpy (p, ");");
 
-                fprintf (stderr, "%s: %d: `%s' used but missing from SYSCALLS\n",
-                        shortpath (NULL, file), user->line,
-                        needed+7);     /* Don't print "extern " */
+                notice ("%s: %d: `%s' used but missing from SYSCALLS\n",
+                       shortpath (NULL, file), user->line,
+                       needed+7);      /* Don't print "extern " */
               }
 #if 0
             else
-              fprintf (stderr, "%s: %d: warning: no extern definition for `%s'\n",
-                      shortpath (NULL, file), user->line,
-                      user->hash_entry->symbol);
+              notice ("%s: %d: warning: no extern definition for `%s'\n",
+                     shortpath (NULL, file), user->line,
+                     user->hash_entry->symbol);
 #endif
         }
     }
@@ -2686,7 +2672,7 @@ find_extern_def (head, user)
 \f
 /* Find the (only?) static definition for a particular function name in a
    given file.  Here we get the function-name and the file info indirectly
-   from the def_dec_info record pointer which is passed in. */
+   from the def_dec_info record pointer which is passed in.  */
 
 static const def_dec_info *
 find_static_definition (user)
@@ -2706,15 +2692,15 @@ find_static_definition (user)
   if (num_static_defs == 0)
     {
       if (!quiet_flag)
-        fprintf (stderr, "%s: warning: no static definition for `%s' in file `%s'\n",
-                pname, head->hash_entry->symbol,
-                shortpath (NULL, user->file->hash_entry->symbol));
+        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)
     {
-      fprintf (stderr, "%s: multiple static defs of `%s' in file `%s'\n",
-              pname, head->hash_entry->symbol,
-              shortpath (NULL, user->file->hash_entry->symbol));
+      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;
     }
   return static_def_p;
@@ -2754,7 +2740,7 @@ connect_defs_and_decs (hp)
 
      Also, for each item which is only a function declaration, but which
      nonetheless has its own prototype already (obviously supplied by the user)
-     declare the item as it's own definition.
+     declare the item as its own definition.
 
      Note that when/if there are multiple user-supplied prototypes already
      present for multiple declarations of any given function, these multiple
@@ -2885,12 +2871,12 @@ declare_source_confusing (clean_p)
   if (!quiet_flag)
     {
       if (clean_p == 0)
-        fprintf (stderr, "%s: %d: warning: source too confusing\n",
-                shortpath (NULL, convert_filename), last_known_line_number);
+        notice ("%s: %d: warning: source too confusing\n",
+               shortpath (NULL, convert_filename), last_known_line_number);
       else
-        fprintf (stderr, "%s: %d: warning: source too confusing\n",
-                shortpath (NULL, convert_filename),
-                identify_lineno (clean_p));
+        notice ("%s: %d: warning: source too confusing\n",
+               shortpath (NULL, convert_filename),
+               identify_lineno (clean_p));
     }
   longjmp (source_confusion_recovery, 1);
 }
@@ -2941,13 +2927,14 @@ seek_to_line (n)
 }
 
 /* Given a pointer to a character in the cleaned text buffer, return a pointer
-   to the next non-whitepace character which follows it.  */
+   to the next non-whitespace character which follows it.  */
 
 static const char *
 forward_to_next_token_char (ptr)
      const char *ptr;
 {
-  for (++ptr; isspace (*ptr); check_source (++ptr < clean_text_limit, 0))
+  for (++ptr; ISSPACE ((const unsigned char)*ptr);
+       check_source (++ptr < clean_text_limit, 0))
     continue;
   return ptr;
 }
@@ -3000,7 +2987,7 @@ output_string (str)
    buffer (which may include original comments and preprocessing directives)
    will be copied into the  output buffer.
 
-   Note that the request implide when this routine is called includes the
+   Note that the request implied when this routine is called includes the
    byte pointed to by the argument pointer `p'.  */
 
 static void
@@ -3093,9 +3080,9 @@ edit_fn_declaration (def_dec_p, clean_text_p)
   if (other_variable_style_function (definition->ansi_decl))
     {
       if (!quiet_flag)
-        fprintf (stderr, "%s: %d: warning: varargs function declaration not converted\n",
-                shortpath (NULL, def_dec_p->file->hash_entry->symbol),
-                def_dec_p->line);
+        notice ("%s: %d: warning: varargs function declaration not converted\n",
+               shortpath (NULL, def_dec_p->file->hash_entry->symbol),
+               def_dec_p->line);
       return;
     }
 
@@ -3108,8 +3095,8 @@ edit_fn_declaration (def_dec_p, clean_text_p)
   if (setjmp (source_confusion_recovery))
     {
       restore_pointers ();
-      fprintf (stderr, "%s: declaration of function `%s' not converted\n",
-              pname, function_to_edit);
+      notice ("%s: declaration of function `%s' not converted\n",
+             pname, function_to_edit);
       return;
     }
 
@@ -3231,8 +3218,8 @@ edit_fn_declaration (def_dec_p, clean_text_p)
       else
         {
           if (!quiet_flag)
-            fprintf (stderr, "%s: warning: too many parameter lists in declaration of `%s'\n",
-                    pname, def_dec_p->hash_entry->symbol);
+            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 */
         }
 #endif /* !defined (UNPROTOIZE) */
@@ -3252,8 +3239,8 @@ edit_fn_declaration (def_dec_p, clean_text_p)
             if (this_f_list_chain_item)
               {
                 if (!quiet_flag)
-                  fprintf (stderr, "\n%s: warning: too few parameter lists in declaration of `%s'\n",
-                          pname, def_dec_p->hash_entry->symbol);
+                  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 */
               }
 #endif /* !defined (UNPROTOIZE) */
@@ -3315,7 +3302,7 @@ edit_formals_lists (end_formals, f_list_count, def_dec_p)
 
       next_end = start_formals - 1;
       check_source (next_end > clean_read_ptr, 0);
-      while (isspace (*next_end))
+      while (ISSPACE ((const unsigned char)*next_end))
         check_source (--next_end > clean_read_ptr, 0);
       check_source (*next_end == ')', next_end);
       check_source (--next_end > clean_read_ptr, 0);
@@ -3335,7 +3322,8 @@ edit_formals_lists (end_formals, f_list_count, def_dec_p)
       const char *func_name_limit;
       size_t func_name_len;
 
-      for (func_name_limit = start_formals-1; isspace (*func_name_limit); )
+      for (func_name_limit = start_formals-1;
+          ISSPACE ((const unsigned char)*func_name_limit); )
         check_source (--func_name_limit > clean_read_ptr, 0);
 
       for (func_name_start = func_name_limit++;
@@ -3349,11 +3337,11 @@ edit_formals_lists (end_formals, f_list_count, def_dec_p)
       if (func_name_len != strlen (expected)
          || strncmp (func_name_start, expected, func_name_len))
         {
-          fprintf (stderr, "%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),
-                  expected);
+          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),
+                 expected);
           return 1;
         }
     }
@@ -3382,11 +3370,11 @@ edit_formals_lists (end_formals, f_list_count, def_dec_p)
   return 0;
 }
 
-/* Given a pointer to a byte in the clean text buffer which points to the
-   beginning of a line that contains a "follower" token for a function
-   definition header, do whatever is necessary to find the right closing
-   paren for the rightmost formals list of the function definition header.
-*/
+/* Given a pointer to a byte in the clean text buffer which points to
+   the beginning of a line that contains a "follower" token for a
+   function definition header, do whatever is necessary to find the
+   right closing paren for the rightmost formals list of the function
+   definition header.  */
 
 static const char *
 find_rightmost_formals_list (clean_text_p)
@@ -3431,8 +3419,8 @@ find_rightmost_formals_list (clean_text_p)
 
     while (*end_formals != ')')
       {
-       if (isspace (*end_formals))
-         while (isspace (*end_formals))
+       if (ISSPACE ((unsigned char)*end_formals))
+         while (ISSPACE ((unsigned char)*end_formals))
            check_source (--end_formals > clean_read_ptr, 0);
        else
          check_source (--end_formals > clean_read_ptr, 0);
@@ -3461,8 +3449,8 @@ find_rightmost_formals_list (clean_text_p)
 
       while (*end_formals != ')')
         {
-          if (isspace (*end_formals))
-            while (isspace (*end_formals))
+          if (ISSPACE ((const unsigned char)*end_formals))
+            while (ISSPACE ((const unsigned char)*end_formals))
               check_source (--end_formals > clean_read_ptr, 0);
           else
             check_source (--end_formals > clean_read_ptr, 0);
@@ -3477,10 +3465,10 @@ find_rightmost_formals_list (clean_text_p)
          sure that this is in fact the right paren that we were looking for.
 
          The one we were looking for *must* be followed by either a '{' or
-         by an alphabetic character, while others *cannot* legally be followed
+         by an alphabetic character, while others *cannot* validly be followed
          by such characters.  */
 
-      if ((ch == '{') || isalpha (ch))
+      if ((ch == '{') || ISALPHA ((unsigned char)ch))
         break;
 
       /* At this point, we have found a right paren, but we know that it is
@@ -3527,8 +3515,8 @@ add_local_decl (def_dec_p, clean_text_p)
   if (setjmp (source_confusion_recovery))
     {
       restore_pointers ();
-      fprintf (stderr, "%s: local declaration for function `%s' not inserted\n",
-              pname, function_to_edit);
+      notice ("%s: local declaration for function `%s' not inserted\n",
+             pname, function_to_edit);
       return;
     }
 
@@ -3554,8 +3542,7 @@ add_local_decl (def_dec_p, clean_text_p)
   if (*start_of_block != '{')
     {
       if (!quiet_flag)
-        fprintf (stderr,
-          "\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;
@@ -3576,7 +3563,7 @@ add_local_decl (def_dec_p, clean_text_p)
        We can now just scan backwards and find the left end of the existing
        indentation string, and then copy it to the output buffer.  */
 
-    for (sp = ep; isspace (*sp) && *sp != '\n'; sp--)
+    for (sp = ep; ISSPACE ((const unsigned char)*sp) && *sp != '\n'; sp--)
       continue;
 
     /* Now write out the open { which began this block, and any following
@@ -3629,8 +3616,8 @@ add_global_decls (file_p, clean_text_p)
   if (setjmp (source_confusion_recovery))
     {
       restore_pointers ();
-      fprintf (stderr, "%s: global declarations for file `%s' not inserted\n",
-              pname, shortpath (NULL, file_p->hash_entry->symbol));
+      notice ("%s: global declarations for file `%s' not inserted\n",
+             pname, shortpath (NULL, file_p->hash_entry->symbol));
       return;
     }
 
@@ -3654,10 +3641,10 @@ add_global_decls (file_p, clean_text_p)
 
   /* Now scan forward for the first non-whitespace character.  In theory,
      this should be the first character of the following function definition
-     header.  We will put in the added declarations just prior to that. */
+     header.  We will put in the added declarations just prior to that.  */
 
   scan_p++;
-  while (isspace (*scan_p))
+  while (ISSPACE ((const unsigned char)*scan_p))
     scan_p++;
   scan_p--;
 
@@ -3720,8 +3707,8 @@ edit_fn_definition (def_dec_p, clean_text_p)
   if (setjmp (source_confusion_recovery))
     {
       restore_pointers ();
-      fprintf (stderr, "%s: definition of function `%s' not converted\n",
-              pname, function_to_edit);
+      notice ("%s: definition of function `%s' not converted\n",
+             pname, function_to_edit);
       return;
     }
 
@@ -3739,10 +3726,10 @@ edit_fn_definition (def_dec_p, clean_text_p)
   if (other_variable_style_function (def_dec_p->ansi_decl))
     {
       if (!quiet_flag)
-        fprintf (stderr, "%s: %d: warning: definition of %s not converted\n",
-                shortpath (NULL, def_dec_p->file->hash_entry->symbol),
-                identify_lineno (end_formals), 
-                other_var_style);
+        notice ("%s: %d: warning: definition of %s not converted\n",
+               shortpath (NULL, def_dec_p->file->hash_entry->symbol),
+               identify_lineno (end_formals), 
+               other_var_style);
       output_up_to (end_formals);
       return;
     }
@@ -3750,8 +3737,8 @@ edit_fn_definition (def_dec_p, clean_text_p)
   if (edit_formals_lists (end_formals, def_dec_p->f_list_count, def_dec_p))
     {
       restore_pointers ();
-      fprintf (stderr, "%s: definition of function `%s' not converted\n",
-              pname, function_to_edit);
+      notice ("%s: definition of function `%s' not converted\n",
+             pname, function_to_edit);
       return;
     }
 
@@ -3797,7 +3784,7 @@ edit_fn_definition (def_dec_p, clean_text_p)
       output_string ("\n");
   }
 #else /* !defined (UNPROTOIZE) */
-  /* If we are protoizing, there may be some flotsum & jetsum (like comments
+  /* If we are protoizing, there may be some flotsam & jetsam (like comments
      and preprocessing directives) after the old formals list but before
      the following { and we would like to preserve that stuff while effectively
      deleting the existing K&R formal parameter declarations.  We do so here
@@ -3810,7 +3797,7 @@ edit_fn_definition (def_dec_p, clean_text_p)
     const char *start_body_orig;
     const char *scan;
     const char *scan_orig;
-    int have_flotsum = 0;
+    int have_flotsam = 0;
     int have_newlines = 0;
 
     for (start_body = end_formals + 1; *start_body != '{';)
@@ -3826,13 +3813,13 @@ edit_fn_definition (def_dec_p, clean_text_p)
           {
             have_newlines |= (*scan_orig == '\n');
             /* Leave identical whitespace alone.  */
-            if (!isspace (*scan_orig))
+            if (!ISSPACE ((const unsigned char)*scan_orig))
               *((NONCONST char *)scan_orig) = ' '; /* identical - so whiteout */
           }
         else
-          have_flotsum = 1;
+          have_flotsam = 1;
       }
-    if (have_flotsum)
+    if (have_flotsam)
       output_bytes (end_formals_orig + 1,
                    (size_t) (start_body_orig - end_formals_orig) - 1);
     else
@@ -3846,13 +3833,13 @@ edit_fn_definition (def_dec_p, clean_text_p)
 }
 
 /* Clean up the clean text buffer.  Do this by converting comments and
-   preprocessor directives into spaces.   Also convert line continuations
+   preprocessing directives into spaces.   Also convert line continuations
    into whitespace.  Also, whiteout string and character literals.  */
 
 static void
 do_cleaning (new_clean_text_base, new_clean_text_limit)
      char *new_clean_text_base;
-     char *new_clean_text_limit;
+     const char *new_clean_text_limit;
 {
   char *scan_p;
   int non_whitespace_since_newline = 0;
@@ -3870,7 +3857,7 @@ do_cleaning (new_clean_text_base, new_clean_text_limit)
             scan_p += 2;
             while (scan_p[1] != '/' || scan_p[0] != '*')
               {
-                if (!isspace (*scan_p))
+                if (!ISSPACE ((const unsigned char)*scan_p))
                   *scan_p = ' ';
                 if (++scan_p >= new_clean_text_limit)
                   abort ();
@@ -3885,7 +3872,7 @@ do_cleaning (new_clean_text_base, new_clean_text_limit)
             *scan_p = ' ';
             while (scan_p[1] != '\n' || scan_p[0] == '\\')
               {
-                if (!isspace (*scan_p))
+                if (!ISSPACE ((const unsigned char)*scan_p))
                   *scan_p = ' ';
                 if (++scan_p >= new_clean_text_limit)
                   abort ();
@@ -3897,9 +3884,10 @@ do_cleaning (new_clean_text_base, new_clean_text_limit)
             non_whitespace_since_newline = 1;
             while (scan_p[1] != '\'' || scan_p[0] == '\\')
               {
-                if (scan_p[0] == '\\' && !isspace (scan_p[1]))
+                if (scan_p[0] == '\\'
+                   && !ISSPACE ((const unsigned char)scan_p[1]))
                   scan_p[1] = ' ';
-                if (!isspace (*scan_p))
+                if (!ISSPACE ((const unsigned char)*scan_p))
                   *scan_p = ' ';
                 if (++scan_p >= new_clean_text_limit)
                   abort ();
@@ -3911,14 +3899,17 @@ do_cleaning (new_clean_text_base, new_clean_text_limit)
             non_whitespace_since_newline = 1;
             while (scan_p[1] != '"' || scan_p[0] == '\\')
               {
-                if (scan_p[0] == '\\' && !isspace (scan_p[1]))
+                if (scan_p[0] == '\\'
+                   && !ISSPACE ((const unsigned char)scan_p[1]))
                   scan_p[1] = ' ';
-                if (!isspace (*scan_p))
+                if (!ISSPACE ((const unsigned char)*scan_p))
                   *scan_p = ' ';
                 if (++scan_p >= new_clean_text_limit)
                   abort ();
               }
-            *scan_p++ = ' ';
+           if (!ISSPACE ((const unsigned char)*scan_p))
+             *scan_p = ' ';
+           scan_p++;
             break;
 
           case '\\':                   /* Handle line continuations.  */
@@ -4009,12 +4000,12 @@ scan_for_missed_items (file_p)
 
           last_r_paren = scan_p;
 
-          for (ahead_p = scan_p + 1; isspace (*ahead_p); )
+          for (ahead_p = scan_p + 1; ISSPACE ((const unsigned char)*ahead_p); )
             check_source (++ahead_p < limit, limit);
 
           scan_p = ahead_p - 1;
 
-          if (isalpha (*ahead_p) || *ahead_p == '{')
+          if (ISALPHA ((const unsigned char)*ahead_p) || *ahead_p == '{')
             {
               const char *last_l_paren;
               const int lineno = identify_lineno (ahead_p);
@@ -4028,7 +4019,8 @@ scan_for_missed_items (file_p)
               do
                 {
                   last_l_paren = careful_find_l_paren (last_r_paren);
-                  for (last_r_paren = last_l_paren-1; isspace (*last_r_paren); )
+                  for (last_r_paren = last_l_paren-1;
+                      ISSPACE ((const unsigned char)*last_r_paren); )
                     check_source (--last_r_paren >= backup_limit, backup_limit);
                 }
               while (*last_r_paren == ')');
@@ -4064,11 +4056,11 @@ scan_for_missed_items (file_p)
                        goto not_missed;
 
 #if 0
-                   fprintf (stderr, "%s: found definition of `%s' at %s(%d)\n",
-                            pname,
-                            func_name,
-                            shortpath (NULL, file_p->hash_entry->symbol),
-                            identify_lineno (id_start));
+                   notice ("%s: found definition of `%s' at %s(%d)\n",
+                           pname,
+                           func_name,
+                           shortpath (NULL, file_p->hash_entry->symbol),
+                           identify_lineno (id_start));
 #endif                         /* 0 */
                    /* We really should check for a match of the function name
                       here also, but why bother.  */
@@ -4080,11 +4072,11 @@ scan_for_missed_items (file_p)
                    /* If we make it here, then we did not know about this
                       function definition.  */
 
-                   fprintf (stderr, "%s: %d: warning: `%s' excluded by preprocessing\n",
-                            shortpath (NULL, file_p->hash_entry->symbol),
-                            identify_lineno (id_start), func_name);
-                   fprintf (stderr, "%s: function definition not converted\n",
-                            pname);
+                   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",
+                           pname);
                  }
                not_missed: ;
                 }
@@ -4096,14 +4088,14 @@ scan_for_missed_items (file_p)
 /* Do all editing operations for a single source file (either a "base" file
    or an "include" file).  To do this we read the file into memory, keep a
    virgin copy there, make another cleaned in-core copy of the original file
-   (i.e. one in which all of the comments and preprocessor directives have
+   (i.e. one in which all of the comments and preprocessing directives have
    been replaced with whitespace), then use these two in-core copies of the
    file to make a new edited in-core copy of the file.  Finally, rename the
    original file (as a way of saving it), and then write the edited version
    of the file from core to a disk file of the same name as the original.
 
    Note that the trick of making a copy of the original sans comments &
-   preprocessor directives make the editing a whole lot easier.  */
+   preprocessing directives make the editing a whole lot easier.  */
    
 static void
 edit_file (hp)
@@ -4142,28 +4134,30 @@ edit_file (hp)
           && !in_system_include_dir (convert_filename)
 #endif /* defined (UNPROTOIZE) */
           )
-        fprintf (stderr, "%s: `%s' not converted\n",
-                pname, shortpath (NULL, convert_filename));
+        notice ("%s: `%s' not converted\n",
+               pname, shortpath (NULL, convert_filename));
       return;
     }
 
   /* Let the user know what we are up to.  */
 
   if (nochange_flag)
-    fprintf (stderr, "%s: would convert file `%s'\n",
-            pname, shortpath (NULL, convert_filename));
+    notice ("%s: would convert file `%s'\n",
+           pname, shortpath (NULL, convert_filename));
   else
-    fprintf (stderr, "%s: converting file `%s'\n",
-            pname, shortpath (NULL, convert_filename));
+    notice ("%s: converting file `%s'\n",
+           pname, shortpath (NULL, convert_filename));
   fflush (stderr);
 
   /* Find out the size (in bytes) of the original file.  */
 
   /* The cast avoids an erroneous warning on AIX.  */
-  if (my_stat ((char *)convert_filename, &stat_buf) == -1)
+  if (stat (convert_filename, &stat_buf) == -1)
     {
-      fprintf (stderr, "%s: can't get status for file `%s': %s\n",
-              pname, shortpath (NULL, convert_filename), sys_errlist[errno]);
+      int errno_val = errno;
+      notice ("%s: can't get status for file `%s': %s\n",
+             pname, shortpath (NULL, convert_filename),
+             xstrerror (errno_val));
       return;
     }
   orig_size = stat_buf.st_size;
@@ -4191,14 +4185,21 @@ edit_file (hp)
 
   {
     int input_file;
+    int fd_flags;
 
     /* Open the file to be converted in READ ONLY mode.  */
 
-    if ((input_file = my_open (convert_filename, O_RDONLY, 0444)) == -1)
+    fd_flags = O_RDONLY;
+#ifdef O_BINARY
+    /* Use binary mode to avoid having to deal with different EOL characters. */
+    fd_flags |= O_BINARY;
+#endif
+    if ((input_file = open (convert_filename, fd_flags, 0444)) == -1)
       {
-        fprintf (stderr, "%s: can't open file `%s' for reading: %s\n",
-                pname, shortpath (NULL, convert_filename),
-                sys_errlist[errno]);
+       int errno_val = errno;
+        notice ("%s: can't open file `%s' for reading: %s\n",
+               pname, shortpath (NULL, convert_filename),
+               xstrerror (errno_val));
         return;
       }
 
@@ -4206,12 +4207,14 @@ edit_file (hp)
        in one swell fwoop.  Then figure out where the end of the text is and
        make sure that it ends with a newline followed by a null.  */
 
-    if (safe_read (input_file, new_orig_text_base, orig_size) != orig_size)
+    if (safe_read (input_file, new_orig_text_base, orig_size) !=
+       (int) orig_size)
       {
+       int errno_val = errno;
         close (input_file);
-        fprintf (stderr, "\n%s: error reading input file `%s': %s\n",
-                pname, shortpath (NULL, convert_filename),
-                sys_errlist[errno]);
+        notice ("\n%s: error reading input file `%s': %s\n",
+               pname, shortpath (NULL, convert_filename),
+               xstrerror (errno_val));
         return;
       }
 
@@ -4242,9 +4245,10 @@ edit_file (hp)
     strcat (clean_filename, ".clean");
     if ((clean_file = creat (clean_filename, 0666)) == -1)
       {
-        fprintf (stderr, "%s: can't create/open clean file `%s': %s\n",
-                pname, shortpath (NULL, clean_filename),
-                sys_errlist[errno]);
+       int errno_val = errno;
+        notice ("%s: can't create/open clean file `%s': %s\n",
+               pname, shortpath (NULL, clean_filename),
+               xstrerror (errno_val));
         return;
       }
   
@@ -4332,38 +4336,49 @@ edit_file (hp)
 
   if (!nosave_flag)
     {
-      char *new_filename =
-          (char *) xmalloc (strlen (convert_filename) + strlen (save_suffix) + 2);
+      char *new_filename
+       = (char *) xmalloc (strlen (convert_filename) + strlen (save_suffix) + 2);
   
       strcpy (new_filename, convert_filename);
+#ifdef __MSDOS__
+      /* MSDOS filenames are restricted to 8.3 format, so we save `foo.c'
+         as `foo.<save_suffix>'.  */
+      new_filename[(strlen (convert_filename) - 1] = '\0';
+#endif
       strcat (new_filename, save_suffix);
-      if (my_link (convert_filename, new_filename) == -1)
+
+      /* Don't overwrite existing file.  */
+      if (access (new_filename, F_OK) == 0)
+       {
+         if (!quiet_flag)
+           notice ("%s: warning: file `%s' already saved in `%s'\n",
+                   pname,
+                   shortpath (NULL, convert_filename),
+                   shortpath (NULL, new_filename));
+       }
+      else if (rename (convert_filename, new_filename) == -1)
         {
-          if (errno == EEXIST)
-            {
-              if (!quiet_flag)
-                fprintf (stderr, "%s: warning: file `%s' already saved in `%s'\n",
-                        pname,
-                        shortpath (NULL, convert_filename),
-                        shortpath (NULL, new_filename));
-            }
-          else
-            {
-              fprintf (stderr, "%s: can't link file `%s' to `%s': %s\n",
-                      pname,
-                      shortpath (NULL, convert_filename),
-                      shortpath (NULL, new_filename),
-                      sys_errlist[errno]);
-              return;
-            }
+         int errno_val = errno;
+         notice ("%s: can't link file `%s' to `%s': %s\n",
+                 pname,
+                 shortpath (NULL, convert_filename),
+                 shortpath (NULL, new_filename),
+                 xstrerror (errno_val));
+         return;
         }
     }
 
-  if (my_unlink (convert_filename) == -1)
+  if (unlink (convert_filename) == -1)
     {
-      fprintf (stderr, "%s: can't delete file `%s': %s\n",
-              pname, shortpath (NULL, convert_filename), sys_errlist[errno]);
-      return;
+      int errno_val = errno;
+      /* The file may have already been renamed.  */
+      if (errno_val != ENOENT)
+        {
+         notice ("%s: can't delete file `%s': %s\n",
+                 pname, shortpath (NULL, convert_filename),
+                 xstrerror (errno_val));
+         return;
+       }
     }
 
   {
@@ -4373,11 +4388,16 @@ edit_file (hp)
   
     if ((output_file = creat (convert_filename, 0666)) == -1)
       {
-        fprintf (stderr, "%s: can't create/open output file `%s': %s\n",
-                pname, shortpath (NULL, convert_filename),
-                sys_errlist[errno]);
+       int errno_val = errno;
+        notice ("%s: can't create/open output file `%s': %s\n",
+               pname, shortpath (NULL, convert_filename),
+               xstrerror (errno_val));
         return;
       }
+#ifdef O_BINARY
+    /* Use binary mode to avoid changing the existing EOL character.  */
+    setmode (output_file, O_BINARY);
+#endif
   
     /* Write the output file.  */
   
@@ -4399,9 +4419,13 @@ edit_file (hp)
   /* Change the mode of the output file to match the original file.  */
 
   /* The cast avoids an erroneous warning on AIX.  */
-  if (my_chmod ((char *)convert_filename, stat_buf.st_mode) == -1)
-    fprintf (stderr, "%s: can't change mode of file `%s': %s\n",
-            pname, shortpath (NULL, convert_filename), sys_errlist[errno]);
+  if (chmod (convert_filename, stat_buf.st_mode) == -1)
+    {
+      int errno_val = errno;
+      notice ("%s: can't change mode of file `%s': %s\n",
+             pname, shortpath (NULL, convert_filename),
+             xstrerror (errno_val));
+    }
 
   /* Note:  We would try to change the owner and group of the output file
      to match those of the input file here, except that may not be a good
@@ -4440,22 +4464,33 @@ do_processing ()
   if (nondefault_syscalls_dir)
     {
       syscalls_absolute_filename
-        = (char *) xmalloc (strlen (nondefault_syscalls_dir)
-                            + sizeof (syscalls_filename) + 1);
+        = (char *) xmalloc (strlen (nondefault_syscalls_dir) + 1
+                            + sizeof (syscalls_filename));
       strcpy (syscalls_absolute_filename, nondefault_syscalls_dir);
     }
   else
     {
+      GET_ENV_PATH_LIST (default_syscalls_dir, "GCC_EXEC_PREFIX");
+      if (!default_syscalls_dir)
+       {
+         default_syscalls_dir = standard_exec_prefix;
+       }
       syscalls_absolute_filename
-        = (char *) xmalloc (strlen (default_syscalls_dir)
-                            + sizeof (syscalls_filename) + 1);
+        = (char *) 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, "/");
+      strcat (syscalls_absolute_filename, target_version);
+      strcat (syscalls_absolute_filename, "/");
     }
 
   syscalls_len = strlen (syscalls_absolute_filename);
-  if (*(syscalls_absolute_filename + syscalls_len - 1) != '/')
+  if (! IS_DIR_SEPARATOR (*(syscalls_absolute_filename + syscalls_len - 1)))
     {
-      *(syscalls_absolute_filename + syscalls_len++) = '/';
+      *(syscalls_absolute_filename + syscalls_len++) = DIR_SEPARATOR;
       *(syscalls_absolute_filename + syscalls_len) = '\0';
     }
   strcat (syscalls_absolute_filename, syscalls_filename);
@@ -4528,6 +4563,8 @@ static struct option longopts[] =
   {0, 0, 0, 0}
 };
 
+extern int main PARAMS ((int, char **const));
+
 int
 main (argc, argv)
      int argc;
@@ -4537,15 +4574,43 @@ main (argc, argv)
   int c;
   const char *params = "";
 
-  pname = rindex (argv[0], '/');
+  pname = strrchr (argv[0], DIR_SEPARATOR);
+#ifdef DIR_SEPARATOR_2
+  {
+    char *slash;
+
+    slash = strrchr (pname ? pname : argv[0], DIR_SEPARATOR_2);
+    if (slash)
+      pname = slash;
+  }
+#endif
   pname = pname ? pname+1 : argv[0];
 
+#ifdef SIGCHLD
+  /* We *MUST* set SIGCHLD to SIG_DFL so that the wait4() call will
+     receive the signal.  A different setting is inheritable */
+  signal (SIGCHLD, SIG_DFL);
+#endif
+
+/* LC_CTYPE determines the character set used by the terminal so it has be set
+   to output messages correctly.  */
+
+#ifdef HAVE_LC_MESSAGES
+  setlocale (LC_CTYPE, "");
+  setlocale (LC_MESSAGES, "");
+#else
+  setlocale (LC_ALL, "");
+#endif
+
+  (void) bindtextdomain (PACKAGE, localedir);
+  (void) textdomain (PACKAGE);
+
   cwd_buffer = getpwd ();
   if (!cwd_buffer)
     {
-      fprintf (stderr, "%s: cannot get working directory: %s\n",
-              pname, sys_errlist[errno]);
-      exit (1);
+      notice ("%s: cannot get working directory: %s\n",
+             pname, xstrerror(errno));
+      return (FATAL_EXIT_CODE);
     }
 
   /* By default, convert the files in the current directory.  */
@@ -4559,7 +4624,7 @@ main (argc, argv)
 #endif
                           longopts, &longind)) != EOF)
     {
-      if (c == 0)              /* Long option. */
+      if (c == 0)              /* Long option.  */
        c = longopts[longind].val;
       switch (c)
        {
@@ -4629,8 +4694,8 @@ main (argc, argv)
 
   /* Now actually make a list of the base source filenames.  */
 
-  base_source_filenames =
-    (const char **) xmalloc ((n_base_source_files + 1) * sizeof (char *));
+  base_source_filenames
+    (const char **) xmalloc ((n_base_source_files + 1) * sizeof (char *));
   n_base_source_files = 0;
   for (; optind < argc; optind++)
     {
@@ -4641,8 +4706,8 @@ main (argc, argv)
        base_source_filenames[n_base_source_files++] = path;
       else
        {
-         fprintf (stderr, "%s: input file names must have .c suffixes: %s\n",
-                  pname, shortpath (NULL, path));
+         notice ("%s: input file names must have .c suffixes: %s\n",
+                 pname, shortpath (NULL, path));
          errors++;
        }
     }
@@ -4654,7 +4719,8 @@ main (argc, argv)
   {
     const char *cp;
 
-    for (cp = varargs_style_indicator; isalnum (*cp) || *cp == '_'; cp++)
+    for (cp = varargs_style_indicator;
+        ISALNUM ((const unsigned char)*cp) || *cp == '_'; cp++)
       continue;
     if (*cp != 0)
       varargs_style_indicator = savestring (varargs_style_indicator,
@@ -4670,9 +4736,6 @@ main (argc, argv)
         fprintf (stderr, "%s: %s\n", pname, version_string);
       do_processing ();
     }
-  if (errors)
-    exit (1);
-  else
-    exit (0);
-  return 1;
+
+  return (errors ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
 }