CVS commit: src/usr.bin/hexdump

2016-03-03 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Fri Mar  4 03:02:52 UTC 2016

Modified Files:
src/usr.bin/hexdump: display.c

Log Message:
Don't try to use stdin after clobbering it with a failed freopen().
Prevents an extra "Bad file descriptor" message when trying to hexdump
a single nonexistent file.

The intended behavior seems to have been to read from stdin if there
was one filename given and it wasn't valid. But this seems like a bad
idea, so prevent that case instead of hacking it up so it works.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/hexdump/display.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/display.c
diff -u src/usr.bin/hexdump/display.c:1.24 src/usr.bin/hexdump/display.c:1.25
--- src/usr.bin/hexdump/display.c:1.24	Fri Mar  4 02:54:38 2016
+++ src/usr.bin/hexdump/display.c	Fri Mar  4 03:02:52 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: display.c,v 1.24 2016/03/04 02:54:38 dholland Exp $	*/
+/*	$NetBSD: display.c,v 1.25 2016/03/04 03:02:52 dholland Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)display.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: display.c,v 1.24 2016/03/04 02:54:38 dholland Exp $");
+__RCSID("$NetBSD: display.c,v 1.25 2016/03/04 03:02:52 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -297,12 +297,32 @@ get(void)
 	}
 }
 
+/*
+ * Save argv for later retrieval.
+ */
 void
 stashargv(char **argv)
 {
 	_argv = argv;
 }
 
