OSDN Git Service

* config/alpha/osf.h (ASM_OUTPUT_WEAK_ALIAS, ASM_WEAKEN_LABEL,
[pf3gnuchains/gcc-fork.git] / gcc / mips-tfile.c
index f40e839..5de540a 100644 (file)
@@ -2,8 +2,9 @@
    contain debugging information specified by the GNU compiler
    in the form of comments (the mips assembler does not support
    assembly access to debug information).
-   Copyright (C) 1991, 1993, 1994 Free Software Foundation, Inc.
-   Contributed by Michael Meissner, meissner@osf.org
+   Copyright (C) 1991, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001
+   Free Software Foundation, Inc.
+   Contributed by Michael Meissner (meissner@cygnus.com).
    
 This file is part of GNU CC.
 
@@ -19,7 +20,8 @@ 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.  */
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
 
 \f
 /* Here is a brief description of the MIPS ECOFF symbol table.  The
@@ -598,13 +600,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 */
 \f
 
-#ifdef __STDC__
-#include "gstdarg.h"
-#else
-#include "gvarargs.h"
-#endif
 #include "config.h"
-#include <stdio.h>
+#include "system.h"
+#include "version.h"
+#include "intl.h"
 
 #ifndef __SABER__
 #define saber_stop()
@@ -614,30 +613,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #define __LINE__ 0
 #endif
 
-#ifdef __STDC__
-typedef void *PTR_T;
-typedef const void *CPTR_T;
-#define __proto(x) x
-#define VPROTO(ARGS)            ARGS
-#define VA_START(va_list,var)  va_start(va_list,var)
-#else
-
-#if defined(_STDIO_H_) || defined(__STDIO_H__)         /* Ultrix 4.0, SGI */
-typedef void *PTR_T;
-typedef void *CPTR_T;
-
-#else
-typedef char *PTR_T;                                   /* Ultrix 3.1 */
-typedef char *CPTR_T;
-#endif
-
-#define __proto(x) ()
-#define const
-#define VPROTO(ARGS)            (va_alist) va_dcl
-#define VA_START(va_list,var)  va_start(va_list)
-#endif
-
-/* Do to size_t being defined in sys/types.h and different
+/* Due to size_t being defined in sys/types.h and different
    in stddef.h, we have to do this by hand.....  Note, these
    types are correct for MIPS based systems, and may not be
    correct for other systems.  Ultrix 4.0 and Silicon Graphics
@@ -656,23 +632,12 @@ typedef char *CPTR_T;
    so they can't be static.  */
 
 extern void    pfatal_with_name
-                               __proto((char *));
-extern void    fancy_abort     __proto((void));
-       void    botch           __proto((const char *));
-extern PTR_T   xmalloc         __proto((Size_t));
-extern PTR_T   xcalloc         __proto((Size_t, Size_t));
-extern PTR_T   xrealloc        __proto((PTR_T, Size_t));
-extern void    xfree           __proto((PTR_T));
-
-#ifdef HAVE_VPRINTF
-extern void    fatal           __proto((char *format, ...));
-extern void    error           __proto((char *format, ...));
-#else
-/* We must not provide any prototype here, even if ANSI C.  */
-extern void    fatal           __proto(());
-extern void    error           __proto(());
-#endif
+                               PARAMS ((const char *)) ATTRIBUTE_NORETURN;
+extern void    fancy_abort     PARAMS ((void)) ATTRIBUTE_NORETURN;
+       void    botch           PARAMS ((const char *)) ATTRIBUTE_NORETURN;
 
+extern void    fatal           PARAMS ((const char *format, ...)) ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
+extern void    error           PARAMS ((const char *format, ...)) ATTRIBUTE_PRINTF_1;
 \f
 #ifndef MIPS_DEBUGGING_INFO
 
@@ -680,8 +645,8 @@ static int   line_number;
 static int      cur_line_start;
 static int      debug;
 static int      had_errors;
-static char    *progname;
-static char    *input_name;
+static const char *progname;
+static const char *input_name;
 
 int
 main ()
@@ -693,18 +658,11 @@ main ()
 #else                          /* MIPS_DEBUGGING defined */
 \f
 /* The local and global symbols have a field index, so undo any defines
-   of index -> strchr and rindex -> strrchr.  */
+   of index -> strchr.  */
 
-#undef rindex
 #undef index
 
-#include <sys/types.h>
-#include <string.h>
-#include <ctype.h>
-#include <fcntl.h>
-#include <errno.h>
 #include <signal.h>
-#include <sys/stat.h>
 
 #ifndef CROSS_COMPILE
 #include <a.out.h>
@@ -712,34 +670,9 @@ main ()
 #include "mips/a.out.h"
 #endif /* CROSS_COMPILE */
 
-#if defined (USG) || defined (NO_STAB_H)
-#include "gstab.h"  /* If doing DBX on sysV, use our own stab.h.  */
-#else
-#include <stab.h>  /* On BSD, use the system's stab.h.  */
-#endif /* not USG */
+#include "gstab.h"
 
-#ifdef __GNU_STAB__
 #define STAB_CODE_TYPE enum __stab_debug_code
-#else
-#define STAB_CODE_TYPE int
-#endif
-
-#ifdef _OSF_SOURCE
-#define HAS_STDLIB_H
-#define HAS_UNISTD_H
-#endif
-
-#ifdef HAS_STDLIB_H
-#include <stdlib.h>
-#endif
-
-#ifdef HAS_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifndef errno
-extern int errno;                      /* MIPS errno.h doesn't declare this */
-#endif
 
 #ifndef MALLOC_CHECK
 #ifdef __SABER__
@@ -748,10 +681,10 @@ extern int errno;                 /* MIPS errno.h doesn't declare this */
 #endif
 
 #define IS_ASM_IDENT(ch) \
-  (isalnum (ch) || (ch) == '_' || (ch) == '.' || (ch) == '$')
+  (ISALNUM (ch) || (ch) == '_' || (ch) == '.' || (ch) == '$')
 
 \f
-/* Redefinition of of storage classes as an enumeration for better
+/* Redefinition of storage classes as an enumeration for better
    debugging.  */
 
 typedef enum sc {
@@ -932,7 +865,7 @@ typedef enum coff_dt {
 typedef enum hash_state {
   hash_no      = 0,            /* don't hash type */
   hash_yes     = 1,            /* ok to hash type, or use previous hash */
-  hash_record  = 2             /* ok to record hash, but don't use prev. */
+  hash_record  = 2             /* ok to record hash, but don't use prev.  */
 } hash_state_t;
 
 
@@ -959,7 +892,7 @@ enum alloc_type {
    grow linearly, and which are written in the object file as sequential
    pages.  On systems with a BSD malloc that define USE_MALLOC, the
    MAX_CLUSTER_PAGES should be 1 less than a power of two, since malloc
-   adds it's overhead, and rounds up to the next power of 2.  Pages are
+   adds its overhead, and rounds up to the next power of 2.  Pages are
    linked together via a linked list.
 
    If PAGE_SIZE is > 4096, the string length in the shash_t structure
@@ -1007,15 +940,15 @@ typedef struct varray {
 #endif
 
 #define INIT_VARRAY(type) {    /* macro to initialize a varray */      \
-  (vlinks_t *)0,               /* first */                             \
-  (vlinks_t *)0,               /* last */                              \
+  (vlinks_t *) 0,              /* first */                             \
+  (vlinks_t *) 0,              /* last */                              \
   0,                           /* num_allocated */                     \
   sizeof (type),               /* object_size */                       \
   OBJECTS_PER_PAGE (type),     /* objects_per_page */                  \
   OBJECTS_PER_PAGE (type),     /* objects_last_page */                 \
 }
 
-/* Master type for indexes within the symbol table. */
+/* Master type for indexes within the symbol table.  */
 typedef unsigned long symint_t;
 
 
@@ -1134,6 +1067,37 @@ typedef struct efdr {
 static efdr_t init_file = 
 {
   {                    /* FDR structure */
+#ifdef __alpha
+    0,                 /* adr:         memory address of beginning of file */
+    0,                 /* cbLineOffset: byte offset from header for this file ln's */
+    0,                 /* cbLine:      size of lines for this file */
+    0,                 /* cbSs:        number of bytes in the ss */
+    0,                 /* rss:         file name (of source, if known) */
+    0,                 /* issBase:     file's string space */
+    0,                 /* isymBase:    beginning of symbols */
+    0,                 /* csym:        count file's of symbols */
+    0,                 /* ilineBase:   file's line symbols */
+    0,                 /* cline:       count of file's line symbols */
+    0,                 /* ioptBase:    file's optimization entries */
+    0,                 /* copt:        count of file's optimization entries */
+    0,                 /* ipdFirst:    start of procedures for this file */
+    0,                 /* cpd:         count of procedures for this file */
+    0,                 /* iauxBase:    file's auxiliary entries */
+    0,                 /* caux:        count of file's auxiliary entries */
+    0,                 /* rfdBase:     index into the file indirect table */
+    0,                 /* crfd:        count file indirect entries */
+    langC,             /* lang:        language for this file */
+    1,                 /* fMerge:      whether this file can be merged */
+    0,                 /* fReadin:     true if read in (not just created) */
+#ifdef HOST_WORDS_BIG_ENDIAN
+    1,                 /* fBigendian:  if 1, compiled on big endian machine */
+#else
+    0,                 /* fBigendian:  if 1, compiled on big endian machine */
+#endif
+    0,                 /* fTrim:       whether the symbol table was trimmed */
+    GLEVEL_2,          /* glevel:      level this file was compiled with */
+    0,                 /* reserved:    reserved for future use */
+#else
     0,                 /* adr:         memory address of beginning of file */
     0,                 /* rss:         file name (of source, if known) */
     0,                 /* issBase:     file's string space */
@@ -1153,7 +1117,7 @@ static efdr_t init_file =
     langC,             /* lang:        language for this file */
     1,                 /* fMerge:      whether this file can be merged */
     0,                 /* fReadin:     true if read in (not just created) */
-#if BYTES_BIG_ENDIAN
+#ifdef HOST_WORDS_BIG_ENDIAN
     1,                 /* fBigendian:  if 1, compiled on big endian machine */
 #else
     0,                 /* fBigendian:  if 1, compiled on big endian machine */
@@ -1162,14 +1126,15 @@ static efdr_t init_file =
     0,                 /* reserved:    reserved for future use */
     0,                 /* cbLineOffset: byte offset from header for this file ln's */
     0,                 /* cbLine:      size of lines for this file */
+#endif
   },
 
-  (FDR *)0,            /* orig_fdr:    original file header pointer */
-  (char *)0,           /* name:        pointer to filename */
+  (FDR *) 0,           /* orig_fdr:    original file header pointer */
+  (char *) 0,          /* name:        pointer to filename */
   0,                   /* name_len:    length of filename */
   0,                   /* void_type:   ptr to aux node for void type */
   0,                   /* int_type:    ptr to aux node for int type */
-  (scope_t *)0,                /* cur_scope:   current scope being processed */
+  (scope_t *) 0,       /* cur_scope:   current scope being processed */
   0,                   /* file_index:  current file # */
   0,                   /* nested_scopes: # nested scopes */
   INIT_VARRAY (char),  /* strings:     local string varray */
@@ -1177,9 +1142,9 @@ static efdr_t init_file =
   INIT_VARRAY (PDR),   /* procs:       procedure varray */
   INIT_VARRAY (AUXU),  /* aux_syms:    auxiliary symbols varray */
 
-  (struct efdr *)0,    /* next_file:   next file structure */
+  (struct efdr *) 0,   /* next_file:   next file structure */
 
-  (shash_t **)0,       /* shash_head:  string hash table */
+  (shash_t **) 0,      /* shash_head:  string hash table */
   { 0 },               /* thash_head:  type hash table */
 };
 
@@ -1211,7 +1176,7 @@ typedef union page {
 
 /* Structure holding allocation information for small sized structures.  */
 typedef struct alloc_info {
-  char         *alloc_name;    /* name of this allocation type (must be first) */
+  const char   *alloc_name;    /* name of this allocation type (must be first) */
   page_t       *cur_page;      /* current page being allocated from */
   small_free_t  free_list;     /* current free list if any */
   int           unallocated;   /* number of elements unallocated on page */
@@ -1602,17 +1567,17 @@ static PDR     *cur_proc_ptr    = (PDR *) 0;    /* current procedure header */
 static SYMR    *cur_oproc_begin        = (SYMR *) 0;   /* original proc. sym begin info */
 static SYMR    *cur_oproc_end  = (SYMR *) 0;   /* original proc. sym end info */
 static PDR     *cur_oproc_ptr  = (PDR *) 0;    /* current original procedure*/
-static thead_t *cur_tag_head   = (thead_t *)0; /* current tag head */
+static thead_t *cur_tag_head   = (thead_t *) 0;/* current tag head */
 static long    file_offset     = 0;            /* current file offset */
 static long    max_file_offset = 0;            /* maximum file offset */
-static FILE    *object_stream  = (FILE *)0;    /* file desc. to output .o */
-static FILE    *obj_in_stream  = (FILE *)0;    /* file desc. to input .o */
-static char    *progname       = (char *)0;    /* program name for errors */
-static char    *input_name     = "stdin";      /* name of input file */
-static char    *object_name    = (char *)0;    /* tmp. name of object file */
-static char    *obj_in_name    = (char *)0;    /* name of input object file */
-static char    *cur_line_start = (char *)0;    /* current line read in */
-static char    *cur_line_ptr   = (char *)0;    /* ptr within current line */
+static FILE    *object_stream  = (FILE *) 0;   /* file desc. to output .o */
+static FILE    *obj_in_stream  = (FILE *) 0;   /* file desc. to input .o */
+static char    *progname       = (char *) 0;   /* program name for errors */
+static const char *input_name  = "stdin";      /* name of input file */
+static char    *object_name    = (char *) 0;   /* tmp. name of object file */
+static char    *obj_in_name    = (char *) 0;   /* name of input object file */
+static char    *cur_line_start = (char *) 0;   /* current line read in */
+static char    *cur_line_ptr   = (char *) 0;   /* ptr within current line */
 static unsigned        cur_line_nbytes = 0;            /* # bytes for current line */
 static unsigned        cur_line_alloc  = 0;            /* # bytes total in buffer */
 static long    line_number     = 0;            /* current input line number */
@@ -1638,152 +1603,121 @@ static char stabs_symbol[] = STABS_SYMBOL;
 #define STATIC static
 #endif
 
-STATIC int     out_of_bounds   __proto((symint_t, symint_t, const char *, int));
+STATIC int     out_of_bounds   PARAMS ((symint_t, symint_t, const char *, int));
 
-STATIC shash_t *hash_string    __proto((const char *,
+STATIC shash_t *hash_string    PARAMS ((const char *,
                                         Ptrdiff_t,
                                         shash_t **,
                                         symint_t *));
 
-STATIC symint_t        add_string      __proto((varray_t *,
+STATIC symint_t        add_string      PARAMS ((varray_t *,
                                         shash_t **,
                                         const char *,
                                         const char *,
                                         shash_t **));
 
 STATIC symint_t        add_local_symbol
-                               __proto((const char *,
+                               PARAMS ((const char *,
                                         const char *,
                                         st_t,
                                         sc_t,
                                         symint_t,
                                         symint_t));
 
-STATIC symint_t        add_ext_symbol  __proto((const char *,
-                                        const char *,
-                                        st_t,
-                                        sc_t,
-                                        long,
-                                        symint_t,
-                                        int));
+STATIC symint_t        add_ext_symbol  PARAMS ((EXTR *,
+                                        int));
 
 STATIC symint_t        add_aux_sym_symint
-                               __proto((symint_t));
+                               PARAMS ((symint_t));
 
 STATIC symint_t        add_aux_sym_rndx
-                               __proto((int, symint_t));
+                               PARAMS ((int, symint_t));
 
-STATIC symint_t        add_aux_sym_tir __proto((type_info_t *,
+STATIC symint_t        add_aux_sym_tir PARAMS ((type_info_t *,
                                         hash_state_t,
                                         thash_t **));
 
-STATIC tag_t * get_tag         __proto((const char *,
+STATIC tag_t * get_tag         PARAMS ((const char *,
                                         const char *,
                                         symint_t,
                                         bt_t));
 
-STATIC void    add_unknown_tag __proto((tag_t *));
+STATIC void    add_unknown_tag PARAMS ((tag_t *));
 
-STATIC void    add_procedure   __proto((const char *,
+STATIC void    add_procedure   PARAMS ((const char *,
                                         const char *));
 
-STATIC void    add_file        __proto((const char *,
+STATIC void    add_file        PARAMS ((const char *,
                                         const char *));
 
-STATIC void    add_bytes       __proto((varray_t *,
+STATIC void    add_bytes       PARAMS ((varray_t *,
                                         char *,
                                         Size_t));
 
-STATIC void    add_varray_page __proto((varray_t *));
-
-STATIC void    update_headers  __proto((void));
-
-STATIC void    write_varray    __proto((varray_t *, off_t, const char *));
-STATIC void    write_object    __proto((void));
-STATIC char    *st_to_string   __proto((st_t));
-STATIC char    *sc_to_string   __proto((sc_t));
-STATIC char    *read_line      __proto((void));
-STATIC void    parse_input     __proto((void));
-STATIC void    mark_stabs      __proto((const char *));
-STATIC void    parse_begin     __proto((const char *));
-STATIC void    parse_bend      __proto((const char *));
-STATIC void    parse_def       __proto((const char *));
-STATIC void    parse_end       __proto((const char *));
-STATIC void    parse_ent       __proto((const char *));
-STATIC void    parse_file      __proto((const char *));
+STATIC void    add_varray_page PARAMS ((varray_t *));
+
+STATIC void    update_headers  PARAMS ((void));
+
+STATIC void    write_varray    PARAMS ((varray_t *, off_t, const char *));
+STATIC void    write_object    PARAMS ((void));
+STATIC const char *st_to_string        PARAMS ((st_t));
+STATIC const char *sc_to_string        PARAMS ((sc_t));
+STATIC char    *read_line      PARAMS ((void));
+STATIC void    parse_input     PARAMS ((void));
+STATIC void    mark_stabs      PARAMS ((const char *));
+STATIC void    parse_begin     PARAMS ((const char *));
+STATIC void    parse_bend      PARAMS ((const char *));
+STATIC void    parse_def       PARAMS ((const char *));
+STATIC void    parse_end       PARAMS ((const char *));
+STATIC void    parse_ent       PARAMS ((const char *));
+STATIC void    parse_file      PARAMS ((const char *));
 STATIC void    parse_stabs_common
-                               __proto((const char *, const char *, const char *));
-STATIC void    parse_stabs     __proto((const char *));
-STATIC void    parse_stabn     __proto((const char *));
-STATIC page_t  *read_seek      __proto((Size_t, off_t, const char *));
-STATIC void    copy_object     __proto((void));
+                               PARAMS ((const char *, const char *, const char *));
+STATIC void    parse_stabs     PARAMS ((const char *));
+STATIC void    parse_stabn     PARAMS ((const char *));
+STATIC page_t  *read_seek      PARAMS ((Size_t, off_t, const char *));
+STATIC void    copy_object     PARAMS ((void));
 
-STATIC void    catch_signal    __proto((int));
-STATIC page_t  *allocate_page  __proto((void));
+STATIC void    catch_signal    PARAMS ((int)) ATTRIBUTE_NORETURN;
+STATIC page_t  *allocate_page  PARAMS ((void));
 
 STATIC page_t  *allocate_multiple_pages
-                               __proto((Size_t));
+                               PARAMS ((Size_t));
 
 STATIC void    free_multiple_pages
-                               __proto((page_t *, Size_t));
+                               PARAMS ((page_t *, Size_t));
 
 #ifndef MALLOC_CHECK
 STATIC page_t  *allocate_cluster
-                               __proto((Size_t));
+                               PARAMS ((Size_t));
 #endif
 
-STATIC forward_t *allocate_forward     __proto((void));
-STATIC scope_t  *allocate_scope        __proto((void));
-STATIC shash_t  *allocate_shash        __proto((void));
-STATIC tag_t    *allocate_tag          __proto((void));
-STATIC thash_t  *allocate_thash        __proto((void));
-STATIC thead_t  *allocate_thead        __proto((void));
-STATIC vlinks_t         *allocate_vlinks       __proto((void));
-
-STATIC void      free_forward          __proto((forward_t *));
-STATIC void      free_scope            __proto((scope_t *));
-STATIC void      free_tag              __proto((tag_t *));
-STATIC void      free_thead            __proto((thead_t *));
-
-STATIC char     *local_index           __proto((const char *, int));
-STATIC char     *local_rindex          __proto((const char *, int));
-
-#ifndef __alpha
-extern char  *sbrk                     __proto((int));
-extern PTR_T  malloc                   __proto((Size_t));
-extern PTR_T  calloc                   __proto((Size_t, Size_t));
-extern PTR_T  realloc                  __proto((PTR_T, Size_t));
-extern void   free                     __proto((PTR_T));
-#endif
-extern char  *mktemp                   __proto((char *));
-extern long   strtol                   __proto((const char *, char **, int));
+STATIC forward_t *allocate_forward     PARAMS ((void));
+STATIC scope_t  *allocate_scope        PARAMS ((void));
+STATIC shash_t  *allocate_shash        PARAMS ((void));
+STATIC tag_t    *allocate_tag          PARAMS ((void));
+STATIC thash_t  *allocate_thash        PARAMS ((void));
+STATIC thead_t  *allocate_thead        PARAMS ((void));
+STATIC vlinks_t         *allocate_vlinks       PARAMS ((void));
+
+STATIC void      free_forward          PARAMS ((forward_t *));
+STATIC void      free_scope            PARAMS ((scope_t *));
+STATIC void      free_tag              PARAMS ((tag_t *));
+STATIC void      free_thead            PARAMS ((thead_t *));
 
 extern char *optarg;
 extern int   optind;
 extern int   opterr;
-extern char *version_string;
-#ifndef NO_SYS_SIGLIST
-#ifndef DONT_DECLARE_SYS_SIGLIST
-extern char *sys_siglist[NSIG + 1];
-#endif
-#endif
-
-#ifndef SEEK_SET       /* Symbolic constants for the "fseek" function: */
-#define        SEEK_SET 0      /* Set file pointer to offset */
-#define        SEEK_CUR 1      /* Set file pointer to its current value plus offset */
-#define        SEEK_END 2      /* Set file pointer to the size of the file plus offset */
-#endif
-
 \f
 /* List of assembler pseudo ops and beginning sequences that need
    special actions.  Someday, this should be a hash table, and such,
    but for now a linear list of names and calls to memcmp will
-   do...... */
+   do......  */
 
 typedef struct _pseudo_ops {
   const char *name;                    /* pseudo-op in ascii */
   int len;                             /* length of name to compare */
-  void (*func) __proto((const char *));        /* function to handle line */
+  void (*func) PARAMS ((const char *));        /* function to handle line */
 } pseudo_ops_t;
 
 static pseudo_ops_t pseudo_ops[] = {
@@ -1822,7 +1756,7 @@ add_varray_page (vp)
   new_links->start_index = vp->num_allocated;
   vp->objects_last_page = 0;
 
-  if (vp->first == (vlinks_t *)0)              /* first allocation? */
+  if (vp->first == (vlinks_t *) 0)             /* first allocation? */
     vp->first = vp->last = new_links;
   else
     {                                          /* 2nd or greater allocation */
@@ -1856,13 +1790,13 @@ hash_string (text, hash_len, hash_tbl, ret_hash_index)
   hi &= (1 << HASHBITS) - 1;
   hi %= SHASH_SIZE;
 
-  if (ret_hash_index != (symint_t *)0)
+  if (ret_hash_index != (symint_t *) 0)
     *ret_hash_index = hi;
 
-  for (ptr = hash_tbl[hi]; ptr != (shash_t *)0; ptr = ptr->next)
-    if (hash_len == ptr->len
+  for (ptr = hash_tbl[hi]; ptr != (shash_t *) 0; ptr = ptr->next)
+    if ((symint_t) hash_len == ptr->len
        && first_ch == ptr->string[0]
-       && memcmp ((CPTR_T) text, (CPTR_T) ptr->string, hash_len) == 0)
+       && memcmp (text, ptr->string, hash_len) == 0)
       break;
 
   return ptr;
@@ -1885,18 +1819,18 @@ add_string (vp, hash_tbl, start, end_p1, ret_hash)
   register shash_t *hash_ptr;
   symint_t hi;
 
-  if (len >= PAGE_USIZE)
+  if (len >= (Ptrdiff_t) PAGE_USIZE)
     fatal ("String too big (%ld bytes)", (long) len);
 
   hash_ptr = hash_string (start, len, hash_tbl, &hi);
-  if (hash_ptr == (shash_t *)0)
+  if (hash_ptr == (shash_t *) 0)
     {
       register char *p;
 
-      if (vp->objects_last_page + len >= PAGE_USIZE)
+      if (vp->objects_last_page + len >= (long) PAGE_USIZE)
        {
-         vp->num_allocated =
-           ((vp->num_allocated + PAGE_USIZE - 1) / PAGE_USIZE) * PAGE_USIZE;
+         vp->num_allocated
+           ((vp->num_allocated + PAGE_USIZE - 1) / PAGE_USIZE) * PAGE_USIZE;
          add_varray_page (vp);
        }
 
@@ -1917,7 +1851,7 @@ add_string (vp, hash_tbl, start, end_p1, ret_hash)
       *p = '\0';
     }
 
-  if (ret_hash != (shash_t **)0)
+  if (ret_hash != (shash_t **) 0)
     *ret_hash = hash_ptr;
 
   return hash_ptr->indx;
@@ -1943,7 +1877,7 @@ add_local_symbol (str_start, str_end_p1, type, storage, value, indx)
   register tag_t *ptag_next;
   register varray_t *vp = &cur_file_ptr->symbols;
   register int scope_delta = 0;
-  shash_t *hash_ptr = (shash_t *)0;
+  shash_t *hash_ptr = (shash_t *) 0;
 
   if (vp->objects_last_page == vp->objects_per_page)
     add_varray_page (vp);
@@ -1954,7 +1888,7 @@ add_local_symbol (str_start, str_end_p1, type, storage, value, indx)
   psym->st = (unsigned) type;
   psym->sc = (unsigned) storage;
   psym->index = indx;
-  psym->iss = (str_start == (const char *)0)
+  psym->iss = (str_start == (const char *) 0)
                ? 0
                : add_string (&cur_file_ptr->strings,
                              &cur_file_ptr->shash_head[0],
@@ -1969,7 +1903,7 @@ add_local_symbol (str_start, str_end_p1, type, storage, value, indx)
 
   /* Save the symbol within the hash table if this is a static
      item, and it has a name.  */
-  if (hash_ptr != (shash_t *)0
+  if (hash_ptr != (shash_t *) 0
       && (type == st_Global || type == st_Static || type == st_Label
          || type == st_Proc || type == st_StaticProc))
     hash_ptr->sym_ptr = psym;
@@ -2026,10 +1960,10 @@ add_local_symbol (str_start, str_end_p1, type, storage, value, indx)
              cur_tag_head = ptag_head->prev;
 
              for (ptag = ptag_head->first_tag;
-                  ptag != (tag_t *)0;
+                  ptag != (tag_t *) 0;
                   ptag = ptag_next)
                {
-                 if (ptag->forward_ref != (forward_t *)0)
+                 if (ptag->forward_ref != (forward_t *) 0)
                    add_unknown_tag (ptag);
 
                  ptag_next = ptag->same_block;
@@ -2080,8 +2014,8 @@ add_local_symbol (str_start, str_end_p1, type, storage, value, indx)
       && (debug > 2 || type == st_Block || type == st_End
          || type == st_Proc || type == st_StaticProc))
     {
-      char *sc_str = sc_to_string (storage);
-      char *st_str = st_to_string (type);
+      const char *sc_str = sc_to_string (storage);
+      const char *st_str = st_to_string (type);
       int depth = cur_file_ptr->nested_scopes + (scope_delta < 0);
 
       fprintf (stderr,
@@ -2089,11 +2023,12 @@ add_local_symbol (str_start, str_end_p1, type, storage, value, indx)
               value, depth, sc_str);
 
       if (str_start && str_end_p1 - str_start > 0)
-       fprintf (stderr, " st= %-11s name= %.*s\n", st_str, str_end_p1 - str_start, str_start);
+       fprintf (stderr, " st= %-11s name= %.*s\n",
+                st_str, (int) (str_end_p1 - str_start), str_start);
       else
        {
          Size_t len = strlen (st_str);
-         fprintf (stderr, " st= %.*s\n", len-1, st_str);
+         fprintf (stderr, " st= %.*s\n", (int) (len-1), st_str);
        }
     }
 
@@ -2104,30 +2039,32 @@ add_local_symbol (str_start, str_end_p1, type, storage, value, indx)
 /* Add an external symbol.  */
 
 STATIC symint_t
-add_ext_symbol (str_start, str_end_p1, type, storage, value, indx, ifd)
-     const char *str_start;            /* first byte in string */
-     const char *str_end_p1;           /* first byte after string */
-     st_t type;                                /* symbol type */
-     sc_t storage;                     /* storage class */
-     long value;                       /* value of symbol */
-     symint_t indx;                    /* index to local/aux. syms */
+add_ext_symbol (esym, ifd)
+     EXTR *esym;                       /* symbol pointer */
      int ifd;                          /* file index */
 {
+  const char *str_start;               /* first byte in string */
+  const char *str_end_p1;              /* first byte after string */
   register EXTR *psym;
   register varray_t *vp = &ext_symbols;
-  shash_t *hash_ptr = (shash_t *)0;
+  shash_t *hash_ptr = (shash_t *) 0;
+
+  str_start = ORIG_ESTRS (esym->asym.iss);
+  str_end_p1 = str_start + strlen(str_start);
 
   if (debug > 1)
     {
-      char *sc_str = sc_to_string (storage);
-      char *st_str = st_to_string (type);
+      long value = esym->asym.value;
+      const char *sc_str = sc_to_string (esym->asym.sc);
+      const char *st_str = st_to_string (esym->asym.st);
 
       fprintf (stderr,
               "\tesym\tv= %10ld, ifd= %2d, sc= %-12s",
               value, ifd, sc_str);
 
       if (str_start && str_end_p1 - str_start > 0)
-       fprintf (stderr, " st= %-11s name= %.*s\n", st_str, str_end_p1 - str_start, str_start);
+       fprintf (stderr, " st= %-11s name= %.*s\n",
+                st_str, (int) (str_end_p1 - str_start), str_start);
       else
        fprintf (stderr, " st= %s\n", st_str);
     }
@@ -2137,12 +2074,10 @@ add_ext_symbol (str_start, str_end_p1, type, storage, value, indx, ifd)
 
   psym = &vp->last->datum->esym[ vp->objects_last_page++ ];
 
+  *psym = *esym;
   psym->ifd = ifd;
-  psym->asym.value = value;
-  psym->asym.st    = (unsigned) type;
-  psym->asym.sc    = (unsigned) storage;
-  psym->asym.index = indx;
-  psym->asym.iss   = (str_start == (const char *)0)
+  psym->asym.index = indexNil;
+  psym->asym.iss   = (str_start == (const char *) 0)
                        ? 0
                        : add_string (&ext_strings,
                                      &ext_str_hash[0],
@@ -2228,7 +2163,7 @@ add_aux_sym_tir (t, state, hash_tbl)
 
 
   /* For anything that adds additional information, we must not hash,
-     so check here, and reset our state. */
+     so check here, and reset our state.  */
 
   if (state != hash_no
       && (t->type_qualifiers[0] == tq_Array
@@ -2258,17 +2193,17 @@ add_aux_sym_tir (t, state, hash_tbl)
       hi %= THASH_SIZE;
 
       for (hash_ptr = hash_tbl[hi];
-          hash_ptr != (thash_t *)0;
+          hash_ptr != (thash_t *) 0;
           hash_ptr = hash_ptr->next)
        {
          if (aux.isym == hash_ptr->type.isym)
            break;
        }
 
-      if (hash_ptr != (thash_t *)0 && state == hash_yes)
+      if (hash_ptr != (thash_t *) 0 && state == hash_yes)
        return hash_ptr->indx;
 
-      if (hash_ptr == (thash_t *)0)
+      if (hash_ptr == (thash_t *) 0)
        {
          hash_ptr = allocate_thash ();
          hash_ptr->next = hash_tbl[hi];
@@ -2278,7 +2213,7 @@ add_aux_sym_tir (t, state, hash_tbl)
        }
     }
 
-  /* Everything is set up, add the aux symbol. */
+  /* Everything is set up, add the aux symbol.  */
   if (vp->objects_last_page == vp->objects_per_page)
     add_varray_page (vp);
 
@@ -2346,15 +2281,15 @@ add_aux_sym_tir (t, state, hash_tbl)
                               cur_file_ptr->int_type);
 
       (void) add_aux_sym_symint (cur_file_ptr->file_index);    /* file index*/
-      (void) add_aux_sym_symint ((symint_t)0);                 /* low bound */
+      (void) add_aux_sym_symint ((symint_t) 0);                        /* low bound */
       (void) add_aux_sym_symint (t->dimensions[i] - 1);                /* high bound*/
       (void) add_aux_sym_symint ((t->dimensions[i] == 0)       /* stride */
                              ? 0
                              : (t->sizes[i] * 8) / t->dimensions[i]);
     };
 
-  /* NOTE:  Mips documentation claism that the bitfield width goes here.
-     But it needs to be emitted earlier. */
+  /* NOTE:  Mips documentation claims that the bitfield width goes here.
+     But it needs to be emitted earlier.  */
 
   return ret;
 }
@@ -2374,10 +2309,10 @@ get_tag (tag_start, tag_end_p1, indx, basic_type)
   hash_ptr = hash_string (tag_start,
                          tag_end_p1 - tag_start,
                          &tag_hash[0],
-                         (symint_t *)0);
+                         (symint_t *) 0);
 
-  if (hash_ptr != (shash_t *)0
-      && hash_ptr->tag_ptr != (tag_t *)0)
+  if (hash_ptr != (shash_t *) 0
+      && hash_ptr->tag_ptr != (tag_t *) 0)
   {
     tag_ptr = hash_ptr->tag_ptr;
     if (indx != indexNil)
@@ -2401,7 +2336,8 @@ get_tag (tag_start, tag_end_p1, indx, basic_type)
   tag_ptr->same_name   = hash_ptr->tag_ptr;
   tag_ptr->basic_type  = basic_type;
   tag_ptr->indx                = indx;
-  tag_ptr->ifd         = (indx == indexNil) ? -1 : cur_file_ptr->file_index;
+  tag_ptr->ifd         = (indx == indexNil
+                          ? (symint_t) -1 : cur_file_ptr->file_index);
   tag_ptr->same_block  = cur_tag_head->first_tag;
 
   cur_tag_head->first_tag = tag_ptr;
@@ -2427,7 +2363,7 @@ add_unknown_tag (ptag)
 
   if (debug > 1)
     {
-      char *agg_type   = "{unknown aggregate type}";
+      const char *agg_type = "{unknown aggregate type}";
       switch (ptag->basic_type)
        {
        case bt_Struct: agg_type = "struct";    break;
@@ -2436,25 +2372,25 @@ add_unknown_tag (ptag)
        default:                                break;
        }
 
-      fprintf (stderr, "unknown %s %.*s found\n", agg_type,
-              hash_ptr->len, name_start);
+      fprintf (stderr, "unknown %s %.*s found\n",
+              agg_type, (int) hash_ptr->len, name_start);
     }
 
   sym_index = add_local_symbol (name_start,
                                name_end_p1,
                                st_Block,
                                sc_Info,
-                               (symint_t)0,
-                               (symint_t)0);
+                               (symint_t) 0,
+                               (symint_t) 0);
 
   (void) add_local_symbol (name_start,
                           name_end_p1,
                           st_End,
                           sc_Info,
-                          (symint_t)0,
-                          (symint_t)0);
+                          (symint_t) 0,
+                          (symint_t) 0);
 
-  while (f_next != (forward_t *)0)
+  while (f_next != (forward_t *) 0)
     {
       f_cur  = f_next;
       f_next = f_next->next;
@@ -2486,7 +2422,7 @@ add_procedure (func_start, func_end_p1)
   register shash_t *shash_ptr = hash_string (func_start,
                                            func_end_p1 - func_start,
                                            &orig_str_hash[0],
-                                           (symint_t *)0);
+                                           (symint_t *) 0);
 
   if (debug)
     fputc ('\n', stderr);
@@ -2500,14 +2436,14 @@ add_procedure (func_start, func_end_p1)
 
 
   /* Did the assembler create this procedure?  If so, get the PDR information.  */
-  cur_oproc_ptr = (PDR *)0;
-  if (shash_ptr != (shash_t *)0)
+  cur_oproc_ptr = (PDR *) 0;
+  if (shash_ptr != (shash_t *) 0)
     {
       register PDR *old_proc_ptr = shash_ptr->proc_ptr;
       register SYMR *sym_ptr = shash_ptr->sym_ptr;
 
-      if (old_proc_ptr != (PDR *)0
-         && sym_ptr != (SYMR *)0
+      if (old_proc_ptr != (PDR *) 0
+         && sym_ptr != (SYMR *) 0
          && ((st_t)sym_ptr->st == st_Proc || (st_t)sym_ptr->st == st_StaticProc))
        {
          cur_oproc_begin = sym_ptr;
@@ -2520,17 +2456,18 @@ add_procedure (func_start, func_end_p1)
        }
     }
 
-  if (cur_oproc_ptr == (PDR *)0)
-    error ("Did not find a PDR block for %.*s", func_end_p1 - func_start, func_start);
+  if (cur_oproc_ptr == (PDR *) 0)
+    error ("Did not find a PDR block for %.*s",
+          (int) (func_end_p1 - func_start), func_start);
 
-  /* Determine the start of symbols. */
+  /* Determine the start of symbols.  */
   new_proc_ptr->isym = file_ptr->symbols.num_allocated;
 
   /* Push the start of the function.  */
   (void) add_local_symbol (func_start, func_end_p1,
                           proc_type, sc_Text,
                           value,
-                          (symint_t)0);
+                          (symint_t) 0);
 }
 
 \f
@@ -2550,30 +2487,30 @@ add_file (file_start, file_end_p1)
   register efdr_t *file_ptr;
 
   if (debug)
-    fprintf (stderr, "\tfile\t%.*s\n", len, file_start);
+    fprintf (stderr, "\tfile\t%.*s\n", (int) len, file_start);
 
   /* See if the file has already been created.  */
   for (file_ptr = first_file;
-       file_ptr != (efdr_t *)0;
+       file_ptr != (efdr_t *) 0;
        file_ptr = file_ptr->next_file)
     {
       if (first_ch == file_ptr->name[0]
          && file_ptr->name[len] == '\0'
-         && memcmp ((CPTR_T) file_start, (CPTR_T) file_ptr->name, len) == 0)
+         && memcmp (file_start, file_ptr->name, len) == 0)
        {
          cur_file_ptr = file_ptr;
          break;
        }
     }
 
-  /* If this is a new file, create it. */
-  if (file_ptr == (efdr_t *)0)
+  /* If this is a new file, create it.  */
+  if (file_ptr == (efdr_t *) 0)
     {
       if (file_desc.objects_last_page == file_desc.objects_per_page)
        add_varray_page (&file_desc);
 
-      file_ptr = cur_file_ptr =
-       &file_desc.last->datum->file[ file_desc.objects_last_page++ ];
+      file_ptr = cur_file_ptr
+       &file_desc.last->datum->file[ file_desc.objects_last_page++ ];
       *file_ptr = init_file;
 
       file_ptr->file_index = file_desc.num_allocated++;
@@ -2586,15 +2523,15 @@ add_file (file_start, file_end_p1)
                  &file_ptr->shash_head[0],
                  &zero_bytes[0],
                  &zero_bytes[0],
-                 (shash_t **)0);
+                 (shash_t **) 0);
 
-      if (file_end_p1 - file_start > PAGE_USIZE-2)
+      if (file_end_p1 - file_start > (long) PAGE_USIZE-2)
        fatal ("Filename goes over one page boundary.");
 
       /* Push the start of the filename. We assume that the filename
          will be stored at string offset 1.  */
       (void) add_local_symbol (file_start, file_end_p1, st_File, sc_Text,
-                              (symint_t)0, (symint_t)0);
+                              (symint_t) 0, (symint_t) 0);
       file_ptr->fdr.rss = 1;
       file_ptr->name = &file_ptr->strings.last->datum->byte[1];
       file_ptr->name_len = file_end_p1 - file_start;
@@ -2643,7 +2580,7 @@ add_bytes (vp, input_ptr, nitems)
 
       if (move_bytes >= 32)
        {
-         (void) memcpy ((PTR_T) ptr, (CPTR_T) input_ptr, move_bytes);
+         (void) memcpy (ptr, input_ptr, move_bytes);
          input_ptr += move_bytes;
        }
       else
@@ -2657,7 +2594,7 @@ add_bytes (vp, input_ptr, nitems)
 \f
 /* Convert storage class to string.  */
 
-STATIC char *
+STATIC const char *
 sc_to_string(storage_class)
      sc_t storage_class;
 {
@@ -2695,7 +2632,7 @@ sc_to_string(storage_class)
 \f
 /* Convert symbol type to string.  */
 
-STATIC char *
+STATIC const char *
 st_to_string(symbol_type)
      st_t symbol_type;
 {
@@ -2733,7 +2670,7 @@ st_to_string(symbol_type)
    semi-colon, and return each logical line independently.  */
 
 STATIC char *
-read_line __proto((void))
+read_line ()
 {
   static   int line_split_p    = 0;
   register int string_p                = 0;
@@ -2741,7 +2678,7 @@ read_line __proto((void))
   register int ch;
   register char *ptr;
 
-  if (cur_line_start == (char *)0)
+  if (cur_line_start == (char *) 0)
     {                          /* allocate initial page */
       cur_line_start = (char *) allocate_page ();
       cur_line_alloc = PAGE_SIZE;
@@ -2800,8 +2737,8 @@ read_line __proto((void))
   if (ferror (stdin))
     pfatal_with_name (input_name);
 
-  cur_line_ptr = (char *)0;
-  return (char *)0;
+  cur_line_ptr = (char *) 0;
+  return (char *) 0;
 }
 
 \f
@@ -2816,42 +2753,44 @@ parse_begin (start)
   int ch;
   shash_t *hash_ptr;                   /* hash pointer to lookup label */
 
-  if (cur_file_ptr == (efdr_t *)0)
+  if (cur_file_ptr == (efdr_t *) 0)
     {
       error ("#.begin directive without a preceding .file directive");
       return;
     }
 
-  if (cur_proc_ptr == (PDR *)0)
+  if (cur_proc_ptr == (PDR *) 0)
     {
       error ("#.begin directive without a preceding .ent directive");
       return;
     }
 
-  for (end_p1 = start; (ch = *end_p1) != '\0' && !isspace (ch); end_p1++)
+  for (end_p1 = start; (ch = *end_p1) != '\0' && !ISSPACE (ch); end_p1++)
     ;
 
   hash_ptr = hash_string (start,
                          end_p1 - start,
                          &orig_str_hash[0],
-                         (symint_t *)0);
+                         (symint_t *) 0);
 
-  if (hash_ptr == (shash_t *)0)
+  if (hash_ptr == (shash_t *) 0)
     {
-      error ("Label %.*s not found for #.begin", end_p1 - start, start);
+      error ("Label %.*s not found for #.begin",
+            (int) (end_p1 - start), start);
       return;
     }
 
-  if (cur_oproc_begin == (SYMR *)0)
+  if (cur_oproc_begin == (SYMR *) 0)
     {
-      error ("Procedure table %.*s not found for #.begin", end_p1 - start, start);
+      error ("Procedure table %.*s not found for #.begin",
+            (int) (end_p1 - start), start);
       return;
     }
 
-  (void) add_local_symbol ((const char *)0, (const char *)0,
+  (void) add_local_symbol ((const char *) 0, (const char *) 0,
                           st_Block, sc_Text,
-                          (symint_t)hash_ptr->sym_ptr->value - cur_oproc_begin->value,
-                          (symint_t)0);
+                          (symint_t) hash_ptr->sym_ptr->value - cur_oproc_begin->value,
+                          (symint_t) 0);
 }
 
 \f
@@ -2866,42 +2805,43 @@ parse_bend (start)
   int ch;
   shash_t *hash_ptr;                   /* hash pointer to lookup label */
 
-  if (cur_file_ptr == (efdr_t *)0)
+  if (cur_file_ptr == (efdr_t *) 0)
     {
       error ("#.begin directive without a preceding .file directive");
       return;
     }
 
-  if (cur_proc_ptr == (PDR *)0)
+  if (cur_proc_ptr == (PDR *) 0)
     {
       error ("#.bend directive without a preceding .ent directive");
       return;
     }
 
-  for (end_p1 = start; (ch = *end_p1) != '\0' && !isspace (ch); end_p1++)
+  for (end_p1 = start; (ch = *end_p1) != '\0' && !ISSPACE (ch); end_p1++)
     ;
 
   hash_ptr = hash_string (start,
                          end_p1 - start,
                          &orig_str_hash[0],
-                         (symint_t *)0);
+                         (symint_t *) 0);
 
-  if (hash_ptr == (shash_t *)0)
+  if (hash_ptr == (shash_t *) 0)
     {
-      error ("Label %.*s not found for #.bend", end_p1 - start, start);
+      error ("Label %.*s not found for #.bend", (int) (end_p1 - start), start);
       return;
     }
 
-  if (cur_oproc_begin == (SYMR *)0)
+  if (cur_oproc_begin == (SYMR *) 0)
     {
-      error ("Procedure table %.*s not found for #.bend", end_p1 - start, start);
+      error ("Procedure table %.*s not found for #.bend",
+            (int) (end_p1 - start), start);
       return;
     }
 
-  (void) add_local_symbol ((const char *)0, (const char *)0,
+  (void) add_local_symbol ((const char *) 0, (const char *) 0,
                           st_End, sc_Text,
                           (symint_t)hash_ptr->sym_ptr->value - cur_oproc_begin->value,
-                          (symint_t)0);
+                          (symint_t) 0);
 }
 
 \f
@@ -2925,12 +2865,12 @@ parse_def (name_start)
   const char *arg_start;                       /* start of current argument */
   const char *arg_end_p1;                      /* end+1 of current argument */
   const char *name_end_p1;                     /* end+1 of label */
-  const char *tag_start          = (const char *)0;    /* start of tag name */
-  const char *tag_end_p1  = (const char *)0;   /* end+1 of tag name */
+  const char *tag_start          = 0;                  /* start of tag name */
+  const char *tag_end_p1  = 0;                 /* end+1 of tag name */
   sc_t storage_class     = sc_Nil;
   st_t symbol_type       = st_Nil;
   type_info_t t;
-  EXTR *eptr             = (EXTR *)0;          /* ext. sym equivalent to def*/
+  EXTR *eptr             = (EXTR *) 0;         /* ext. sym equivalent to def*/
   int is_function        = 0;                  /* != 0 if function */
   symint_t value         = 0;
   symint_t indx                  = cur_file_ptr->void_type;
@@ -2988,7 +2928,7 @@ parse_def (name_start)
           (ch = *dir_end_p1) != ' ' && ch != '\t';
           dir_end_p1++)
        {
-         if (ch == '\0' || isspace (ch))
+         if (ch == '\0' || ISSPACE (ch))
            {
              error_line = __LINE__;
              saber_stop ();
@@ -2998,13 +2938,13 @@ parse_def (name_start)
 
       /* Pick up the subdirective argument now.  */
       arg_was_number = arg_number = 0;
-      arg_end_p1 = (const char *)0;
+      arg_end_p1 = 0;
       arg_start = dir_end_p1+1;
       ch = *arg_start;
       while (ch == ' ' || ch == '\t')
        ch = *++arg_start;
 
-      if (isdigit (ch) || ch == '-' || ch == '+')
+      if (ISDIGIT (ch) || ch == '-' || ch == '+')
        {
          int ch2;
          arg_number = strtol (arg_start, (char **) &arg_end_p1, 0);
@@ -3012,7 +2952,7 @@ parse_def (name_start)
            arg_was_number++;
        }
 
-      else if (ch == '\0' || isspace (ch))
+      else if (ch == '\0' || ISSPACE (ch))
        {
          error_line = __LINE__;
          saber_stop ();
@@ -3060,7 +3000,7 @@ parse_def (name_start)
                    ch = *++arg_start;
 
                  arg_was_number = 0;
-                 if (isdigit (ch) || ch == '-' || ch == '+')
+                 if (ISDIGIT (ch) || ch == '-' || ch == '+')
                    {
                      int ch2;
                      arg_number = strtol (arg_start, (char **) &arg_end_p1, 0);
@@ -3134,7 +3074,7 @@ parse_def (name_start)
                    ch = *++arg_start;
 
                  arg_was_number = 0;
-                 if (isdigit (ch) || ch == '-' || ch == '+')
+                 if (ISDIGIT (ch) || ch == '-' || ch == '+')
                    {
                      int ch2;
                      arg_number = strtol (arg_start, (char **) &arg_end_p1, 0);
@@ -3243,30 +3183,30 @@ parse_def (name_start)
                  ext_hash_ptr = hash_string (arg_start,
                                              arg_end_p1 - arg_start,
                                              &ext_str_hash[0],
-                                             (symint_t *)0);
+                                             (symint_t *) 0);
 
-                 if (ext_hash_ptr != (shash_t *)0
-                     && ext_hash_ptr->esym_ptr != (EXTR *)0)
+                 if (ext_hash_ptr != (shash_t *) 0
+                     && ext_hash_ptr->esym_ptr != (EXTR *) 0)
                    eptr = ext_hash_ptr->esym_ptr;
 
                  orig_hash_ptr = hash_string (arg_start,
                                               arg_end_p1 - arg_start,
                                               &orig_str_hash[0],
-                                              (symint_t *)0);
+                                              (symint_t *) 0);
 
-                 if ((orig_hash_ptr == (shash_t *)0
-                      || orig_hash_ptr->sym_ptr == (SYMR *)0)
-                     && eptr == (EXTR *)0)
+                 if ((orig_hash_ptr == (shash_t *) 0
+                      || orig_hash_ptr->sym_ptr == (SYMR *) 0)
+                     && eptr == (EXTR *) 0)
                    {
                      fprintf (stderr, "warning, %.*s not found in original or external symbol tables, value defaults to 0\n",
-                              arg_end_p1 - arg_start,
+                              (int) (arg_end_p1 - arg_start),
                               arg_start);
                      value = 0;
                    }
                  else
                    {
-                     SYMR *ptr = (orig_hash_ptr != (shash_t *)0
-                                  && orig_hash_ptr->sym_ptr != (SYMR *)0)
+                     SYMR *ptr = (orig_hash_ptr != (shash_t *) 0
+                                  && orig_hash_ptr->sym_ptr != (SYMR *) 0)
                                        ? orig_hash_ptr->sym_ptr
                                        : &eptr->asym;
 
@@ -3290,14 +3230,22 @@ parse_def (name_start)
     }
 
 
-  t.extra_sizes = (tag_start != (char *)0);
+  if (storage_class == sc_Bits)
+    {
+      t.bitfield = 1;
+      t.extra_sizes = 1;
+    }
+  else
+    t.extra_sizes = 0;
+
   if (t.num_dims > 0)
     {
-      int diff = t.num_dims - t.num_sizes;
+      int num_real_sizes = t.num_sizes - t.extra_sizes;
+      int diff = t.num_dims - num_real_sizes;
       int i = t.num_dims - 1;
       int j;
 
-      if (t.num_sizes != 1 || diff < 0)
+      if (num_real_sizes != 1 || diff < 0)
        {
          error_line = __LINE__;
          saber_stop ();
@@ -3308,10 +3256,9 @@ parse_def (name_start)
         and sizes were passed, creating extra sizes for multiply
         dimensioned arrays if not passed.  */
 
-      t.extra_sizes = 0;
       if (diff)
        {
-         for (j = (sizeof (t.sizes) / sizeof (t.sizes[0])) - 1; j >= 0; j--)
+         for (j = ARRAY_SIZE (t.sizes) - 1; j >= 0; j--)
            t.sizes[ j ] = ((j-diff) >= 0) ? t.sizes[ j-diff ] : 0;
 
          t.num_sizes = i + 1;
@@ -3325,14 +3272,6 @@ parse_def (name_start)
        }
     }
 
-  else if (symbol_type == st_Member && t.num_sizes - t.extra_sizes == 1)
-    { /* Is this a bitfield?  This is indicated by a structure memeber
-        having a size field that isn't an array.  */
-
-      t.bitfield = 1;
-    }
-
-
   /* Except for enumeration members & begin/ending of scopes, put the
      type word in the aux. symbol table.  */
 
@@ -3348,10 +3287,10 @@ parse_def (name_start)
          || t.basic_type == bt_Union
          || t.basic_type == bt_Enum)
        {
-         if (tag_start == (char *)0)
+         if (tag_start == (char *) 0)
            {
              error ("No tag specified for %.*s",
-                    name_end_p1 - name_start,
+                    (int) (name_end_p1 - name_start),
                     name_start);
              return;
            }
@@ -3376,8 +3315,8 @@ parse_def (name_start)
   /* If this is an external or static symbol, update the appropriate
      external symbol.  */
 
-  if (eptr != (EXTR *)0
-      && (eptr->asym.index == indexNil || cur_proc_ptr == (PDR *)0))
+  if (eptr != (EXTR *) 0
+      && (eptr->asym.index == indexNil || cur_proc_ptr == (PDR *) 0))
     {
       eptr->ifd = cur_file_ptr->file_index;
       eptr->asym.index = indx;
@@ -3414,7 +3353,7 @@ parse_def (name_start)
         that any error reporting above gives the correct name.  */
 
     case st_End:
-      name_start = name_end_p1 = (const char *)0;
+      name_start = name_end_p1 = 0;
       value = inside_enumeration = 0;
       break;
 
@@ -3436,9 +3375,9 @@ parse_def (name_start)
   /* Add the symbol, except for global symbols outside of functions,
      for which the external symbol table is fine enough.  */
 
-  if (eptr == (EXTR *)0
+  if (eptr == (EXTR *) 0
       || eptr->asym.st == (int)st_Nil
-      || cur_proc_ptr != (PDR *)0)
+      || cur_proc_ptr != (PDR *) 0)
     {
       symint_t isym = add_local_symbol (name_start, name_end_p1,
                                        symbol_type, storage_class,
@@ -3461,7 +3400,7 @@ parse_def (name_start)
          forward_t *f_next = tag_ptr->forward_ref;
          forward_t *f_cur;
 
-         while (f_next != (forward_t *)0)
+         while (f_next != (forward_t *) 0)
            {
              f_cur  = f_next;
              f_next = f_next->next;
@@ -3472,7 +3411,7 @@ parse_def (name_start)
              free_forward (f_cur);
            }
 
-         tag_ptr->forward_ref = (forward_t *)0;
+         tag_ptr->forward_ref = (forward_t *) 0;
         }
     }
 
@@ -3501,20 +3440,20 @@ parse_end (start)
   register symint_t value;
   register FDR *orig_fdr;
 
-  if (cur_file_ptr == (efdr_t *)0)
+  if (cur_file_ptr == (efdr_t *) 0)
     {
       error (".end directive without a preceding .file directive");
       return;
     }
 
-  if (cur_proc_ptr == (PDR *)0)
+  if (cur_proc_ptr == (PDR *) 0)
     {
       error (".end directive without a preceding .ent directive");
       return;
     }
 
   /* Get the function name, skipping whitespace.  */
-  for (start_func = start; isspace (*start_func); start_func++)
+  for (start_func = start; ISSPACE ((unsigned char)*start_func); start_func++)
     ;
 
   ch = *start_func;
@@ -3537,18 +3476,19 @@ parse_end (start)
 
   orig_fdr = cur_file_ptr->orig_fdr;
   value = 0;
-  if (orig_fdr != (FDR *)0 && cur_oproc_end != (SYMR *)0)
+  if (orig_fdr != (FDR *)0 && cur_oproc_end != (SYMR *) 0)
     value = cur_oproc_end->value;
 
   else
-    error ("Cannot find .end block for %.*s", end_func_p1 - start_func, start_func);
+    error ("Cannot find .end block for %.*s",
+          (int) (end_func_p1 - start_func), start_func);
 
   (void) add_local_symbol (start_func, end_func_p1,
                           st_End, sc_Text,
                           value,
-                          (symint_t)0);
+                          (symint_t) 0);
 
-  cur_proc_ptr = cur_oproc_ptr = (PDR *)0;
+  cur_proc_ptr = cur_oproc_ptr = (PDR *) 0;
 }
 
 \f
@@ -3561,19 +3501,19 @@ parse_ent (start)
   register const char *start_func, *end_func_p1;
   register int ch;
 
-  if (cur_file_ptr == (efdr_t *)0)
+  if (cur_file_ptr == (efdr_t *) 0)
     {
       error (".ent directive without a preceding .file directive");
       return;
     }
 
-  if (cur_proc_ptr != (PDR *)0)
+  if (cur_proc_ptr != (PDR *) 0)
     {
       error ("second .ent directive found before .end directive");
       return;
     }
 
-  for (start_func = start; isspace (*start_func); start_func++)
+  for (start_func = start; ISSPACE ((unsigned char)*start_func); start_func++)
     ;
 
   ch = *start_func;
@@ -3601,14 +3541,14 @@ parse_file (start)
 
   (void) strtol (start, &p, 0);
   if (start == p
-      || (start_name = local_index (p, '"')) == (char *)0
-      || (end_name_p1 = local_rindex (++start_name, '"')) == (char *)0)
+      || (start_name = strchr (p, '"')) == (char *) 0
+      || (end_name_p1 = strrchr (++start_name, '"')) == (char *) 0)
     {
       error ("Invalid .file directive");
       return;
     }
 
-  if (cur_proc_ptr != (PDR *)0)
+  if (cur_proc_ptr != (PDR *) 0)
     {
       error ("No way to handle .file within .ent/.end section");
       return;
@@ -3622,11 +3562,11 @@ parse_file (start)
 
 static void
 mark_stabs (start)
-     const char *start;                        /* Start of directive (ignored) */
+  const char *start ATTRIBUTE_UNUSED;  /* Start of directive (ignored) */
 {
   if (!stabs_seen)
     {
-      /* Add a dummy @stabs dymbol. */
+      /* Add a dummy @stabs symbol.  */
       stabs_seen = 1;
       (void) add_local_symbol (stabs_symbol,
                               stabs_symbol + sizeof (stabs_symbol),
@@ -3669,7 +3609,7 @@ STATIC void
 parse_stabs_common (string_start, string_end, rest)
      const char *string_start;         /* start of string or NULL */
      const char *string_end;           /* end+1 of string or NULL */
-     const char *rest;                 /* rest of the directive. */
+     const char *rest;                 /* rest of the directive.  */
 {
   efdr_t *save_file_ptr = cur_file_ptr;
   symint_t code;
@@ -3683,7 +3623,7 @@ parse_stabs_common (string_start, string_end, rest)
     mark_stabs ("");
 
   /* Read code from stabs.  */
-  if (!isdigit (*rest))
+  if (!ISDIGIT (*rest))
     {
       error ("Invalid .stabs/.stabn directive, code is non-numeric");
       return;
@@ -3703,7 +3643,7 @@ parse_stabs_common (string_start, string_end, rest)
       shash_t *shash_ptr;
 
       /* Skip ,0, */
-      if (p[0] != ',' || p[1] != '0' || p[2] != ',' || !isdigit (p[3]))
+      if (p[0] != ',' || p[1] != '0' || p[2] != ',' || !ISDIGIT (p[3]))
        {
          error ("Invalid line number .stabs/.stabn directive");
          return;
@@ -3711,7 +3651,7 @@ parse_stabs_common (string_start, string_end, rest)
 
       code = strtol (p+3, &p, 0);
       ch = *++p;
-      if (p[-1] != ',' || isdigit (ch) || !IS_ASM_IDENT (ch))
+      if (p[-1] != ',' || ISDIGIT (ch) || !IS_ASM_IDENT (ch))
        {
          error ("Invalid line number .stabs/.stabn directive");
          return;
@@ -3720,7 +3660,7 @@ parse_stabs_common (string_start, string_end, rest)
       dummy_symr.index = code;
       if (dummy_symr.index != code)
        {
-         error ("Line number (%d) for .stabs/.stabn directive cannot fit in index field (20 bits)",
+         error ("Line number (%lu) for .stabs/.stabn directive cannot fit in index field (20 bits)",
                 code);
 
          return;
@@ -3729,10 +3669,10 @@ parse_stabs_common (string_start, string_end, rest)
       shash_ptr = hash_string (p,
                               strlen (p) - 1,
                               &orig_str_hash[0],
-                              (symint_t *)0);
+                              (symint_t *) 0);
 
-      if (shash_ptr == (shash_t *)0
-         || (sym_ptr = shash_ptr->sym_ptr) == (SYMR *)0)
+      if (shash_ptr == (shash_t *) 0
+         || (sym_ptr = shash_ptr->sym_ptr) == (SYMR *) 0)
        {
          error ("Invalid .stabs/.stabn directive, value not found");
          return;
@@ -3753,11 +3693,11 @@ parse_stabs_common (string_start, string_end, rest)
       /* Skip ,<num>,<num>, */
       if (*p++ != ',')
        goto failure;
-      for (; isdigit (*p); p++)
+      for (; ISDIGIT (*p); p++)
        ;
       if (*p++ != ',')
        goto failure;
-      for (; isdigit (*p); p++)
+      for (; ISDIGIT (*p); p++)
        ;
       if (*p++ != ',')
        goto failure;
@@ -3769,7 +3709,7 @@ parse_stabs_common (string_start, string_end, rest)
          return;
        }
 
-      if (isdigit (ch) || ch == '-')
+      if (ISDIGIT (ch) || ch == '-')
        {
          st = st_Nil;
          sc = sc_Nil;
@@ -3792,27 +3732,27 @@ parse_stabs_common (string_start, string_end, rest)
          const char *start, *end_p1;
 
          start = p;
-         if ((end_p1 = strchr (start, '+')) == (char *)0)
+         if ((end_p1 = strchr (start, '+')) == (char *) 0)
            {
-             if ((end_p1 = strchr (start, '-')) == (char *)0)
+             if ((end_p1 = strchr (start, '-')) == (char *) 0)
                end_p1 = start + strlen(start) - 1;
            }
 
          shash_ptr = hash_string (start,
                                   end_p1 - start,
                                   &orig_str_hash[0],
-                                  (symint_t *)0);
+                                  (symint_t *) 0);
 
-         if (shash_ptr == (shash_t *)0
-             || (sym_ptr = shash_ptr->sym_ptr) == (SYMR *)0)
+         if (shash_ptr == (shash_t *) 0
+             || (sym_ptr = shash_ptr->sym_ptr) == (SYMR *) 0)
            {
              shash_ptr = hash_string (start,
                                       end_p1 - start,
                                       &ext_str_hash[0],
-                                      (symint_t *)0);
+                                      (symint_t *) 0);
 
-             if (shash_ptr == (shash_t *)0
-                 || shash_ptr->esym_ptr == (EXTR *)0)
+             if (shash_ptr == (shash_t *) 0
+                 || shash_ptr->esym_ptr == (EXTR *) 0)
                {
                  error ("Invalid .stabs/.stabn directive, value not found");
                  return;
@@ -3821,8 +3761,8 @@ parse_stabs_common (string_start, string_end, rest)
                sym_ptr = &(shash_ptr->esym_ptr->asym);
            }
 
-         /* Traditionally, N_LBRAC and N_RBRAC are *not* relocated. */
-         if (code == (int)N_LBRAC || code == (int)N_RBRAC)
+         /* Traditionally, N_LBRAC and N_RBRAC are *not* relocated.  */
+         if (code == (int) N_LBRAC || code == (int) N_RBRAC)
            {
              sc = scNil;
              st = stNil;
@@ -3837,7 +3777,7 @@ parse_stabs_common (string_start, string_end, rest)
          ch = *end_p1++;
          if (ch != '\n')
            {
-             if (((!isdigit (*end_p1)) && (*end_p1 != '-'))
+             if (((!ISDIGIT (*end_p1)) && (*end_p1 != '-'))
                  || ((ch != '+') && (ch != '-')))
                {
                  error ("Invalid .stabs/.stabn directive, badly formed value");
@@ -3868,9 +3808,9 @@ STATIC void
 parse_stabs (start)
      const char *start;                        /* start of directive */
 {
-  const char *end = local_index (start+1, '"');
+  const char *end = strchr (start+1, '"');
 
-  if (*start != '"' || end == (const char *)0 || end[1] != ',')
+  if (*start != '"' || end == (const char *) 0 || end[1] != ',')
     {
       error ("Invalid .stabs directive, no string");
       return;
@@ -3884,7 +3824,7 @@ STATIC void
 parse_stabn (start)
      const char *start;                        /* start of directive */
 {
-  parse_stabs_common ((const char *)0, (const char *)0, start);
+  parse_stabs_common ((const char *) 0, (const char *) 0, start);
 }
 
 \f
@@ -3892,10 +3832,10 @@ parse_stabn (start)
    if needed.  */
 
 STATIC void
-parse_input __proto((void))
+parse_input ()
 {
   register char *p;
-  register int i;
+  register Size_t i;
   register thead_t *ptag_head;
   register tag_t *ptag;
   register tag_t *ptag_next;
@@ -3910,19 +3850,19 @@ parse_input __proto((void))
   ptag_head->prev = cur_tag_head;
   cur_tag_head = ptag_head;
 
-  while ((p = read_line ()) != (char *)0)
+  while ((p = read_line ()) != (char *) 0)
     {
       /* Skip leading blanks */
-      while (isspace (*p))
+      while (ISSPACE ((unsigned char)*p))
        p++;
 
       /* See if it's a directive we handle.  If so, dispatch handler.  */
-      for (i = 0; i < sizeof (pseudo_ops) / sizeof (pseudo_ops[0]); i++)
+      for (i = 0; i < ARRAY_SIZE (pseudo_ops); i++)
        if (memcmp (p, pseudo_ops[i].name, pseudo_ops[i].len) == 0
-           && isspace (p[pseudo_ops[i].len]))
+           && ISSPACE ((unsigned char)(p[pseudo_ops[i].len])))
          {
            p += pseudo_ops[i].len;     /* skip to first argument */
-           while (isspace (*p))
+           while (ISSPACE ((unsigned char)*p))
              p++;
 
            (*pseudo_ops[i].func)( p );
@@ -3935,10 +3875,10 @@ parse_input __proto((void))
   cur_tag_head = ptag_head->prev;
 
   for (ptag = ptag_head->first_tag;
-       ptag != (tag_t *)0;
+       ptag != (tag_t *) 0;
        ptag = ptag_next)
     {
-      if (ptag->forward_ref != (forward_t *)0)
+      if (ptag->forward_ref != (forward_t *) 0)
        add_unknown_tag (ptag);
 
       ptag_next = ptag->same_block;
@@ -3955,7 +3895,7 @@ parse_input __proto((void))
    to write out the .T file.  */
 
 STATIC void
-update_headers __proto((void))
+update_headers ()
 {
   register symint_t i;
   register efdr_t *file_ptr;
@@ -3981,14 +3921,50 @@ update_headers __proto((void))
      for the filename.  */
 
   for (file_ptr = first_file;
-       file_ptr != (efdr_t *)0;
+       file_ptr != (efdr_t *) 0;
        file_ptr = file_ptr->next_file)
     {
+      register SYMR *sym_start;
+      register SYMR *sym;
+      register SYMR *sym_end_p1;
+      register FDR *fd_ptr = file_ptr->orig_fdr;
+
       cur_file_ptr = file_ptr;
-      (void) add_local_symbol ((const char *)0, (const char *)0,
+
+      /* Copy st_Static symbols from the original local symbol table if
+        they did not get added to the new local symbol table.
+        This happens with stabs-in-ecoff or if the source file is
+        compiled without debugging.  */
+      sym_start = ORIG_LSYMS (fd_ptr->isymBase);
+      sym_end_p1 = sym_start + fd_ptr->csym;
+      for (sym = sym_start; sym < sym_end_p1; sym++)
+       {
+         if ((st_t)sym->st == st_Static)
+           {
+             register char *str = ORIG_LSTRS (fd_ptr->issBase + sym->iss);
+             register Size_t len = strlen (str);
+             register shash_t *hash_ptr;
+
+             /* Ignore internal labels.  */
+             if (str[0] == '$' && str[1] == 'L')
+               continue;
+             hash_ptr = hash_string (str,
+                                     (Ptrdiff_t)len,
+                                     &file_ptr->shash_head[0],
+                                     (symint_t *) 0);
+             if (hash_ptr == (shash_t *) 0)
+               {
+                 (void) add_local_symbol (str, str + len,
+                                          (st_t)sym->st, (sc_t)sym->sc,
+                                          (symint_t)sym->value,
+                                          (symint_t)indexNil);
+               }
+           }
+       }
+      (void) add_local_symbol ((const char *) 0, (const char *) 0,
                               st_End, sc_Text,
-                              (symint_t)0,
-                              (symint_t)0);
+                              (symint_t) 0,
+                              (symint_t) 0);
 
       file_ptr->fdr.cpd = file_ptr->procs.num_allocated;
       file_ptr->fdr.ipdFirst = symbolic_header.ipdMax;
@@ -4007,12 +3983,17 @@ update_headers __proto((void))
       symbolic_header.issMax += file_ptr->fdr.cbSs;
     }
 
+#ifndef ALIGN_SYMTABLE_OFFSET
+#define ALIGN_SYMTABLE_OFFSET(OFFSET) (OFFSET)
+#endif
 
+  file_offset = ALIGN_SYMTABLE_OFFSET (file_offset);
   i = WORD_ALIGN (symbolic_header.cbLine);     /* line numbers */
   if (i > 0)
     {
       symbolic_header.cbLineOffset = file_offset;
       file_offset += i;
+      file_offset = ALIGN_SYMTABLE_OFFSET (file_offset);
     }
 
   i = symbolic_header.ioptMax;                 /* optimization symbols */
@@ -4020,6 +4001,7 @@ update_headers __proto((void))
     {
       symbolic_header.cbOptOffset = file_offset;
       file_offset += i * sizeof (OPTR);
+      file_offset = ALIGN_SYMTABLE_OFFSET (file_offset);
     }
 
   i = symbolic_header.idnMax;                  /* dense numbers */
@@ -4027,6 +4009,7 @@ update_headers __proto((void))
     {
       symbolic_header.cbDnOffset = file_offset;
       file_offset += i * sizeof (DNR);
+      file_offset = ALIGN_SYMTABLE_OFFSET (file_offset);
     }
 
   i = symbolic_header.ipdMax;                  /* procedure tables */
@@ -4034,6 +4017,7 @@ update_headers __proto((void))
     {
       symbolic_header.cbPdOffset = file_offset;
       file_offset += i * sizeof (PDR);
+      file_offset = ALIGN_SYMTABLE_OFFSET (file_offset);
     }
 
   i = symbolic_header.isymMax;                 /* local symbols */
@@ -4041,13 +4025,15 @@ update_headers __proto((void))
     {
       symbolic_header.cbSymOffset = file_offset;
       file_offset += i * sizeof (SYMR);
+      file_offset = ALIGN_SYMTABLE_OFFSET (file_offset);
     }
 
-  i = symbolic_header.iauxMax;                 /* aux syms. */
+  i = symbolic_header.iauxMax;                 /* aux syms.  */
   if (i > 0)
     {
       symbolic_header.cbAuxOffset = file_offset;
       file_offset += i * sizeof (TIR);
+      file_offset = ALIGN_SYMTABLE_OFFSET (file_offset);
     }
 
   i = WORD_ALIGN (symbolic_header.issMax);     /* local strings */
@@ -4055,6 +4041,7 @@ update_headers __proto((void))
     {
       symbolic_header.cbSsOffset = file_offset;
       file_offset += i;
+      file_offset = ALIGN_SYMTABLE_OFFSET (file_offset);
     }
 
   i = WORD_ALIGN (symbolic_header.issExtMax);  /* external strings */
@@ -4062,6 +4049,7 @@ update_headers __proto((void))
     {
       symbolic_header.cbSsExtOffset = file_offset;
       file_offset += i;
+      file_offset = ALIGN_SYMTABLE_OFFSET (file_offset);
     }
 
   i = symbolic_header.ifdMax;                  /* file tables */
@@ -4069,6 +4057,7 @@ update_headers __proto((void))
     {
       symbolic_header.cbFdOffset = file_offset;
       file_offset += i * sizeof (FDR);
+      file_offset = ALIGN_SYMTABLE_OFFSET (file_offset);
     }
 
   i = symbolic_header.crfd;                    /* relative file descriptors */
@@ -4076,6 +4065,7 @@ update_headers __proto((void))
     {
       symbolic_header.cbRfdOffset = file_offset;
       file_offset += i * sizeof (symint_t);
+      file_offset = ALIGN_SYMTABLE_OFFSET (file_offset);
     }
 
   i = symbolic_header.iextMax;                 /* external symbols */
@@ -4083,6 +4073,7 @@ update_headers __proto((void))
     {
       symbolic_header.cbExtOffset = file_offset;
       file_offset += i * sizeof (EXTR);
+      file_offset = ALIGN_SYMTABLE_OFFSET (file_offset);
     }
 }
 
@@ -4102,20 +4093,24 @@ write_varray (vp, offset, str)
     return;
 
   if (debug)
-    fprintf (stderr, "\twarray\tvp = 0x%.8x, offset = %7u, size = %7u, %s\n",
-            vp, offset, vp->num_allocated * vp->object_size, str);
-
+    {
+      fputs ("\twarray\tvp = ", stderr);
+      fprintf (stderr, HOST_PTR_PRINTF, (PTR) vp);
+      fprintf (stderr, ", offset = %7lu, size = %7lu, %s\n",
+              (unsigned long) offset, vp->num_allocated * vp->object_size, str);
+    }
+  
   if (file_offset != offset
       && fseek (object_stream, (long)offset, SEEK_SET) < 0)
     pfatal_with_name (object_name);
 
-  for (ptr = vp->first; ptr != (vlinks_t *)0; ptr = ptr->next)
+  for (ptr = vp->first; ptr != (vlinks_t *) 0; ptr = ptr->next)
     {
-      num_write = (ptr->next == (vlinks_t *)0)
+      num_write = (ptr->next == (vlinks_t *) 0)
        ? vp->objects_last_page * vp->object_size
        : vp->objects_per_page  * vp->object_size;
 
-      sys_write = fwrite ((PTR_T) ptr->datum, 1, num_write, object_stream);
+      sys_write = fwrite ((PTR) ptr->datum, 1, num_write, object_stream);
       if (sys_write <= 0)
        pfatal_with_name (object_name);
 
@@ -4133,18 +4128,21 @@ write_varray (vp, offset, str)
 /* Write out the symbol table in the object file.  */
 
 STATIC void
-write_object __proto((void))
+write_object ()
 {
   int sys_write;
   efdr_t *file_ptr;
   off_t offset;
 
   if (debug)
-    fprintf (stderr, "\n\twrite\tvp = 0x%.8x, offset = %7u, size = %7u, %s\n",
-            (PTR_T *) &symbolic_header, 0, sizeof (symbolic_header),
-            "symbolic header");
+    {
+      fputs ("\n\twrite\tvp = ", stderr);
+      fprintf (stderr, HOST_PTR_PRINTF, (PTR) &symbolic_header);
+      fprintf (stderr, ", offset = %7u, size = %7lu, %s\n",
+              0, (unsigned long) sizeof (symbolic_header), "symbolic header");
+    }
 
-  sys_write = fwrite ((PTR_T) &symbolic_header,
+  sys_write = fwrite ((PTR) &symbolic_header,
                      1,
                      sizeof (symbolic_header),
                      object_stream);
@@ -4154,7 +4152,7 @@ write_object __proto((void))
 
   else if (sys_write != sizeof (symbolic_header))
     fatal ("Wrote %d bytes to %s, system returned %d",
-          sizeof (symbolic_header),
+          (int) sizeof (symbolic_header),
           object_name,
           sys_write);
 
@@ -4170,11 +4168,15 @@ write_object __proto((void))
        pfatal_with_name (object_name);
 
       if (debug)
-       fprintf (stderr, "\twrite\tvp = 0x%.8x, offset = %7u, size = %7u, %s\n",
-                (PTR_T *) &orig_linenum, symbolic_header.cbLineOffset,
-                symbolic_header.cbLine, "Line numbers");
+       {
+         fputs ("\twrite\tvp = ", stderr);
+         fprintf (stderr, HOST_PTR_PRINTF, (PTR) &orig_linenum);
+         fprintf (stderr, ", offset = %7lu, size = %7lu, %s\n",
+                  (long) symbolic_header.cbLineOffset,
+                  (long) symbolic_header.cbLine, "Line numbers");
+       }
 
-      sys_write = fwrite ((PTR_T) orig_linenum,
+      sys_write = fwrite ((PTR) orig_linenum,
                          1,
                          symbolic_header.cbLine,
                          object_stream);
@@ -4183,8 +4185,8 @@ write_object __proto((void))
        pfatal_with_name (object_name);
 
       else if (sys_write != symbolic_header.cbLine)
-       fatal ("Wrote %d bytes to %s, system returned %d",
-              symbolic_header.cbLine,
+       fatal ("Wrote %ld bytes to %s, system returned %ld",
+              (long) symbolic_header.cbLine,
               object_name,
               sys_write);
 
@@ -4201,11 +4203,15 @@ write_object __proto((void))
        pfatal_with_name (object_name);
 
       if (debug)
-       fprintf (stderr, "\twrite\tvp = 0x%.8x, offset = %7u, size = %7u, %s\n",
-                (PTR_T *) &orig_opt_syms, symbolic_header.cbOptOffset,
-                num_write, "Optimizer symbols");
+       {
+         fputs ("\twrite\tvp = ", stderr);
+         fprintf (stderr, HOST_PTR_PRINTF, (PTR) &orig_opt_syms);
+         fprintf (stderr, ", offset = %7lu, size = %7lu, %s\n",
+                  (long) symbolic_header.cbOptOffset,
+                  num_write, "Optimizer symbols");
+       }
 
-      sys_write = fwrite ((PTR_T) orig_opt_syms,
+      sys_write = fwrite ((PTR) orig_opt_syms,
                          1,
                          num_write,
                          object_stream);
@@ -4214,7 +4220,7 @@ write_object __proto((void))
        pfatal_with_name (object_name);
 
       else if (sys_write != num_write)
-       fatal ("Wrote %d bytes to %s, system returned %d",
+       fatal ("Wrote %ld bytes to %s, system returned %ld",
               num_write,
               object_name,
               sys_write);
@@ -4229,7 +4235,7 @@ write_object __proto((void))
     {
       offset = symbolic_header.cbPdOffset;
       for (file_ptr = first_file;
-          file_ptr != (efdr_t *)0;
+          file_ptr != (efdr_t *) 0;
           file_ptr = file_ptr->next_file)
        {
          write_varray (&file_ptr->procs, offset, "Procedure tables");
@@ -4241,7 +4247,7 @@ write_object __proto((void))
     {
       offset = symbolic_header.cbSymOffset;
       for (file_ptr = first_file;
-          file_ptr != (efdr_t *)0;
+          file_ptr != (efdr_t *) 0;
           file_ptr = file_ptr->next_file)
        {
          write_varray (&file_ptr->symbols, offset, "Local symbols");
@@ -4253,7 +4259,7 @@ write_object __proto((void))
     {
       offset = symbolic_header.cbAuxOffset;
       for (file_ptr = first_file;
-          file_ptr != (efdr_t *)0;
+          file_ptr != (efdr_t *) 0;
           file_ptr = file_ptr->next_file)
        {
          write_varray (&file_ptr->aux_syms, offset, "Aux. symbols");
@@ -4265,7 +4271,7 @@ write_object __proto((void))
     {
       offset = symbolic_header.cbSsOffset;
       for (file_ptr = first_file;
-          file_ptr != (efdr_t *)0;
+          file_ptr != (efdr_t *) 0;
           file_ptr = file_ptr->next_file)
        {
          write_varray (&file_ptr->strings, offset, "Local strings");
@@ -4285,12 +4291,17 @@ write_object __proto((void))
 
       file_offset = offset;
       for (file_ptr = first_file;
-          file_ptr != (efdr_t *)0;
+          file_ptr != (efdr_t *) 0;
           file_ptr = file_ptr->next_file)
        {
          if (debug)
-           fprintf (stderr, "\twrite\tvp = 0x%.8x, offset = %7u, size = %7u, %s\n",
-                    (PTR_T *) &file_ptr->fdr, file_offset, sizeof (FDR), "File header");
+           {
+             fputs ("\twrite\tvp = ", stderr);
+             fprintf (stderr, HOST_PTR_PRINTF, (PTR) &file_ptr->fdr);
+             fprintf (stderr, ", offset = %7lu, size = %7lu, %s\n",
+                      file_offset, (unsigned long) sizeof (FDR),
+                      "File header");
+           }
 
          sys_write = fwrite (&file_ptr->fdr,
                              1,
@@ -4302,7 +4313,7 @@ write_object __proto((void))
 
          else if (sys_write != sizeof (FDR))
            fatal ("Wrote %d bytes to %s, system returned %d",
-                  sizeof (FDR),
+                  (int) sizeof (FDR),
                   object_name,
                   sys_write);
 
@@ -4320,9 +4331,13 @@ write_object __proto((void))
        pfatal_with_name (object_name);
 
       if (debug)
-       fprintf (stderr, "\twrite\tvp = 0x%.8x, offset = %7u, size = %7u, %s\n",
-                (PTR_T *) &orig_rfds, symbolic_header.cbRfdOffset,
-                num_write, "Relative file descriptors");
+       {
+         fputs ("\twrite\tvp = ", stderr);
+         fprintf (stderr, HOST_PTR_PRINTF, (PTR) &orig_rfds);
+         fprintf (stderr, ", offset = %7lu, size = %7lu, %s\n",
+                  (long) symbolic_header.cbRfdOffset,
+                  num_write, "Relative file descriptors");
+       }
 
       sys_write = fwrite (orig_rfds,
                          1,
@@ -4332,8 +4347,8 @@ write_object __proto((void))
       if (sys_write <= 0)
        pfatal_with_name (object_name);
 
-      else if (sys_write != num_write)
-       fatal ("Wrote %d bytes to %s, system returned %d",
+      else if (sys_write != (long)num_write)
+       fatal ("Wrote %lu bytes to %s, system returned %ld",
               num_write,
               object_name,
               sys_write);
@@ -4361,11 +4376,12 @@ read_seek (size, offset, str)
   long sys_read = 0;
 
   if (size == 0)               /* nothing to read */
-    return (page_t *)0;
+    return (page_t *) 0;
 
   if (debug)
-    fprintf (stderr, "\trseek\tsize = %7u, offset = %7u, currently at %7u, %s\n",
-            size, offset, file_offset, str);
+    fprintf (stderr,
+            "\trseek\tsize = %7lu, offset = %7lu, currently at %7lu, %s\n",
+            (unsigned long) size, (unsigned long) offset, file_offset, str);
 
 #ifndef MALLOC_CHECK
   ptr = allocate_multiple_pages ((size + PAGE_USIZE - 1) / PAGE_USIZE);
@@ -4387,9 +4403,9 @@ read_seek (size, offset, str)
          if (sys_read <= 0)
            pfatal_with_name (obj_in_name);
 
-         if (sys_read != difference)
-           fatal ("Wanted to read %d bytes from %s, system returned %d",
-                  size,
+         if ((symint_t)sys_read != difference)
+           fatal ("Wanted to read %lu bytes from %s, system returned %ld",
+                  (unsigned long) size,
                   obj_in_name,
                   sys_read);
        }
@@ -4397,13 +4413,13 @@ read_seek (size, offset, str)
        pfatal_with_name (obj_in_name);
     }
 
-  sys_read = fread ((PTR_T)ptr, 1, size, obj_in_stream);
+  sys_read = fread ((PTRptr, 1, size, obj_in_stream);
   if (sys_read <= 0)
     pfatal_with_name (obj_in_name);
 
-  if (sys_read != size)
-    fatal ("Wanted to read %d bytes from %s, system returned %d",
-          size,
+  if (sys_read != (long) size)
+    fatal ("Wanted to read %lu bytes from %s, system returned %ld",
+          (unsigned long) size,
           obj_in_name,
           sys_read);
 
@@ -4421,7 +4437,7 @@ read_seek (size, offset, str)
    symbol table.  */
 
 STATIC void
-copy_object __proto((void))
+copy_object ()
 {
   char buffer[ PAGE_SIZE ];
   register int sys_read;
@@ -4440,7 +4456,7 @@ copy_object __proto((void))
       || fseek (obj_in_stream, 0L, SEEK_SET) != 0)
     pfatal_with_name (obj_in_name);
 
-  sys_read = fread ((PTR_T) &orig_file_header,
+  sys_read = fread ((PTR) &orig_file_header,
                    1,
                    sizeof (struct filehdr),
                    obj_in_stream);
@@ -4451,23 +4467,23 @@ copy_object __proto((void))
   else if (sys_read == 0 && feof (obj_in_stream))
     return;                    /* create a .T file sans file header */
 
-  else if (sys_read < sizeof (struct filehdr))
+  else if (sys_read < (int) sizeof (struct filehdr))
     fatal ("Wanted to read %d bytes from %s, system returned %d",
-          sizeof (struct filehdr),
+          (int) sizeof (struct filehdr),
           obj_in_name,
           sys_read);
 
 
   if (orig_file_header.f_nsyms != sizeof (HDRR))
-    fatal ("%s symbolic header wrong size (%d bytes, should be %d)",
-          input_name, orig_file_header.f_nsyms, sizeof (HDRR));
+    fatal ("%s symbolic header wrong size (%ld bytes, should be %ld)",
+          input_name, (long) orig_file_header.f_nsyms, (long) sizeof (HDRR));
 
 
   /* Read in the current symbolic header.  */
   if (fseek (obj_in_stream, (long) orig_file_header.f_symptr, SEEK_SET) != 0)
     pfatal_with_name (input_name);
 
-  sys_read = fread ((PTR_T) &orig_sym_hdr,
+  sys_read = fread ((PTR) &orig_sym_hdr,
                    1,
                    sizeof (orig_sym_hdr),
                    obj_in_stream);
@@ -4475,9 +4491,9 @@ copy_object __proto((void))
   if (sys_read < 0)
     pfatal_with_name (object_name);
 
-  else if (sys_read < sizeof (struct filehdr))
+  else if (sys_read < (int) sizeof (struct filehdr))
     fatal ("Wanted to read %d bytes from %s, system returned %d",
-          sizeof (struct filehdr),
+          (int) sizeof (struct filehdr),
           obj_in_name,
           sys_read);
 
@@ -4487,7 +4503,7 @@ copy_object __proto((void))
      sections, so in theory no extra seeks are done.
 
      For simplicity sake, round each read up to a page boundary,
-     we may want to revisit this later.... */
+     we may want to revisit this later....  */
 
   file_offset =  orig_file_header.f_symptr + sizeof (struct filehdr);
 
@@ -4556,7 +4572,7 @@ copy_object __proto((void))
   if (max_file_offset != stat_buf.st_size)
     fatal ("Symbol table is not last (symbol table ends at %ld, .o ends at %ld",
           max_file_offset,
-          stat_buf.st_size);
+          (long) stat_buf.st_size);
 
 
   /* If the first original file descriptor is a dummy which the assembler
@@ -4566,9 +4582,9 @@ copy_object __proto((void))
       && orig_files->caux == 0)
     {
       char *filename = orig_local_strs + (orig_files->issBase + orig_files->rss);
-      char *suffix = local_rindex (filename, '.');
+      char *suffix = strrchr (filename, '.');
 
-      if (suffix != (char *)0 && strcmp (suffix, ".s") == 0)
+      if (suffix != (char *) 0 && strcmp (suffix, ".s") == 0)
        delete_ifd = 1;
     }
 
@@ -4607,16 +4623,10 @@ copy_object __proto((void))
   for (es = 0; es < orig_sym_hdr.iextMax; es++)
     {
       register EXTR *eptr = orig_ext_syms + es;
-      register char *ename = ORIG_ESTRS (eptr->asym.iss);
       register unsigned ifd = eptr->ifd;
 
-      (void) add_ext_symbol (ename,
-                            ename + strlen (ename),
-                            (st_t) eptr->asym.st,
-                            (sc_t) eptr->asym.sc,
-                            eptr->asym.value,
-                            (symint_t)((eptr->asym.index == indexNil) ? indexNil : 0),
-                            (ifd < orig_sym_hdr.ifdMax) ? remap_file_number[ ifd ] : ifd);
+      (void) add_ext_symbol (eptr, ((long) ifd < orig_sym_hdr.ifdMax)
+                            ? remap_file_number[ ifd ] : ifd );
     }
 
 
@@ -4680,7 +4690,7 @@ copy_object __proto((void))
                                                           &orig_str_hash[0],
                                                           &hash_index);
 
-               if (shash_ptr != (shash_t *)0)
+               if (shash_ptr != (shash_t *) 0)
                  error ("internal error, %s is already in original symbol table", str);
 
                else
@@ -4708,9 +4718,9 @@ copy_object __proto((void))
                      register shash_t *shash_ptr = hash_string (str,
                                                                 (Ptrdiff_t)len,
                                                                 &orig_str_hash[0],
-                                                                (symint_t *)0);
+                                                                (symint_t *) 0);
 
-                     if (shash_ptr != (shash_t *)0)
+                     if (shash_ptr != (shash_t *) 0)
                        shash_ptr->end_ptr = sym;
                    }
                }
@@ -4738,9 +4748,9 @@ copy_object __proto((void))
          register shash_t *shash_ptr = hash_string (str,
                                                     (Ptrdiff_t)len,
                                                     &orig_str_hash[0],
-                                                    (symint_t *)0);
+                                                    (symint_t *) 0);
 
-         if (shash_ptr == (shash_t *)0)
+         if (shash_ptr == (shash_t *) 0)
            error ("internal error, function %s is not in original symbol table", str);
 
          else
@@ -4756,20 +4766,22 @@ copy_object __proto((void))
 
   /* Copy all of the object file up to the symbol table.  Originally
      we were going to use ftruncate, but that doesn't seem to work
-     on Ultrix 3.1.... */
+     on Ultrix 3.1....  */
 
-  if (fseek (obj_in_stream, (long)0, SEEK_SET) != 0)
+  if (fseek (obj_in_stream, (long) 0, SEEK_SET) != 0)
     pfatal_with_name (obj_in_name);
 
-  if (fseek (object_stream, (long)0, SEEK_SET) != 0)
+  if (fseek (object_stream, (long) 0, SEEK_SET) != 0)
     pfatal_with_name (object_name);
 
   for (remaining = orig_file_header.f_symptr;
        remaining > 0;
        remaining -= num_write)
     {
-      num_write = (remaining <= sizeof (buffer)) ? remaining : sizeof (buffer);
-      sys_read = fread ((PTR_T) buffer, 1, num_write, obj_in_stream);
+      num_write
+       = (remaining <= (int) sizeof (buffer))
+         ? remaining : (int) sizeof (buffer);
+      sys_read = fread ((PTR) buffer, 1, num_write, obj_in_stream);
       if (sys_read <= 0)
        pfatal_with_name (obj_in_name);
 
@@ -4794,13 +4806,15 @@ copy_object __proto((void))
 \f
 /* Ye olde main program.  */
 
+extern int main PARAMS ((int, char **));
+
 int
 main (argc, argv)
      int argc;
-     char *argv[];
+     char **argv;
 {
   int iflag = 0;
-  char *p = local_rindex (argv[0], '/');
+  char *p = strrchr (argv[0], '/');
   char *num_end;
   int option;
   int i;
@@ -4814,13 +4828,13 @@ main (argc, argv)
 #if !defined(__SABER__) && !defined(lint)
   if (sizeof (efdr_t) > PAGE_USIZE)
     fatal ("Efdr_t has a sizeof %d bytes, when it should be less than %d",
-          sizeof (efdr_t),
-          PAGE_USIZE);
+          (int) sizeof (efdr_t),
+          (int) PAGE_USIZE);
 
   if (sizeof (page_t) != PAGE_USIZE)
     fatal ("Page_t has a sizeof %d bytes, when it should be %d",
-          sizeof (page_t),
-          PAGE_USIZE);
+          (int) sizeof (page_t),
+          (int) PAGE_USIZE);
 
 #endif
 
@@ -4855,7 +4869,7 @@ main (argc, argv)
        break;
 
       case 'I':
-       if (rename_output || obj_in_name != (char *)0)
+       if (rename_output || obj_in_name != (char *) 0)
          had_errors++;
        else
          rename_output = 1;
@@ -4863,7 +4877,7 @@ main (argc, argv)
        /* fall through to 'i' case.  */
 
       case 'i':
-       if (obj_in_name == (char *)0)
+       if (obj_in_name == (char *) 0)
          {
            obj_in_name = optarg;
            iflag++;
@@ -4873,7 +4887,7 @@ main (argc, argv)
        break;
 
       case 'o':
-       if (object_name == (char *)0)
+       if (object_name == (char *) 0)
          object_name = optarg;
        else
          had_errors++;
@@ -4884,47 +4898,47 @@ main (argc, argv)
        break;
       }
 
-  if (obj_in_name == (char *)0 && optind <= argc - 2)
+  if (obj_in_name == (char *) 0 && optind <= argc - 2)
     obj_in_name = argv[--argc];
 
-  if (object_name == (char *)0 && optind <= argc - 2)
+  if (object_name == (char *) 0 && optind <= argc - 2)
     object_name = argv[--argc];
 
   /* If there is an output name, but no input name use
      the same file for both, deleting the name between
      opening it for input and opening it for output.  */
-  if (obj_in_name == (char *)0 && object_name != (char *)0)
+  if (obj_in_name == (char *) 0 && object_name != (char *)0)
     {
       obj_in_name = object_name;
       delete_input = 1;
     }
 
-  if (object_name == (char *)0 || had_errors || optind != argc - 1)
+  if (object_name == (char *) 0 || had_errors || optind != argc - 1)
     {
-      fprintf (stderr, "Calling Sequence:\n");
-      fprintf (stderr, "\tmips-tfile [-d <num>] [-v] [-i <o-in-file>] -o <o-out-file> <s-file> (or)\n");
-      fprintf (stderr, "\tmips-tfile [-d <num>] [-v] [-I <o-in-file>] -o <o-out-file> <s-file> (or)\n");
-      fprintf (stderr, "\tmips-tfile [-d <num>] [-v] <s-file> <o-in-file> <o-out-file>\n");
+      fprintf (stderr, _("Calling Sequence:\n"));
+      fprintf (stderr, _("\tmips-tfile [-d <num>] [-v] [-i <o-in-file>] -o <o-out-file> <s-file> (or)\n"));
+      fprintf (stderr, _("\tmips-tfile [-d <num>] [-v] [-I <o-in-file>] -o <o-out-file> <s-file> (or)\n"));
+      fprintf (stderr, _("\tmips-tfile [-d <num>] [-v] <s-file> <o-in-file> <o-out-file>\n"));
       fprintf (stderr, "\n");
-      fprintf (stderr, "Debug levels are:\n");
-      fprintf (stderr, "    1\tGeneral debug + trace functions/blocks.\n");
-      fprintf (stderr, "    2\tDebug level 1 + trace externals.\n");
-      fprintf (stderr, "    3\tDebug level 2 + trace all symbols.\n");
-      fprintf (stderr, "    4\tDebug level 3 + trace memory allocations.\n");
+      fprintf (stderr, _("Debug levels are:\n"));
+      fprintf (stderr, _("    1\tGeneral debug + trace functions/blocks.\n"));
+      fprintf (stderr, _("    2\tDebug level 1 + trace externals.\n"));
+      fprintf (stderr, _("    3\tDebug level 2 + trace all symbols.\n"));
+      fprintf (stderr, _("    4\tDebug level 3 + trace memory allocations.\n"));
       return 1;
     }
 
 
   if (version)
     {
-      fprintf (stderr, "mips-tfile version %s", version_string);
+      fprintf (stderr, _("mips-tfile version %s"), version_string);
 #ifdef TARGET_VERSION
       TARGET_VERSION;
 #endif
       fputc ('\n', stderr);
     }
 
-  if (obj_in_name == (char *)0)
+  if (obj_in_name == (char *) 0)
     obj_in_name = object_name;
 
   if (rename_output && rename (object_name, obj_in_name) != 0)
@@ -4969,14 +4983,14 @@ main (argc, argv)
   /* Must open input before output, since the output may be the same file, and
      we need to get the input handle before truncating it.  */
   obj_in_stream = fopen (obj_in_name, "r");
-  if (obj_in_stream == (FILE *)0)
+  if (obj_in_stream == (FILE *) 0)
     pfatal_with_name (obj_in_name);
 
   if (delete_input && unlink (obj_in_name) != 0)
     pfatal_with_name (obj_in_name);
 
   object_stream = fopen (object_name, "w");
-  if (object_stream == (FILE *)0)
+  if (object_stream == (FILE *) 0)
     pfatal_with_name (object_name);
 
   if (strcmp (argv[optind], "-") != 0)
@@ -5017,12 +5031,8 @@ STATIC void
 catch_signal (signum)
      int signum;
 {
-  (void) signal (signum, SIG_DFL);     /* just in case... */
-#ifdef NO_SYS_SIGLIST
-  fatal ("caught signal");
-#else
-  fatal (sys_siglist[signum]);
-#endif  
+  (void) signal (signum, SIG_DFL);     /* just in case...  */
+  fatal ("%s", strsignal(signum));
 }
 
 /* Print a fatal error message.  NAME is the text.
@@ -5030,9 +5040,9 @@ catch_signal (signum)
 
 void
 pfatal_with_name (msg)
-     char *msg;
+  const char *msg;
 {
-  int save_errno = errno;              /* just in case.... */
+  int save_errno = errno;              /* just in case....  */
   if (line_number > 0)
     fprintf (stderr, "%s, %s:%ld ", progname, input_name, line_number);
   else
@@ -5062,7 +5072,7 @@ out_of_bounds (indx, max, str, prog_line)
   if (indx < max)              /* just in case */
     return 0;
 
-  fprintf (stderr, "%s, %s:%ld index %u is out of bounds for %s, max is %u, mips-tfile.c line# %d\n",
+  fprintf (stderr, "%s, %s:%ld index %lu is out of bounds for %s, max is %lu, mips-tfile.c line# %d\n",
           progname, input_name, line_number, indx, str, max, prog_line);
 
   exit (1);
@@ -5071,7 +5081,7 @@ out_of_bounds (indx, max, str, prog_line)
 
 \f
 /* Allocate a cluster of pages.  USE_MALLOC says that malloc does not
-   like sbrk's behind it's back (or sbrk isn't available).  If we use
+   like sbrk's behind its back (or sbrk isn't available).  If we use
    sbrk, we assume it gives us zeroed pages.  */
 
 #ifndef MALLOC_CHECK
@@ -5081,10 +5091,7 @@ STATIC page_t *
 allocate_cluster (npages)
      Size_t npages;
 {
-  register page_t *value = (page_t *) calloc (npages, PAGE_USIZE);
-
-  if (value == 0)
-    fatal ("Virtual memory exhausted.");
+  register page_t *value = (page_t *) xcalloc (npages, PAGE_USIZE);
 
   if (debug > 3)
     fprintf (stderr, "\talloc\tnpages = %d, value = 0x%.8x\n", npages, value);
@@ -5113,7 +5120,12 @@ allocate_cluster (npages)
     pfatal_with_name ("allocate_cluster");
 
   if (debug > 3)
-    fprintf (stderr, "\talloc\tnpages = %d, value = 0x%.8x\n", npages, ptr);
+    {
+      fprintf (stderr, "\talloc\tnpages = %lu, value = ",
+              (unsigned long) npages);
+      fprintf (stderr, HOST_PTR_PRINTF, (PTR) ptr);
+      fputs ("\n", stderr);
+    }
 
   return ptr;
 }
@@ -5191,7 +5203,7 @@ free_multiple_pages (page_ptr, npages)
 /* Allocate one page (which is initialized to 0).  */
 
 STATIC page_t *
-allocate_page __proto((void))
+allocate_page ()
 {
 #ifndef MALLOC_CHECK
   if (pages_left == 0)
@@ -5213,14 +5225,14 @@ allocate_page __proto((void))
 /* Allocate scoping information.  */
 
 STATIC scope_t *
-allocate_scope __proto((void))
+allocate_scope ()
 {
   register scope_t *ptr;
   static scope_t initial_scope;
 
 #ifndef MALLOC_CHECK
   ptr = alloc_counts[ (int)alloc_type_scope ].free_list.f_scope;
-  if (ptr != (scope_t *)0)
+  if (ptr != (scope_t *) 0)
     alloc_counts[ (int)alloc_type_scope ].free_list.f_scope = ptr->free;
 
   else
@@ -5262,7 +5274,7 @@ free_scope (ptr)
   alloc_counts[ (int)alloc_type_scope ].free_list.f_scope = ptr;
 
 #else
-  xfree ((PTR_T) ptr);
+  free ((PTR) ptr);
 #endif
 
 }
@@ -5271,7 +5283,7 @@ free_scope (ptr)
 /* Allocate links for pages in a virtual array.  */
 
 STATIC vlinks_t *
-allocate_vlinks __proto((void))
+allocate_vlinks ()
 {
   register vlinks_t *ptr;
   static vlinks_t initial_vlinks;
@@ -5304,7 +5316,7 @@ allocate_vlinks __proto((void))
 /* Allocate string hash buckets.  */
 
 STATIC shash_t *
-allocate_shash __proto((void))
+allocate_shash ()
 {
   register shash_t *ptr;
   static shash_t initial_shash;
@@ -5337,7 +5349,7 @@ allocate_shash __proto((void))
 /* Allocate type hash buckets.  */
 
 STATIC thash_t *
-allocate_thash __proto((void))
+allocate_thash ()
 {
   register thash_t *ptr;
   static thash_t initial_thash;
@@ -5370,14 +5382,14 @@ allocate_thash __proto((void))
 /* Allocate structure, union, or enum tag information.  */
 
 STATIC tag_t *
-allocate_tag __proto((void))
+allocate_tag ()
 {
   register tag_t *ptr;
   static tag_t initial_tag;
 
 #ifndef MALLOC_CHECK
   ptr = alloc_counts[ (int)alloc_type_tag ].free_list.f_tag;
-  if (ptr != (tag_t *)0)
+  if (ptr != (tag_t *) 0)
     alloc_counts[ (int)alloc_type_tag ].free_list.f_tag = ptr->free;
 
   else
@@ -5419,7 +5431,7 @@ free_tag (ptr)
   alloc_counts[ (int)alloc_type_tag ].free_list.f_tag = ptr;
 
 #else
-  xfree ((PTR_T) ptr);
+  free ((PTR) ptr);
 #endif
 
 }
@@ -5428,14 +5440,14 @@ free_tag (ptr)
 /* Allocate forward reference to a yet unknown tag.  */
 
 STATIC forward_t *
-allocate_forward __proto((void))
+allocate_forward ()
 {
   register forward_t *ptr;
   static forward_t initial_forward;
 
 #ifndef MALLOC_CHECK
   ptr = alloc_counts[ (int)alloc_type_forward ].free_list.f_forward;
-  if (ptr != (forward_t *)0)
+  if (ptr != (forward_t *) 0)
     alloc_counts[ (int)alloc_type_forward ].free_list.f_forward = ptr->free;
 
   else
@@ -5477,7 +5489,7 @@ free_forward (ptr)
   alloc_counts[ (int)alloc_type_forward ].free_list.f_forward = ptr;
 
 #else
-  xfree ((PTR_T) ptr);
+  free ((PTR) ptr);
 #endif
 
 }
@@ -5486,14 +5498,14 @@ free_forward (ptr)
 /* Allocate head of type hash list.  */
 
 STATIC thead_t *
-allocate_thead __proto((void))
+allocate_thead ()
 {
   register thead_t *ptr;
   static thead_t initial_thead;
 
 #ifndef MALLOC_CHECK
   ptr = alloc_counts[ (int)alloc_type_thead ].free_list.f_thead;
-  if (ptr != (thead_t *)0)
+  if (ptr != (thead_t *) 0)
     alloc_counts[ (int)alloc_type_thead ].free_list.f_thead = ptr->free;
 
   else
@@ -5535,7 +5547,7 @@ free_thead (ptr)
   alloc_counts[ (int)alloc_type_thead ].free_list.f_thead = ptr;
 
 #else
-  xfree ((PTR_T) ptr);
+  free ((PTR) ptr);
 #endif
 
 }
@@ -5543,23 +5555,21 @@ free_thead (ptr)
 #endif /* MIPS_DEBUGGING_INFO */
 
 \f
-#ifdef HAVE_VPRINTF
-
 /* Output an error message and exit */
 
 /*VARARGS*/
 void
-fatal VPROTO((char *format, ...))
+fatal VPARAMS ((const char *format, ...))
 {
-#ifndef __STDC__
-  char *format;
+#ifndef ANSI_PROTOTYPES
+  const char *format;
 #endif
   va_list ap;
 
   VA_START (ap, format);
 
-#ifndef __STDC__
-  format = va_arg (ap, char*);
+#ifndef ANSI_PROTOTYPES
+  format = va_arg (ap, const char *);
 #endif
 
   if (line_number > 0)
@@ -5579,17 +5589,17 @@ fatal VPROTO((char *format, ...))
 
 /*VARARGS*/
 void
-error VPROTO((char *format, ...))
+error VPARAMS ((const char *format, ...))
 {
-#ifndef __STDC__
+#ifndef ANSI_PROTOTYPES
   char *format;
 #endif
   va_list ap;
 
   VA_START (ap, format);
 
-#ifndef __STDC__
-  format = va_arg (ap, char*);
+#ifndef ANSI_PROTOTYPES
+  format = va_arg (ap, char *);
 #endif
 
   if (line_number > 0)
@@ -5608,27 +5618,6 @@ error VPROTO((char *format, ...))
   saber_stop ();
 }
 
-#else /* not HAVE_VPRINTF */
-
-void
-fatal (msg, arg1, arg2)
-     char *msg, *arg1, *arg2;
-{
-  error (msg, arg1, arg2);
-  exit (1);
-}
-
-void
-error (msg, arg1, arg2)
-     char *msg, *arg1, *arg2;
-{
-  fprintf (stderr, "%s: ", progname);
-  fprintf (stderr, msg, arg1, arg2);
-  fprintf (stderr, "\n");
-}
-
-#endif /* not HAVE_VPRINTF */
-
 /* More 'friendly' abort that prints the line and file.
    config.h can #define abort fancy_abort if you like that sort of thing.  */
 
@@ -5646,103 +5635,5 @@ void
 botch (s)
      const char *s;
 {
-  fatal (s);
-}
-
-/* Same as `malloc' but report error if no memory available.  */
-
-PTR_T
-xmalloc (size)
-     Size_t size;
-{
-  register PTR_T value = malloc (size);
-  if (value == 0)
-    fatal ("Virtual memory exhausted.");
-
-  if (debug > 3)
-    fprintf (stderr, "\tmalloc\tptr = 0x%.8x, size = %10u\n", value, size);
-
-  return value;
-}
-
-/* Same as `calloc' but report error if no memory available.  */
-
-PTR_T
-xcalloc (size1, size2)
-     Size_t size1, size2;
-{
-  register PTR_T value = calloc (size1, size2);
-  if (value == 0)
-    fatal ("Virtual memory exhausted.");
-
-  if (debug > 3)
-    fprintf (stderr, "\tcalloc\tptr = 0x%.8x, size1 = %10u, size2 = %10u [%u]\n",
-            value, size1, size2, size1+size2);
-
-  return value;
-}
-
-/* Same as `realloc' but report error if no memory available.  */
-
-PTR_T
-xrealloc (ptr, size)
-     PTR_T ptr;
-     Size_t size;
-{
-  register PTR_T result = realloc (ptr, size);
-  if (!result)
-    fatal ("Virtual memory exhausted.");
-
-  if (debug > 3)
-    fprintf (stderr, "\trealloc\tptr = 0x%.8x, size = %10u, orig = 0x%.8x\n",
-            result, size, ptr);
-
-  return result;
-}
-
-void
-xfree (ptr)
-     PTR_T ptr;
-{
-  if (debug > 3)
-    fprintf (stderr, "\tfree\tptr = 0x%.8x\n", ptr);
-
-  free (ptr);
-}
-
-\f
-/* Define our own index/rindex, since the local and global symbol
-   structures as defined by MIPS has an 'index' field.  */
-
-STATIC char *
-local_index (str, sentinel)
-     const char *str;
-     int sentinel;
-{
-  int ch;
-
-  for ( ; (ch = *str) != sentinel; str++)
-    {
-      if (ch == '\0')
-       return (char *)0;
-    }
-
-  return (char *)str;
-}
-
-STATIC char *
-local_rindex (str, sentinel)
-     const char *str;
-     int sentinel;
-{
-  int ch;
-  const char *ret = (const char *)0;
-
-  for ( ; (ch = *str) != '\0'; str++)
-    {
-      if (ch == sentinel)
-       ret = str;
-    }
-
-  return (char *)ret;
+  fatal ("%s", s);
 }