File: diff_hypermail.pl

package info (click to toggle)
hypermail 2.2.0-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 5,732 kB
  • ctags: 3,176
  • sloc: ansic: 34,794; sh: 13,432; yacc: 844; makefile: 775; perl: 744; python: 292
file content (70 lines) | stat: -rwxr-xr-x 1,478 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/local/bin/perl

#
# Compare 2 directories with archives produced by Hypermail.
# Intended primarily to test changes to Hypermail.
# Written by Peter McCluskey (pcm@rahul.net).
#

$dir1 = $ARGV[0];
$dir2 = $ARGV[1];

opendir(FDDIR,$dir1) || die("cant open $dir1");
@files1 = sort readdir(FDDIR);

foreach $file (@files1)
{
    my $file1name = "$dir1/$file";
    my $file2name = "$dir2/$file";
    if(!(-e $file2name))
    {
	print "$file2name is missing\n";
	next;
    }
    if(-d $file1name)
    {
	print "$file2name is not a directory\n" if(!(-d $file2name));
	next;
    }
    open(FD, "diff $file1name $file2name |") || die("cannot diff $file1name $file2name");
    while($line = <FD>)
    {
	if($line =~ /\d+c\d+/)
	{
	    if(&non_date_diffs($diff1, $diff2))
	    {
		print "$file: $diffs";
	    }
	    $diffs = '';
	    $diff1 = '';
	    $diff2 = '';
	}
	$diffs .= $line;
	$diff1 .= $line if(substr($line,0,1) eq '<');
	$diff2 .= $line if(substr($line,0,1) eq '>');
    }
    if(&non_date_diffs($diff1, $diff2))
    {
	print "$file: $diffs";
    }
    $diffs = '';
    $diff1 = '';
    $diff2 = '';
}

sub non_date_diffs
{
    my ($diff1, $diff2) = @_;
    my $i;
    return 1 if(length($diff1) != length($diff2));
    for($i = 0; $i < length($diff2); ++$i)
    {
	my $c1 = substr($diff1, $i, 1);
	my $c2 = substr($diff2, $i, 1);
	next if($c1 eq $c2);
	next if(($c1 eq "<") && ($c2 eq ">"));
	next if(($c1 =~ /\d/) && ($c2 =~ /\d/));
	return 1;
    }
    return 0;
}