From f96dd9122277a1265e4b54ee1adbd6f56192122b Mon Sep 17 00:00:00 2001 From: Michael Mikonos <127171689+mknos@users.noreply.github.com> Date: Tue, 26 Dec 2023 22:08:40 +0800 Subject: [PATCH] od: fix line offsets * Byte offsets were broken in a previous commit * $offset1 is advanced by -j SKIP_BYTES; otherwise it counts from zero * Advance $offset1 only after successfully printing a line of output (this does not affect $is_limit) * At EOF, $offset1 is advanced by the remaining bytes; length($data) is correct %perl od -c od | head -n1 00000017 # ! / u s r / b i n / p e r l \n %od -c od | head -n1 0000000 # ! / u s r / b i n / p e r l \n --- bin/od | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/od b/bin/od index a9ba16ee..0695cb5f 100755 --- a/bin/od +++ b/bin/od @@ -156,10 +156,9 @@ while ($len = read($fh, $buf, 1)) { print "*\n"; } $lastline = $data . '|'; + $offset1 += length $data; undef $data; } - - $offset1++; last if $is_limit; } unless (defined $len) {