diff --git a/usr.bin/nm/nm.1 b/usr.bin/nm/nm.1 index 0ebeb987e60b..a1f8b3c462fa 100644 --- a/usr.bin/nm/nm.1 +++ b/usr.bin/nm/nm.1 @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)nm.1 8.1 (Berkeley) 6/6/93 -.\" $Id$ +.\" $Id: nm.1,v 1.7 1997/02/22 19:56:28 peter Exp $ .\" .Dd June 6, 1993 .Dt NM 1 @@ -39,9 +39,9 @@ .Nm nm .Nd display name list (symbol table) .Sh SYNOPSIS -.Nm nm +.Nm .Op Fl agnoprtuwW -.Ar +.Op Ar .Sh DESCRIPTION The symbol table (name list) of each object in .Ar file(s) @@ -121,6 +121,6 @@ The output is sorted alphabetically. .Xr stab 5 .Sh HISTORY An -.Nm nm +.Nm command appeared in .At v1 . diff --git a/usr.bin/nm/nm.1aout b/usr.bin/nm/nm.1aout index 0ebeb987e60b..a1f8b3c462fa 100644 --- a/usr.bin/nm/nm.1aout +++ b/usr.bin/nm/nm.1aout @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)nm.1 8.1 (Berkeley) 6/6/93 -.\" $Id$ +.\" $Id: nm.1,v 1.7 1997/02/22 19:56:28 peter Exp $ .\" .Dd June 6, 1993 .Dt NM 1 @@ -39,9 +39,9 @@ .Nm nm .Nd display name list (symbol table) .Sh SYNOPSIS -.Nm nm +.Nm .Op Fl agnoprtuwW -.Ar +.Op Ar .Sh DESCRIPTION The symbol table (name list) of each object in .Ar file(s) @@ -121,6 +121,6 @@ The output is sorted alphabetically. .Xr stab 5 .Sh HISTORY An -.Nm nm +.Nm command appeared in .At v1 . diff --git a/usr.bin/nm/nm.c b/usr.bin/nm/nm.c index 9ee4b6e29767..19b1d1a57a3f 100644 --- a/usr.bin/nm/nm.c +++ b/usr.bin/nm/nm.c @@ -35,27 +35,31 @@ */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1989, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint +#if 0 static char sccsid[] = "@(#)nm.c 8.1 (Berkeley) 6/6/93"; +#endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ #include #include -#include #include -#include -#include -#include -#include #include +#include +#include +#include +#include #include #include #include +#include int ignore_bad_archive_entries = 1; int print_only_external_symbols; @@ -76,7 +80,7 @@ int (*sfunc)() = fname; #define SYMBOL_BIND(x) (((x) >> 4) & 0xf) void *emalloc(); -void usage __P(( void )); +static void usage __P(( void )); int process_file __P(( char * )); int show_archive __P(( char *, FILE * )); int show_objfile __P(( char *, FILE * )); @@ -165,7 +169,7 @@ process_file(fname) char magic[SARMAG]; if (!(fp = fopen(fname, "r"))) { - (void)fprintf(stderr, "nm: cannot read %s.\n", fname); + warnx("cannot read %s", fname); return(1); } @@ -177,7 +181,7 @@ process_file(fname) * header, and skip back to the beginning */ if (fread((char *)&exec_head, sizeof(exec_head), (size_t)1, fp) != 1) { - (void)fprintf(stderr, "nm: %s: bad format.\n", fname); + warnx("%s: bad format", fname); (void)fclose(fp); return(1); } @@ -187,8 +191,7 @@ process_file(fname) if (N_BADMAG(exec_head)) { if (fread(magic, sizeof(magic), (size_t)1, fp) != 1 || strncmp(magic, ARMAG, SARMAG)) { - (void)fprintf(stderr, - "nm: %s: not object file or archive.\n", fname); + warnx("%s: not object file or archive", fname); (void)fclose(fp); return(1); } @@ -239,8 +242,7 @@ show_archive(fname, fp) while (fread((char *)&ar_head, sizeof(ar_head), (size_t)1, fp) == 1) { /* bad archive entry - stop processing this archive */ if (strncmp(ar_head.ar_fmag, ARFMAG, sizeof(ar_head.ar_fmag))) { - (void)fprintf(stderr, - "nm: %s: bad format archive header", fname); + warnx("%s: bad format archive header", fname); (void)free(name); return(1); } @@ -261,12 +263,12 @@ show_archive(fname, fp) if (len <= 0 || len > MAXNAMLEN) { - fprintf(stderr, "nm: Illegal length for format 1 long name.\n"); + warnx("illegal length for format 1 long name"); goto skip; } if (fread(ar_name, 1, len, fp) != len) { - (void)fprintf(stderr, "nm: EOF reading format 1 long name.\n"); + warnx("EOF reading format 1 long name"); (void)free(name); return(1); } @@ -296,15 +298,14 @@ show_archive(fname, fp) /* get and check current object's header */ if (fread((char *)&exec_head, sizeof(exec_head), (size_t)1, fp) != 1) { - (void)fprintf(stderr, "nm: %s: premature EOF.\n", name); + warnx("%s: premature EOF", name); (void)free(name); return(1); } if (N_BADMAG(exec_head)) { if (!ignore_bad_archive_entries) { - (void)fprintf(stderr, - "nm: %s: bad format.\n", name); + warnx("%s: bad format", name); rval = 1; } } else { @@ -322,8 +323,7 @@ show_archive(fname, fp) #define even(x) (((x) + 1) & ~1) skip: if (fseek(fp, last_ar_off + even(atol(ar_head.ar_size)), SEEK_SET)) { - (void)fprintf(stderr, - "nm: %s: %s\n", fname, strerror(errno)); + warn("%s", fname); (void)free(name); return(1); } @@ -351,8 +351,7 @@ show_objfile(objname, fp) /* read a.out header */ if (fread((char *)&head, sizeof(head), (size_t)1, fp) != 1) { - (void)fprintf(stderr, - "nm: %s: cannot read header.\n", objname); + warnx("%s: cannot read header", objname); return(1); } @@ -361,28 +360,24 @@ show_objfile(objname, fp) * to the beginning of the a.out header */ if (fseek(fp, (long)-sizeof(head), SEEK_CUR)) { - (void)fprintf(stderr, - "nm: %s: %s\n", objname, strerror(errno)); + warn("%s", objname); return(1); } /* stop if this is no valid object file */ if (N_BADMAG(head)) { - (void)fprintf(stderr, - "nm: %s: bad format.\n", objname); + warnx("%s: bad format", objname); return(1); } /* stop if the object file contains no symbol table */ if (!head.a_syms) { - (void)fprintf(stderr, - "nm: %s: no name list.\n", objname); + warnx("%s: no name list", objname); return(1); } if (fseek(fp, (long)N_SYMOFF(head), SEEK_CUR)) { - (void)fprintf(stderr, - "nm: %s: %s\n", objname, strerror(errno)); + warn("%s", objname); return(1); } @@ -390,8 +385,7 @@ show_objfile(objname, fp) names = emalloc((size_t)head.a_syms); nrawnames = head.a_syms / sizeof(*names); if (fread((char *)names, (size_t)head.a_syms, (size_t)1, fp) != 1) { - (void)fprintf(stderr, - "nm: %s: cannot read symbol table.\n", objname); + warnx("%s: cannot read symbol table", objname); (void)free((char *)names); return(1); } @@ -402,8 +396,7 @@ show_objfile(objname, fp) * _including_ the size specification itself. */ if (fread((char *)&stabsize, sizeof(stabsize), (size_t)1, fp) != 1) { - (void)fprintf(stderr, - "nm: %s: cannot read stab size.\n", objname); + warnx("%s: cannot read stab size", objname); (void)free((char *)names); return(1); } @@ -415,8 +408,7 @@ show_objfile(objname, fp) */ stabsize -= 4; /* we already have the size */ if (fread(stab + 4, (size_t)stabsize, (size_t)1, fp) != 1) { - (void)fprintf(stderr, - "nm: %s: stab truncated..\n", objname); + warnx("%s: stab truncated..", objname); (void)free((char *)names); (void)free(stab); return(1); @@ -672,13 +664,12 @@ emalloc(size) /* NOSTRICT */ if ( (p = malloc(size)) ) return(p); - (void)fprintf(stderr, "nm: %s\n", strerror(errno)); - exit(1); + err(1, NULL); } -void +static void usage(void) { - (void)fprintf(stderr, "usage: nm [-agnopruw] [file ...]\n"); + (void)fprintf(stderr, "usage: nm [-agnoprtuwW] [file ...]\n"); exit(1); }