Skip to content

Commit 3dacf1f

Browse files
committed
Fixing some errors in the compare logic and argument validation
1 parent 5ee7fa1 commit 3dacf1f

File tree

1 file changed

+31
-16
lines changed

1 file changed

+31
-16
lines changed

tests/diff_hypermail_archives.pl

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ sub filter_filenames {
121121
foreach my $regex (@ignore_files_regex) {
122122
if ($filename =~ m/$regex/) {
123123
$res = 1;
124-
print "$filename is ignored per regex: " . $regex . "\n" unless $quiet;
124+
print "$filename is ignored per regex: " . $regex . "\n" if $debug && !$quiet;
125125
}
126126
}
127127

@@ -192,17 +192,32 @@ sub diff_files_complete {
192192
# things that changed are the version number and/or the
193193
# generation date. We ignore the rest of the diff output at
194194
# this point.
195-
if ($line =~ /\d+c\d+/) {
196-
if (!$is_attachment_dir) {
197-
my ($ln_1, $ln_2) = split /c/, $line, 2;
198-
199-
if ($ln_1 eq $ln_2 && %{ $generated_by_lines }) {
200-
if ($ignore_footer) {
201-
if ($ln_1 >= $footer_line) {
195+
if ($line =~ /^\d/) {
196+
if ($line =~ /\d+c\d+/) {
197+
if (!$is_attachment_dir) {
198+
my ($ln_1, $ln_2) = split /c/, $line;
199+
200+
# if we have diffs in a series of sequential lines
201+
my ($ln_1_1, $ln_1_2) = split /,/, $ln_1;
202+
my ($ln_2_1, $ln_2_2) = split /,/, $ln_2;
203+
204+
if (%{ $generated_by_lines }
205+
&& (defined $ln_1_2 && defined $ln_2_2
206+
&& ($ln_1_2 - $ln_1_1) == ($ln_2_1 - $ln_1_1))
207+
|| (defined $ln_1_1 && defined $ln_2_1
208+
&& !defined $ln_1_2 && !defined $ln_2_2)) {
209+
210+
if ($ignore_footer) {
211+
if ($ln_1_1 >= $footer_line) {
212+
last;
213+
}
214+
} elsif ((!defined $ln_1_2
215+
&& $$generated_by_lines{$ln_1_1})
216+
|| (defined $ln_1_2
217+
&& $$generated_by_lines{$ln_1_1}
218+
&& $$generated_by_lines{$ln_1_2})) {
202219
last;
203220
}
204-
} elsif ($$generated_by_lines{$ln_1}) {
205-
last;
206221
}
207222
}
208223
}
@@ -215,7 +230,7 @@ sub diff_files_complete {
215230
if ($diffs ne "" && !$quiet) {
216231
$errors++;
217232
print "\n" if $show_progress;
218-
print "[$errors] $filename1\n[$errors] $filename2: found $local_errors difference" . ($errors == 1 ? "" : "s") . "\n";
233+
print "[$errors] $filename1\n[$errors] $filename2: found $local_errors difference" . ($local_errors == 1 ? "" : "s") . "\n";
219234
print "$diffs\n";
220235
}
221236

@@ -274,12 +289,12 @@ sub process_options {
274289
$dir1 = abs_path ($dir1);
275290
$dir2 = abs_path ($dir2);
276291

277-
if (!-d $dir1) {
278-
die ("$dir1 is not a directory\n");
292+
if (!defined $dir1 || !-d $dir1) {
293+
die ("$ARGV[0] is not a directory\n");
279294
}
280295

281-
if (!-d $dir2) {
282-
die ("$dir2 is not a directory\n");
296+
if (!defined $dir2 || !-d $dir2) {
297+
die ("$ARGV[1] is not a directory\n");
283298
}
284299

285300
if (defined $options{i}) {
@@ -321,7 +336,7 @@ sub process_options {
321336
print "\n" unless $quiet;
322337

323338
if ($errors) {
324-
print "=> $dir1 and $dir2 differ ($errors difference", $errors > 1 ? "s" : "", ")\n\n" unless $quiet;
339+
print "=> $dir1 and $dir2 dirs differ: $errors file", $errors > 1 ? "s are" : " is", " different\n\n" unless $quiet;
325340
} else {
326341
print "=> Archives are identical\n\n" unless $quiet;
327342
}

0 commit comments

Comments
 (0)