OSDN Git Service

[pf3gnuchains/gcc-fork.git] / gcc / protoize.c
index bf5cfc7..a7a5ae9 100644 (file)
@@ -1,5 +1,5 @@
 /* Protoize program - Original version by Ron Guilmette (rfg@segfault.us.com).
-   Copyright (C) 1989, 92-96, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1989, 92-97, 1998 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -57,13 +57,7 @@ Boston, MA 02111-1307, USA.  */
 #define _POSIX_SOURCE
 #endif
 
-#include <varargs.h>
-/* On some systems stdio.h includes stdarg.h;
-   we must bring in varargs.h first.  */
-#include <stdio.h>
-#include <ctype.h>
-#include <errno.h>
-#include <sys/types.h>
+#include "system.h"
 #include <sys/stat.h>
 #if ! defined (_WIN32) || defined (__CYGWIN32__)
 #if defined(POSIX) || defined(CONCURRENT)
@@ -73,9 +67,20 @@ Boston, MA 02111-1307, USA.  */
 #endif
 #endif
 #include <setjmp.h>
-
 #include "gansidecl.h"
 
+/* Some systems like Linux don't declare rindex if _POSIX_SOURCE is declared,
+   but it normally does declare it.  This means that configure thinks we don't
+   need to declare it.  Favor using strrchr if it is available.  */
+
+#ifndef strrchr
+#ifndef HAVE_STRRCHR
+#ifdef  HAVE_RINDEX
+#define strrchr rindex
+#endif
+#endif
+#endif
+
 /* 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.  */
@@ -83,21 +88,6 @@ Boston, MA 02111-1307, USA.  */
 #include "getopt.h"
 #undef getopt
 
-#ifndef errno
-extern int errno;
-#endif
-
-#ifndef HAVE_STRERROR
-extern int sys_nerr;
-#if defined(bsd4_4)
-extern const char *const sys_errlist[];
-#else
-extern char *sys_errlist[];
-#endif
-#else
-extern char *strerror();
-#endif
-
 extern char *version_string;
 
 /* Systems which are compatible only with POSIX 1003.1-1988 (but *not*
@@ -109,7 +99,11 @@ extern char *version_string;
 
 #define my_access(file,flag)   access((char *)file, flag)
 #define my_stat(file,pkt)      stat((char *)file, pkt)
+#ifdef __MINGW32__
+#define my_link(file1, file2)  -1
+#else
 #define my_link(file1, file2)  link((char *)file1, (char *)file2)
+#endif
 #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)
@@ -117,6 +111,7 @@ extern char *version_string;
 extern char *getpwd ();
 
 extern char *choose_temp_base PROTO ((void));
+extern char * my_strerror PROTO ((int));
 
 extern int pexecute PROTO ((const char *, char * const *, const char *,
                            const char *, char **, char **, int));
@@ -140,27 +135,11 @@ typedef char * const_pointer_type;
 
 #if defined(POSIX)
 
-#include <stdlib.h>
-#include <unistd.h>
 #include <signal.h>
-#include <fcntl.h>
 #include <sys/wait.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 */
-
-#ifndef O_RDONLY
-#define O_RDONLY        0
-#endif
-
-#ifndef O_WRONLY
-#define O_WRONLY        1
-#endif
-
 #ifndef WIFSIGNALED
 #define WIFSIGNALED(S) (((S) & 0xff) != 0 && ((S) & 0xff) != 0x7f)
 #endif
@@ -177,29 +156,20 @@ typedef char * const_pointer_type;
 /* 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 creat ();
 #if 0 /* These conflict with stdio.h on some systems.  */
+extern int creat ();
 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 ();
+#endif /* 0 */
 extern int close ();
 extern int fflush ();
 extern int atoi ();
 extern int puts ();
 extern int fputs ();
 extern int fputc ();
-#if !defined(_WIN32)
-extern int link ();
-#endif
 extern int unlink ();
 extern int access ();
 
@@ -216,20 +186,10 @@ extern size_t   strlen ()
 
 #endif /* !defined (POSIX) */
 
-extern char *rindex ();
-
 /* Look for these where the `const' qualifier is intentionally cast aside.  */
 
 #define NONCONST
 
-/* Define a STRINGIFY macro that's right for ANSI or traditional C.  */
-
-#ifdef __STDC__
-#define STRINGIFY(STRING) #STRING
-#else
-#define STRINGIFY(STRING) "STRING"
-#endif
-
 /* Define a default place to find the SYSCALLS.X file.  */
 
 #ifndef STD_PROTO_DIR
