aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@tigress.co.uk>2015-03-12 20:10:40 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2015-03-12 20:11:48 +0100
commit53e9c51aded0af85c33d657143ed94c5151ba6f3 (patch)
treeb58ca53b2200137dc23a52d292e7ad2ee213dd73
parent8dff01d06a7ebd7330e3a1dd1ba47b3c74ee7dfb (diff)
downloadbusybox-w32-53e9c51aded0af85c33d657143ed94c5151ba6f3.tar.gz
busybox-w32-53e9c51aded0af85c33d657143ed94c5151ba6f3.tar.bz2
busybox-w32-53e9c51aded0af85c33d657143ed94c5151ba6f3.zip
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>
-rw-r--r--coreutils/od_bloaty.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c
index 2c26dda16..ab7ea997d 100644
--- a/coreutils/od_bloaty.c
+++ b/coreutils/od_bloaty.c
@@ -387,11 +387,11 @@ print_named_ascii(size_t n_bytes, const char *block,
387 " sp" 387 " sp"
388 }; 388 };
389 // buf[N] pos: 01234 56789 389 // buf[N] pos: 01234 56789
390 char buf[12] = " x\0 0xx\0"; 390 char buf[12] = " x\0 xxx\0";
391 // actually " x\0 xxx\0", but want to share string with print_ascii.
392 // [12] because we take three 32bit stack slots anyway, and 391 // [12] because we take three 32bit stack slots anyway, and
393 // gcc is too dumb to initialize with constant stores, 392 // gcc is too dumb to initialize with constant stores,
394 // it copies initializer from rodata. Oh well. 393 // it copies initializer from rodata. Oh well.
394 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65410
395 395
396 while (n_bytes--) { 396 while (n_bytes--) {
397 unsigned masked_c = *(unsigned char *) block++; 397 unsigned masked_c = *(unsigned char *) block++;
@@ -419,7 +419,7 @@ print_ascii(size_t n_bytes, const char *block,
419 const char *unused_fmt_string UNUSED_PARAM) 419 const char *unused_fmt_string UNUSED_PARAM)
420{ 420{
421 // buf[N] pos: 01234 56789 421 // buf[N] pos: 01234 56789
422 char buf[12] = " x\0 0xx\0"; 422 char buf[12] = " x\0 xxx\0";
423 423
424 while (n_bytes--) { 424 while (n_bytes--) {
425 const char *s; 425 const char *s;
@@ -455,11 +455,9 @@ print_ascii(size_t n_bytes, const char *block,
455 case '\v': 455 case '\v':
456 s = " \\v"; 456 s = " \\v";
457 break; 457 break;
458 case '\x7f': 458 default:
459 s = " 177"; 459 buf[6] = (c >> 6 & 3) + '0';
460 break; 460 buf[7] = (c >> 3 & 7) + '0';
461 default: /* c is never larger than 040 */
462 buf[7] = (c >> 3) + '0';
463 buf[8] = (c & 7) + '0'; 461 buf[8] = (c & 7) + '0';
464 s = buf + 5; 462 s = buf + 5;
465 } 463 }