From 9bfabc294132adbb34bb0c4776fd1f606ab501fa Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 17 Jun 2022 17:23:51 -0500 Subject: [PATCH] Make xxd pass TEST_HOST, and fix rounding error in xxd spacing that diverged. --- tests/xxd.test | 2 +- toys/other/xxd.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/xxd.test b/tests/xxd.test index 37061e89..d4ae10b8 100755 --- a/tests/xxd.test +++ b/tests/xxd.test @@ -22,7 +22,7 @@ testing "xxd" "xxd" \ testing "-c 8 -g 4 file1" "xxd -c 8 -g 4 file1" \ "00000000: 74686973 20697320 this is \n00000008: 736f6d65 20746578 some tex\n00000010: 740a t.\n" "" "" testing "-c 8 -g 3 file1" "xxd -c 8 -g 3 file1" \ - "00000000: 746869 732069 7320 this is \n00000008: 736f6d 652074 6578 some tex\n00000010: 740a t.\n" "" "" + "00000000: 746869 732069 7320 this is \n00000008: 736f6d 652074 6578 some tex\n00000010: 740a t.\n" "" "" testing "-i" "cat file1 | xxd -i -" " 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x73, 0x6f, 0x6d, 0x65,\n 0x20, 0x74, 0x65, 0x78, 0x74, 0x0a\n" "" "" diff --git a/toys/other/xxd.c b/toys/other/xxd.c index fba78bca..70b95d4c 100644 --- a/toys/other/xxd.c +++ b/toys/other/xxd.c @@ -55,7 +55,7 @@ static void do_xxd(int fd, char *name) { if (!FLAG(p)) printf("%08llx: ", TT.o + pos); pos += len; - space = 2*TT.c+TT.c/TT.g+1; + space = 2*TT.c+(TT.c+TT.g-1)/TT.g+1; for (i=0; i=' ' && toybuf[i]<='~') ? toybuf[i] : '.'); } putchar('\n'); -- 2.39.2