Subject: bin/5017: The -C option to hexdump
To: None <gnats-bugs@gnats.netbsd.org>
From: None <jnilsson@ludd.luth.se>
List: netbsd-bugs
Date: 02/19/1998 12:12:25
>Number:         5017
>Category:       bin
>Synopsis:       improvement of hexdump
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 19 03:20:00 1998
>Last-Modified:
>Originator:     Jens A Nilsson
>Organization:
>Release:        NetBSD-1.3
>Environment:
	
System: NetBSD subzero 1.3 NetBSD 1.3 (SUBZERO) #7: Thu Jan 29 14:16:22 CET 1998 jens@subzero:/u1/NetBSD-src/sys/arch/i386/compile/SUBZERO i386


>Description:
	Hexdump has a nice option in FreeBSD '-C' it would be nice to have
    in the NetBSD hexdump to.
>How-To-Repeat:
	
>Fix:
	Here is the diff -u to implement '-C' option to hexdump.

diff -u /usr/src/usr.bin/hexdump/hexdump.1 hexdump-patch/hexdump.1
--- /usr/src/usr.bin/hexdump/hexdump.1  Sun Oct 19 16:18:53 1997
+++ hexdump-patch/hexdump.1     Wed Feb 18 16:22:18 1998
@@ -41,7 +41,7 @@
 .Nd ascii, decimal, hexadecimal, octal dump
 .Sh SYNOPSIS
 .Nm
-.Op Fl bcdovx
+.Op Fl bcCdovx
 .Op Fl e Ar format_string
 .Op Fl f Ar format_file
 .Op Fl n Ar length
@@ -66,6 +66,11 @@
 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
diff -u /usr/src/usr.bin/hexdump/hexsyntax.c hexdump-patch/hexsyntax.c
--- /usr/src/usr.bin/hexdump/hexsyntax.c        Sun Oct 19 16:18:55 1997
+++ hexdump-patch/hexsyntax.c   Wed Feb 18 16:14:59 1998
@@ -63,7 +63,7 @@
        char *p, **argv;
 
        argv = *argvp;
-       while ((ch = getopt(argc, argv, "bcde:f:n:os:vx")) != -1)
+       while ((ch = getopt(argc, argv, "bcCde:f:n:os:vx")) != -1)
                switch (ch) {
                case 'b':
                        add("\"%07.7_Ax\n\"");
@@ -72,6 +72,11 @@
                case 'c':
                        add("\"%07.7_Ax\n\"");
                        add("\"%07.7_ax \" 16/1 \"%3_c \" \"\\n\"");
+                       break;
+               case 'C':
+                       add("\"%08.8_Ax\n\"");
+                       add("\"%08.8_ax  \" 8/1 \"%02x \" \"  \" 8/1 \"%02x \" "
);
+                       add("\"  |\" 16/1 \"%_p\" \"|\\n\"");
                        break;
                case 'd':
                        add("\"%07.7_Ax\n\"");

>Audit-Trail:
>Unformatted: