diff options
author | Ron Yorston <rmy@pobox.com> | 2014-12-05 14:42:18 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2014-12-05 14:42:18 +0000 |
commit | bec486664a470cafb655fa62627784ad27fa4c67 (patch) | |
tree | 22bd2208fdf4acd0af0f16cfc4ad698b44db70f0 /coreutils | |
parent | a85d49580e2c1251d7ea9eebad672f802d82ec40 (diff) | |
download | busybox-w32-bec486664a470cafb655fa62627784ad27fa4c67.tar.gz busybox-w32-bec486664a470cafb655fa62627784ad27fa4c67.tar.bz2 busybox-w32-bec486664a470cafb655fa62627784ad27fa4c67.zip |
od: print valid octal values with -c flag
For characters with the top bit set od_bloaty produces silly octal
values with the -c flag:
$ echo £ | busybox od -c # od_bloaty.c (CONFIG_DESKTOP set)
0000000 0H2 0D3 \n
0000003
$ echo £ | busybox od -c # od.c (CONFIG_DESKTOP not set)
0000000 302 243 \n
0000003
$ echo £ | od -c # coreutils
0000000 302 243 \n
0000003
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/od_bloaty.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c index c4d11601f..34ceefb1c 100644 --- a/coreutils/od_bloaty.c +++ b/coreutils/od_bloaty.c | |||
@@ -394,8 +394,8 @@ print_named_ascii(size_t n_bytes, const char *block, | |||
394 | " sp" | 394 | " sp" |
395 | }; | 395 | }; |
396 | // buf[N] pos: 01234 56789 | 396 | // buf[N] pos: 01234 56789 |
397 | char buf[12] = " x\0 0xx\0"; | 397 | char buf[12] = " x\0 xxx\0"; |
398 | // actually " x\0 xxx\0", but want to share string with print_ascii. | 398 | // share string with print_ascii. |
399 | // [12] because we take three 32bit stack slots anyway, and | 399 | // [12] because we take three 32bit stack slots anyway, and |
400 | // gcc is too dumb to initialize with constant stores, | 400 | // gcc is too dumb to initialize with constant stores, |
401 | // it copies initializer from rodata. Oh well. | 401 | // it copies initializer from rodata. Oh well. |
@@ -426,7 +426,7 @@ print_ascii(size_t n_bytes, const char *block, | |||
426 | const char *unused_fmt_string UNUSED_PARAM) | 426 | const char *unused_fmt_string UNUSED_PARAM) |
427 | { | 427 | { |
428 | // buf[N] pos: 01234 56789 | 428 | // buf[N] pos: 01234 56789 |
429 | char buf[12] = " x\0 0xx\0"; | 429 | char buf[12] = " x\0 xxx\0"; |
430 | 430 | ||
431 | while (n_bytes--) { | 431 | while (n_bytes--) { |
432 | const char *s; | 432 | const char *s; |
@@ -465,8 +465,9 @@ print_ascii(size_t n_bytes, const char *block, | |||
465 | case '\x7f': | 465 | case '\x7f': |
466 | s = " 177"; | 466 | s = " 177"; |
467 | break; | 467 | break; |
468 | default: /* c is never larger than 040 */ | 468 | default: |
469 | buf[7] = (c >> 3) + '0'; | 469 | buf[6] = (c >> 6 & 3) + '0'; |
470 | buf[7] = (c >> 3 & 7) + '0'; | ||
470 | buf[8] = (c & 7) + '0'; | 471 | buf[8] = (c & 7) + '0'; |
471 | s = buf + 5; | 472 | s = buf + 5; |
472 | } | 473 | } |