@@ -304,39 +264,41 @@ static const int hash_mask = (HASH_TABLE_SIZE - 1);
 #define LOCAL_INCLUDE_DIR "/usr/local/include"
 #endif
 
-struct default_include { const char *fname; int x1, x2; } 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, 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, 0 },
+    { GCC_INCLUDE_DIR, "GCC", 0, 0 },
     /* For cross-compilation, this dir name is generated
        automatically in Makefile.in.  */
-    { CROSS_INCLUDE_DIR, 0, 0 },
+    { CROSS_INCLUDE_DIR, 0, 0, 0 },
     /* This is another place that the target system's headers might be.  */
-    { TOOL_INCLUDE_DIR, 0, 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, 1 },
+    { 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, 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, 0 },
+    { GCC_INCLUDE_DIR, "GCC", 0, 0 },
     /* Some systems have an extra dir of include files.  */
 #ifdef SYSTEM_INCLUDE_DIR
-    { SYSTEM_INCLUDE_DIR, 0, 0 },
+    { SYSTEM_INCLUDE_DIR, 0, 0, 0 },
 #endif
-    { STANDARD_INCLUDE_DIR, 0, 0},
+    { STANDARD_INCLUDE_DIR, 0, 0, 0},
 #endif /* not CROSS_COMPILE */
-    { 0, 0, 0}
+    { 0, 0, 0, 0}
     };
 #endif /* no INCLUDE_DEFAULTS */
 
@@ -773,7 +735,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;
@@ -825,12 +787,13 @@ safe_write (desc, ptr, len, out_fname)
     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), my_strerror(errno));
+                pname, shortpath (NULL, out_fname), my_strerror (errno_val));
        return;
       }
     ptr += written;
@@ -863,7 +826,7 @@ static int
 is_id_char (ch)
      char ch;
 {
-  return (isalnum (ch) || (ch == '_') || (ch == '$'));
+  return (ISALNUM (ch) || (ch == '_') || (ch == '$'));
 }
 
 /* Give a message indicating the proper way to invoke this program and then
@@ -919,7 +882,7 @@ file_could_be_converted (const char *path)
     char *dir_last_slash;
 
     strcpy (dir_name, path);
-    dir_last_slash = rindex (dir_name, '/');
+    dir_last_slash = strrchr (dir_name, '/');
     if (dir_last_slash)
       *dir_last_slash = '\0';
     else
@@ -953,7 +916,7 @@ 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, '/');
     if (dir_last_slash)
       *dir_last_slash = '\0';
     else
@@ -1323,12 +1286,12 @@ abspath (cwd, rel_filename)
     if (rel_filename[0] != '/')
       {
         src_p = cwd2;
-        while (*endp++ = *src_p++)
+        while ((*endp++ = *src_p++))
           continue;
         *(endp-1) = '/';                       /* overwrite null */
       }
     src_p = rel_filename;
-    while (*endp++ = *src_p++)
+    while ((*endp++ = *src_p++))
       continue;
   }
 
@@ -1480,7 +1443,7 @@ 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) == '/')
@@ -1521,8 +1484,10 @@ find_file (filename, do_not_stat)
         {
           if (my_stat (filename, &stat_buf) == -1)
             {
+             int errno_val = errno;
               fprintf (stderr, "%s: %s: can't get status: %s\n",
-                      pname, shortpath (NULL, filename), my_strerror(errno));
+                      pname, shortpath (NULL, filename),
+                      my_strerror (errno_val));
               stat_buf.st_mtime = (time_t) -1;
             }
         }
@@ -1947,7 +1912,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.
@@ -2037,12 +2002,12 @@ munge_compile_params (params_list)
   temp_params[param_count++] = compiler_file_name;
   for (;;)
     {
-      while (isspace (*params_list))
+      while (ISSPACE (*params_list))
         params_list++;
       if (!*params_list)
         break;
       param = params_list;
-      while (*params_list && !isspace (*params_list))
+      while (*params_list && !ISSPACE (*params_list))
         params_list++;
       if (param[0] != '-')
         temp_params[param_count++]
@@ -2057,9 +2022,9 @@ munge_compile_params (params_list)
               case 'c':
                 break;         /* Don't copy these.  */
               case 'o':
-                while (isspace (*params_list))
+                while (ISSPACE (*params_list))
                   params_list++;
-                while (*params_list && !isspace (*params_list))
+                while (*params_list && !ISSPACE (*params_list))
                   params_list++;
                 break;
               default:
@@ -2212,9 +2177,10 @@ start_over: ;
        }
       else
        {
+         int errno_val = errno;
          fprintf (stderr, "%s: can't read aux info file `%s': %s\n",
                   pname, shortpath (NULL, aux_info_filename),
-                  my_strerror(errno));
+                  my_strerror (errno_val));
          errors++;
          return;
        }
