od: For the 'c' type, format non-printable charecters as octal
This is the behavior specified by POSIX.
This commit is contained in:
parent
f83c468b55
commit
d098ac4abc
3
od.c
3
od.c
|
@ -1,4 +1,5 @@
|
||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
#include <ctype.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -69,6 +70,8 @@ printchunk(const unsigned char *s, unsigned char format, size_t len)
|
||||||
case 'c':
|
case 'c':
|
||||||
if (strchr("\a\b\t\n\v\f\r\0", *s)) {
|
if (strchr("\a\b\t\n\v\f\r\0", *s)) {
|
||||||
printf(" %3s", escdict[*s]);
|
printf(" %3s", escdict[*s]);
|
||||||
|
} else if (!isprint(*s)) {
|
||||||
|
printf(" %3o", *s);
|
||||||
} else {
|
} else {
|
||||||
printf(" %3c", *s);
|
printf(" %3c", *s);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user