#! /usr/bin/perl # $Id: grep-changelog,v 1.2 2000/05/05 13:19:05 gerd Exp $ # Copyright (C) 1999, 2000 Free Software Foundation, Inc. # # This file is part of GNU Emacs. # # GNU Emacs is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # GNU Emacs is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Emacs; see the file COPYING. If not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # Extract entries from ChangeLogs matching specified criteria. # Optionally format the resulting output to a form suitable for RCS # logs, like they are used in Emacs, for example. In this format, # author lines leading spaces, and file names are removed. require 5; # Parse command line options. use Getopt::Long; $result = GetOptions ("author=s" => \$author, "text=s" => \$regexp, "exclude=s" => \$exclude, "from-date=s" => \$from_date, "to-date=s" => \$to_date, "rcs-log" => \$rcs_log, "with-date" => \$with_date, "version" => \$version, "help" => \$help); # If date options are specified, check that they have the format # YYYY-MM-DD. $result = 0 if $from_date && $from_date !~ /^\d\d\d\d-\d\d-\d\d$/; $result = 0 if $to_date && $to_date !~ /^\d\d\d\d-\d\d-\d\d$/; # Print usage information and exit when necessary. if ($result == 0 || $help) { print <) { if ($line =~ /^\S/) { # Line is an author-line. Print previous entry if # it matches. print_log ($header, $entry) if header_match_p ($header) && entry_match_p ($entry); $entry = ""; $header = $line; # Add empty lines below the header. while (($line = ) && $line =~ /^\s*$/) { $header = "$header$line"; } } if ($line =~ /^\s*\*/) { # LINE is the first line of a ChangeLog entry. Print # previous entry if it matches. print_log ($header, $entry) if header_match_p ($header) && entry_match_p ($entry); $entry = $line; } else { # Add LINE to the current entry. $entry = "$entry$line"; } } # Print last entry if it matches. print_log ($header, $entry) if header_match_p ($header) && entry_match_p ($entry); close IN; } # Main program. Process ChangeLogs. if (@ARGV > 0) { # If files were specified on the command line, parse those files. while ($log = shift @ARGV) { parse_changelog ($log); } } else { # Parse default files ChangeLog and ChangeLog.9...ChangeLog.1 in # that order. parse_changelog ("ChangeLog"); for ($i = 9; $i >= 1; --$i) { my $log = "ChangeLog.$i"; parse_changelog ($log) if -f $log; } } # grep-changelog ends here.