@@ -2240,9 +2206,10 @@ start_over: ;
        }
       if (my_access (aux_info_filename, R_OK) == -1)
        {
+         int errno_val = errno;
          fprintf (stderr, "%s: can't read aux info file `%s': %s\n",
                   pname, shortpath (NULL, aux_info_filename),
-                  my_strerror(errno));
+                  my_strerror (errno_val));
          errors++;
          return;
        }
@@ -2255,9 +2222,10 @@ start_over: ;
   
     if (my_stat (aux_info_filename, &stat_buf) == -1)
       {
+       int errno_val = errno;
         fprintf (stderr, "%s: can't get status of aux info file `%s': %s\n",
                 pname, shortpath (NULL, aux_info_filename),
-                my_strerror(errno));
+                my_strerror (errno_val));
         errors++;
         return;
       }
@@ -2282,9 +2250,10 @@ start_over: ;
 
        if (my_stat (base_source_filename, &stat_buf) == -1)
          {
+           int errno_val = errno;
            fprintf (stderr, "%s: can't get status of aux info file `%s': %s\n",
                     pname, shortpath (NULL, base_source_filename),
-                    my_strerror(errno));
+                    my_strerror (errno_val));
            errors++;
            return;
          }
@@ -2303,9 +2272,10 @@ start_over: ;
   
     if ((aux_info_file = my_open (aux_info_filename, O_RDONLY, 0444 )) == -1)
       {
+       int errno_val = errno;
         fprintf (stderr, "%s: can't open aux info file `%s' for reading: %s\n",
                 pname, shortpath (NULL, aux_info_filename),
-                my_strerror(errno));
+                my_strerror (errno_val));
         return;
       }
   
@@ -2319,9 +2289,10 @@ start_over: ;
   
     if (safe_read (aux_info_file, aux_info_base, aux_info_size) != aux_info_size)
       {
+       int errno_val = errno;
         fprintf (stderr, "%s: error reading aux info file `%s': %s\n",
                 pname, shortpath (NULL, aux_info_filename),
-                my_strerror(errno));
+                my_strerror (errno_val));
         free (aux_info_base);
         close (aux_info_file);
         return;
@@ -2331,9 +2302,10 @@ start_over: ;
   
     if (close (aux_info_file))
       {
+       int errno_val = errno;
         fprintf (stderr, "%s: error closing aux info file `%s': %s\n",
                 pname, shortpath (NULL, aux_info_filename),
-                my_strerror(errno));
+                my_strerror (errno_val));
         free (aux_info_base);
         close (aux_info_file);
         return;
@@ -2345,9 +2317,12 @@ start_over: ;
 
   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),
-              my_strerror(errno));
+      {
+       int errno_val = errno;
+       fprintf (stderr, "%s: can't delete aux info file `%s': %s\n",
+                pname, shortpath (NULL, aux_info_filename),
+                my_strerror (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
@@ -2380,7 +2355,7 @@ start_over: ;
        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, '/');
        if (dir_end)
          dir_end++;
        else
@@ -2411,9 +2386,10 @@ start_over: ;
                xfree (aux_info_relocated_name);
                 if (keep_it && my_unlink (aux_info_filename) == -1)
                   {
+                   int errno_val = errno;
                     fprintf (stderr, "%s: can't delete file `%s': %s\n",
                             pname, shortpath (NULL, aux_info_filename),
-                            my_strerror(errno));
+                            my_strerror (errno_val));
                     return;
                   }
                must_create = 1;
@@ -2487,17 +2463,19 @@ rename_c_file (hp)
 
   if (my_link (filename, new_filename) == -1)
     {
+      int errno_val = errno;
       fprintf (stderr, "%s: warning: can't link file `%s' to `%s': %s\n",
               pname, shortpath (NULL, filename),
-              shortpath (NULL, new_filename), my_strerror(errno));
+              shortpath (NULL, new_filename), my_strerror (errno_val));
       errors++;
       return;
     }
 
   if (my_unlink (filename) == -1)
     {
+      int errno_val = errno;
       fprintf (stderr, "%s: warning: can't delete file `%s': %s\n",
-              pname, shortpath (NULL, filename), my_strerror(errno));
+              pname, shortpath (NULL, filename), my_strerror (errno_val));
       errors++;
       return;
     }
