forked from veripool/verilog-mode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makechangelog
executable file
·201 lines (160 loc) · 4.4 KB
/
makechangelog
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/usr/bin/perl -w # -*- Perl -*-
# See copyright, etc in below POD section.
######################################################################
require 5.006_001;
use Getopt::Long;
#use Data::Dumper; $Data::Dumper::Indent=1; #Debug
use IO::File;
use IO::Dir;
use Pod::Usage;
use strict;
use vars qw ($Debug);
#======================================================================
# main
our $Opt_FileA;
our $Opt_FileB;
our $Opt_Git;
our $Opt_Svn;
autoflush STDOUT 1;
autoflush STDERR 1;
Getopt::Long::config ("no_auto_abbrev");
if (! GetOptions (
"help" => \&usage,
"debug" => sub { $Debug = 1; },
"<>" => \¶meter,
"git!" => \$Opt_Git,
"svn!" => \$Opt_Svn,
)) {
die "%Error: Bad usage, try 'makechangelog --help'\n";
}
if ($Opt_Svn) {
my $now = $Opt_FileA;
$Opt_FileA = ".svn/text-base/${now}.svn-base";
$Opt_FileB = $now;
} elsif ($Opt_Git) {
my $now = $Opt_FileA;
$Opt_FileA = "/tmp/mcl.$$";
$Opt_FileB = $now;
system("git show HEAD:${now} > $Opt_FileA");
}
read_file($Opt_FileA, $Opt_FileB);
if ($Opt_Git) {
unlink($Opt_FileA);
}
#----------------------------------------------------------------------
sub usage {
print '$Id$ ', "\n";
pod2usage(-verbose=>2, -exitval => 2);
exit (1);
}
sub parameter {
my $param = shift;
if (!$Opt_FileA) {
$Opt_FileA = $param;
} elsif (!$Opt_FileB) {
$Opt_FileB = $param;
} else {
die "%Error: Unknown parameter: $param\n";
}
}
#######################################################################
sub read_file {
my $a = shift;
my $b = shift;
my @l = (read_lines($a), read_lines($b));
# Note we ignore whitespace
my $fh = IO::File->new("diff -b -c $a $b |") or die "%Error: $!,";
my @ln = (0,0);
my %difffuncs;
my $mode = 0;
my @difflines;
while (defined(my $line = $fh->getline)) {
my $fn = "";
if ($line =~ /^\*\*\* (\d+)/) {
$mode = 0;
$ln[$mode] = $1 - 1;
} elsif ($line =~ /^\-\-\- (\d+)/) {
$mode = 1;
$ln[$mode] = $1 - 1;
} elsif ($line =~ /^\*\*\*/) {
} elsif ($line =~ /^\-\-\-/) {
} else {
$ln[$mode]++;
if ($line =~ /^[!-+]/) {
my $checkline = substr($line,2);
chomp $checkline;
$checkline =~ s/;.*$//;
$checkline =~ s/[ \t\n]+$//;
if ($checkline ne "") {
$fn = $l[$mode][ $ln[$mode] ] || "Line#".$ln[$mode];
$difffuncs{$fn} = 1;
}
}
}
(my $fnq = $fn||"") =~ s/^verilog-/v-/g;
push @difflines, sprintf ("%05d: %-20s: %s",$ln[$mode],substr($fnq,0,20), $line);
}
$fh->close;
print "-*- Change-Log -*-\n\n";
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
printf "<Put one line comment with trailing period here. This must be first line of commit message.>\n\n";
print "\t* verilog-mode.el";
my $f="";
my $sep = " (";
foreach my $func (sort keys %difffuncs) {
next if $func eq 'verilog-mode-release-date';
next if $func eq 'verilog-mode-version';
$f .= $sep.$func;
$sep = ", ";
}
$f .= ")" if $f;
print "$f:\n";
print "\n";
print "="x70,"\n";
print join('',@difflines);
}
sub read_lines {
my $filename = shift;
my @lines;
my $func;
my $fh = IO::File->new($filename) or die "%Error: $! $filename\n";
my $ln = 0;
while (defined(my $line = $fh->getline)) {
$ln++;
$func = undef if ($line =~ /^\(/);
$func = $1 if $line =~ /^\(def[---a-z]+\s+\'?(\S+)/;
$lines[$ln] = $func;
printf "%05d %-30s %s", $ln, $func||"", $line if $Debug;
}
$fh->close;
return \@lines;
}
#######################################################################
__END__
=pod
=head1 NAME
makechangelog -
=head1 SYNOPSIS
./makechangelog --svn verilog-mode.el
=head1 DESCRIPTION
dd
=head1 ARGUMENTS
=over 4
=item --help
Displays this message and program version and exits.
=back
=head1 DISTRIBUTION
This is part of the L<http://www.veripool.org/> free Verilog EDA software
tool suite. The latest version is available from CPAN and from
L<http://www.veripool.org/>.
Copyright 2008-2021 by Wilson Snyder. This package is free software; you
can redistribute it and/or modify it under the terms of either the GNU
Lesser General Public License or the Perl Artistic License.
=head1 AUTHORS
Wilson Snyder <[email protected]>
=head1 SEE ALSO
=cut
######################################################################
### Local Variables:
### compile-command: "./makechangelog --svn verilog-mode.el"
### End: