od: fix printing of high-bit chars
Example: echo £ | od -c Signed-off-by: Ron Yorston <rmy@tigress.co.uk> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
8dff01d06a
commit
53e9c51ade
@ -387,11 +387,11 @@ print_named_ascii(size_t n_bytes, const char *block,
|
|||||||
" sp"
|
" sp"
|
||||||
};
|
};
|
||||||
// buf[N] pos: 01234 56789
|
// buf[N] pos: 01234 56789
|
||||||
char buf[12] = " x\0 0xx\0";
|
char buf[12] = " x\0 xxx\0";
|
||||||
// actually " x\0 xxx\0", but want to share string with print_ascii.
|
|
||||||
// [12] because we take three 32bit stack slots anyway, and
|
// [12] because we take three 32bit stack slots anyway, and
|
||||||
// gcc is too dumb to initialize with constant stores,
|
// gcc is too dumb to initialize with constant stores,
|
||||||
// it copies initializer from rodata. Oh well.
|
// it copies initializer from rodata. Oh well.
|
||||||
|
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65410
|
||||||
|
|
||||||
while (n_bytes--) {
|
while (n_bytes--) {
|
||||||
unsigned masked_c = *(unsigned char *) block++;
|
unsigned masked_c = *(unsigned char *) block++;
|
||||||
@ -419,7 +419,7 @@ print_ascii(size_t n_bytes, const char *block,
|
|||||||
const char *unused_fmt_string UNUSED_PARAM)
|
const char *unused_fmt_string UNUSED_PARAM)
|
||||||
{
|
{
|
||||||
// buf[N] pos: 01234 56789
|
// buf[N] pos: 01234 56789
|
||||||
char buf[12] = " x\0 0xx\0";
|
char buf[12] = " x\0 xxx\0";
|
||||||
|
|
||||||
while (n_bytes--) {
|
while (n_bytes--) {
|
||||||
const char *s;
|
const char *s;
|
||||||
@ -455,11 +455,9 @@ print_ascii(size_t n_bytes, const char *block,
|
|||||||
case '\v':
|
case '\v':
|
||||||
s = " \\v";
|
s = " \\v";
|
||||||
break;
|
break;
|
||||||
case '\x7f':
|
default:
|
||||||
s = " 177";
|
buf[6] = (c >> 6 & 3) + '0';
|
||||||
break;
|
buf[7] = (c >> 3 & 7) + '0';
|
||||||
default: /* c is never larger than 040 */
|
|
||||||
buf[7] = (c >> 3) + '0';
|
|
||||||
buf[8] = (c & 7) + '0';
|
buf[8] = (c & 7) + '0';
|
||||||
s = buf + 5;
|
s = buf + 5;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user