@@ -2784,7 +2762,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
@@ -2977,7 +2955,7 @@ 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 (*ptr); check_source (++ptr < clean_text_limit, 0))
     continue;
   return ptr;
 }
@@ -3345,7 +3323,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 (*next_end))
         check_source (--next_end > clean_read_ptr, 0);
       check_source (*next_end == ')', next_end);
       check_source (--next_end > clean_read_ptr, 0);
@@ -3365,7 +3343,7 @@ 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 (*func_name_limit); )
         check_source (--func_name_limit > clean_read_ptr, 0);
 
       for (func_name_start = func_name_limit++;
@@ -3461,8 +3439,8 @@ find_rightmost_formals_list (clean_text_p)
 
     while (*end_formals != ')')
       {
-       if (isspace (*end_formals))
-         while (isspace (*end_formals))
+       if (ISSPACE (*end_formals))
+         while (ISSPACE (*end_formals))
            check_source (--end_formals > clean_read_ptr, 0);
        else
          check_source (--end_formals > clean_read_ptr, 0);
@@ -3491,8 +3469,8 @@ find_rightmost_formals_list (clean_text_p)
 
       while (*end_formals != ')')
         {
-          if (isspace (*end_formals))
-            while (isspace (*end_formals))
+          if (ISSPACE (*end_formals))
+            while (ISSPACE (*end_formals))
               check_source (--end_formals > clean_read_ptr, 0);
           else
             check_source (--end_formals > clean_read_ptr, 0);
@@ -3510,7 +3488,7 @@ find_rightmost_formals_list (clean_text_p)
          by an alphabetic character, while others *cannot* validly be followed
          by such characters.  */
 
-      if ((ch == '{') || isalpha (ch))
+      if ((ch == '{') || ISALPHA (ch))
         break;
 
       /* At this point, we have found a right paren, but we know that it is
@@ -3606,7 +3584,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 (*sp) && *sp != '\n'; sp--)
       continue;
 
     /* Now write out the open { which began this block, and any following
@@ -3687,7 +3665,7 @@ add_global_decls (file_p, clean_text_p)
      header.  We will put in the added declarations just prior to that.  */
 
   scan_p++;
-  while (isspace (*scan_p))
+  while (ISSPACE (*scan_p))
     scan_p++;
   scan_p--;
 
@@ -3856,7 +3834,7 @@ edit_fn_definition (def_dec_p, clean_text_p)
           {
             have_newlines |= (*scan_orig == '\n');
             /* Leave identical whitespace alone.  */
-            if (!isspace (*scan_orig))
+            if (!ISSPACE (*scan_orig))
               *((NONCONST char *)scan_orig) = ' '; /* identical - so whiteout */
           }
         else
@@ -3900,7 +3878,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 (*scan_p))
                   *scan_p = ' ';
                 if (++scan_p >= new_clean_text_limit)
                   abort ();
@@ -3915,7 +3893,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 (*scan_p))
                   *scan_p = ' ';
                 if (++scan_p >= new_clean_text_limit)
                   abort ();
@@ -3927,9 +3905,9 @@ 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 (scan_p[1]))
                   scan_p[1] = ' ';
-                if (!isspace (*scan_p))
+                if (!ISSPACE (*scan_p))
                   *scan_p = ' ';
                 if (++scan_p >= new_clean_text_limit)
                   abort ();
@@ -3941,14 +3919,14 @@ 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 (scan_p[1]))
                   scan_p[1] = ' ';
-                if (!isspace (*scan_p))
+                if (!ISSPACE (*scan_p))
                   *scan_p = ' ';
                 if (++scan_p >= new_clean_text_limit)
                   abort ();
               }
-           if (!isspace (*scan_p))
+           if (!ISSPACE (*scan_p))
              *scan_p = ' ';
            scan_p++;
             break;
@@ -4041,12 +4019,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 (*ahead_p); )
             check_source (++ahead_p < limit, limit);
 
           scan_p = ahead_p - 1;
 
