annotate lib-src/grep-changelog @ 33349:b8015b527f27

(ispell-library-path): Don't call check-ispell-version when byte-compiling because that starts an ispell process, and ispell might not be installed. (toplevel): Don't set up a menu when byte-compiling.
author Gerd Moellmann <gerd@gnu.org>
date Thu, 09 Nov 2000 16:09:04 +0000
parents f6a97d806845
children 3db3b0888252
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28823
72c6f8275e0b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 25216
diff changeset
1 #! /usr/bin/perl
29638
f6a97d806845 Fix typos in comments. Remove trailing blanks.
Jim Meyering <jim@meyering.net>
parents: 28823
diff changeset
2 # $Id: grep-changelog,v 1.2 2000/05/05 13:19:05 gerd Exp $
25216
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
3
29638
f6a97d806845 Fix typos in comments. Remove trailing blanks.
Jim Meyering <jim@meyering.net>
parents: 28823
diff changeset
4 # Copyright (C) 1999, 2000 Free Software Foundation, Inc.
25216
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5 #
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 # This file is part of GNU Emacs.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7 #
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 # GNU Emacs is free software; you can redistribute it and/or modify
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9 # it under the terms of the GNU General Public License as published by
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10 # the Free Software Foundation; either version 2, or (at your option)
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 # any later version.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 #
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 # GNU Emacs is distributed in the hope that it will be useful,
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 # GNU General Public License for more details.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 #
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 # You should have received a copy of the GNU General Public License
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 # along with GNU Emacs; see the file COPYING. If not, write to the
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21 # Boston, MA 02111-1307, USA.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24 # Extract entries from ChangeLogs matching specified criteria.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25 # Optionally format the resulting output to a form suitable for RCS
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26 # logs, like they are used in Emacs, for example. In this format,
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27 # author lines leading spaces, and file names are removed.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 require 5;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 # Parse command line options.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33 use Getopt::Long;
29638
f6a97d806845 Fix typos in comments. Remove trailing blanks.
Jim Meyering <jim@meyering.net>
parents: 28823
diff changeset
34 $result = GetOptions ("author=s" => \$author,
25216
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35 "text=s" => \$regexp,
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 "exclude=s" => \$exclude,
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37 "from-date=s" => \$from_date,
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 "to-date=s" => \$to_date,
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 "rcs-log" => \$rcs_log,
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 "with-date" => \$with_date,
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41 "version" => \$version,
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 "help" => \$help);
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44 # If date options are specified, check that they have the format
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 # YYYY-MM-DD.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47 $result = 0 if $from_date && $from_date !~ /^\d\d\d\d-\d\d-\d\d$/;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 $result = 0 if $to_date && $to_date !~ /^\d\d\d\d-\d\d-\d\d$/;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 # Print usage information and exit when necessary.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 if ($result == 0 || $help) {
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 print <<USAGE;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54 Usage: $0 [options] [CHANGELOG...]
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 Print entries in ChangeLogs matching various criteria. Valid options
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 are
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57
29638
f6a97d806845 Fix typos in comments. Remove trailing blanks.
Jim Meyering <jim@meyering.net>
parents: 28823
diff changeset
58 --author=AUTHOR match entries whose author line matches
25216
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 regular expression AUTHOR
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60 --text=TEXT match entries whose text matches regular
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61 expression TEXT.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62 --exclude=TEXT exclude entries matching TEXT.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63 --from-date=YYYY-MM-DD match entries not older than given date
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64 --to-date=YYYY-MM-DD match entries not younger than given date
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 --rcs-log format output suitable for RCS log entries.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
66 --with-date print short date line in RCS log
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67 --version print version info
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68 --help print this help
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 If no CHANGELOG is specified scan the files "ChangeLog" and
29638
f6a97d806845 Fix typos in comments. Remove trailing blanks.
Jim Meyering <jim@meyering.net>
parents: 28823
diff changeset
71 "ChangeLog.[9-1]" in the current directory. Old-style dates in ChangeLogs
25216
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
72 are not recognized.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73 USAGE
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 exit $help ? 0 : 1;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 }
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 # Print version info and exit if `--version' was specified.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79 if ($version) {
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 print "0.1\n";
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81 exit 0;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 }
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85 # Value is non-zero if HEADER matches according to command line
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86 # options specified, i.e. it matches $author, and its date is in
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87 # the range $from_date <= date <= $to_date.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 sub header_match_p ($) {
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 my $header = shift;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 # No match if AUTHOR-regexp specified and doesn't match.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93 return 0 if $author && $header !~ /$author/;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95 # Check that the date of the entry matches if date options
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96 # `--from-date' and/or `--to-date' were specified . Old-style
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97 # dates in ChangeLogs are not recognized, and never match.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98 if ($from_date || $to_date) {
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99 if ($header =~ /^(\d\d\d\d-\d\d-\d\d)/) {
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 my $date = $1;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 return 0 if $from_date && $date lt $from_date;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102 return 0 if $to_date && $date gt $to_date;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103 } else {
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 # Don't bother recognizing old-style dates.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105 return 0;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106 }
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107 }
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109 return 1;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
110 }
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
111
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112
29638
f6a97d806845 Fix typos in comments. Remove trailing blanks.
Jim Meyering <jim@meyering.net>
parents: 28823
diff changeset
113 # Value is non-zero if ENTRY matches the criteria specified on the
25216
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
114 # command line, i.e. it matches $regexp, and it doesn't match
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
115 # $exclude.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
116
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
117 sub entry_match_p ($) {
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118 my $entry = shift;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
119
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
120 if ($regexp) {
29638
f6a97d806845 Fix typos in comments. Remove trailing blanks.
Jim Meyering <jim@meyering.net>
parents: 28823
diff changeset
121 return 1 if ($entry =~ /$regexp/
25216
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
122 && (!$exclude || $entry !~ $exclude));
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123 } else {
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124 return 1 if !$exclude || $entry !~ $exclude;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 }
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 return 0;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128 }
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131 # Print HEADER and/or ENTRY in a format suitable for what was
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132 # specified on the command line. If $rcs_log is specified, author
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133 # lines are not printed, and leading spaces and file names are removed
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134 # from ChangeLog entries.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136 sub print_log ($$) {
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 my ($header, $entry) = @_;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 if ($rcs_log) {
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140 # Remove leading whitespace from entry.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141 $entry =~ s/^\s+//mg;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 # Remove file name parts.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143 $entry =~ s/^\*.*\(/(/mg;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144 # Remove file name parts, 2.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 $entry =~ s/^\*.*://mg;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146 if ($with_date) {
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 $header =~ /(\d\d\d\d-\d\d-\d\d)/;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 print "!changelog-date $1\n";
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149 }
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 print $entry;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151 } else {
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
152 print $header, $entry;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
153 }
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154 }
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156 # Scan LOG for matching entries, and print them to standard output.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158 sub parse_changelog ($) {
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159 my $log = shift;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 my $entry;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
161 my $match;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
163 # Open the ChangeLog.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164 open (IN, "< $log") || die "Cannot open $log: $!";
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
165
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
166 while ($line = <IN>) {
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
167 if ($line =~ /^\S/) {
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168 # Line is an author-line. Print previous entry if
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
169 # it matches.
29638
f6a97d806845 Fix typos in comments. Remove trailing blanks.
Jim Meyering <jim@meyering.net>
parents: 28823
diff changeset
170 print_log ($header, $entry)
25216
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
171 if header_match_p ($header) && entry_match_p ($entry);
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
173 $entry = "";
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174 $header = $line;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
176 # Add empty lines below the header.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
177 while (($line = <IN>) && $line =~ /^\s*$/) {
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
178 $header = "$header$line";
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179 }
29638
f6a97d806845 Fix typos in comments. Remove trailing blanks.
Jim Meyering <jim@meyering.net>
parents: 28823
diff changeset
180 }
25216
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182 if ($line =~ /^\s*\*/) {
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183 # LINE is the first line of a ChangeLog entry. Print
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184 # previous entry if it matches.
29638
f6a97d806845 Fix typos in comments. Remove trailing blanks.
Jim Meyering <jim@meyering.net>
parents: 28823
diff changeset
185 print_log ($header, $entry)
25216
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
186 if header_match_p ($header) && entry_match_p ($entry);
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
187 $entry = $line;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
188 } else {
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
189 # Add LINE to the current entry.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
190 $entry = "$entry$line";
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
191 }
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
192 }
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
193
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
194 # Print last entry if it matches.
29638
f6a97d806845 Fix typos in comments. Remove trailing blanks.
Jim Meyering <jim@meyering.net>
parents: 28823
diff changeset
195 print_log ($header, $entry)
25216
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
196 if header_match_p ($header) && entry_match_p ($entry);
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
197
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
198 close IN;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
199 }
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
200
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
201
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
202 # Main program. Process ChangeLogs.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
203
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
204 if (@ARGV > 0) {
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
205 # If files were specified on the command line, parse those files.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
206 while ($log = shift @ARGV) {
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
207 parse_changelog ($log);
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
208 }
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
209 } else {
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
210 # Parse default files ChangeLog and ChangeLog.9...ChangeLog.1 in
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
211 # that order.
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
212 parse_changelog ("ChangeLog");
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
213 for ($i = 9; $i >= 1; --$i) {
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
214 my $log = "ChangeLog.$i";
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
215 parse_changelog ($log) if -f $log;
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
216 }
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
217 }
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
218
40dc181e545b Initial revision
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
219
29638
f6a97d806845 Fix typos in comments. Remove trailing blanks.
Jim Meyering <jim@meyering.net>
parents: 28823
diff changeset
220 # grep-changelog ends here.