od: Don't modify bytes in the line for the 'a' type

Subsequent types should still print the full 8-bit value.
This commit is contained in:
Michael Forney 2018-02-25 12:56:36 -08:00
parent 1ff2a54e8f
commit f83c468b55

13
od.c
View File

@ -36,11 +36,12 @@ printaddress(off_t addr)
} }
static void static void
printchunk(unsigned char *s, unsigned char format, size_t len) printchunk(const unsigned char *s, unsigned char format, size_t len)
{ {
long long res, basefac; long long res, basefac;
size_t i; size_t i;
char fmt[] = " %#*ll#"; char fmt[] = " %#*ll#";
unsigned char c;
const char *namedict[] = { const char *namedict[] = {
"nul", "soh", "stx", "etx", "eot", "enq", "ack", "nul", "soh", "stx", "etx", "eot", "enq", "ack",
@ -58,11 +59,11 @@ printchunk(unsigned char *s, unsigned char format, size_t len)
switch (format) { switch (format) {
case 'a': case 'a':
*s &= ~128; /* clear high bit as required by standard */ c = *s & ~128; /* clear high bit as required by standard */
if (*s < LEN(namedict) || *s == 127) { if (c < LEN(namedict) || c == 127) {
printf(" %3s", (*s == 127) ? "del" : namedict[*s]); printf(" %3s", (c == 127) ? "del" : namedict[c]);
} else { } else {
printf(" %3c", *s); printf(" %3c", c);
} }
break; break;
case 'c': case 'c':
@ -91,7 +92,7 @@ printchunk(unsigned char *s, unsigned char format, size_t len)
} }
static void static void
printline(unsigned char *line, size_t len, off_t addr) printline(const unsigned char *line, size_t len, off_t addr)
{ {
struct type *t = NULL; struct type *t = NULL;
size_t i; size_t i;