mail-uplift fix lines before and after message separator
[ipreg/sccs2rcs2cvs2git.git] / rcsmtlogmsg
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 unless (@ARGV) {
7 die <<USAGE;
8 usage: rcsmtlogmsg <file,v>
9
10 rcsmtlogmsg alters the given RCS file so that log messages saying
11 *** empty log messsage*** are replaced by empty log messages.
12
13 USAGE
14 }
15
16 sub shite { die "rcsmtlogmsg: @_: $!\n"; }
17
18 undef $/;
19
20 for my $name (@ARGV) {
21 my $mode = (stat $name)[2]
22 or shite "stat $name";
23 open my $in, '<', $name
24 or shite "open < $name";
25 my $file = <$in>;
26 close $in;
27 $file =~ s{\nlog\n\@\*\*\* empty log message \*\*\*\n\@}
28 {\nlog\n\@\@}g;
29 chmod 0644, $name
30 or shite "chmod 0644 $name";
31 open my $out, '>', $name
32 or shite "open > $name";
33 print $out $file;
34 close $out;
35 chmod $mode, $name
36 or shite "chmod $mode $name";
37 }