<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#! /usr/bin/perl

use Getopt::Std;

# main procedure

{
  getopts('s:');

  my $section_name = defined($opt_s) ? $opt_s : "SDCC Docs";

  my $body_stuff = "bgcolor=\"white\" link=\"teal\" vlink=\"#483d8b\"";
  my $font_begin = "&lt;font face=\"Arial,Helvetica,Geneva,Swiss,SunSans-Regular\"&gt;";
  my $font_end = "&lt;/font&gt;";
  my $header_begin = "&lt;table border=\"0\" cellpadding=\"0\" cellspacing=\"1\" width=\"100%\" bgcolor=\"#5f9ea0\"&gt;&lt;tr&gt;&lt;td&gt;";
  my $header_end = "&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;";
  my $favicon = "&lt;link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/images/sdcc.ico\" /&gt;\n";

  my $at_body_begin = 0;
  my $seen_header = 0;
  my $subsections = undef;

  while (&lt;&gt;) {
    # add favicon at the end of head
    if (/^&lt;\/HEAD&gt;/) {
      print($favicon . $_);
      next;
    }

    # treak the title, so google results and bookmarks show SDCC as first word
    if (/^&lt;TITLE&gt;/) {
      my $t = $_;
      while ($t !~ /&lt;\/TITLE&gt;/) {
        $t =~ s/\s+$//;
        $t .= ' ';
        $t .= &lt;&gt;;
      }
      $t =~ /&lt;TITLE&gt;([^&lt;&gt;]+)&lt;\/TITLE&gt;/;
      my $orig_title = $1;
      my $title = $section_name . ': ' . $orig_title;
      print "&lt;TITLE&gt;$title&lt;/TITLE&gt;$'\n";
      next;
    }

    # add the top title, body colors and left side nav bar
    if (/^&lt;BODY\s*&gt;/) {
      print "&lt;BODY $body_stuff&gt;$'\n";
      print "&lt;div align=\"left\"&gt;\n";
      print "&lt;h2&gt;$font_begin&lt;i&gt;$title&lt;/i&gt;$font_end&lt;/h2&gt;\n";
      print "&lt;p&gt;\n";
      print "&lt;table border=\"0\" cellpadding=\"2\" cellspacing=\"1\" width=\"100%\" bgcolor=\"white\"&gt;\n";
      print "&lt;tbody&gt;\n";
      print "&lt;tr&gt;\n";
      print "&lt;td width=\"15%\" valign=\"top\"&gt;\n";
      print "&lt;?php echo(file_get_contents('../../left_menu.inc'));?&gt;\n";
      print "&lt;/td&gt;\n";
      print "&lt;td width=\"85%\" valign=\"top\"&gt;\n";
      print "$font_begin\n";
      $at_body_begin = 1;
      next;
    }

    # complete the div and table opened by the nav bar
    if (/^&lt;\/BODY&gt;/) {
      print "$font_end\n";
      print "&lt;/table&gt;\n";
      print "&lt;/div&gt;\n";
      print;
      next;
    }

    # remove the latex2html nav at top of the page
    if (/^&lt;!--Navigation Panel--&gt;/ &amp;&amp; $at_body_begin) {
      my $nav = '';
      my $nav_buttons = 1;
      while (&lt;&gt;) {
        $nav_buttons = 0 if /&lt;BR&gt;/;
        $nav .= $_ if $nav_buttons;
        last if /&lt;!--End of Navigation Panel--&gt;/;
      }
      if ($nav) {
        print "&lt;table align=right width=70&gt;";
        print "&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;u&gt;$section_name&lt;/tr&gt;&lt;/td&gt;\n";
        print "&lt;tr&gt;&lt;td&gt;";
        print $nav;
        print "&lt;/td&gt;&lt;/tr&gt;\n";
        print "&lt;tr height=800&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;\n";
        print "&lt;/table&gt;\n";
      }
      next;
    }

    # find headers and massage them a bit
    if (/^&lt;H[1-6]&gt;/) {
      print $header_begin;
      print;
      while (&lt;&gt;) {
        next if /^&lt;BR&gt;\s*$/;  #omit excessive blank lines
        print;
        last if /^&lt;\/H[1-6]&gt;/;
      }
      print $header_end;
      if ($subsections) {
        print $subsections;
        undef $subsections;
      }
      $seen_header = 1;
    }

    # remove subsections html (will put back in later)
    if (/^&lt;!--Table of Child-Links--&gt;/ &amp;&amp; ! $seen_header) {
      $subsections = $_;
      while (&lt;&gt;) {
        $subsections .= $_;
        last if /&lt;!--End of Table of Child-Links--&gt;/;
      }
      $_ = &lt;&gt;;
      last unless $_;
      next if /^&lt;HR&gt;/;
    }

    # if we find a hr and have stored subsections, better print em!
    if (/&lt;HR&gt;/) {
      print $subsections;
      undef $subsections;
    }

    print;
    $at_body_begin = 0;
  }
}
</pre></body></html>