# HG changeset patch # User Gerd Moellmann # Date 934292029 0 # Node ID 40dc181e545be2771ab6db03b2adf67153695296 # Parent 5d684a6517dbe965d6d800c812019f6eb7a1f6ae Initial revision diff -r 5d684a6517db -r 40dc181e545b lib-src/grep-changelog --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib-src/grep-changelog Tue Aug 10 13:33:49 1999 +0000 @@ -0,0 +1,220 @@ +#! /usr/local/bin/perl +# $Id: grep-changelog,v 1.19 1999/08/10 13:22:23 gerd Exp $ + +# Copyright (C) 1999 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; + } +} + + +# gre-changelog ends here.