1 # gen_known_bugs.pl - generate knownbugs.html
3 # Copyright (c) 2007-2013 Borut Razem
5 # This file is part of sdcc.
7 # This software is provided 'as-is', without any express or implied
8 # warranty. In no event will the authors be held liable for any damages
9 # arising from the use of this software.
11 # Permission is granted to anyone to use this software for any purpose,
12 # including commercial applications, and to alter it and redistribute it
13 # freely, subject to the following restrictions:
15 # 1. The origin of this software must not be misrepresented; you must not
16 # claim that you wrote the original software. If you use this software
17 # in a product, an acknowledgment in the product documentation would be
18 # appreciated but is not required.
19 # 2. Altered source versions must be plainly marked as such, and must not be
20 # misrepresented as being the original software.
21 # 3. This notice may not be removed or altered from any source distribution.
24 # borut.razem@siol.net
30 use HTML
::TreeBuilder
;
33 # trim function to remove whitespace from the start and end of the string
43 my @headerList = ('#', 'Summary', 'Owner', 'Creator', 'Created', 'Priority');
44 my $nFields = $#headerList + 1; # Number of colums is number of header fields + 1 for "Select Columns" icon
46 # check if the line is a correct header
52 my @headers = $line->look_down('_tag', 'th');
53 foreach my $header (@headerList) {
56 my $content = trim
($_->as_text());
57 if ($content =~ /\Q$header\E/i) {
72 # check if the line has correct number of fields
77 my @len = $line->look_down('_tag', 'td');
78 return $#len == $nFields;
99 my ($date) = @_; #Mon Mar 14, 2011 10:42 AM UTC
100 my (undef, $month, $day, $year) = split(' ' , $date);
101 $day =~ s/^(\d+),$/$1/;
102 return $year . '-' . $months{$month} . '-' . sprintf('%02d', $day);
111 foreach ($line->look_down('_tag', 'td')) {
112 if (!defined($headerList[$i])) {
113 # don't print columns which are not in the header list
116 elsif ($headerList[$i] eq 'Summary') {
117 # convert relative to absolute href in the 'Summary' field
118 foreach ($_->look_down('_tag', 'a')) {
119 my $attr = $_->attr('href');
120 if (defined($attr)) {
121 $_->attr('href', 'https://sourceforge.net' . $attr);
125 elsif ($headerList[$i] eq 'Owner' || $headerList[$i] eq 'Creator') {
126 $_->normalize_content();
128 elsif ($headerList[$i] eq 'Created') {
129 my $date = $_->look_down('_tag', 'span')->attr('title');
130 $_->delete_content();
131 $_->push_content(date_to_iso
($date));
133 elsif ($headerList[$i] eq 'Priority') {
134 my @content = $_->content_list();
136 $v = $content[0] if (0 == $#content);
137 $_->{'_parent'}->{'class'} = 'p' . $v;
141 $line->delete_ignorable_whitespace();
145 # process the HTML page
150 # create HTML tree from the page
151 my $tree = HTML
::TreeBuilder
->new();
154 # find table with the required header
156 foreach my $table ($tree->look_down('_tag', 'table')) {
157 my $thead = $table->look_down('_tag', 'thead');
158 if (is_header
($thead)) {
159 my $tbody = $table->look_down('_tag', 'tbody');
160 my @lines = $tbody->content_list();
162 # process the lines in table
163 # if they have required number of fields
164 foreach my $line (@lines) {
165 if (ref($line) && has_all_fields
($line)) {
169 print($line->as_HTML(undef, ' '));
188 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
189 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
190 <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
192 This file is generated automagicaly by gen_known_bugs.pl script.
195 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
196 <title>SourceForge.net: Known Bugs</title>
197 <style type="text/css">
198 .p1 {background-color: #9ff;}
199 .p2 {background-color: #cff;}
200 .p3 {background-color: #9fc;}
201 .p4 {background-color: #cfc;}
202 .p5 {background-color: #cf9;}
203 .p6 {background-color: #ffc;}
204 .p7 {background-color: #ff9;}
205 .p8 {background-color: #fc9;}
206 .p9 {background-color: #fcc; color: #300;}
210 <h2>Small Device C Compiler - Release $version Known Bug List</h2>
212 <li><a href="http://sdcc.sourceforge.net">Home Page</a></li>
213 <li class="selected"><a href="http://sourceforge.net/p/sdcc/bugs/">Current Bugs</a></li>
215 <table width="100%" border="0" cellspacing="2" cellpadding="3">
216 <tr bgcolor="#ffffff">
219 foreach my $header (@headerList) {
220 # don't print Status and Resolution columns
221 if ($header ne 'Status' && $header ne 'Resolution') {
222 print(' <td align="center"><font color="#000000"><b>' . $header . "</b></font></td>\n");
236 <p><b>Priority Colors:</b></p>
239 <td class="p1">1</td>
240 <td class="p2">2</td>
241 <td class="p3">3</td>
242 <td class="p4">4</td>
243 <td class="p5">5</td>
244 <td class="p6">6</td>
245 <td class="p7">7</td>
246 <td class="p8">8</td>
247 <td class="p9">9</td>
251 <p><b>Number of open bugs: $lines</b></p>
259 my $url = "http://sourceforge.net/p/sdcc/bugs/?limit=%d&page=%d&sort=ticket_num+desc&q=%%7B%%22status%%22%%3A+%%7B%%22%%24nin%%22%%3A+%%5B%%22closed-invalid%%22%%2C+%%22closed-later%%22%%2C+%%22closed-accepted%%22%%2C+%%22closed-duplicate%%22%%2C+%%22closed-out-of-date%%22%%2C+%%22closed-fixed%%22%%2C+%%22closed-rejected%%22%%2C+%%22closed-remind%%22%%2C+%%22closed-works-for-me%%22%%2C+%%22closed%%22%%2C+%%22closed-wont-fix%%22%%2C+%%22closed-postponed%%22%%5D%%7D%%7D&columns-0.name=ticket_num&columns-0.sort_name=ticket_num&columns-0.label=Ticket+Number&columns-0.active=on&columns-1.name=summary&columns-1.sort_name=summary&columns-1.label=Summary&columns-1.active=on&columns-2.name=_milestone&columns-2.sort_name=custom_fields._milestone&columns-2.label=Milestone&columns-3.name=status&columns-3.sort_name=status&columns-3.label=Status&columns-4.name=assigned_to&columns-4.sort_name=assigned_to_username&columns-4.label=Owner&columns-4.active=on&columns-5.name=reported_by&columns-5.sort_name=reported_by&columns-5.label=Creator&columns-5.active=on&columns-6.name=created_date&columns-6.sort_name=created_date&columns-6.label=Created&columns-6.active=on&columns-7.name=mod_date&columns-7.sort_name=mod_date&columns-7.label=Updated&columns-8.name=labels&columns-8.sort_name=labels&columns-8.label=Labels&columns-9.name=_priority&columns-9.sort_name=_priority&columns-9.label=Priority&columns-9.active=on";
262 printf("Usage: gen_known_bugs.pl <version>\n");
268 # get the SDCC version number from command line
269 my $version = $ARGV[0];
272 print_header
($version);
274 # get pages from SF bug tracker
278 while (my $linesRead = process_page
(get
(sprintf($url, $limit, $page)))) {
279 $lines += $linesRead;
284 print_footer
($lines);