Skip to content

Commit

Permalink
diff: empty files are the same (#578)
Browse files Browse the repository at this point in the history
* Test case: "touch empty && perl diff empty empty"
* Program seems to hang; ctrl-c in perl debugger hints that we are stuck in Algorithm::Diff::traverse_sequences()
* Program grew to use >2GB of memory before I killed it
* traverse_sequences() doesn't seem to handle when both lists of input lines are empty (I didn't bother investigating why)
* Put a sanity check before diff()+traverse_sequences() are called; input files are read in total before diff() so the size of line list is know
* I also tested a non-empty file against an empty one
  • Loading branch information
mknos committed Apr 26, 2024
1 parent b8e3715 commit 235f16a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions bin/diff
Expand Up @@ -145,6 +145,7 @@ chomp(@f1 = <$fh1>);
close $fh1;
chomp(@f2 = <$fh2>);
close $fh2;
exit(EX_SUCCESS) if (scalar(@f1) == 0 && scalar(@f2) == 0);

# diff yields lots of pieces, each of which is basically a Block object
my $diffs = diff(\@f1, \@f2);
Expand Down

0 comments on commit 235f16a

Please sign in to comment.