Trying again.
--
"No data yet," he answered. "It is a capital mistake to theorize before you
have all the evidence. It biases the judgement."
by Arthur Conan Doyle via his character Sherlock Holmes
>From 1050d721f389146fe8b02eb1da9ff5dd8594ef97 Mon Sep 17 00:00:00 2001
From: Greg Reagle <greg.rea...@umbc.edu>
Date: Fri, 2 Oct 2015 02:54:00 -0400
Subject: [PATCH] od: added options -b and -d; bug fix affecting size C
---
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
@@ -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
@@ -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
@@ -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
@@ -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);
}
@@ -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
@@ -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