From 22899763ba50ba9ed89122a89695f34f230f8060 Mon Sep 17 00:00:00 2001 From: Michael Mikonos <127171689+mknos@users.noreply.github.com> Date: Wed, 13 Mar 2024 09:59:42 +0800 Subject: [PATCH] od: duplicate marker incorrectly repeats (#498) * I noticed the duplicate line identifier "*\n" was repeated for each duplicate line, instead of being printed only once * In dump_line() the variable $ml had no effect; possibly it was broken by previous changes * Make $ml a flag which is set when previous line was duplicate and we already printed "*\n"; flag is set until a line differs * With this patch, output is equivalent when dumping /dev/zero on OpenBSD and Linux %dd if=/dev/zero bs=1000 count=1 2> /dev/null | perl od -c 00000000 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 * 00001740 \0 \0 \0 \0 \0 \0 \0 \0 00001750 --- bin/od | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/od b/bin/od index 332900eb..cb203ad0 100755 --- a/bin/od +++ b/bin/od @@ -142,15 +142,15 @@ sub emit_offset { } sub dump_line { - $ml = ''; # multi-line indention if (&diffdata || $opt_v) { emit_offset(); &$fmt; - printf("%s$strfmt\n", $ml, @arr); - $ml = ' ' x 9; + printf "$strfmt\n", @arr; + $ml = 0; } else { - print "*\n"; + print "*\n" unless $ml; + $ml = 1; } $lastline = $data . '|'; $offset1 += length $data;