WARNSify, fix .Nm usage, deprecate register

This commit is contained in:
lukem 1997-10-19 02:34:02 +00:00
parent fb7eb8074d
commit c6810a0286
8 changed files with 90 additions and 106 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: conv.c,v 1.5 1997/10/18 13:54:03 mrg Exp $ */
/* $NetBSD: conv.c,v 1.6 1997/10/19 02:34:02 lukem Exp $ */
/*
* Copyright (c) 1989, 1993
@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)conv.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: conv.c,v 1.5 1997/10/18 13:54:03 mrg Exp $";
__RCSID("$NetBSD: conv.c,v 1.6 1997/10/19 02:34:02 lukem Exp $");
#endif
#endif /* not lint */

View File

@ -1,4 +1,4 @@
/* $NetBSD: display.c,v 1.6 1997/10/18 13:54:07 mrg Exp $ */
/* $NetBSD: display.c,v 1.7 1997/10/19 02:34:03 lukem Exp $ */
/*
* Copyright (c) 1989, 1993
@ -33,17 +33,20 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)display.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: display.c,v 1.6 1997/10/18 13:54:07 mrg Exp $";
__RCSID("$NetBSD: display.c,v 1.7 1997/10/19 02:34:03 lukem Exp $");
#endif
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@ -62,14 +65,15 @@ static inline void print __P((PR *, u_char *));
void
display()
{
register FS *fs;
register FU *fu;
register PR *pr;
register int cnt;
register u_char *bp;
FS *fs;
FU *fu;
PR *pr;
int cnt;
u_char *bp;
off_t saveaddress;
u_char savech, *savebp;
savech = 0;
while ((bp = get()) != NULL)
for (fs = fshead, savebp = bp, saveaddress = address; fs;
fs = fs->nextfs, bp = savebp, address = saveaddress)
@ -143,11 +147,11 @@ print(pr, bp)
case F_DBL:
switch(pr->bcnt) {
case 4:
bcopy(bp, &f4, sizeof(f4));
memmove(&f4, bp, sizeof(f4));
(void)printf(pr->fmt, f4);
break;
case 8:
bcopy(bp, &f8, sizeof(f8));
memmove(&f8, bp, sizeof(f8));
(void)printf(pr->fmt, f8);
break;
}
@ -158,15 +162,15 @@ print(pr, bp)
(void)printf(pr->fmt, (quad_t)*bp);
break;
case 2:
bcopy(bp, &s2, sizeof(s2));
memmove(&s2, bp, sizeof(s2));
(void)printf(pr->fmt, (quad_t)s2);
break;
case 4:
bcopy(bp, &s4, sizeof(s4));
memmove(&s4, bp, sizeof(s4));
(void)printf(pr->fmt, (quad_t)s4);
break;
case 8:
bcopy(bp, &s8, sizeof(s8));
memmove(&s8, bp, sizeof(s8));
(void)printf(pr->fmt, s8);
break;
}
@ -189,15 +193,15 @@ print(pr, bp)
(void)printf(pr->fmt, (u_quad_t)*bp);
break;
case 2:
bcopy(bp, &u2, sizeof(u2));
memmove(&u2, bp, sizeof(u2));
(void)printf(pr->fmt, (u_quad_t)u2);
break;
case 4:
bcopy(bp, &u4, sizeof(u4));
memmove(&u4, bp, sizeof(u4));
(void)printf(pr->fmt, (u_quad_t)u4);
break;
case 8:
bcopy(bp, &u8, sizeof(u8));
memmove(&u8, bp, sizeof(u8));
(void)printf(pr->fmt, u8);
break;
}
@ -210,7 +214,7 @@ bpad(pr)
PR *pr;
{
static const char *spec = " -0+#";
register char *p1, *p2;
char *p1, *p2;
/*
* Remove all conversion flags; '-' is the only one valid
@ -231,7 +235,7 @@ get()
{
static int ateof = 1;
static u_char *curp, *savp;
register int n;
int n;
int need, nread;
u_char *tmpp;
@ -253,12 +257,12 @@ get()
if (!length || (ateof && !next(NULL))) {
if (need == blocksize)
return(NULL);
if (vflag != ALL && !bcmp(curp, savp, nread)) {
if (vflag != ALL && !memcmp(curp, savp, nread)) {
if (vflag != DUP)
(void)printf("*\n");
return(NULL);
}
bzero((char *)curp + nread, need);
memset((char *)curp + nread, 0, need);
eaddress = address + nread;
return(curp);
}
@ -266,8 +270,7 @@ get()
length == -1 ? need : MIN(length, need), stdin);
if (!n) {
if (ferror(stdin))
(void)fprintf(stderr, "hexdump: %s: %s\n",
_argv[-1], strerror(errno));
warn("%s", _argv[-1]);
ateof = 1;
continue;
}
@ -276,7 +279,7 @@ get()
length -= n;
if (!(need -= n)) {
if (vflag == ALL || vflag == FIRST ||
bcmp(curp, savp, blocksize)) {
memcmp(curp, savp, blocksize)) {
if (vflag == DUP || vflag == FIRST)
vflag = WAIT;
return(curp);
@ -307,8 +310,7 @@ next(argv)
for (;;) {
if (*_argv) {
if (!(freopen(*_argv, "r", stdin))) {
(void)fprintf(stderr, "hexdump: %s: %s\n",
*_argv, strerror(errno));
warn("%s", *_argv);
exitval = 1;
++_argv;
continue;
@ -334,12 +336,12 @@ doskip(fname, statok)
char *fname;
int statok;
{
register int cnt;
int cnt;
struct stat sb;
if (statok) {
if (fstat(fileno(stdin), &sb))
err("%s: %s", fname, strerror(errno));
err(1, "fstat %s", fname);
if (S_ISREG(sb.st_mode) && skip >= sb.st_size) {
address += sb.st_size;
skip -= sb.st_size;
@ -348,7 +350,7 @@ doskip(fname, statok)
}
if (S_ISREG(sb.st_mode)) {
if (fseek(stdin, skip, SEEK_SET))
err("%s: %s", fname, strerror(errno));
err(1, "fseek %s", fname);
address += skip;
skip = 0;
} else {
@ -368,12 +370,12 @@ emalloc(size)
if ((p = malloc((u_int)size)) == NULL)
nomem();
bzero(p, size);
memset(p, 0, size);
return(p);
}
void
nomem()
{
err("%s", strerror(errno));
err(1, "%s", "");
}

View File

@ -1,4 +1,4 @@
.\" $NetBSD: hexdump.1,v 1.7 1997/10/18 13:54:11 mrg Exp $
.\" $NetBSD: hexdump.1,v 1.8 1997/10/19 02:34:05 lukem Exp $
.\"
.\" Copyright (c) 1989, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@ -40,7 +40,7 @@
.Nm hexdump
.Nd ascii, decimal, hexadecimal, octal dump
.Sh SYNOPSIS
.Nm hexdump
.Nm
.Op Fl bcdovx
.Op Fl e Ar format_string
.Op Fl f Ar format_file
@ -135,7 +135,7 @@ data, in hexadecimal, per line.
.El
.Pp
For each input file,
.Nm hexdump
.Nm
sequentially copies the input to standard output, transforming the
data according to the format strings specified by the
.Fl e
@ -307,7 +307,7 @@ to specifying the
.Fl x
option.
.Pp
.Nm hexdump
.Nm
exits 0 on success and >0 if an error occurred.
.Sh EXAMPLES
Display the input in perusal format:
@ -324,7 +324,7 @@ Implement the \-x option:
.Ed
.Sh STANDARDS
The
.Nm hexdump
.Nm
utility is expected to be
.St -p1003.2
compatible.

View File

@ -1,4 +1,4 @@
/* $NetBSD: hexdump.c,v 1.6 1997/10/18 13:54:17 mrg Exp $ */
/* $NetBSD: hexdump.c,v 1.7 1997/10/19 02:34:06 lukem Exp $ */
/*
* Copyright (c) 1989, 1993
@ -33,17 +33,17 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
static char copyright[] =
"@(#) Copyright (c) 1989, 1993\n\
The Regents of the University of California. All rights reserved.\n";
__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[] = "@(#)hexdump.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: hexdump.c,v 1.6 1997/10/18 13:54:17 mrg Exp $";
__RCSID("$NetBSD: hexdump.c,v 1.7 1997/10/19 02:34:06 lukem Exp $");
#endif
#endif /* not lint */
@ -61,12 +61,14 @@ int blocksize; /* data block size */
int exitval; /* final exit value */
int length = -1; /* max bytes to read */
int main __P((int, char **));
int
main(argc, argv)
int argc;
char *argv[];
{
register FS *tfs;
FS *tfs;
char *p;
if (!(p = strrchr(argv[0], 'o')) || strcmp(p, "od"))
@ -88,32 +90,3 @@ main(argc, argv)
display();
exit(exitval);
}
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
void
#if __STDC__
err(const char *fmt, ...)
#else
err(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
va_list ap;
#if __STDC__
va_start(ap, fmt);
#else
va_start(ap);
#endif
(void)fprintf(stderr, "hexdump: ");
(void)vfprintf(stderr, fmt, ap);
va_end(ap);
(void)fprintf(stderr, "\n");
exit(1);
/* NOTREACHED */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: hexsyntax.c,v 1.5 1997/10/18 13:54:27 mrg Exp $ */
/* $NetBSD: hexsyntax.c,v 1.6 1997/10/19 02:34:07 lukem Exp $ */
/*-
* Copyright (c) 1990, 1993
@ -33,16 +33,18 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)hexsyntax.c 8.2 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: hexsyntax.c,v 1.5 1997/10/18 13:54:27 mrg Exp $";
__RCSID("$NetBSD: hexsyntax.c,v 1.6 1997/10/19 02:34:07 lukem Exp $");
#endif
#endif /* not lint */
#include <sys/types.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -83,7 +85,7 @@ newsyntax(argc, argvp)
break;
case 'n':
if ((length = atoi(optarg)) < 0)
err("%s: bad length value", optarg);
errx(1, "%s: bad length value", optarg);
break;
case 'o':
add("\"%07.7_Ax\n\"");
@ -91,7 +93,7 @@ newsyntax(argc, argvp)
break;
case 's':
if ((skip = strtol(optarg, &p, 0)) < 0)
err("%s: bad skip value", optarg);
errx(1, "%s: bad skip value", optarg);
switch(*p) {
case 'b':
skip *= 512;

View File

@ -1,4 +1,4 @@
.\" $NetBSD: od.1,v 1.4 1997/10/18 13:54:31 mrg Exp $
.\" $NetBSD: od.1,v 1.5 1997/10/19 02:34:08 lukem Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@ -31,7 +31,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $NetBSD: od.1,v 1.4 1997/10/18 13:54:31 mrg Exp $
.\" $NetBSD: od.1,v 1.5 1997/10/19 02:34:08 lukem Exp $
.\" from: @(#)od.1 8.1 (Berkeley) 6/6/93
.\"
.Dd %Q
@ -41,7 +41,7 @@
.Nm od
.Nd octal, decimal, hex, ascii dump
.Sh SYNOPSIS
.Nm od
.Nm
.Op Fl aBbcDdeFfHhIiLlOovXx
.Sm off
.Oo
@ -52,13 +52,13 @@
.Oc
.Ar file
.Sh DESCRIPTION
.Nm Od
.Nm
has been deprecated in favor of
.Xr hexdump 1 .
.Pp
.Xr Hexdump ,
if called as
.Nm od ,
.Nm "" ,
provides compatibility for the options listed above.
.Pp
It does not provide compatibility for the

View File

@ -1,4 +1,4 @@
/* $NetBSD: odsyntax.c,v 1.7 1997/10/18 13:54:35 mrg Exp $ */
/* $NetBSD: odsyntax.c,v 1.8 1997/10/19 02:34:09 lukem Exp $ */
/*-
* Copyright (c) 1990, 1993
@ -33,17 +33,19 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)odsyntax.c 8.2 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: odsyntax.c,v 1.7 1997/10/18 13:54:35 mrg Exp $";
__RCSID("$NetBSD: odsyntax.c,v 1.8 1997/10/19 02:34:09 lukem Exp $");
#endif
#endif /* not lint */
#include <sys/types.h>
#include <ctype.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@ -135,11 +137,10 @@ oldsyntax(argc, argvp)
case 'w':
case '?':
default:
(void)fprintf(stderr,
"od: od(1) has been deprecated for hexdump(1).\n");
warnx("od(1) has been deprecated for hexdump(1).");
if (ch != '?')
(void)fprintf(stderr,
"od: hexdump(1) compatibility doesn't support the -%c option%s\n",
warnx(
"hexdump(1) compatibility doesn't support the -%c option%s\n",
ch, ch == 's' ? "; see strings(1)." : ".");
usage();
}
@ -161,7 +162,7 @@ odoffset(argc, argvp)
int argc;
char ***argvp;
{
register char *num, *p;
char *num, *p;
int base;
char *end;

View File

@ -1,4 +1,4 @@
/* $NetBSD: parse.c,v 1.6 1997/10/18 13:54:39 mrg Exp $ */
/* $NetBSD: parse.c,v 1.7 1997/10/19 02:34:10 lukem Exp $ */
/*
* Copyright (c) 1989, 1993
@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: parse.c,v 1.6 1997/10/18 13:54:39 mrg Exp $";
__RCSID("$NetBSD: parse.c,v 1.7 1997/10/19 02:34:10 lukem Exp $");
#endif
#endif /* not lint */
@ -45,6 +46,7 @@ static char rcsid[] = "$NetBSD: parse.c,v 1.6 1997/10/18 13:54:39 mrg Exp $";
#include <sys/file.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
@ -59,16 +61,16 @@ void
addfile(name)
char *name;
{
register char *p;
char *p;
FILE *fp;
int ch;
char buf[2048 + 1];
if ((fp = fopen(name, "r")) == NULL)
err("%s: %s\n", name, strerror(errno));
err(1, "fopen %s", name);
while (fgets(buf, sizeof(buf), fp)) {
if (!(p = strchr(buf, '\n'))) {
(void)fprintf(stderr, "hexdump: line too long.\n");
warnx("line too long.");
while ((ch = getchar()) != '\n' && ch != EOF);
continue;
}
@ -85,7 +87,7 @@ void
add(fmt)
char *fmt;
{
register char *p;
char *p;
static FS **nextfs;
FS *tfs;
FU *tfu, **nextfu;
@ -160,9 +162,9 @@ int
size(fs)
FS *fs;
{
register FU *fu;
register int bcnt, cursize;
register char *fmt;
FU *fu;
int bcnt, cursize;
char *fmt;
int prec;
/* figure out the data block size needed for each format unit */
@ -215,12 +217,14 @@ rewrite(fs)
FS *fs;
{
enum { NOTOKAY, USEBCNT, USEPREC } sokay;
register PR *pr, **nextpr;
register FU *fu;
register char *p1, *p2;
PR *pr, **nextpr;
FU *fu;
char *p1, *p2;
char savech, *fmtp, cs[3];
int nconv, prec;
nextpr = NULL;
prec = 0;
for (fu = fs->nextfu; fu; fu = fu->nextfu) {
/*
* Break each format unit into print units; each conversion
@ -399,7 +403,8 @@ isint2: switch(fu->bcnt) {
/* Only one conversion character if byte count. */
if (!(pr->flags&F_ADDRESS) && fu->bcnt && nconv++)
err("byte count with multiple conversion characters");
errx(1,
"byte count with multiple conversion characters");
}
/*
* If format unit byte count not specified, figure it out
@ -446,9 +451,9 @@ isint2: switch(fu->bcnt) {
void
escape(p1)
register char *p1;
char *p1;
{
register char *p2;
char *p2;
/* alphabetic escape sequences have to be done in place */
for (p2 = p1;; ++p1, ++p2) {
@ -491,25 +496,25 @@ void
badcnt(s)
char *s;
{
err("%s: bad byte count", s);
errx(1, "%s: bad byte count", s);
}
void
badsfmt()
{
err("%%s: requires a precision or a byte count\n");
errx(1, "%%s: requires a precision or a byte count\n");
}
void
badfmt(fmt)
char *fmt;
{
err("\"%s\": bad format\n", fmt);
errx(1, "\"%s\": bad format\n", fmt);
}
void
badconv(ch)
char *ch;
{
err("%%%s: bad conversion character\n", ch);
errx(1, "%%%s: bad conversion character\n", ch);
}