]> git.sur5r.net Git - cc65/blobdiff - src/ca65html/ca65html
Fixed a problem and a typo
[cc65] / src / ca65html / ca65html
index eaf6901063488f1534d3b77417a1bb0473b56493..c86e4b8af604f994589ddbcfbb9a5c0ddaa8e181 100755 (executable)
 
 
 
+# Things currently missing:
+#
+#   - Scoping with .proc/.endproc
+#   - .global is ignored
+#   - .constructor/.destructor/.condes dito
+#   - .ignorecase is ignored, labels are always case sensitive
+#   - .include handling (difficult)
+#   - The global namespace operator ::
+#
+
+
+
 use strict 'vars';
 use warnings;
 
@@ -62,13 +74,19 @@ my $Debug   = 0;            # No debugging
 my $Help       = 0;            # Help flag
 my $HTMLDir    = "";           # Directory in which to create the files
 my $IndexCols          = 6;            # Columns in the file listing
-my $IndexTitle = "Index";      # Title of index page
-my $IndexName  = "index.html"; # Name of index page
-my $IndexPage  = 0;            # Create an index page
+my $IndexTitle         = "Index";      # Title of index page
+my $IndexName          = "index.html"; # Name of index page
+my $IndexPage          = 0;            # Create an index page
 my $LinkStyle          = 0;            # Default link style
-my $ReplaceExt = 0;            # Replace extension instead of appending
-my $TextColor  = "#000000";    # Text color
-my $Verbose            = 0;            # Be quiet
+my $ReplaceExt         = 0;            # Replace extension instead of appending
+my $TextColor          = "#000000";    # Text color
+my $Verbose            = 0;            # Be quiet
+
+# Table used to convert the label number into names
+my @NameTab            = ("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K",
+                          "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
+                          "W", "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6",
+                          "7", "8", "9");
 
 
 
@@ -93,8 +111,17 @@ sub Gabble {
 
 # Generate a label and return it
 sub GenLabel {
+
+    my $I;
+    my $L = "";;
+    my $Num = $LabelNum++;
+
     # Generate the label
-    return sprintf ("L%06X", $LabelNum++);
+    for ($I = 0; $I < 4; $I++) {
+       $L = $NameTab[$Num % 36] . $L;
+       $Num /= 36;
+    }
+    return $L;
 }
 
 # Make an output file name from an input file name
@@ -135,7 +162,7 @@ sub StripPath {
 
 
 #-----------------------------------------------------------------------------#
-#                        Document header and footer                          #
+#                        Document header and footer                          #
 # ----------------------------------------------------------------------------#
 
 
@@ -173,11 +200,9 @@ sub DocFooter {
 <p><br><p>
 <hr size=1 noshade>
 <address>
-    <a href=\"http://validator.w3.org/check/referer\"><img border=0
-       src=\"http://validator.w3.org/images/vh40\"
-       alt=\"Valid HTML 4.0!\" height=31 width=88 align=right></a>
-    $Name; generated on $Today by ca65html<br>
-    <a href=\"mailto:uz\@cc65.org\">uz\@cc65.org</a>
+<a href="http://validator.w3.org/check/referer"><img border=0 src="http://validator.w3.org/images/vh40" alt="Valid HTML 4.0!" height=31 width=88 align=right></a>
+$Name; generated on $Today by ca65html<br>
+<a href=\"mailto:uz\@cc65.org\">uz\@cc65.org</a>
 </address>
 </body>
 </html>
@@ -270,7 +295,7 @@ sub RefLabel {
 
 
 #-----------------------------------------------------------------------------#
-#                                  Pass 1                                    #
+#                                  Pass 1                                    #
 # ----------------------------------------------------------------------------#
 
 
@@ -473,24 +498,28 @@ sub Process2 {
                $Line = $2;
 
                # Variable to assemble HTML representation
-               my $Item = $Id;
+                       my $Contents = "";
+
+               # Make this import a link target
+               if (exists ($Imports{$OutName}{$Id})) {
+                           $Label = $Imports{$OutName}{$1};
+                           $Contents .= sprintf (" name=\"%s\"", $Label);
+               }
 
                # If we have an export for this import, add a link to this
                # export definition
                if (exists ($Exports{$Id})) {
                    $Label = $Exports{$Id};
-                   $Item = sprintf ("<a href=\"%s\">%s</a>", $Label, $Item);
+                   $Contents .= sprintf (" href=\"%s\"", $Label);
                }
 
-               # Make this import a link target
-               if (exists ($Imports{$OutName}{$Id})) {
-                           $Label = $Imports{$OutName}{$1};
-                   $Item = sprintf ("<a name=\"%s\">%s</a>", $Label, $Item);
+               # Add the HTML stuff to the output line
+               if ($Contents ne "") {
+                   $OutLine .= sprintf ("<a%s>%s</a>", $Contents, $Id);
+               } else {
+                   $OutLine .= $Id;
                }
 
-               # Add the HTML stuff to the output line
-               $OutLine .= $Item;
-
                # Check if another identifier follows
                if ($Line =~ /^(\s*),(\s*)(.*)$/) {
                    $OutLine .= "$1,$2";
@@ -518,13 +547,13 @@ sub Process2 {
                $Line = $2;
 
                # Variable to assemble HTML representation
-               my $Item = $Id;
+                       my $Contents = "";
 
                # If we have a definition for this export in this file, add
                # a link to the definition.
                if (exists ($Labels{$OutName}{$1})) {
                    $Label = $Labels{$OutName}{$1};
-                           $Item = sprintf ("<a href=\"#%s\">%s</a>", $Label, $Item);
+                           $Contents = sprintf (" href=\"#%s\"", $Label);
                }
 
                # If we have this identifier in the list of exports, add a
@@ -532,12 +561,16 @@ sub Process2 {
                if (exists ($Exports{$Id})) {
                    $Label = $Exports{$Id};
                            # Be sure to use only the label part
-                   $Label =~ s/^(.*#)(.*)$/$2/;
-                   $Item = sprintf ("<a name=\"%s\">%s</a>", $Label, $Item);
+                   $Label =~ s/^(.*#)(.*)$/$2/;        # ##FIXME: Expensive
+                   $Contents .= sprintf (" name=\"%s\"", $Label);
                }
 
                # Add the HTML stuff to the output line
-               $OutLine .= $Item;
+               if ($Contents ne "") {
+                   $OutLine .= sprintf ("<a%s>%s</a>", $Contents, $Id);
+               } else {
+                   $OutLine .= $Id;
+               }
 
                # Check if another identifier follows
                if ($Line =~ /^(\s*),(\s*)(.*)$/) {
@@ -793,20 +826,7 @@ EOF
     ExportIndex (INDEX);
 
     # Print the document footer
-    my $Today = localtime;
-    print INDEX <<"EOF";
-<p><br><p>
-<hr size=1 noshade>
-<address>
-    <a href="http://validator.w3.org/check/referer"><img border=0
-       src="http://validator.w3.org/images/vh40"
-       alt="Valid HTML 4.0!" height="31" width="88" align=right></a>
-    $IndexName; generated on $Today by ca65html<br>
-    <a href=\"mailto:uz\@cc65.org\">uz\@cc65.org</a>
-</address>
-</body>
-</html>
-EOF
+    DocFooter (INDEX, $IndexName);
 
     # Close the index file
     close (INDEX);