Skip to content

Commit

Permalink
od: duplicate marker incorrectly repeats (#498)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
mknos committed Mar 13, 2024
1 parent fb58e9b commit 2289976
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bin/od
Expand Up @@ -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;
Expand Down

0 comments on commit 2289976

Please sign in to comment.