d2/tfile.h: Call ungetc() when test for non-primary transformation command fails.
[Ale.git] / doc / make-changelog
blobc205b3599e67bfe95b0e7aea991b04151ce4e91e
1 #!/usr/bin/perl -w
3 print <<END;
4 <?xml version="1.0"?>
5 <!DOCTYPE set PUBLIC "-//Norman Walsh//DTD DocBk XML V3.1.4//EN"
6 "file:///usr/share/xml/docbook/schema/dtd/4.4/docbookx.dtd">
8 <article>
10 <articleinfo xmlns:xi="http://www.w3.org/2001/XInclude">
11 <t>Change log</t>
12 <abstract>This article contains detailed change information for each release.</abstract>
13 </articleinfo>
15 <changelog>
16 END
18 sub flush_words {
20 if (!defined $_[0]) {
21 return;
24 $_[0] =~ s/\&/\&amp;/gs;
25 $_[0] =~ s/</\&lt;/gs;
27 print "<entry><text>$_[0]</text>\n";
29 @keywords = split /\W/, $_[0];
31 foreach (@keywords) {
32 print "<word>" . lc $_ . "</word>";
35 print "</entry>\n";
38 sub unset_version {
39 if (defined $version) {
40 print "</release>";
44 sub set_version {
47 # Initialize variables and trim whitespace.
50 chomp($version = $_[0]);
51 $version =~ s/^\s*(.*)\s*$/$1/;
54 # Check the version style for included date
57 if ($version =~ /(\S+)\s*(2\d\d\d)(\S*)/) {
60 # Handle the date, if available, and add a rudimentary
61 # edit history.
64 $version = $1;
65 $year = $2;
66 $date = $year . $3;
68 print "<release version=\"$version\" date=\"$date\">\n";
70 print "<edit by=\"David Hilvert\" in-year=\"$year\"/>";
72 } else {
75 # Handle the case where the date is not available
78 print "<release version=\"$version\">\n";
83 sub flush_path {
85 if (!defined @path) {
86 return;
89 foreach $element (reverse(@path)) {
90 if ($element =~ /\S/) {
91 print "</$element>";
95 undef @path;
98 sub set_path {
99 chomp(@path = split /\//, $_[0]);
100 foreach $element (@path) {
101 if ($element =~ /\S/) {
102 print "<$element>";
108 while(<STDIN>) {
110 if (/^\S/) {
113 ###If a non-whitespace character begins a line, this means that any
114 ###open entry must be closed.
117 flush_words($entry);
118 undef $entry;
121 if (/^o\t/) {
124 ###Entry
127 $entry = $_;
128 $entry =~ s/^o\t//;
130 } elsif (/^\t/) {
133 ###Entry continuation
136 if (defined $entry) {
137 $entry .= $_;
140 } elsif (/^\//) {
143 ###Path
146 $newpath = $_;
147 flush_words($entry);
148 flush_path();
149 set_path($newpath);
151 } elsif (/^V/) {
154 ###Version
157 $newversion = $_;
158 $newversion =~ s/V//;
160 $newpath= $_;
161 flush_path();
162 unset_version();
163 set_version($newversion);
165 } elsif (/^E/) {
168 ###Edit note
171 s/E//;
172 print;
177 flush_words($entry);
178 flush_path();
179 unset_version();
181 print "</changelog></article>";