1 # gen_known_bugs.pl - generate knownbugs.html
\r
3 # Copyright (c) 2007 - 2008 Borut Razem
\r
5 # This file is part of sdcc.
\r
7 # This software is provided 'as-is', without any express or implied
\r
8 # warranty. In no event will the authors be held liable for any damages
\r
9 # arising from the use of this software.
\r
11 # Permission is granted to anyone to use this software for any purpose,
\r
12 # including commercial applications, and to alter it and redistribute it
\r
13 # freely, subject to the following restrictions:
\r
15 # 1. The origin of this software must not be misrepresented; you must not
\r
16 # claim that you wrote the original software. If you use this software
\r
17 # in a product, an acknowledgment in the product documentation would be
\r
18 # appreciated but is not required.
\r
19 # 2. Altered source versions must be plainly marked as such, and must not be
\r
20 # misrepresented as being the original software.
\r
21 # 3. This notice may not be removed or altered from any source distribution.
\r
24 # borut.razem@siol.net
\r
30 use HTML::TreeBuilder;
\r
33 my @headerList = ('Request ID', 'Summary', 'Open Date', 'Priority', 'Status', 'Assigned To', 'Submitted By');
\r
36 # check if the line is a correct header
\r
43 foreach ($line->look_down('_tag', 'td')) {
\r
44 if ($_->as_text() ne $headerList[$i++]) {
\r
56 # check if the line has correct number of fields
\r
57 sub has_all_fields($)
\r
61 my @len = $line->look_down('_tag', 'td');
\r
62 return $#len == $#headerList;
\r
72 foreach ($line->look_down('_tag', 'td')) {
\r
74 # remove nowrap attribute from 'Request ID' field
\r
75 $_->attr('nowrap', undef);
\r
78 # convert relative to absolute href in the 'Summary' field
\r
79 foreach ($_->look_down('_tag', 'a')) {
\r
80 my $attr = $_->attr('href');
\r
81 if (defined($attr) && $attr =~ m!^/tracker/index.php?!) {
\r
82 $_->attr('href', 'http://sourceforge.net' . $attr);
\r
87 # remove text formatting from 'Open Date' field
\r
88 my $text = $_->as_text();
\r
89 $text =~ s/^\W*\**\W//;
\r
90 $_->delete_content();
\r
91 $_->push_content($text);
\r
94 # remove the 'Status' field
\r
97 elsif ($i == 5 || $i == 6) {
\r
98 # remove hrefs in 'Assigned To' and 'Submitted By' fields
\r
99 foreach ($_->look_down('_tag', 'a')) {
\r
100 $_->replace_with($_->as_text());
\r
105 $line->delete_ignorable_whitespace();
\r
109 # process the HTML page
\r
110 sub process_page($)
\r
114 # create HTML tree from the page
\r
115 my $tree = HTML::TreeBuilder->new();
\r
116 $tree->parse($html);
\r
118 # find table with the required header
\r
120 foreach my $table ($tree->look_down('_tag', 'table')) {
\r
121 my @lines = $table->content_list();
\r
122 if (is_header($lines[0])) {
\r
123 shift(@lines); #remove the header
\r
125 # process the following lines in table
\r
126 # if they have required number of fields
\r
127 foreach my $line (@lines) {
\r
128 if (ref($line) && has_all_fields($line)) {
\r
130 process_line($line);
\r
132 print($line->as_HTML(undef, ' '));
\r
145 # print HTML header
\r
146 sub print_header($)
\r
148 my ($version) = @_;
\r
151 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
\r
152 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
\r
153 <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
\r
155 This file is generated automagicaly by gen_known_bugs.pl script.
\r
158 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
\r
159 <title>SourceForge.net: Known Bugs</title>
\r
162 <h2>Small Device C Compiler - Release $version Known Bug List</h2>
\r
164 <li><a href="http://sdcc.sourceforge.net" >Home Page</a></li>
\r
165 <li class="selected"><a href="http://sourceforge.net/tracker/?group_id=599&atid=100599" >Current Bugs</a></li>
\r
167 <table width="100%" border="0" cellspacing="2" cellpadding="3">
\r
168 <tr bgcolor="#ffffff">
\r
169 <td align="center"><font color="#000000"><b>Request ID</b></font></td>
\r
170 <td align="center"><font color="#000000"><b>Summary</b></font></td>
\r
171 <td align="center"><font color="#000000"><b>Open Date</b></font></td>
\r
172 <td align="center"><font color="#000000"><b>Priority</b></font></td>
\r
173 <td align="center"><font color="#000000"><b>Assigned To</b></font></td>
\r
174 <td align="center"><font color="#000000"><b>Submitted By</b></font></td>
\r
180 # print HTML footer
\r
181 sub print_footer($)
\r
187 <p><b>Priority Colors:</b></p>
\r
190 <td bgcolor="#dadada">1</td>
\r
191 <td bgcolor="#dad0d0">2</td>
\r
192 <td bgcolor="#dacaca">3</td>
\r
193 <td bgcolor="#dac0c0">4</td>
\r
194 <td bgcolor="#dababa">5</td>
\r
195 <td bgcolor="#dab0b0">6</td>
\r
196 <td bgcolor="#daaaaa">7</td>
\r
197 <td bgcolor="#da9090">8</td>
\r
198 <td bgcolor="#da8a8a">9</td>
\r
202 <p><b>Number of open bugs: $lines</b></p>
\r
210 my $url = "http://sourceforge.net/tracker/index.php?func=browse&group_id=599&atid=100599&set=custom&_assigned_to=0&_status=1&_category=100&_group=100&order=artifact_id&sort=DESC&offset=";
\r
213 printf("Usage: gen_known_bugs.pl <version>\n");
\r
217 # get the SDCC version number from command line
\r
218 my $version = $ARGV[0];
\r
220 my $lines = 0; # number of lines
\r
222 # print HTML header
\r
223 print_header($version);
\r
225 # get pages from SF bug tracker
\r
226 for (my $i = 0; my $html = get($url . $i); $i += 50) {
\r
228 last if (!(my $myLines = process_page($html)));
\r
229 $lines += $myLines;
\r
232 # print HTML footer
\r
233 print_footer($lines);
\r