[PATCH] od: added options -b and -d; bug fix affecting size C

From: Greg Reagle <greg.reagle_AT_umbc.edu>
Date: Fri, 2 Oct 2015 02:54:00 -0400

---
 od.1 |   22 ++++++++++++++--------
 od.c |   14 ++++++++++++--
 2 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/od.1 b/od.1
index b47d752..cd65a94 100644
--- a/od.1
+++ b/od.1
_AT_@ -7,6 +7,8 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl A Ar d|o|x|n
+.Op Fl b
+.Op Fl d
 .Op Fl t Ar a|c|d|o|u|x
 .Op Fl v
 .Op Fl j Ar skip
_AT_@ -26,6 +28,18 @@ reads from stdin.
 .It Fl A Ar d|o|x|n
 Display the address in base \fId\fRecimal | \fIo\fRctal |
 he\fIx\fRadecimal | \fIn\fRone.  If unspecified, the default is octal.
+.It Fl b
+Same as -t oC
+.It Fl d
+Same as -t uS
+.It Fl j Ar skip
+Ignore the first
+.Ar skip
+bytes.
+.It Fl N Ar count
+Process at most
+.Ar count
+bytes.
 .It Fl t Ar a|c|d|o|u|x
 Display the content as n\fIa\fRmed character, \fIc\fRharacter, signed
 \fId\fRecimal, \fIo\fRctal, \fIu\fRnsigned decimal, or
_AT_@ -35,12 +49,4 @@ Another character is optional indicating size of \fIC\fRhar, \fII\fRnt,
 char for types a or c.
 .It Fl v
 Always set. Write all input data, including duplicate lines.
-.It Fl j Ar skip
-Ignore the first
-.Ar skip
-bytes.
-.It Fl N Ar count
-Process at most
-.Ar count
-bytes.
 .El
diff --git a/od.c b/od.c
index 1ab1ea3..ec89528 100644
--- a/od.c
+++ b/od.c
_AT_@ -120,7 +120,9 @@ od(FILE *in, char *in_name, FILE *out, char *out_name)
 			printaddress(out, addr);
 		}
 		value[counter % incr] = buf[0];
-		if ( ((counter % incr) == (incr - 1)) && counter) {
+		if (incr == 1)
+			printvalue(out, value);
+		else if ( ((counter % incr) == (incr - 1)) && counter) {
 			printvalue(out, value);
 			clear(value, incr);
 		}
_AT_@ -141,7 +143,7 @@ od(FILE *in, char *in_name, FILE *out, char *out_name)
 static void
 usage(void)
 {
-	eprintf("usage: %s [-A d|o|x|n] [-t a|c|d|o|u|x] [-v] [file ...]\n", argv0);
+	eprintf("usage: %s [-A d|o|x|n] [-b|-d|-t a|c|d|o|u|x] [-v] [file ...]\n", argv0);
 }
 
 int
_AT_@ -166,6 +168,14 @@ main(int argc, char *argv[])
 		if ((maxbytes = parseoffset(EARGF(usage()))) < 0)
 			return 1;
 		break;
+	case 'b':
+		type = 'o';
+		size = 'C';
+		break;
+	case 'd':
+		type = 'u';
+		size = 'S';
+		break;
 	case 't':
 		s = EARGF(usage());
 		if (strlen(s) < 1 || strlen(s) > 2 || !strchr("acdoux", s[0]))
-- 
1.7.10.4
--------------070706070105090904000802--
Received on Mon Sep 17 2001 - 00:00:00 CEST

This archive was generated by hypermail 2.3.0 : Fri Oct 02 2015 - 09:12:10 CEST