+/*
+ * Get the next file. The idea with the twisty logic seems to be to
+ * either read N filenames from argv and then exit, or if there aren't
+ * any, to use stdin and then exit. It should probably be simplified.
+ * The "done" flag doesn't mean "we are done", it means "we are done
+ * once we run out of filenames".
+ *
+ * XXX: is there any reason not to remove the logic that inhibits
+ * calling fstat if using stdin and not a filename? It should be safe
+ * to call fstat on any fd.
+ *
+ * Note: I have ruled that if there is one file on the command line
+ * and it doesn't open, we should exit after complaining about it and
+ * not then proceed to read stdin; the latter seems like unexpected
+ * and undesirable behavior. Also, it didn't work anyway, because the
+ * freopen call clobbers stdin while failing. -- dholland 20160303
+ */
 int
 next(void)
 {
@@ -311,13 +331,14 @@ next(void)
 
 	for (;;) {
 		if (*_argv) {
+			done = 1;
 			if (!(freopen(*_argv, "r", stdin))) {
 warn("%s", *_argv);
 exitval = 1;
 ++_argv;
 continue;
 			}
-			statok = done = 1;
+			statok = 1;
 		} else {
 			if (done++)
 return(0);



CVS commit: src/usr.bin/hexdump

2016-03-03 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Fri Mar  4 02:54:38 UTC 2016

Modified Files:
src/usr.bin/hexdump: display.c hexdump.c hexdump.h

Log Message:
Don't use one function for two different things. Two functions is the
ticket.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/hexdump/display.c
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/hexdump/hexdump.c
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/hexdump/hexdump.h

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/display.c
diff -u src/usr.bin/hexdump/display.c:1.23 src/usr.bin/hexdump/display.c:1.24
--- src/usr.bin/hexdump/display.c:1.23	Fri Mar  4 02:46:19 2016
+++ src/usr.bin/hexdump/display.c	Fri Mar  4 02:54:38 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: display.c,v 1.23 2016/03/04 02:46:19 dholland Exp $	*/
+/*	$NetBSD: display.c,v 1.24 2016/03/04 02:54:38 dholland Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)display.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: display.c,v 1.23 2016/03/04 02:46:19 dholland Exp $");
+__RCSID("$NetBSD: display.c,v 1.24 2016/03/04 02:54:38 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -254,7 +254,7 @@ get(void)
 		 * and no other files are available, zero-pad the rest of the
 		 * block and set the end flag.
 		 */
-		if (!length || (ateof && !next(NULL))) {
+		if (!length || (ateof && !next())) {
 			if (need == blocksize)
 return(NULL);
 			if (!need && vflag != ALL &&
@@ -297,16 +297,18 @@ get(void)
 	}
 }
 
+void
+stashargv(char **argv)
+{
+	_argv = argv;
+}
+
 int
-next(char **argv)
+next(void)
 {
 	static int done;
 	int statok;
 
-	if (argv) {
-		_argv = argv;
-		return(1);
-	}
 	for (;;) {
 		if (*_argv) {
 			if (!(freopen(*_argv, "r", stdin))) {

Index: src/usr.bin/hexdump/hexdump.c
diff -u src/usr.bin/hexdump/hexdump.c:1.18 src/usr.bin/hexdump/hexdump.c:1.19
--- src/usr.bin/hexdump/hexdump.c:1.18	Fri Jul  6 09:06:43 2012
+++ src/usr.bin/hexdump/hexdump.c	Fri Mar  4 02:54:38 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: hexdump.c,v 1.18 2012/07/06 09:06:43 wiz Exp $	*/
+/*	$NetBSD: hexdump.c,v 1.19 2016/03/04 02:54:38 dholland Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = "@(#)hexdump.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: hexdump.c,v 1.18 2012/07/06 09:06:43 wiz Exp $");
+__RCSID("$NetBSD: hexdump.c,v 1.19 2016/03/04 02:54:38 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -88,7 +88,7 @@ main(int argc, char *argv[])
 	for (tfs = fshead; tfs; tfs = tfs->nextfs)
 		rewrite(tfs);
 
-	(void)next(argv);
+	stashargv(argv);
 	display();
 	exit(exitval);
 }

Index: src/usr.bin/hexdump/hexdump.h
diff -u src/usr.bin/hexdump/hexdump.h:1.14 src/usr.bin/hexdump/hexdump.h:1.15
--- src/usr.bin/hexdump/hexdump.h:1.14	Fri Mar  4 02:46:19 2016
+++ src/usr.bin/hexdump/hexdump.h	Fri Mar  4 02:54:38 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: hexdump.h,v 1.14 2016/03/04 02:46:19 dholland Exp $	*/
+/*	$NetBSD: hexdump.h,v 1.15 2016/03/04 02:54:38 dholland Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -88,7 +88,8 @@ void	 display(void);
 void	 doskip(const char *, int);
 void	 escape(char *);
 void	 hexsyntax(int, char ***);
-int	 next(char **);
+void	 stashargv(char **);
+int	 next(void);
 void	 odsyntax(int, char ***);
 void	 rewrite(FS *);
 int	 size(FS *);



CVS commit: src/usr.bin/hexdump

2016-03-03 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Fri Mar  4 02:46:19 UTC 2016

Modified Files:
src/usr.bin/hexdump: display.c hexdump.h

Log Message:
use "static"


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/hexdump/display.c
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/hexdump/hexdump.h

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/display.c
diff -u src/usr.bin/hexdump/display.c:1.22 src/usr.bin/hexdump/display.c:1.23
--- src/usr.bin/hexdump/display.c:1.22	Fri Oct 18 20:19:03 2013
+++ src/usr.bin/hexdump/display.c	Fri Mar  4 02:46:19 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: display.c,v 1.22 2013/10/18 20:19:03 christos Exp $	*/
+/*	$NetBSD: display.c,v 1.23 2016/03/04 02:46:19 dholland Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)display.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: display.c,v 1.22 2013/10/18 20:19:03 christos Exp $");
+__RCSID("$NetBSD: display.c,v 1.23 2016/03/04 02:46:19 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -62,6 +62,7 @@ enum _vflag vflag = FIRST;
 static off_t address;			/* address/offset in stream */
 static off_t eaddress;			/* end address */
 
+static u_char *get(void);
 static inline void print(PR *, u_char *);
 
 void
@@ -229,7 +230,7 @@ bpad(PR *pr)
 
 static char **_argv;
 
-u_char *
+static u_char *
 get(void)
 {
 	static int ateof = 1;

Index: src/usr.bin/hexdump/hexdump.h
diff -u src/usr.bin/hexdump/hexdump.h:1.13 src/usr.bin/hexdump/hexdump.h:1.14
--- src/usr.bin/hexdump/hexdump.h:1.13	Sun Sep  4 20:27:27 2011
+++ src/usr.bin/hexdump/hexdump.h	Fri Mar  4 02:46:19 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: hexdump.h,v 1.13 2011/09/04 20:27:27 joerg Exp $	*/
+/*	$NetBSD: hexdump.h,v 1.14 2016/03/04 02:46:19 dholland Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -87,7 +87,6 @@ void	 conv_u(PR *, u_char *);
 void	 display(void);
 void	 doskip(const char *, int);
 void	 escape(char *);
-u_char	*get(void);
 void	 hexsyntax(int, char ***);
 int	 next(char **);
 void	 odsyntax(int, char ***);



CVS commit: src/usr.bin/hexdump

2013-10-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct 18 20:19:03 UTC 2013

Modified Files:
src/usr.bin/hexdump: display.c

Log Message:
don't read random garbage from the stack


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/hexdump/display.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/display.c
diff -u src/usr.bin/hexdump/display.c:1.21 src/usr.bin/hexdump/display.c:1.22
--- src/usr.bin/hexdump/display.c:1.21	Sun Jan 18 16:34:32 2009
+++ src/usr.bin/hexdump/display.c	Fri Oct 18 16:19:03 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: display.c,v 1.21 2009/01/18 21:34:32 apb Exp $	*/
+/*	$NetBSD: display.c,v 1.22 2013/10/18 20:19:03 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = @(#)display.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: display.c,v 1.21 2009/01/18 21:34:32 apb Exp $);
+__RCSID($NetBSD: display.c,v 1.22 2013/10/18 20:19:03 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -344,7 +344,9 @@ doskip(const char *fname, int statok)
 			skip -= sb.st_size;
 			return;
 		}
-	}
+	} else
+		sb.st_mode = S_IFIFO;
+
 	if (S_ISREG(sb.st_mode)) {
 		if (fseek(stdin, skip, SEEK_SET))
 			err(1, fseek %s, fname);



CVS commit: src/usr.bin/hexdump

2013-02-08 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sat Feb  9 02:49:36 UTC 2013

Modified Files:
src/usr.bin/hexdump: conv.c

Log Message:
dcl is not dc1.

Fixes PR#47547


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/hexdump/conv.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/conv.c
diff -u src/usr.bin/hexdump/conv.c:1.13 src/usr.bin/hexdump/conv.c:1.14
--- src/usr.bin/hexdump/conv.c:1.13	Tue Feb  9 14:06:37 2010
+++ src/usr.bin/hexdump/conv.c	Sat Feb  9 02:49:36 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: conv.c,v 1.13 2010/02/09 14:06:37 drochner Exp $	*/
+/*	$NetBSD: conv.c,v 1.14 2013/02/09 02:49:36 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = @(#)conv.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: conv.c,v 1.13 2010/02/09 14:06:37 drochner Exp $);
+__RCSID($NetBSD: conv.c,v 1.14 2013/02/09 02:49:36 jakllsch Exp $);
 #endif
 #endif /* not lint */
 
@@ -105,7 +105,7 @@ conv_u(PR *pr, u_char *p)
 	static const char *list[] = {
 		nul, soh, stx, etx, eot, enq, ack, bel,
 		 bs,  ht,  lf,  vt,  ff,  cr,  so,  si,
-		dle, dcl, dc2, dc3, dc4, nak, syn, etb,
+		dle, dc1, dc2, dc3, dc4, nak, syn, etb,
 		can,  em, sub, esc,  fs,  gs,  rs,  us,
 	};
 



CVS commit: src/usr.bin/hexdump

2012-07-06 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Jul  6 09:03:34 UTC 2012

Modified Files:
src/usr.bin/hexdump: hexdump.1

Log Message:
From Bug Hunting:
- sort options in `SYNOPSIS' and `DESCRIPTION' sections;
- correct / improve macro usage;
- synchronize argument name to `-s' option;
- improve punctuation / wording;
- augment `SEE ALSO' section;
- bump date.

While here:
Use Sq for single characters instead of Dq.
Use Aq instead of \*[Lt]...\*[Gt].
Mark up NULL with Dv.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/hexdump/hexdump.1

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.1
diff -u src/usr.bin/hexdump/hexdump.1:1.22 src/usr.bin/hexdump/hexdump.1:1.23
--- src/usr.bin/hexdump/hexdump.1:1.22	Sun Apr  8 22:00:38 2012
+++ src/usr.bin/hexdump/hexdump.1	Fri Jul  6 09:03:34 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: hexdump.1,v 1.22 2012/04/08 22:00:38 wiz Exp $
+.\	$NetBSD: hexdump.1,v 1.23 2012/07/06 09:03:34 wiz Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\	from: @(#)hexdump.1	8.2 (Berkeley) 4/18/94
 .\
-.Dd February 27, 2010
+.Dd June 24, 2012
 .Dt HEXDUMP 1
 .Os
 .Sh NAME
@@ -37,15 +37,20 @@
 .Nd ascii, decimal, hexadecimal, octal dump
 .Sh SYNOPSIS
 .Nm
-.Op Fl bcCdovx
+.Op Fl bCcdovx
 .Op Fl e Ar format_string
 .Op Fl f Ar format_file
 .Op Fl n Ar length
 .Op Fl s Ar skip
-.Ar file ...
+.Op Ar
 .Sh DESCRIPTION
-The hexdump utility is a filter which displays the specified files, or
-the standard input, if no files are specified, in a user specified
+The
+.Nm
+utility is a filter which displays each specified
+.Ar file ,
+or the standard input if no
+.Ar file
+arguments are specified, in a user specified
 format.
 .Pp
 The options are as follows:
@@ -55,16 +60,18 @@ The options are as follows:
 Display the input offset in hexadecimal, followed by sixteen
 space-separated, three column, zero-filled, bytes of input data,
 in octal, per line.
+.It Fl C
+.Em Canonical hex+ASCII display .
+Display the input offset in hexadecimal, followed by sixteen
+space-separated, two column, hexadecimal bytes, followed by the
+same sixteen bytes in %_p format enclosed in
+.Sq |
+characters.
 .It Fl c
 .Em One-byte character display .
 Display the input offset in hexadecimal, followed by sixteen
 space-separated, three column, space-filled, characters of input
 data per line.
-.It Fl C
-.Em Canonical hex+ASCII display .
-Display the input offset in hexadecimal, followed by sixteen
-space-separated, two column, hexadecimal bytes, followed by the
-same sixteen bytes in %_p format enclosed in ``|'' characters.
 .It Fl d
 .Em Two-byte decimal display .
 Display the input offset in hexadecimal, followed by eight
@@ -75,7 +82,7 @@ Specify a format string to be used for d
 .It Fl f Ar format_file
 Specify a file that contains one or more newline separated format strings.
 Empty lines and lines whose first non-blank character is a hash mark
-.Pf ( Cm \# )
+.Pq Sq #
 are ignored.
 .It Fl n Ar length
 Interpret only
@@ -86,22 +93,22 @@ bytes of input.
 Display the input offset in hexadecimal, followed by eight
 space-separated, six column, zero-filled, two byte quantities of
 input data, in octal, per line.
-.It Fl s Ar offset
+.It Fl s Ar skip
 Skip
-.Ar offset
+.Ar skip
 bytes from the beginning of the input.
 By default,
-.Ar offset
+.Ar skip
 is interpreted as a decimal number.
 With a leading
 .Cm 0x
 or
 .Cm 0X ,
-.Ar offset
-is interpreted as a hexadecimal number,
+.Ar skip
+is interpreted as a hexadecimal number;
 otherwise, with a leading
 .Cm 0 ,
-.Ar offset
+.Ar skip
 is interpreted as an octal number.
 Appending the character
 .Cm b ,
@@ -109,7 +116,7 @@ Appending the character
 or
 .Cm m
 to
-.Ar offset
+.Ar skip
 causes it to be interpreted as a multiple of
 .Li 512 ,
 .Li 1024 ,
@@ -119,13 +126,16 @@ respectively.
 .It Fl v
 The
 .Fl v
-option causes hexdump to display all input data.
+option causes
+.Nm
+to display all input data.
 Without the
 .Fl v
 option, any number of groups of output lines, which would be
 identical to the immediately preceding group of output lines (except
 for the input offsets), are replaced with a line containing a
-single asterisk.
+single asterisk
+.Pq Sq \* .
 .It Fl x
 .Em Two-byte hexadecimal display .
 Display the input offset in hexadecimal, followed by eight, space
@@ -156,47 +166,61 @@ If specified it defines the number of by
 each iteration of the format.
 .Pp
 If an iteration count and/or a byte count is specified, a single slash
+.Pq Sq /
 must be placed after the iteration count and/or before the byte count
 to disambiguate them.
 Any whitespace before or after the slash is ignored.
 .Pp
 The format is required and must be surrounded by double quote
-( ) marks.
+.Pq Sq \
+marks.
 It is interpreted as a fprintf-style format 

CVS commit: src/usr.bin/hexdump

2012-07-06 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Jul  6 09:05:26 UTC 2012

Modified Files:
src/usr.bin/hexdump: od.1

Log Message:
From Bug Hunting:
- correct / improve macro usage;
- (re-)add an actual description in `DESCRIPTION' section;
- synchronize argument name to `-j' option;
- improve wording;
- bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/hexdump/od.1

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/od.1
diff -u src/usr.bin/hexdump/od.1:1.26 src/usr.bin/hexdump/od.1:1.27
--- src/usr.bin/hexdump/od.1:1.26	Sun Apr  8 22:00:38 2012
+++ src/usr.bin/hexdump/od.1	Fri Jul  6 09:05:26 2012
@@ -1,4 +1,4 @@
-.\  $NetBSD: od.1,v 1.26 2012/04/08 22:00:38 wiz Exp $
+.\  $NetBSD: od.1,v 1.27 2012/07/06 09:05:26 wiz Exp $
 .\
 .\ Copyright (c) 2001 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -27,7 +27,7 @@
 .\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\ POSSIBILITY OF SUCH DAMAGE.
 .\/
-.Dd February 9, 2010
+.Dd June 24, 2012
 .Dt OD 1
 .Os
 .Sh NAME
@@ -48,8 +48,17 @@
 .Op Cm Bb
 .Sm on
 .Oc
-.Ar file ...
+.Op Ar
 .Sh DESCRIPTION
+The
+.Nm
+utility is a filter which displays each specified
+.Ar file ,
+or the standard input if no
+.Ar file
+arguments are specified, in a user specified
+format.
+.Pp
 The options are as follows:
 .Bl -tag -width Fl
 .It Fl A Ar base
@@ -125,22 +134,22 @@ decimal, per line.
 Display the input offset in octal, followed by eight space-separated,
 six column, space filled, two-byte units of input data, in decimal,
 per line.
-.It Fl j Ar offset
+.It Fl j Ar skip
 Skip
-.Ar offset
+.Ar skip
 bytes from the beginning of the input.
 By default,
-.Ar offset
+.Ar skip
 is interpreted as a decimal number.
 With a leading
 .Cm 0x
 or
 .Cm 0X ,
-.Ar offset
-is interpreted as a hexadecimal number,
+.Ar skip
+is interpreted as a hexadecimal number;
 otherwise, with a leading
 .Cm 0 ,
-.Ar offset
+.Ar skip
 is interpreted as an octal number.
 Appending the character
 .Cm b ,
@@ -148,7 +157,7 @@ Appending the character
 or
 .Cm m
 to
-.Ar offset
+.Ar skip
 causes it to be interpreted as a multiple of
 .Li 512 ,
 .Li 1024 ,
@@ -188,13 +197,15 @@ selects US-ASCII output, with control ch
 names instead of as C escape sequences.
 See also the
 .Cm _u
-conversion provided by hexdump(1).
+conversion provided by
+.Xr hexdump 1 .
 .Pp
 .Cm c
 selects a standard character based conversion.
 See also the
 .Cm _c
-conversion provided by hexdump(1).
+conversion provided by
+.Xr hexdump 1 .
 .Pp
 .Cm f
 selects the floating point output format.
@@ -210,7 +221,8 @@ to specify eight byte floating point out
 The default output format is eight byte floats.
 See also the
 .Cm e
-conversion provided by hexdump(1).
+conversion provided by
+.Xr hexdump 1 .
 .Pp
 .Cm d ,
 .Cm o ,
@@ -250,7 +262,8 @@ See also the
 .Cm u ,
 and
 .Cm x
-conversions provided by hexdump(1).
+conversions provided by
+.Xr hexdump 1 .
 .\(a|c|f[FLD]?|[doux][C1S2I4L8]?)*
 .It Fl v
 The
@@ -263,7 +276,8 @@ Without the
 option, any number of groups of output lines, which would be
 identical to the immediately preceding group of output lines (except
 for the input offsets), are replaced with a line comprised of a
-single asterisk.
+single asterisk
+.Pq Sq \* .
 .It Fl X
 Same as
 .Fl H .
@@ -280,18 +294,19 @@ If no options are specified, the
 default display is equivalent to specifying the
 .Fl o
 option.
-.Pp
-.Nm
-exits 0 on success and \*[Gt]0 if an error occurred.
+.Sh EXIT STATUS
+.Ex -std
 .Sh SEE ALSO
 .Xr hexdump 1 ,
 .Xr strings 1
 .Sh HISTORY
-A
+An
 .Nm
-command appears in
+command appeared in
 .At v1 .
 .Pp
-This man page was written in February 2001 by Andrew Brown, shortly
-after he augmented the deprecated od syntax to include things he felt
+This man page was initially written in February 2001 by Andrew Brown, shortly
+after he augmented the deprecated
+.Nm
+syntax to include things he felt
 had been missing for a long time.



CVS commit: src/usr.bin/hexdump

2012-07-06 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Jul  6 09:06:43 UTC 2012

Modified Files:
src/usr.bin/hexdump: hexdump.c

Log Message:
From Bug Hunting:
- de-capitalize ``usage'' in `usage' message;
- synchronize `usage' message with man pages.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/hexdump/hexdump.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.17 src/usr.bin/hexdump/hexdump.c:1.18
--- src/usr.bin/hexdump/hexdump.c:1.17	Sun Nov 28 10:45:32 2010
+++ src/usr.bin/hexdump/hexdump.c	Fri Jul  6 09:06:43 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: hexdump.c,v 1.17 2010/11/28 10:45:32 mrg Exp $	*/
+/*	$NetBSD: hexdump.c,v 1.18 2012/07/06 09:06:43 wiz Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -40,7 +40,7 @@ __COPYRIGHT(@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = @(#)hexdump.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: hexdump.c,v 1.17 2010/11/28 10:45:32 mrg Exp $);
+__RCSID($NetBSD: hexdump.c,v 1.18 2012/07/06 09:06:43 wiz Exp $);
 #endif
 #endif /* not lint */
 
@@ -98,13 +98,13 @@ usage(void)
 {
 	const char *pname = getprogname();
 
-	(void)fprintf(stderr, Usage: %s , pname);
+	(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] 
+		(void)fprintf(stderr, [-bCcdovx] [-e format_string] [-f format_file] 
 		[-n length] [-s skip] [file ...]\n);
 	exit(1);
 }



CVS commit: src/usr.bin/hexdump

2012-07-06 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Jul  6 14:10:06 UTC 2012

Modified Files:
src/usr.bin/hexdump: hexdump.1

Log Message:
Bug Hunting:
improve wording


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/hexdump/hexdump.1

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.1
diff -u src/usr.bin/hexdump/hexdump.1:1.23 src/usr.bin/hexdump/hexdump.1:1.24
--- src/usr.bin/hexdump/hexdump.1:1.23	Fri Jul  6 09:03:34 2012
+++ src/usr.bin/hexdump/hexdump.1	Fri Jul  6 14:10:06 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: hexdump.1,v 1.23 2012/07/06 09:03:34 wiz Exp $
+.\	$NetBSD: hexdump.1,v 1.24 2012/07/06 14:10:06 wiz Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -239,13 +239,13 @@ conversion string except that it is only
 once, when all of the input data has been processed.
 .It Cm \_c
 Output characters in the default character set.
-Nonprinting characters are displayed in three character, zero-padded
+Non-printing characters are displayed in three character, zero-padded
 octal, except for those representable by standard escape notation
 (see above),
 which are displayed as two character strings.
 .It Cm _p
 Output characters in the default character set.
-Nonprinting characters are displayed as a single
+Non-printing characters are displayed as a single
 .Sq Cm \. .
 .It Cm _u
 Output US ASCII characters, with the exception that control characters are
@@ -319,6 +319,7 @@ and precision as the original conversion
 string but with any
 .Sq Li \+ ,
 .Sq \\ \ ,
+and
 .Sq Li \#
 conversion flag characters
 removed, and referencing a



CVS commit: src/usr.bin/hexdump

2011-09-04 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sun Sep  4 20:27:27 UTC 2011

Modified Files:
src/usr.bin/hexdump: hexdump.h parse.c

Log Message:
static + __dead


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/hexdump/hexdump.h
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/hexdump/parse.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.h
diff -u src/usr.bin/hexdump/hexdump.h:1.12 src/usr.bin/hexdump/hexdump.h:1.13
--- src/usr.bin/hexdump/hexdump.h:1.12	Sat Nov 27 20:46:38 2010
+++ src/usr.bin/hexdump/hexdump.h	Sun Sep  4 20:27:27 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: hexdump.h,v 1.12 2010/11/27 20:46:38 christos Exp $	*/
+/*	$NetBSD: hexdump.h,v 1.13 2011/09/04 20:27:27 joerg Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -81,10 +81,6 @@
 
 void	 add(const char *);
 void	 addfile(char *);
-void	 badcnt(char *);
-void	 badconv(char *);
-void	 badfmt(const char *);
-void	 badsfmt(void);
 void	 bpad(PR *);
 void	 conv_c(PR *, u_char *);
 void	 conv_u(PR *, u_char *);

Index: src/usr.bin/hexdump/parse.c
diff -u src/usr.bin/hexdump/parse.c:1.26 src/usr.bin/hexdump/parse.c:1.27
--- src/usr.bin/hexdump/parse.c:1.26	Sun Jan 18 21:34:32 2009
+++ src/usr.bin/hexdump/parse.c	Sun Sep  4 20:27:27 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.26 2009/01/18 21:34:32 apb Exp $	*/
+/*	$NetBSD: parse.c,v 1.27 2011/09/04 20:27:27 joerg Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = @(#)parse.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: parse.c,v 1.26 2009/01/18 21:34:32 apb Exp $);
+__RCSID($NetBSD: parse.c,v 1.27 2011/09/04 20:27:27 joerg Exp $);
 #endif
 #endif /* not lint */
 
@@ -57,6 +57,11 @@
 
 #include hexdump.h
 
+__dead static void	 badcnt(char *);
+__dead static void	 badconv(char *);
+__dead static void	 badfmt(const char *);
+__dead static void	 badsfmt(void);
+
 FU *endfu;	/* format at end-of-data */
 
 void
@@ -518,25 +523,25 @@
 	}
 }
 
-void
+static void
 badcnt(char *s)
 {
 	errx(1, %s: bad byte count, s);
 }
 
-void
+static void
 badsfmt(void)
 {
 	errx(1, %%s: requires a precision or a byte count);
 }
 
-void
+static void
 badfmt(const char *fmt)
 {
 	errx(1, \%s\: bad format, fmt);
 }
 
-void
+static void
 badconv(char *ch)
 {
 	errx(1, %%%s: bad conversion character, ch);



CVS commit: src/usr.bin/hexdump

2011-08-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug 14 13:45:34 UTC 2011

Modified Files:
src/usr.bin/hexdump: Makefile

Log Message:
document non-literal format strings.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/hexdump/Makefile

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/Makefile
diff -u src/usr.bin/hexdump/Makefile:1.13 src/usr.bin/hexdump/Makefile:1.14
--- src/usr.bin/hexdump/Makefile:1.13	Tue Apr 14 18:15:21 2009
+++ src/usr.bin/hexdump/Makefile	Sun Aug 14 09:45:34 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.13 2009/04/14 22:15:21 lukem Exp $
+#	$NetBSD: Makefile,v 1.14 2011/08/14 13:45:34 christos Exp $
 #	from: @(#)Makefile	8.1 (Berkeley) 6/6/93
 
 PROG=	hexdump
@@ -12,4 +12,7 @@
 LINKS=	${BINDIR}/hexdump ${BINDIR}/od
 .endif
 
+COPTS.conv.c += -Wno-format-nonliteral
+COPTS.display.c += -Wno-format-nonliteral
+
 .include bsd.prog.mk



CVS commit: src/usr.bin/hexdump

2010-12-18 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Dec 18 14:22:42 UTC 2010

Modified Files:
src/usr.bin/hexdump: hexdump.1

Log Message:
Replace \t with Ta in table.
Fixes output with mandoc. Noted by njoly.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/hexdump/hexdump.1

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.1
diff -u src/usr.bin/hexdump/hexdump.1:1.20 src/usr.bin/hexdump/hexdump.1:1.21
--- src/usr.bin/hexdump/hexdump.1:1.20	Sat Feb 27 10:45:23 2010
+++ src/usr.bin/hexdump/hexdump.1	Sat Dec 18 14:22:42 2010
@@ -1,4 +1,4 @@
-.\	$NetBSD: hexdump.1,v 1.20 2010/02/27 10:45:23 mbalmer Exp $
+.\	$NetBSD: hexdump.1,v 1.21 2010/12/18 14:22:42 wiz Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -237,12 +237,12 @@
 Characters greater than 0xff, hexadecimal, are displayed as hexadecimal
 strings.
 .Bl -column \000_nu \001_so \002_st \003_et \004_eo
-.It \000\ nul\t001\ soh\t002\ stx\t003\ etx\t004\ eot\t005\ enq
-.It \006\ ack\t007\ bel\t008\ bs\t009\ ht\t00A\ lf\t00B\ vt
-.It \00C\ ff\t00D\ cr\t00E\ so\t00F\ si\t010\ dle\t011\ dc1
-.It \012\ dc2\t013\ dc3\t014\ dc4\t015\ nak\t016\ syn\t017\ etb
-.It \018\ can\t019\ em\t01A\ sub\t01B\ esc\t01C\ fs\t01D\ gs
-.It \01E\ rs\t01F\ us\t07F\ del
+.It \000\ nul Ta 001\ soh Ta 002\ stx Ta 003\ etx Ta 004\ eot Ta 005\ enq
+.It \006\ ack Ta 007\ bel Ta 008\ bs Ta 009\ ht Ta 00A\ lf Ta 00B\ vt
+.It \00C\ ff Ta 00D\ cr Ta 00E\ so Ta 00F\ si Ta 010\ dle Ta 011\ dc1
+.It \012\ dc2 Ta 013\ dc3 Ta 014\ dc4 Ta 015\ nak Ta 016\ syn Ta 017\ etb
+.It \018\ can Ta 019\ em Ta 01A\ sub Ta 01B\ esc Ta 01C\ fs Ta 01D\ gs
+.It \01E\ rs Ta 01F\ us Ta 07F\ del
 .El
 .El
 .Pp



CVS commit: src/usr.bin/hexdump

2010-11-28 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Nov 28 10:45:33 UTC 2010

Modified Files:
src/usr.bin/hexdump: hexdump.c

Log Message:
properly detect that we aren't od(1) and act as hexdump.  fixes hexdump,
which also broke startx (second time this week!)

from mlelstv.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/hexdump/hexdump.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.16 src/usr.bin/hexdump/hexdump.c:1.17
--- src/usr.bin/hexdump/hexdump.c:1.16	Sat Nov 27 20:46:38 2010
+++ src/usr.bin/hexdump/hexdump.c	Sun Nov 28 10:45:32 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: hexdump.c,v 1.16 2010/11/27 20:46:38 christos Exp $	*/
+/*	$NetBSD: hexdump.c,v 1.17 2010/11/28 10:45:32 mrg 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.16 2010/11/27 20:46:38 christos Exp $);
+__RCSID($NetBSD: hexdump.c,v 1.17 2010/11/28 10:45:32 mrg Exp $);
 #endif
 #endif /* not lint */
 
@@ -68,7 +68,11 @@
 
 	setlocale(LC_ALL, );
 
-	isod = (p = strrchr(argv[0], 'o')) == NULL || strcmp(p, od) == 0;
+	isod = 0;
+	p = strrchr(argv[0], 'o');
+	if (p != NULL  strcmp(p, od) == 0)
+		isod = 1;
+
 	if (isod)
 		odsyntax(argc, argv);
 	else



CVS commit: src/usr.bin/hexdump

2010-11-27 Thread Christos Zoulas
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 /* 

CVS commit: src/usr.bin/hexdump

2010-11-26 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat Nov 27 00:42:58 UTC 2010

Modified Files:
src/usr.bin/hexdump: odsyntax.c

Log Message:
PR 44156: od -? prints usage for hexdump rather than od


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 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/odsyntax.c
diff -u src/usr.bin/hexdump/odsyntax.c:1.26 src/usr.bin/hexdump/odsyntax.c:1.27
--- src/usr.bin/hexdump/odsyntax.c:1.26	Tue Feb  9 14:06:37 2010
+++ src/usr.bin/hexdump/odsyntax.c	Sat Nov 27 00:42:58 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: odsyntax.c,v 1.26 2010/02/09 14:06:37 drochner Exp $	*/
+/*	$NetBSD: odsyntax.c,v 1.27 2010/11/27 00:42:58 dholland 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.26 2010/02/09 14:06:37 drochner Exp $);
+__RCSID($NetBSD: odsyntax.c,v 1.27 2010/11/27 00:42:58 dholland Exp $);
 #endif
 #endif /* not lint */
 
@@ -72,6 +72,7 @@
 
 static void odoffset(int, char ***);
 static void posixtypes(char const *);
+static void odusage(void);
 
 void
 odsyntax(int argc, char ***argvp)
@@ -176,7 +177,7 @@
 			break;
 		case '?':
 		default:
-			usage();
+			odusage();
 		}
 
 	if (fshead-nextfs-nextfs == NULL)
@@ -246,7 +247,7 @@
 default:
 	warnx(Bad type-size qualifier '%c',
 	*type_string);
-	usage();
+	odusage();
 }
 type_string++;
 			} else if (isdigit((unsigned char)*type_string)) {
@@ -276,7 +277,7 @@
 default:
 	warnx(Bad type-size qualifier '%c',
 	*type_string);
-	usage();
+	odusage();
 }
 type_string++;
 			} else if (isdigit((unsigned char)*type_string)) {
@@ -286,7 +287,7 @@
 nbytes = 4;
 			break;
 		default:
-			usage();
+			odusage();
 		}
 		for (odf = odftab; odf-type != 0; odf++)
 			if (odf-type == type  odf-nbytes == nbytes)
@@ -396,3 +397,12 @@
 	/* 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);
+}



CVS commit: src/usr.bin/hexdump

2010-02-09 Thread Matthias Drochner
Module Name:src
Committed By:   drochner
Date:   Tue Feb  9 14:06:37 UTC 2010

Modified Files:
src/usr.bin/hexdump: conv.c hexdump.c hexdump.h od.1 odsyntax.c

Log Message:
remove agitation that od(1) was deprecated -- it is still POSIX


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/hexdump/conv.c
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/hexdump/hexdump.c
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/hexdump/hexdump.h
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/hexdump/od.1
cvs rdiff -u -r1.25 -r1.26 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/conv.c
diff -u src/usr.bin/hexdump/conv.c:1.12 src/usr.bin/hexdump/conv.c:1.13
--- src/usr.bin/hexdump/conv.c:1.12	Wed Jan  4 01:30:21 2006
+++ src/usr.bin/hexdump/conv.c	Tue Feb  9 14:06:37 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: conv.c,v 1.12 2006/01/04 01:30:21 perry Exp $	*/
+/*	$NetBSD: conv.c,v 1.13 2010/02/09 14:06:37 drochner Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = @(#)conv.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: conv.c,v 1.12 2006/01/04 01:30:21 perry Exp $);
+__RCSID($NetBSD: conv.c,v 1.13 2010/02/09 14:06:37 drochner Exp $);
 #endif
 #endif /* not lint */
 
@@ -61,7 +61,7 @@
 		goto strpr;
 	/* case '\a': */
 	case '\007':
-		if (deprecated)		/* od didn't know about \a */
+		if (odmode)		/* od doesn't know about \a */
 			break;
 		str = \\a;
 		goto strpr;
@@ -81,7 +81,7 @@
 		str = \\t;
 		goto strpr;
 	case '\v':
-		if (deprecated)
+		if (odmode)
 			break;
 		str = \\v;
 		goto strpr;
@@ -112,14 +112,14 @@
 		/* od used nl, not lf */
 	if (*p = 0x1f) {
 		*pr-cchar = 's';
-		if (deprecated  *p == 0x0a)
+		if (odmode  *p == 0x0a)
 			(void)printf(pr-fmt, nl);
 		else
 			(void)printf(pr-fmt, list[*p]);
 	} else if (*p == 0x7f) {
 		*pr-cchar = 's';
 		(void)printf(pr-fmt, del);
-	} else if (deprecated  *p == 0x20) {	/* od replaced space with sp */
+	} else if (odmode  *p == 0x20) {	/* od replaces space with sp */
 		*pr-cchar = 's';
 		(void)printf(pr-fmt,  sp);
 	} else if (isprint(*p)) {

Index: src/usr.bin/hexdump/hexdump.c
diff -u src/usr.bin/hexdump/hexdump.c:1.14 src/usr.bin/hexdump/hexdump.c:1.15
--- src/usr.bin/hexdump/hexdump.c:1.14	Mon Jul 21 14:19:23 2008
+++ src/usr.bin/hexdump/hexdump.c	Tue Feb  9 14:06:37 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: hexdump.c,v 1.14 2008/07/21 14:19:23 lukem Exp $	*/
+/*	$NetBSD: hexdump.c,v 1.15 2010/02/09 14:06:37 drochner 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.14 2008/07/21 14:19:23 lukem Exp $);
+__RCSID($NetBSD: hexdump.c,v 1.15 2010/02/09 14:06:37 drochner Exp $);
 #endif
 #endif /* not lint */
 
@@ -72,7 +72,7 @@
 	if (!(p = strrchr(argv[0], 'o')) || strcmp(p, od))
 		newsyntax(argc, argv);
 	else
-		oldsyntax(argc, argv);
+		odsyntax(argc, argv);
 
 	/* figure out the data block size */
 	for (blocksize = 0, tfs = fshead; tfs; tfs = tfs-nextfs) {

Index: src/usr.bin/hexdump/hexdump.h
diff -u src/usr.bin/hexdump/hexdump.h:1.10 src/usr.bin/hexdump/hexdump.h:1.11
--- src/usr.bin/hexdump/hexdump.h:1.10	Sat Aug 26 18:17:42 2006
+++ src/usr.bin/hexdump/hexdump.h	Tue Feb  9 14:06:37 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: hexdump.h,v 1.10 2006/08/26 18:17:42 christos Exp $	*/
+/*	$NetBSD: hexdump.h,v 1.11 2010/02/09 14:06:37 drochner Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -71,7 +71,7 @@
 enum _vflag { ALL, DUP, FIRST, WAIT };	/* -v values */
 
 extern int blocksize;			/* data block size */
-extern int deprecated;			/* od compatibility */
+extern int odmode;			/* od compatibility */
 extern FU *endfu;			/* format at end-of-data */
 extern int exitval;			/* final exit value */
 extern FS *fshead;			/* head of format strings list */
@@ -95,7 +95,7 @@
 u_char	*get(void);
 void	 newsyntax(int, char ***);
 int	 next(char **);
-void	 oldsyntax(int, char ***);
+void	 odsyntax(int, char ***);
 void	 rewrite(FS *);
 int	 size(FS *);
 void	 usage(void);

Index: src/usr.bin/hexdump/od.1
diff -u src/usr.bin/hexdump/od.1:1.23 src/usr.bin/hexdump/od.1:1.24
--- src/usr.bin/hexdump/od.1:1.23	Wed Sep  3 16:32:57 2008
+++ src/usr.bin/hexdump/od.1	Tue Feb  9 14:06:37 2010
@@ -1,4 +1,4 @@
-.\  $NetBSD: od.1,v 1.23 2008/09/03 16:32:57 drochner Exp $
+.\  $NetBSD: od.1,v 1.24 2010/02/09 14:06:37 drochner Exp $
 .\
 .\ Copyright (c) 2001 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -56,26 +56,6 @@
 .Oc
 .Ar file ...
 .Sh DESCRIPTION
-.Nm
-has been deprecated in favor of
-.Xr hexdump 1 .
-.Pp
-.Xr hexdump 1 ,
-if called as
-.Nm ,
-provides compatibility for the options described below.
-It does not provide compatibility for the
-.Fl s
-option (see
-.Xr strings 1 )
-or the
-.Fl P ,
-.Fl p ,
-or
-.Fl w
-options, nor is compatibility provided for the ``label'' 

CVS commit: src/usr.bin/hexdump

2009-10-14 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Wed Oct 14 17:44:59 UTC 2009

Modified Files:
src/usr.bin/hexdump: hexdump.1

Log Message:
Do not use .Xo/.Xc to workaround ancient groff limits.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/hexdump/hexdump.1

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.1
diff -u src/usr.bin/hexdump/hexdump.1:1.18 src/usr.bin/hexdump/hexdump.1:1.19
--- src/usr.bin/hexdump/hexdump.1:1.18	Thu Aug  7 11:14:03 2003
+++ src/usr.bin/hexdump/hexdump.1	Wed Oct 14 17:44:59 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: hexdump.1,v 1.18 2003/08/07 11:14:03 agc Exp $
+.\	$NetBSD: hexdump.1,v 1.19 2009/10/14 17:44:59 joerg Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -251,13 +251,9 @@
 .Bl -tag -width  Xc,_Xc,_Xc,_Xc,_Xc,_Xc -offset indent
 .It Li \%_c , \%_p , \%_u , \%c
 One byte counts only.
-.It Xo
-.Li \%d , \%i , \%o , \%u , \%X , \%x
-.Xc
+.It Li \%d , \%i , \%o , \%u , \%X , \%x
 Four byte default, one, two, four and eight byte counts supported.
-.It Xo
-.Li \%E , \%e , \%f , \%G , \%g
-.Xc
+.It Li \%E , \%e , \%f , \%G , \%g
 Eight byte default, four byte counts supported.
 .El
 .Pp