diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2023-05-26 13:33:08 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2023-05-26 13:33:08 +0200 |
commit | de851bc9b2dcf3f5fad424172d08e850c8af7d62 (patch) | |
tree | d178ffb04bd9c99cb000b1811622caa2dd800ac1 | |
parent | 25a10ffe1fcec1adc40d91d1f4ddfdf7fe12cc74 (diff) | |
download | busybox-w32-de851bc9b2dcf3f5fad424172d08e850c8af7d62.tar.gz busybox-w32-de851bc9b2dcf3f5fad424172d08e850c8af7d62.tar.bz2 busybox-w32-de851bc9b2dcf3f5fad424172d08e850c8af7d62.zip |
od, hexdump: byte 0x11 is "dc1" not "dcl"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | libbb/dump.c | 6 | ||||
-rwxr-xr-x | testsuite/hexdump.tests | 16 | ||||
-rwxr-xr-x | testsuite/od.tests | 32 |
3 files changed, 45 insertions, 9 deletions
diff --git a/libbb/dump.c b/libbb/dump.c index 21c6c7083..fc145edf9 100644 --- a/libbb/dump.c +++ b/libbb/dump.c | |||
@@ -516,10 +516,12 @@ static void conv_u(PR *pr, unsigned char *p) | |||
516 | static const char list[] ALIGN1 = | 516 | static const char list[] ALIGN1 = |
517 | "nul\0soh\0stx\0etx\0eot\0enq\0ack\0bel\0" | 517 | "nul\0soh\0stx\0etx\0eot\0enq\0ack\0bel\0" |
518 | "bs\0_ht\0_lf\0_vt\0_ff\0_cr\0_so\0_si\0_" | 518 | "bs\0_ht\0_lf\0_vt\0_ff\0_cr\0_so\0_si\0_" |
519 | "dle\0dcl\0dc2\0dc3\0dc4\0nak\0syn\0etb\0" | 519 | "dle\0dc1\0dc2\0dc3\0dc4\0nak\0syn\0etb\0" |
520 | "can\0em\0_sub\0esc\0fs\0_gs\0_rs\0_us"; | 520 | "can\0em\0_sub\0esc\0fs\0_gs\0_rs\0_us"; |
521 | /* NB: bug: od uses %_u to implement -a, | ||
522 | * but it should use "nl", not "lf", for char #10. | ||
523 | */ | ||
521 | 524 | ||
522 | /* od used nl, not lf */ | ||
523 | if (*p <= 0x1f) { | 525 | if (*p <= 0x1f) { |
524 | *pr->cchar = 's'; | 526 | *pr->cchar = 's'; |
525 | printf(pr->fmt, list + (4 * (int)*p)); | 527 | printf(pr->fmt, list + (4 * (int)*p)); |
diff --git a/testsuite/hexdump.tests b/testsuite/hexdump.tests index cfb20187e..084156af4 100755 --- a/testsuite/hexdump.tests +++ b/testsuite/hexdump.tests | |||
@@ -34,4 +34,20 @@ testing "hexdump thinks last full block can match" \ | |||
34 | '' \ | 34 | '' \ |
35 | '\0\0\0\0\0\0\0\0\0\0\0\0' | 35 | '\0\0\0\0\0\0\0\0\0\0\0\0' |
36 | 36 | ||
37 | testing "hexdump e %3_u" \ | ||
38 | "hexdump -e '16/1 \" %3_u\" \"\n\"'" \ | ||
39 | "\ | ||
40 | nul soh stx etx eot enq ack bel bs ht lf vt ff cr so si | ||
41 | dle dc1 dc2 dc3 dc4 nak syn etb can em sub esc fs gs rs us | ||
42 | p q r s t u v w x y z { | } ~ del | ||
43 | 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f | ||
44 | f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff | ||
45 | " \ | ||
46 | "" \ | ||
47 | "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"\ | ||
48 | "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"\ | ||
49 | "\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"\ | ||
50 | "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"\ | ||
51 | "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"\ | ||
52 | |||
37 | exit $FAILCOUNT | 53 | exit $FAILCOUNT |
diff --git a/testsuite/od.tests b/testsuite/od.tests index 677968967..fce66efbb 100755 --- a/testsuite/od.tests +++ b/testsuite/od.tests | |||
@@ -26,21 +26,39 @@ optional !DESKTOP | |||
26 | testing "od -a (!DESKTOP)" \ | 26 | testing "od -a (!DESKTOP)" \ |
27 | "od -a" \ | 27 | "od -a" \ |
28 | "\ | 28 | "\ |
29 | 0000000 soh stx etx lf A B C fe | 29 | 0000000 nul soh stx etx eot enq ack bel bs ht lf vt ff cr so si |
30 | 0000010 | 30 | 0000020 dle dc1 dc2 dc3 dc4 nak syn etb can em sub esc fs gs rs us |
31 | 0000040 p q r s t u v w x y z { | } ~ del | ||
32 | 0000060 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f | ||
33 | 0000100 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff | ||
34 | 0000120 | ||
31 | " \ | 35 | " \ |
32 | "" "$input" | 36 | "" \ |
37 | "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"\ | ||
38 | "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"\ | ||
39 | "\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"\ | ||
40 | "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"\ | ||
41 | "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff" | ||
33 | SKIP= | 42 | SKIP= |
34 | # ^^^ a bit incorrect handling of ctrl/high bytes. | 43 | # ^^^ a bit incorrect handling of ctrl ("lf" should be "nl") and high bytes. |
35 | # vvv this output is correct. | 44 | # vvv this output is correct. |
36 | optional DESKTOP | 45 | optional DESKTOP |
37 | testing "od -a (DESKTOP)" \ | 46 | testing "od -a (DESKTOP)" \ |
38 | "od -a" \ | 47 | "od -a" \ |
39 | "\ | 48 | "\ |
40 | 0000000 soh stx etx nl A B C ~ | 49 | 0000000 nul soh stx etx eot enq ack bel bs ht nl vt ff cr so si |
41 | 0000010 | 50 | 0000020 dle dc1 dc2 dc3 dc4 nak syn etb can em sub esc fs gs rs us |
51 | 0000040 p q r s t u v w x y z { | } ~ del | ||
52 | 0000060 nul soh stx etx eot enq ack bel bs ht nl vt ff cr so si | ||
53 | 0000100 p q r s t u v w x y z { | } ~ del | ||
54 | 0000120 | ||
42 | " \ | 55 | " \ |
43 | "" "$input" | 56 | "" \ |
57 | "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"\ | ||
58 | "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"\ | ||
59 | "\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"\ | ||
60 | "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"\ | ||
61 | "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff" | ||
44 | SKIP= | 62 | SKIP= |
45 | 63 | ||
46 | testing "od -B" \ | 64 | testing "od -B" \ |