Module Name: src
Committed By: christos
Date: Sat Nov 27 20:46:38 UTC 2010
Modified Files:
src/usr.bin/hexdump: hexdump.c hexdump.h hexsyntax.c odsyntax.c
Log Message:
revert and fix the usage to be consistent with other programs.
To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/hexdump/hexdump.c
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/hexdump/hexdump.h
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/hexdump/hexsyntax.c
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/hexdump/odsyntax.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/hexdump/hexdump.c
diff -u src/usr.bin/hexdump/hexdump.c:1.15 src/usr.bin/hexdump/hexdump.c:1.16
--- src/usr.bin/hexdump/hexdump.c:1.15 Tue Feb 9 09:06:37 2010
+++ src/usr.bin/hexdump/hexdump.c Sat Nov 27 15:46:38 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: hexdump.c,v 1.15 2010/02/09 14:06:37 drochner Exp $ */
+/* $NetBSD: hexdump.c,v 1.16 2010/11/27 20:46:38 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -40,7 +40,7 @@
#if 0
static char sccsid[] = "@(#)hexdump.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: hexdump.c,v 1.15 2010/02/09 14:06:37 drochner Exp $");
+__RCSID("$NetBSD: hexdump.c,v 1.16 2010/11/27 20:46:38 christos Exp $");
#endif
#endif /* not lint */
@@ -58,8 +58,7 @@
int blocksize; /* data block size */
int exitval; /* final exit value */
int length = -1; /* max bytes to read */
-
-int main(int, char **);
+static int isod = 0;
int
main(int argc, char *argv[])
@@ -69,10 +68,11 @@
setlocale(LC_ALL, "");
- if (!(p = strrchr(argv[0], 'o')) || strcmp(p, "od"))
- newsyntax(argc, &argv);
- else
+ isod = (p = strrchr(argv[0], 'o')) == NULL || strcmp(p, "od") == 0;
+ if (isod)
odsyntax(argc, &argv);
+ else
+ hexsyntax(argc, &argv);
/* figure out the data block size */
for (blocksize = 0, tfs = fshead; tfs; tfs = tfs->nextfs) {
@@ -88,3 +88,19 @@
display();
exit(exitval);
}
+
+void
+usage(void)
+{
+ const char *pname = getprogname();
+
+ (void)fprintf(stderr, "Usage: %s ", pname);
+ if (isod)
+ (void)fprintf(stderr, "[-aBbcDdeFfHhIiLlOovXx] [-A base] "
+ "[-j skip] [-N length] [-t type_string] [[+]offset[.][Bb]] "
+ "[file ...]\n");
+ else
+ (void)fprintf(stderr, "[-bcCdovx] [-e fmt] [-f fmt_file] "
+ "[-n length] [-s skip] [file ...]\n");
+ exit(1);
+}
Index: src/usr.bin/hexdump/hexdump.h
diff -u src/usr.bin/hexdump/hexdump.h:1.11 src/usr.bin/hexdump/hexdump.h:1.12
--- src/usr.bin/hexdump/hexdump.h:1.11 Tue Feb 9 09:06:37 2010
+++ src/usr.bin/hexdump/hexdump.h Sat Nov 27 15:46:38 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: hexdump.h,v 1.11 2010/02/09 14:06:37 drochner Exp $ */
+/* $NetBSD: hexdump.h,v 1.12 2010/11/27 20:46:38 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -90,12 +90,11 @@
void conv_u(PR *, u_char *);
void display(void);
void doskip(const char *, int);
-/*void err(const char *, ...);*/
void escape(char *);
u_char *get(void);
-void newsyntax(int, char ***);
+void hexsyntax(int, char ***);
int next(char **);
void odsyntax(int, char ***);
void rewrite(FS *);
int size(FS *);
-void usage(void);
+void usage(void) __attribute__((__noreturn__));
Index: src/usr.bin/hexdump/hexsyntax.c
diff -u src/usr.bin/hexdump/hexsyntax.c:1.13 src/usr.bin/hexdump/hexsyntax.c:1.14
--- src/usr.bin/hexdump/hexsyntax.c:1.13 Tue Jan 3 20:30:21 2006
+++ src/usr.bin/hexdump/hexsyntax.c Sat Nov 27 15:46:38 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: hexsyntax.c,v 1.13 2006/01/04 01:30:21 perry Exp $ */
+/* $NetBSD: hexsyntax.c,v 1.14 2010/11/27 20:46:38 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)hexsyntax.c 8.2 (Berkeley) 5/4/95";
#else
-__RCSID("$NetBSD: hexsyntax.c,v 1.13 2006/01/04 01:30:21 perry Exp $");
+__RCSID("$NetBSD: hexsyntax.c,v 1.14 2010/11/27 20:46:38 christos Exp $");
#endif
#endif /* not lint */
@@ -55,7 +55,7 @@
off_t skip; /* bytes to skip */
void
-newsyntax(int argc, char ***argvp)
+hexsyntax(int argc, char ***argvp)
{
int ch;
char *p, **argv;
@@ -127,12 +127,3 @@
*argvp += optind;
}
-
-void
-usage(void)
-{
- (void)fprintf(stderr,
-"hexdump: [-bcCdovx] [-e fmt] [-f fmt_file] [-n length] [-s skip] [file ...]\n"
- );
- exit(1);
-}
Index: src/usr.bin/hexdump/odsyntax.c
diff -u src/usr.bin/hexdump/odsyntax.c:1.27 src/usr.bin/hexdump/odsyntax.c:1.28
--- src/usr.bin/hexdump/odsyntax.c:1.27 Fri Nov 26 19:42:58 2010
+++ src/usr.bin/hexdump/odsyntax.c Sat Nov 27 15:46:38 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: odsyntax.c,v 1.27 2010/11/27 00:42:58 dholland Exp $ */
+/* $NetBSD: odsyntax.c,v 1.28 2010/11/27 20:46:38 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)odsyntax.c 8.2 (Berkeley) 5/4/95";
#else
-__RCSID("$NetBSD: odsyntax.c,v 1.27 2010/11/27 00:42:58 dholland Exp $");
+__RCSID("$NetBSD: odsyntax.c,v 1.28 2010/11/27 20:46:38 christos Exp $");
#endif
#endif /* not lint */
@@ -72,7 +72,6 @@
static void odoffset(int, char ***);
static void posixtypes(char const *);
-static void odusage(void);
void
odsyntax(int argc, char ***argvp)
@@ -177,7 +176,7 @@
break;
case '?':
default:
- odusage();
+ usage();
}
if (fshead->nextfs->nextfs == NULL)
@@ -247,7 +246,7 @@
default:
warnx("Bad type-size qualifier '%c'",
*type_string);
- odusage();
+ usage();
}
type_string++;
} else if (isdigit((unsigned char)*type_string)) {
@@ -277,7 +276,7 @@
default:
warnx("Bad type-size qualifier '%c'",
*type_string);
- odusage();
+ usage();
}
type_string++;
} else if (isdigit((unsigned char)*type_string)) {
@@ -287,7 +286,7 @@
nbytes = 4;
break;
default:
- odusage();
+ usage();
}
for (odf = odftab; odf->type != 0; odf++)
if (odf->type == type && odf->nbytes == nbytes)
@@ -397,12 +396,3 @@
/* Terminate file list. */
(*argvp)[1] = NULL;
}
-
-static void
-odusage(void)
-{
- (void)warnx("Usage: od [-aBbcDdeFfHhIiLlOovXx] [-A base] [-j skip]"
- " [-N length]");
- (void)warnx(" [-t type_string] [[+]offset[.][Bb]] [file ...]");
- exit(1);
-}