sbase

suckless unix tools
git clone git://git.suckless.org/sbase
Log | Files | Refs | README | LICENSE

commit d098ac4abc805d6bdfc2b331de4633d7bda03b00
parent f83c468b558d87ca27e99d7d8559eec3281a33c6
Author: Michael Forney <mforney@mforney.org>
Date:   Sun, 25 Feb 2018 22:56:07 -0800

od: For the 'c' type, format non-printable charecters as octal

This is the behavior specified by POSIX.

Diffstat:
Mod.c | 3+++
1 file changed, 3 insertions(+), 0 deletions(-)

diff --git a/od.c b/od.c @@ -1,4 +1,5 @@ /* See LICENSE file for copyright and license details. */ +#include <ctype.h> #include <fcntl.h> #include <stdint.h> #include <stdio.h> @@ -69,6 +70,8 @@ printchunk(const unsigned char *s, unsigned char format, size_t len) case 'c': if (strchr("\a\b\t\n\v\f\r\0", *s)) { printf(" %3s", escdict[*s]); + } else if (!isprint(*s)) { + printf(" %3o", *s); } else { printf(" %3c", *s); }