diff options
author | Bart Schaefer <barts@users.sourceforge.net> | 2002-04-17 18:10:18 +0000 |
---|---|---|
committer | Bart Schaefer <barts@users.sourceforge.net> | 2002-04-17 18:10:18 +0000 |
commit | 75eca01e4f1844f27e051d2c1fa64393e389deb6 (patch) | |
tree | 32637cd5fad047180657c8c54f92af83b5acd2cf | |
parent | 91edfa3b258cfd90854eb50e1a2ad74fe95043ed (diff) | |
download | zsh-75eca01e4f1844f27e051d2c1fa64393e389deb6.tar.gz zsh-75eca01e4f1844f27e051d2c1fa64393e389deb6.tar.xz zsh-75eca01e4f1844f27e051d2c1fa64393e389deb6.zip |
Diff by article number, not just by attribution line.
-rw-r--r-- | Util/difflog.pl | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/Util/difflog.pl b/Util/difflog.pl index 741d7ed9a..d27489cd3 100644 --- a/Util/difflog.pl +++ b/Util/difflog.pl @@ -1,5 +1,6 @@ #!/usr/bin/perl +use strict; use IO::File; my @differ = qw(diff -bw); @@ -10,6 +11,8 @@ my $newfn = pop(@ARGV); my $oldfn = pop(@ARGV); my (%oldhash, %newhash); +my $article = q[(:?(:?workers?|users?)/)?\d{4,5}]; + read_file($newfn, \%newhash); read_file($oldfn, \%oldhash); @@ -68,6 +71,38 @@ while ($new < @newentries) printf("only in %s: %s\n", $newfn, $newentries[$new++]); } +sub append_entry +{ + my ($hashref, $entry, $tag, $block) = @_; + + if (exists($hashref->{$entry})) { + $hashref->{$entry} .= "$tag\n$block"; + } else { + $hashref->{$entry} = ''; + if (defined($tag) || defined($block)) { + $hashref->{$entry} .= "$tag\n$block"; + } + } +} + +sub make_entries +{ + my ($hashref, $entry, $tag, $block) = @_; + + if ($entry =~ s/($article)/ARTICLE/) { + my $key = $1; + $key =~ s:workers?/::; + &append_entry($hashref, $key, $tag, $block); + while ($entry =~ s/($article)/ARTICLE/) { + $key = $1; + $key =~ s:workers?/::; + &append_entry($hashref, $key, $tag, $block); + } + } else { + &append_entry($hashref, $entry, $tag, $block); + } +} + sub read_file { my $fn = shift; @@ -75,9 +110,8 @@ sub read_file my $fh = new IO::File($fn, 'r'); my ($tag, $date, $entry, $block); - my $attrib = q[(:?(:?workers?|users?)/)?\d+]; - $attrib = q[(?:\w+\s+)*] . $attrib; - $attrib = q[(?:[^/]*\D:\s*)?] . $attrib; + my $attrib = q[(?:\w+\s+)*] . $article; + $attrib = q[(?:[^/]*\D[:,]\s*)?] . $attrib; $attrib = qq[(?:unposted|$attrib)]; $attrib = qq[(?:(?:$attrib,\\s*)*$attrib)]; @@ -89,7 +123,7 @@ sub read_file $date = $1; $block =~ s/\n*\Z/\n/; if ($entry) { - $hashref->{$entry} .= "$tag\n$block"; + &make_entries($hashref, $entry, $tag, $block); } elsif ($tag) { $hashref->{unattributed} .= "\n$tag$block"; } @@ -99,13 +133,9 @@ sub read_file my $next = $1; if ($entry) { $block =~ s/\n*\Z/\n/; - $hashref->{$entry} .= "$tag\n$block"; - } - if (exists($hashref->{$next})) { - $hashref->{$next} .= "\n"; - } else { - $hashref->{$next} = ''; + &make_entries($hashref, $entry, $tag, $block); } + &make_entries($hashref, $next); $entry = $next; $block = $line; } else { |