* support/scripts/gen_known_bugs.pl: added script which generates knownbugs.html
authorborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 9 May 2007 22:22:10 +0000 (22:22 +0000)
committerborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 9 May 2007 22:22:10 +0000 (22:22 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4800 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
support/scripts/gen_known_bugs.pl [new file with mode: 0644]

index a62c908e82da4f3ed2440abe040dc6ad4a5ce55a..c487f8a253e33e5bc839c818d46ac50707f4fd24 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-05-10 Borut Razem <borut.razem AT siol.net>
+
+       * support/scripts/gen_known_bugs.pl: added script
+         which generates knownbugs.html
+
 2007-05-09 Maarten Brock <sourceforge.brock AT dse.nl>
 
        * doc/knownbugs.html: updated for release 2.7.0
diff --git a/support/scripts/gen_known_bugs.pl b/support/scripts/gen_known_bugs.pl
new file mode 100644 (file)
index 0000000..cc8ece1
--- /dev/null
@@ -0,0 +1,232 @@
+# gen_known_bugs.pl - generate knownbugs.html\r
+#\r
+# Copyright (c) 2007 Borut Razem\r
+#\r
+# This file is part of sdcc.\r
+#\r
+#  This software is provided 'as-is', without any express or implied\r
+#  warranty.  In no event will the authors be held liable for any damages\r
+#  arising from the use of this software.\r
+#\r
+#  Permission is granted to anyone to use this software for any purpose,\r
+#  including commercial applications, and to alter it and redistribute it\r
+#  freely, subject to the following restrictions:\r
+#\r
+#  1. The origin of this software must not be misrepresented; you must not\r
+#     claim that you wrote the original software. If you use this software\r
+#     in a product, an acknowledgment in the product documentation would be\r
+#     appreciated but is not required.\r
+#  2. Altered source versions must be plainly marked as such, and must not be\r
+#     misrepresented as being the original software.\r
+#  3. This notice may not be removed or altered from any source distribution.\r
+#\r
+#  Borut Razem\r
+#  borut.razem@siol.net\r
+\r
+use strict;\r
+use warnings;\r
+\r
+use LWP::Simple;\r
+use HTML::TreeBuilder;\r
+\r
+\r
+my @headerList = ('Request ID', 'Summary', 'Open Date', 'Priority', 'Status', 'Assigned To', 'Submitted By');\r
+my $version;\r
+\r
+\r
+# check if the line is a correct header\r
+sub is_header($)\r
+{\r
+  my ($line) = @_;\r
+  \r
+  if (ref($line)) {\r
+    my $i = 0;\r
+    foreach ($line->look_down('_tag', 'td')) {\r
+      if ($_->as_text() ne $headerList[$i++]) {\r
+        return 0;\r
+      }\r
+    }\r
+    return 1;\r
+  }\r
+  else {\r
+    return 0;\r
+  }\r
+}\r
+\r
+\r
+# check if the line has correct number of fields\r
+sub has_all_fields($)\r
+{\r
+  my ($line) = @_;\r
\r
+  my @len = $line->look_down('_tag', 'td');\r
+  return $#len == $#headerList;\r
+}\r
+\r
+\r
+# process a line\r
+sub process_line($)\r
+{\r
+  my ($line) = @_;\r
+\r
+  my $i = 0;\r
+  foreach ($line->look_down('_tag', 'td')) {\r
+    if ($i == 0) {\r
+      # remove nowrap attribute from 'Request ID' field\r
+      $_->attr('nowrap', undef);\r
+    }\r
+    elsif ($i == 1) {\r
+      # convert relative to absolute href in the 'Summary' field\r
+      foreach ($_->look_down('_tag', 'a')) {\r
+        my $attr = $_->attr('href');\r
+        if (defined($attr) && $attr =~ m!^/tracker/index.php?!) {\r
+          $_->attr('href', 'http://sourceforge.net' . $attr);\r
+        }\r
+      }\r
+    }\r
+    elsif ($i == 2) {\r
+      # remove text formatting from 'Open Date' field\r
+      my $text = $_->as_text();\r
+      $text =~ s/^\W*\*//;\r
+      $_->delete_content();\r
+      $_->push_content($text);\r
+    }\r
+    elsif ($i == 4) {\r
+      # remove the 'Status' field\r
+      $_->delete();\r
+    }\r
+    elsif ($i == 5 || $i == 6) {\r
+      # remove hrefs in 'Assigned To' and 'Submitted By' fields\r
+      foreach ($_->look_down('_tag', 'a')) {\r
+       $_->replace_with($_->as_text());\r
+      }\r
+    }\r
+    ++$i;\r
+  }\r
+  $line->delete_ignorable_whitespace();\r
+}\r
+\r
+\r
+# process the HTML page\r
+sub process_page($)\r
+{\r
+  my ($html) = @_;\r
+\r
+  # create HTML tree from the page\r
+  my $tree = HTML::TreeBuilder->new();\r
+  $tree->parse($html);\r
+\r
+  # find table with the required header\r
+  my $hasTable = 0;\r
+  foreach my $table ($tree->look_down('_tag', 'table')) {\r
+    my @lines = $table->content_list();\r
+    if (is_header($lines[0])) {\r
+      shift(@lines);  #remove the header\r
+\r
+      # process the following lines in table\r
+      # if they have required number of fields\r
+      foreach my $line (@lines) {\r
+        if (ref($line) && has_all_fields($line)) {\r
+          # process a line\r
+          process_line($line);\r
+          # and print it\r
+          print($line->as_HTML(undef, '  '));\r
+          $hasTable = 1;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  $tree->delete;\r
+  \r
+  return $hasTable;\r
+}\r
+\r
+\r
+# print HTML header\r
+sub print_header()\r
+{\r
+  print <<EOF;\r
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\r
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en">\r
+<!--\r
+This file is generated automagicaly by gen_known_bugs.pl script.\r
+-->\r
+  <head>\r
+    <meta http-equiv="content-type" content="text/html; charset=utf-8" />\r
+    <title>SourceForge.net: Known Bugs</title>\r
+  </head>\r
+  <body>\r
+    <h2>Small Device C Compiler - Release $version Known Bug List</h2>\r
+    <ul>\r
+      <li><a href="http://sdcc.sourceforge.net" >Home&nbsp;Page</a></li>\r
+      <li class="selected"><a href="http://sourceforge.net/tracker/?group_id=599&amp;atid=100599" >Current Bugs</a></li>\r
+    </ul>\r
+    <table width="100%" border="0" cellspacing="2" cellpadding="3">\r
+      <tr bgcolor="#ffffff">\r
+        <td align="center"><font color="#000000"><b>Request ID</b></font></td>\r
+        <td align="center"><font color="#000000"><b>Summary</b></font></td>\r
+        <td align="center"><font color="#000000"><b>Open Date</b></font></td>\r
+        <td align="center"><font color="#000000"><b>Priority</b></font></td>\r
+        <td align="center"><font color="#000000"><b>Assigned To</b></font></td>\r
+        <td align="center"><font color="#000000"><b>Submitted By</b></font></td>\r
+      </tr>\r
+EOF\r
+}\r
+\r
+\r
+# print HTML footer\r
+sub print_footer()\r
+{\r
+  print <<EOF;\r
+    </table>\r
+    <p><b>Priority Colors:</b></p>\r
+    <br />\r
+    <table border="0">\r
+      <tr>\r
+        <td bgcolor="#dadada">1</td>\r
+        <td bgcolor="#dad0d0">2</td>\r
+        <td bgcolor="#dacaca">3</td>\r
+        <td bgcolor="#dac0c0">4</td>\r
+        <td bgcolor="#dababa">5</td>\r
+        <td bgcolor="#dab0b0">6</td>\r
+        <td bgcolor="#daaaaa">7</td>\r
+        <td bgcolor="#da9090">8</td>\r
+        <td bgcolor="#da8a8a">9</td>\r
+      </tr>\r
+    </table>\r
+  </body>\r
+</html>\r
+EOF\r
+}\r
+\r
+\r
+# main procedure\r
+{\r
+  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
+\r
+  if ($#ARGV != 0) {\r
+    printf("Usage: gen_known_bugs.pl <version>\n");\r
+    exit(1);\r
+  }\r
+\r
+  # get the SDCC version number from command line\r
+  $version = $ARGV[0];\r
+\r
+  # print HTML header\r
+  print_header();\r
+\r
+  # get pages from SF bug tracker\r
+  for (my $i = 0; my $html = get($url . $i); $i += 50) {\r
+    # and process them\r
+    if (!process_page($html)) {\r
+      last;\r
+    }\r
+  }\r
+\r
+  # print HTML footer\r
+  print_footer();\r
+\r
+  exit(0);\r
+}\r