svn commit: trunk/busybox: include util-linux

pgf at busybox.net pgf at busybox.net
Mon Nov 28 21:06:02 UTC 2005


Author: pgf
Date: 2005-11-28 13:06:00 -0800 (Mon, 28 Nov 2005)
New Revision: 12560

Log:
add "-C" format to hexdump

fixes bug #113 and satisfies a personal need at the same time.

output compares identically to util-linux version.  (with
exception of whitespace differences on last lines of output with
non-uniform length, which are neither fixed nor worsened by this
change.)



Modified:
   trunk/busybox/include/usage.h
   trunk/busybox/util-linux/hexdump.c


Changeset:
Modified: trunk/busybox/include/usage.h
===================================================================
--- trunk/busybox/include/usage.h	2005-11-28 18:07:53 UTC (rev 12559)
+++ trunk/busybox/include/usage.h	2005-11-28 21:06:00 UTC (rev 12560)
@@ -1087,13 +1087,14 @@
 	"daemon:x:1:1:daemon:/usr/sbin:/bin/sh\n"
 
 #define hexdump_trivial_usage \
-	"[-[bcdefnosvx]] [OPTION] FILE"
+	"[-[bcCdefnosvx]] [OPTION] FILE"
 #define hexdump_full_usage \
 	"The hexdump utility is a filter which displays the specified files,\n" \
 	"or the standard input, if no files are specified, in a user specified\n" \
 	"format\n" \
 	"\t-b\t\tOne-byte octal display\n" \
 	"\t-c\t\tOne-byte character display\n" \
+	"\t-C\t\tCanonical hex+ASCII, 16 bytes per line\n" \
 	"\t-d\t\tTwo-byte decimal display\n" \
 	"\t-e FORMAT STRING\n" \
 	"\t-f FORMAT FILE\n" \

Modified: trunk/busybox/util-linux/hexdump.c
===================================================================
--- trunk/busybox/util-linux/hexdump.c	2005-11-28 18:07:53 UTC (rev 12559)
+++ trunk/busybox/util-linux/hexdump.c	2005-11-28 21:06:00 UTC (rev 12560)
@@ -57,7 +57,7 @@
 
 static const char add_first[] = "\"%07.7_Ax\n\"";
 
-static const char hexdump_opts[] = "bcdoxe:f:n:s:v";
+static const char hexdump_opts[] = "bcdoxCe:f:n:s:v";
 
 static const struct suffix_mult suffixes[] = {
 	{"b",  512 },
@@ -80,6 +80,10 @@
 			if ((p - hexdump_opts) < 5) {
 				bb_dump_add(add_first);
 				bb_dump_add(add_strings[(int)(p - hexdump_opts)]);
+			} else if (ch == 'C') {
+			        bb_dump_add("\"%08.8_Ax\n\"");
+				bb_dump_add("\"%08.8_ax  \" 8/1 \"%02x \" \"  \" 8/1 \"%02x \" ");
+			        bb_dump_add("\"  |\" 16/1 \"%_p\" \"|\\n\"");
 			} else {
 				/* Sae a little bit of space below by omitting the 'else's. */
 				if (ch == 'e') {




More information about the busybox-cvs mailing list