-          if (isalpha (*ahead_p) || *ahead_p == '{')
+          if (ISALPHA (*ahead_p) || *ahead_p == '{')
             {
               const char *last_l_paren;
               const int lineno = identify_lineno (ahead_p);
@@ -4060,7 +4038,7 @@ 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 (*last_r_paren); )
                     check_source (--last_r_paren >= backup_limit, backup_limit);
                 }
               while (*last_r_paren == ')');
@@ -4194,8 +4172,10 @@ edit_file (hp)
   /* The cast avoids an erroneous warning on AIX.  */
   if (my_stat ((char *)convert_filename, &stat_buf) == -1)
     {
+      int errno_val = errno;
       fprintf (stderr, "%s: can't get status for file `%s': %s\n",
-              pname, shortpath (NULL, convert_filename), my_strerror(errno));
+              pname, shortpath (NULL, convert_filename),
+              my_strerror (errno_val));
       return;
     }
   orig_size = stat_buf.st_size;
@@ -4228,9 +4208,10 @@ edit_file (hp)
 
     if ((input_file = my_open (convert_filename, O_RDONLY, 0444)) == -1)
       {
+       int errno_val = errno;
         fprintf (stderr, "%s: can't open file `%s' for reading: %s\n",
                 pname, shortpath (NULL, convert_filename),
-                my_strerror(errno));
+                my_strerror (errno_val));
         return;
       }
 
@@ -4240,10 +4221,11 @@ edit_file (hp)
 
     if (safe_read (input_file, new_orig_text_base, orig_size) != 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),
-                my_strerror(errno));
+                my_strerror (errno_val));
         return;
       }
 
@@ -4274,9 +4256,10 @@ edit_file (hp)
     strcat (clean_filename, ".clean");
     if ((clean_file = creat (clean_filename, 0666)) == -1)
       {
+       int errno_val = errno;
         fprintf (stderr, "%s: can't create/open clean file `%s': %s\n",
                 pname, shortpath (NULL, clean_filename),
-                my_strerror(errno));
+                my_strerror (errno_val));
         return;
       }
   
@@ -4371,7 +4354,8 @@ edit_file (hp)
       strcat (new_filename, save_suffix);
       if (my_link (convert_filename, new_filename) == -1)
         {
-          if (errno == EEXIST)
+         int errno_val = errno;
+         if (errno_val == EEXIST)
             {
               if (!quiet_flag)
                 fprintf (stderr, "%s: warning: file `%s' already saved in `%s'\n",
@@ -4385,7 +4369,7 @@ edit_file (hp)
                       pname,
                       shortpath (NULL, convert_filename),
                       shortpath (NULL, new_filename),
-                      my_strerror(errno));
+                      my_strerror (errno_val));
               return;
             }
         }
@@ -4393,8 +4377,10 @@ edit_file (hp)
 
   if (my_unlink (convert_filename) == -1)
     {
+      int errno_val = errno;
       fprintf (stderr, "%s: can't delete file `%s': %s\n",
-              pname, shortpath (NULL, convert_filename), my_strerror(errno));
+              pname, shortpath (NULL, convert_filename),
+              my_strerror (errno_val));
       return;
     }
 
@@ -4405,9 +4391,10 @@ edit_file (hp)
   
     if ((output_file = creat (convert_filename, 0666)) == -1)
       {
+       int errno_val = errno;
         fprintf (stderr, "%s: can't create/open output file `%s': %s\n",
                 pname, shortpath (NULL, convert_filename),
-                my_strerror(errno));
+                my_strerror (errno_val));
         return;
       }
   
@@ -4432,8 +4419,12 @@ edit_file (hp)
 
   /* 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), my_strerror(errno));
+    {
+      int errno_val = errno;
+      fprintf (stderr, "%s: can't change mode of file `%s': %s\n",
+              pname, shortpath (NULL, convert_filename),
+              my_strerror (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
@@ -4569,7 +4560,7 @@ main (argc, argv)
   int c;
   const char *params = "";
 
-  pname = rindex (argv[0], '/');
+  pname = strrchr (argv[0], '/');
   pname = pname ? pname+1 : argv[0];
 
   cwd_buffer = getpwd ();
@@ -4686,7 +4677,7 @@ main (argc, argv)
   {
     const char *cp;
 
-    for (cp = varargs_style_indicator; isalnum (*cp) || *cp == '_'; cp++)
+    for (cp = varargs_style_indicator; ISALNUM (*cp) || *cp == '_'; cp++)
       continue;
     if (*cp != 0)
       varargs_style_indicator = savestring (varargs_style_indicator,