new-func revision 5fa46bc91672ef5737aee6f99763161511566c24
45e9809aff7304721fddb95654901b32195c9c7avboxsync#!/usr/bin/perl
45e9809aff7304721fddb95654901b32195c9c7avboxsync#
45e9809aff7304721fddb95654901b32195c9c7avboxsync# Copyright (C) 2005, 2007, 2012 Internet Systems Consortium, Inc. ("ISC")
45e9809aff7304721fddb95654901b32195c9c7avboxsync#
45e9809aff7304721fddb95654901b32195c9c7avboxsync# Permission to use, copy, modify, and/or distribute this software for any
45e9809aff7304721fddb95654901b32195c9c7avboxsync# purpose with or without fee is hereby granted, provided that the above
45e9809aff7304721fddb95654901b32195c9c7avboxsync# copyright notice and this permission notice appear in all copies.
45e9809aff7304721fddb95654901b32195c9c7avboxsync#
45e9809aff7304721fddb95654901b32195c9c7avboxsync# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
45e9809aff7304721fddb95654901b32195c9c7avboxsync# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
45e9809aff7304721fddb95654901b32195c9c7avboxsync# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
45e9809aff7304721fddb95654901b32195c9c7avboxsync# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
45e9809aff7304721fddb95654901b32195c9c7avboxsync# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
45e9809aff7304721fddb95654901b32195c9c7avboxsync# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
45e9809aff7304721fddb95654901b32195c9c7avboxsync# PERFORMANCE OF THIS SOFTWARE.
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync# $Id$
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync# Given two CHANGES files, list [bug] entries present in the
45e9809aff7304721fddb95654901b32195c9c7avboxsync# first one but not in the second one.
45e9809aff7304721fddb95654901b32195c9c7avboxsync#
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncuse FileHandle;
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync# $/ = "";
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync# Read the CHANGES file $fn and return a hash of change
45e9809aff7304721fddb95654901b32195c9c7avboxsync# texts and categories indexed by change number.
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncsub readfile {
45e9809aff7304721fddb95654901b32195c9c7avboxsync my ($fn) = @_;
45e9809aff7304721fddb95654901b32195c9c7avboxsync my $fh = new FileHandle($fn, "r")
45e9809aff7304721fddb95654901b32195c9c7avboxsync or die "open: $fn: $!";
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync my $changes = { };
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync my ($changeid, $category);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync $changeid = "none";
45e9809aff7304721fddb95654901b32195c9c7avboxsync $category = "none";
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync while (<$fh>) {
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (m/^\s*(\d+)\.\s+\[(\w+)\]/) {
45e9809aff7304721fddb95654901b32195c9c7avboxsync $changeid = $1;
45e9809aff7304721fddb95654901b32195c9c7avboxsync $category = $2;
45e9809aff7304721fddb95654901b32195c9c7avboxsync # print "*** $1 $2\n";
45e9809aff7304721fddb95654901b32195c9c7avboxsync } elsif (m/---.* released ---/) {
45e9809aff7304721fddb95654901b32195c9c7avboxsync $changeid = "none";
45e9809aff7304721fddb95654901b32195c9c7avboxsync $category = "none";
45e9809aff7304721fddb95654901b32195c9c7avboxsync next;
45e9809aff7304721fddb95654901b32195c9c7avboxsync } elsif (m/^# /) {
45e9809aff7304721fddb95654901b32195c9c7avboxsync $changeid = "none";
45e9809aff7304721fddb95654901b32195c9c7avboxsync $category = "none";
45e9809aff7304721fddb95654901b32195c9c7avboxsync next;
45e9809aff7304721fddb95654901b32195c9c7avboxsync }
45e9809aff7304721fddb95654901b32195c9c7avboxsync if ($changeid eq "none") {
45e9809aff7304721fddb95654901b32195c9c7avboxsync next;
45e9809aff7304721fddb95654901b32195c9c7avboxsync }
45e9809aff7304721fddb95654901b32195c9c7avboxsync $changeid =~ s/\.$//;
45e9809aff7304721fddb95654901b32195c9c7avboxsync $changes->{$changeid}->{text} .= $_;
45e9809aff7304721fddb95654901b32195c9c7avboxsync $changes->{$changeid}->{category} = $category;
45e9809aff7304721fddb95654901b32195c9c7avboxsync }
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync return $changes;
45e9809aff7304721fddb95654901b32195c9c7avboxsync}
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync@ARGV == 2 || @ARGV == 3 or die "usage: $0 changes-file-1 changes-file-2\n";
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncmy $c1 = readfile($ARGV[0]);
45e9809aff7304721fddb95654901b32195c9c7avboxsyncmy $c2 = readfile($ARGV[1]);
45e9809aff7304721fddb95654901b32195c9c7avboxsyncif (@ARGV == 3) {
45e9809aff7304721fddb95654901b32195c9c7avboxsync $c3 = readfile($ARGV[2]);
45e9809aff7304721fddb95654901b32195c9c7avboxsync} else {
45e9809aff7304721fddb95654901b32195c9c7avboxsync my $c3 = { };
45e9809aff7304721fddb95654901b32195c9c7avboxsync}
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncforeach my $c (sort {$a <=> $b} keys %$c1) {
45e9809aff7304721fddb95654901b32195c9c7avboxsync my $category = $c1->{$c}->{category};
45e9809aff7304721fddb95654901b32195c9c7avboxsync my $text = $c1->{$c}->{text};
45e9809aff7304721fddb95654901b32195c9c7avboxsync if ($category eq "func" && !exists($c2->{$c}) && !exists($c3->{$c})) {
45e9809aff7304721fddb95654901b32195c9c7avboxsync print $c1->{$c}->{text};
45e9809aff7304721fddb95654901b32195c9c7avboxsync }
45e9809aff7304721fddb95654901b32195c9c7avboxsync}
45e9809aff7304721fddb95654901b32195c9c7avboxsync