2 ###############################################################################
6 # Convert a ca65 source into HTML #
10 # (C) 2000-2007 Ullrich von Bassewitz #
12 # D-70794 Filderstadt #
13 # EMail: uz@cc65.org #
16 # This software is provided 'as-is', without any expressed or implied #
17 # warranty. In no event will the authors be held liable for any damages #
18 # arising from the use of this software. #
20 # Permission is granted to anyone to use this software for any purpose, #
21 # including commercial applications, and to alter it and redistribute it #
22 # freely, subject to the following restrictions: #
24 # 1. The origin of this software must not be misrepresented; you must not #
25 # claim that you wrote the original software. If you use this software #
26 # in a product, an acknowledgment in the product documentation would be #
27 # appreciated but is not required. #
28 # 2. Altered source versions must be plainly marked as such, and must not #
29 # be misrepresented as being the original software. #
30 # 3. This notice may not be removed or altered from any source #
33 ###############################################################################
37 # Things currently missing:
39 # - Scoping with .proc/.endproc
40 # - .global is ignored
41 # - .constructor/.destructor/.condes dito
42 # - .ignorecase is ignored, labels are always case sensitive
43 # - .include handling (difficult)
44 # - The global namespace operator ::
57 #-----------------------------------------------------------------------------#
59 # ----------------------------------------------------------------------------#
64 my %Files = (); # List of all files.
65 my $FileCount = 0; # Number of input files
66 my %Exports = (); # List of exported symbols.
67 my %Imports = (); # List of imported symbols.
68 my %Labels = (); # List of all labels
69 my $LabelNum = 0; # Counter to generate unique labels
71 # Command line options
72 my $BGColor = "#FFFFFF"; # Background color
73 my $Colorize = 0; # Colorize the output
74 my $CommentColor = "#B22222"; # Color for comments
75 my $CRefs = 0; # Add references to the C file
76 my $CtrlColor = "#228B22"; # Color for control directives
77 my $CvtTabs = 0; # Convert tabs to spaces
78 my $Debug = 0; # No debugging
79 my $Help = 0; # Help flag
80 my $HTMLDir = ""; # Directory in which to create the files
81 my $IndexCols = 6; # Columns in the file listing
82 my $IndexTitle = "Index"; # Title of index page
83 my $IndexName = "index.html"; # Name of index page
84 my $IndexPage = 0; # Create an index page
85 my $KeywordColor = "#A020F0"; # Color for keywords
86 my $LineLabels = 0; # Add a HTML label to each line
87 my $LineNumbers = 0; # Add line numbers to the output
88 my $LinkStyle = 0; # Default link style
89 my $ReplaceExt = 0; # Replace extension instead of appending
90 my $StringColor = "#6169C1"; # Color for strings
91 my $TextColor = "#000000"; # Text color
92 my $Verbose = 0; # Be quiet
94 # Table used to convert the label number into names
95 my @NameTab = ("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K",
96 "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
97 "W", "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6",
102 #-----------------------------------------------------------------------------#
104 # ----------------------------------------------------------------------------#
108 # Terminate with an error
110 print STDERR "ca65html: @_\n";
114 # Print a message if verbose is true
117 print "ca65html: @_\n";
121 # Generate a label and return it
126 my $Num = $LabelNum++;
129 for ($I = 0; $I < 4; $I++) {
130 $L = $NameTab[$Num % 36] . $L;
136 # Make an output file name from an input file name
139 # Input name is parameter
142 # Create the output file name from the input file name
143 if ($ReplaceExt && $InName =~ /^(.+)\.([^\.\/]*)$/) {
146 return "$InName.html";
150 # Remove illegal characters from a string
160 # Strip a path from a filename and return just the name
163 # Filename is argument
164 my $FileName = $_[0];
166 # Remove a path name if we have one
167 $FileName =~ /^(.*?)([^\/]*)$/;
173 #-----------------------------------------------------------------------------#
174 # Document header and footer #
175 # ----------------------------------------------------------------------------#
179 # Print the document header
181 my $OUT = shift (@_);
182 my $Asm = shift (@_);
183 print $OUT "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
187 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
188 <meta name="GENERATOR" content="ca65html">
190 <style type=\"text/css\">
192 background-color: $BGColor;
200 border-bottom: 1px solid grey;
205 border-top: 1px solid grey;
216 color: $KeywordColor;
222 color: $CommentColor;
236 <div id=\"top\"><h1>$Asm</h1></div>
240 # Print the document footer
242 my $OUT = shift (@_);
243 my $Name = shift (@_);
245 # Get the current date and time
246 my $Today = localtime;
249 print $OUT "<div id=\"bottom\">\n";
250 print $OUT "<address>\n";
251 print $OUT "<a href=\"http://validator.w3.org/check?uri=referer\"><img src=\"http://www.w3.org/Icons/valid-xhtml10-blue\" alt=\"Valid XHTML 1.0 Strict\" height=\"31\" width=\"88\" /></a>";
252 print $OUT "$Name; generated on $Today by ca65html<br>\n";
253 print $OUT "<a href=\"mailto:uz@cc65.org\">uz@cc65.org</a>\n";
254 print $OUT "</address>\n";
255 print $OUT "</div>\n";
256 print $OUT "</body>\n";
257 print $OUT "</html>\n";
262 #-----------------------------------------------------------------------------#
264 #-----------------------------------------------------------------------------#
268 sub ColorizeComment {
269 if ($Colorize && $_[0] ne "") {
270 return "<span class=\"comment\">$_[0]</span>";
280 return "<span class=\"ctrl\">$_[0]</span>";
288 sub ColorizeKeyword {
290 return "<span class=\"keyword\">$_[0]</span>";
300 return "<span class=\"string\">$_[0]</span>";
308 #-----------------------------------------------------------------------------#
309 # File list management #
310 #-----------------------------------------------------------------------------#
316 # Argument is file to add
317 my $FileName = $_[0];
319 # Get just the name (remove a path if there is one)
320 my $Name = StripPath ($FileName);
322 # Check if we have the file already
323 if (exists ($Files{$Name})) {
324 Gabble ("File \"$FileName\" already known");
328 # Check with the full pathname. If we don't find it, search in the current
330 if (-f $FileName && -r _) {
331 $Files{$Name} = $FileName;
333 } elsif (-f $Name && -r _) {
334 $Files{$Name} = $Name;
337 Abort ("$FileName not found or not readable");
343 #-----------------------------------------------------------------------------#
344 # Referencing and defining labels #
345 #-----------------------------------------------------------------------------#
349 # Get a label reference
352 # Arguments are: Filename, identifier, item that should be tagged
353 my $FileName = $_[0];
357 # Search for the identifier in the list of labels
358 if (exists ($Labels{$FileName}{$Id})) {
359 # It is a label (in this file)
360 return sprintf ("<a href=\"#%s\">%s</a>", $Labels{$FileName}{$Id}, $Item);
361 } elsif (exists ($Imports{$FileName}{$Id})) {
362 # It is an import. If LinkStyle is 1, or if the file exporting the
363 # identifier is not visible, we link to the .import statement in the
364 # current file. Otherwise we link directly to the referenced symbol
365 # in the file that exports it.
366 if ($LinkStyle == 1 or not exists ($Exports{$Id})) {
367 return sprintf ("<a href=\"#%s\">%s</a>", $Imports{$FileName}{$Id}, $Item);
369 # Get the filename from the export
371 ($FileName, $Label) = split (/#/, $Exports{$Id});
372 if (not defined ($Labels{$FileName}{$Id})) {
373 # This may currently happen because we don't see .include
374 # statements, so we may have an export but no definition.
375 # Link to the .export statement instead
376 $Label = $Exports{$Id};
378 # Link to the definition in the file
379 $Label = sprintf ("%s#%s", $FileName, $Labels{$FileName}{$Id});
381 return sprintf ("<a href=\"%s\">%s</a>", $Label, $Item);
384 # The symbol is unknown, return as is
391 #-----------------------------------------------------------------------------#
393 # ----------------------------------------------------------------------------#
397 # Process1: Read one file for the first time.
404 # Filename is parameter
405 my $InName = shift(@_);
407 # Create the output file name from the input file name
408 my $OutName = GetOutName ($InName);
410 # Current cheap local label prefix is empty
411 my $CheapPrefix = "";
413 # Open a the input file
414 my $FileName = $Files{$InName}; # Includes path if needed
415 open (INPUT, "<$FileName") or Abort ("Cannot open $FileName: $!");
417 # Keep the user happy
418 Gabble ("$FileName => $OutName");
420 # Read and process all lines from the file
421 while ($Line = <INPUT>) {
427 if ($Line =~ /^\s*(\@?)([_a-zA-Z]\w*)(:(?!=)|\s*:?=)/) {
429 # Is this a local label?
432 $Id = "$CheapPrefix$1$2";
436 # Remember the id as new cheap local prefix
441 $Labels{$OutName}{$Id} = GenLabel();
443 # Check for an import statement
444 } elsif ($Line =~ /^\s*(\.import|\.importzp)\s+(.*?)(\s*)(;.*$|$)/) {
446 # Split into a list of identifiers
447 my @Ids = split (/\s*,\s*/, $2);
449 $Imports{$OutName}{$Id} = GenLabel();
452 # Check for an export statement
453 } elsif ($Line =~ /^\s*(\.export|\.exportzp)\s+(.*?)(\s*)(;.*$|$)/) {
455 # Split into a list of identifiers
456 my @Ids = split (/\s*,\s*/, $2);
458 $Exports{$Id} = sprintf ("%s#%s", $OutName, GenLabel());
461 # Check for a .proc statement
462 } elsif ($Line =~ /^\s*\.proc\s+([_a-zA-Z]\w*)?.*$/) {
467 $Labels{$OutName}{$Id} = GenLabel();
473 # Close the input file
479 # Pass1: Read all files for the first time.
482 # Keep the user happy
485 # Walk over the files
486 for my $InName (keys (%Files)) {
494 #-----------------------------------------------------------------------------#
496 # ----------------------------------------------------------------------------#
500 # Process2: Read one file the second time.
514 # Input file is parameter
515 my $InName = shift(@_);
517 # Create the output file name from the input file name
518 my $OutName = GetOutName ($InName);
520 # Current cheap local label prefix is empty
521 my $CheapPrefix = "";
523 # Open a the input file
524 my $FileName = $Files{$InName}; # Includes path if needed
525 open (INPUT, "<$FileName") or Abort ("Cannot open $FileName: $!");
527 # Open the output file and print the HTML header
528 open (OUTPUT, ">$HTMLDir$OutName") or Abort ("Cannot open $OutName: $!");
529 DocHeader (OUTPUT, $InName);
530 print OUTPUT "<pre>\n";
532 # Keep the user happy
533 Gabble ("$FileName => $OutName");
535 # The instructions that will have hyperlinks if a label is used
536 my $LabelIns = "adc|add|and|asl|bcc|bcs|beq|bit|bmi|bne|bpl|bra|bvc|bvs|".
537 "cmp|cpx|cpy|dec|eor|inc|jmp|jsr|lda|ldx|ldy|lsr|ora|rol|".
538 "ror|sbc|sta|stx|sty|stz|sub|";
540 # The instructions that will have hyperlinks if a label is used
541 my $AllIns = "adc|add|and|asl|bcc|bcs|beq|bge|bit|blt|bmi|bne|bpl|bvc|".
542 "bra|brk|brl|bvs|clc|cld|cli|clv|cmp|cop|cpa|cpx|cpy|dea|".
543 "dec|dex|dey|eor|ina|inc|inx|iny|jml|jmp|jsl|jsr|lda|ldx|".
544 "ldy|lsr|mvn|mvp|nop|ora|pea|pei|per|pha|phb|phd|phk|php|".
545 "phx|phy|pla|plb|pld|plp|plx|ply|rep|rol|ror|rti|rtl|rts|".
546 "sbc|sec|sed|sei|sep|sta|stx|sty|stz|sub|swa|tad|tax|tay|".
547 "tcd|tcs|tda|tdc|trb|tsa|tsb|tsc|tsx|txa|txs|txy|tya|tyx|".
550 # Read the input file, replacing references by hyperlinks and mark
551 # labels as link targets.
553 while ($Line = <INPUT>) {
561 # If requested, convert tabs to spaces
563 # Don't ask me - this is from the perl manual page
564 1 while ($Line =~ s/\t+/' ' x (length($&)*8 - length($`)%8)/e) ;
567 # Clear the output line
570 # If requested, add a html label to each line with a name "linexxx",
571 # so it can be referenced from the outside (this is the same convention
572 # that is used by c2html). If we have line numbers enabled, add them.
573 if ($LineLabels && $LineNumbers) {
574 $OutLine .= sprintf ("<a name=\"line%d\">%6d</a>: ", $LineNo, $LineNo);
575 } elsif ($LineLabels) {
576 $OutLine .= sprintf ("<a name=\"line%d\"></a>", $LineNo);
577 } elsif ($LineNumbers) {
578 $OutLine .= sprintf ("%6d: ", $LineNo);
581 # Cut off a comment from the input line. Beware: We have to check for
582 # strings, since these may contain a semicolon that is no comment
584 ($Line, $Comment) = $Line =~ /^((?:[^"';]+|".*?"|'.*?')*)(.*)$/;
585 if ($Comment =~ /^["']/) {
586 # Line with invalid syntax - there's a string start but
588 Abort (sprintf ("Invalid input at %s(%d)", $FileName, $LineNo));
591 # Remove trailing whitespace and move it together with the comment
592 # into the $Trailer variable.
594 $Trailer = $& . ColorizeComment (Cleanup ($Comment));
596 # Check for a label at the start of the line. If we have one, process
597 # it and remove it from the line
598 if ($Line =~ s/^\s*?(\@?)([_a-zA-Z]\w*)(:(?!=)|\s*:?=)//) {
600 # Is this a local label?
603 $Id = "$CheapPrefix$1$2";
607 # Remember the id as new cheap local prefix
611 # Get the label for the id
612 $Label = $Labels{$OutName}{$Id};
614 # Print the label with a tag
615 $OutLine .= sprintf ("<a name=\"%s\">%s%s</a>%s", $Label, $1, $2, $3);
618 # Print any leading whitespace and remove it, so we don't have to
619 # care about whitespace below.
620 if ($Line =~ s/^\s+//) {
624 # Handle the import statements
625 if ($Line =~ s/^(\.import|\.importzp)\s+//) {
627 # Print any fixed stuff from the line and remove it
630 # Print all identifiers if there are any
631 while ($Line =~ s/^[_a-zA-Z]\w*//) {
633 # Remember the identifier
636 # Variable to assemble HTML representation
639 # Make this import a link target
640 if (exists ($Imports{$OutName}{$Id})) {
641 $Label = $Imports{$OutName}{$Id};
642 $Contents .= sprintf (" name=\"%s\"", $Label);
645 # If we have an export for this import, add a link to this
647 if (exists ($Exports{$Id})) {
648 $Label = $Exports{$Id};
649 $Contents .= sprintf (" href=\"%s\"", $Label);
652 # Add the HTML stuff to the output line
653 if ($Contents ne "") {
654 $OutLine .= sprintf ("<a%s>%s</a>", $Contents, $Id);
659 # Check if another identifier follows
660 if ($Line =~ s/^\s*,\s*//) {
667 # Add an remainder if there is one
668 $OutLine .= Cleanup ($Line);
670 # Handle export statements
671 } elsif ($Line =~ s/^(\.export|\.exportzp)\s+//) {
673 # Print the command the and white space
676 # Print all identifiers if there are any
677 while ($Line =~ s/^[_a-zA-Z]\w*//) {
679 # Remember the identifier
682 # Variable to assemble HTML representation
685 # If we have a definition for this export in this file, add
686 # a link to the definition.
687 if (exists ($Labels{$OutName}{$Id})) {
688 $Label = $Labels{$OutName}{$Id};
689 $Contents = sprintf (" href=\"#%s\"", $Label);
692 # If we have this identifier in the list of exports, add a
693 # jump target for the export.
694 if (exists ($Exports{$Id})) {
695 $Label = $Exports{$Id};
696 # Be sure to use only the label part
698 $Contents .= sprintf (" name=\"%s\"", $Label);
701 # Add the HTML stuff to the output line
702 if ($Contents ne "") {
703 $OutLine .= sprintf ("<a%s>%s</a>", $Contents, $Id);
708 # Check if another identifier follows
709 if ($Line =~ s/^\s*,\s*//) {
716 # Add an remainder if there is one
717 $OutLine .= Cleanup ($Line);
719 # Check for .addr and .word
720 } elsif ($Line =~ s/^(\.addr|\.word)\s+//) {
722 # Print the command and the white space
725 # Print all identifiers if there are any
726 while ($Line =~ /^([^_a-zA-Z]*)([_a-zA-Z]\w*)(.*)$/) {
727 # Add the non label stuff
728 $OutLine .= Cleanup ($1);
730 # If the identifier is a known label, add a link
731 if (exists ($Labels{$OutName}{$2})) {
732 $Label = $Labels{$OutName}{$2};
733 $OutLine .= sprintf ("<a href=\"#%s\">%s</a>", $Label, $2);
738 # Proceed with the remainder of the line
742 # Add an remainder if there is one
743 $OutLine .= Cleanup ($Line);
746 } elsif ($Line =~ /^(\.proc)(\s+)([_a-zA-Z]\w*)?(.*)$/) {
748 # Do we have an identifier?
750 # Get the label for the id
751 $Label = $Labels{$OutName}{$3};
753 # Print the label with a tag
754 $OutLine .= "$1$2<a name=\"$Label\">$3</a>";
759 $OutLine .= "$1$2$3";
764 $OutLine .= Cleanup ($4);
767 } elsif ($Line =~ /^(\.include)(\s+)\"((?:[^\"]+?|\\\")+)(\".*)$/) {
769 # Add the fixed stuff to the output line
770 $OutLine .= "$1$2"";
772 # Get the filename into a named variable
773 my $FileName = Cleanup ($3);
775 # Get the name without a path
776 my $Name = StripPath ($3);
778 # If the include file is among the list of our files, add a link,
779 # otherwise just add the name as is.
780 if (exists ($Files{$Name})) {
781 $OutLine .= sprintf ("<a href=\"%s\">%s</a>", GetOutName ($Name), $FileName);
783 $OutLine .= $FileName;
787 $OutLine .= Cleanup ($4);
790 } elsif ($CRefs && $Line =~ s/^\.dbg\s+//) {
792 # Add the fixed stuff to the output line
795 # Check for the type of the .dbg directive
796 if ($Line =~ /^(line,\s*)\"((?:[^\"]+?|\\\")+)\"(,\s*)(\d+)(.*)$/) {
798 # Add the fixed stuff to the output line
799 $OutLine .= "$1"";
801 # Get the filename and line number into named variables
805 # Remember the remainder
808 # Get the name without a path
809 my $Name = StripPath ($DbgFile);
811 # We don't need FileName any longer as is, so clean it up
812 $DbgFile = Cleanup ($DbgFile);
814 # Add a link to the source file
815 $OutLine .= sprintf ("<a href=\"%s.html#line%d\">%s</a>", $Name, $DbgLine, $DbgFile);
818 $OutLine .= Cleanup ($Line);
820 } elsif ($Line =~ /^(file,\s*)\"((?:[^\"]+?|\\\")+)\"(.*)$/) { #pf FIXME: doesn't handle \" correctly!
822 # Get the filename into a named variables
823 my $DbgFile = Cleanup ($2);
825 # Get the name without a path
826 my $Name = Cleanup (StripPath ($2));
828 # Add the fixed stuff to the output line
829 $OutLine .= sprintf ("%s\"<a href=\"%s.html\">%s</a>\"%s",
830 $1, $Name, $DbgFile, $3);
835 $OutLine .= Cleanup ($Line);
839 } elsif ($CRefs && $Line =~ /^(\.dbg)(\s+line,\s*)\"((?:[^\"]+?|\\\")+)\"(,\s*)(\d+)(.*$)/) {
841 # Add the fixed stuff to the output line
842 $OutLine .= "$1$2"";
844 # Get the filename and line number into named variables
848 # Remember the remainder
851 # Get the name without a path
852 my $Name = StripPath ($FileName);
854 # We don't need FileName any longer as is, so clean it up
855 $FileName = Cleanup ($FileName);
857 # Add a link to the source file
858 $OutLine .= sprintf ("<a href=\"%s.html#line%d\">%s</a>", $Name, $LineNo, $FileName);
861 $OutLine .= Cleanup ($Line);
863 # Check for instructions with labels
864 } elsif ($Line =~ /^($LabelIns)\b(\s+)(.*)$/) {
866 # Print the instruction and white space
867 $OutLine .= ColorizeKeyword ($1) . $2;
869 # Remember the remaining parts
872 # Check for the first identifier in the operand and replace it
874 if ($Operand =~ /^([^_a-zA-Z]*?)(\@?)([_a-zA-Z]\w*)(.*)$/) {
876 # Is this a local label?
879 $Id = "$CheapPrefix$2$3";
885 # Get the reference to this label if we find it
886 $Operand = Cleanup($1) . RefLabel($OutName, $Id, $2 . $3) . Cleanup($4);
889 # Reassemble and print the line
890 $OutLine .= $Operand;
892 # Check for all other instructions
893 } elsif ($Line =~ /^($AllIns)\b(.*)$/) {
896 $OutLine .= ColorizeKeyword ($1) . Cleanup ($2);
900 # Nothing known - print the line
901 $OutLine .= Cleanup ($Line);
905 # Colorize all keywords
906 $OutLine =~ s/(?<![\w;])\.[_a-zA-Z]\w*/ColorizeCtrl ($&)/ge;
909 $OutLine .= $Trailer;
912 print OUTPUT "$OutLine\n";
915 # Print the HTML footer
916 print OUTPUT "</pre>\n";
917 DocFooter (OUTPUT, $OutName);
926 # Pass2: Read all files the second time.
929 # Keep the user happy
932 # Walk over the files
933 for my $InName (keys (%Files)) {
941 #-----------------------------------------------------------------------------#
942 # Create an index page #
943 # ----------------------------------------------------------------------------#
947 # Print a list of all files
953 # Print the file list in a table
954 print $INDEX "<h2>Files</h2><p>\n";
955 print $INDEX "<table border=\"0\" width=\"100%\">\n";
957 for my $File (sort (keys (%Files))) {
960 if (($Count % $IndexCols) == 0) {
961 print $INDEX "<tr>\n";
963 printf $INDEX "<td><a href=\"%s\">%s</a></td>\n", GetOutName ($File), $File;
964 if (($Count % $IndexCols) == $IndexCols-1) {
965 print $INDEX "</tr>\n";
969 if (($Count % $IndexCols) != 0) {
970 print $INDEX "</tr>\n";
972 print $INDEX "</table><p><br><p>\n";
977 # Print a list of all exports
983 # Print the file list in a table
984 print $INDEX "<h2>Exports</h2><p>\n";
985 print $INDEX "<table border=\"0\" width=\"100%\">\n";
987 for my $Export (sort (keys (%Exports))) {
992 ($File, $Label) = split (/#/, $Exports{$Export});
994 # The label is the label of the export statement. If we can find the
995 # actual label, use this instead.
996 if (exists ($Labels{$File}{$Export})) {
997 $Label = $Labels{$File}{$Export};
1001 if (($Count % $IndexCols) == 0) {
1002 print $INDEX "<tr>\n";
1004 printf $INDEX "<td><a href=\"%s#%s\">%s</a></td>\n", $File, $Label, $Export;
1005 if (($Count % $IndexCols) == $IndexCols-1) {
1006 print $INDEX "</tr>\n";
1010 if (($Count % $IndexCols) != 0) {
1011 print $INDEX "</tr>\n";
1013 print $INDEX "</table><p><br><p>\n";
1020 # Open the index page file
1021 open (INDEX, ">$HTMLDir$IndexName") or Abort ("Cannot open $IndexName: $!");
1024 DocHeader (INDEX, $IndexTitle, 0);
1026 # Print the file list in a table
1028 ExportIndex (INDEX);
1030 # Print the document footer
1031 DocFooter (INDEX, $IndexName);
1033 # Close the index file
1039 #-----------------------------------------------------------------------------#
1040 # Print usage information #
1041 # ----------------------------------------------------------------------------#
1046 print "Usage: ca65html [options] file ...\n";
1048 print " --bgcolor c Use background color c instead of $BGColor\n";
1049 print " --colorize Colorize the output (generates non standard HTML)\n";
1050 print " --commentcolor c Use color c for comments instead of $CommentColor\n";
1051 print " --crefs Generate references to the C source file(s)\n";
1052 print " --ctrlcolor c Use color c for directives instead of $CtrlColor\n";
1053 print " --cvttabs Convert tabs to spaces in the output\n";
1054 print " --help This text\n";
1055 print " --htmldir dir Specify directory for HTML files\n";
1056 print " --indexcols n Use n columns on index page (default $IndexCols)\n";
1057 print " --indexname file Use file for the index file instead of $IndexName\n";
1058 print " --indexpage Create an index page\n";
1059 print " --indextitle title Use title as the index title instead of $IndexTitle\n";
1060 print " --keywordcolor c Use color c for keywords instead of $KeywordColor\n";
1061 print " --linelabels Generate a linexxx HTML label for each line\n";
1062 print " --linenumbers Add line numbers to the output\n";
1063 print " --linkstyle style Use the given link style\n";
1064 print " --replaceext Replace source extension instead of appending .html\n";
1065 print " --textcolor c Use text color c instead of $TextColor\n";
1066 print " --verbose Be more verbose\n";
1071 #-----------------------------------------------------------------------------#
1073 # ----------------------------------------------------------------------------#
1077 # Get program options
1078 GetOptions ("bgcolor=s" => \$BGColor,
1079 "colorize" => \$Colorize,
1080 "commentcolor=s" => \$CommentColor,
1082 "ctrlcolor=s" => \$CtrlColor,
1083 "cvttabs" => \$CvtTabs,
1084 "debug!" => \$Debug,
1086 "htmldir=s" => \$HTMLDir,
1087 "indexcols=i" => \$IndexCols,
1088 "indexname=s" => \$IndexName,
1089 "indexpage" => \$IndexPage,
1090 "indextitle=s" => \$IndexTitle,
1091 "keywordcolor=s" => \$KeywordColor,
1092 "linelabels" => \$LineLabels,
1093 "linenumbers" => \$LineNumbers,
1094 "linkstyle=i" => \$LinkStyle,
1095 "replaceext" => \$ReplaceExt,
1096 "textcolor=s" => \$TextColor,
1097 "verbose!" => \$Verbose,
1100 # Check some arguments
1101 if ($IndexCols <= 0 || $IndexCols >= 20) {
1102 Abort ("Invalid value for --indexcols option");
1104 if ($HTMLDir ne "" && $HTMLDir =~ /[^\/]$/) {
1105 # Add a trailing path separator
1111 # Print help if requested
1116 # Check if we have input files given
1117 if ($FileCount == 0) {
1118 Abort ("No input files");
1121 # Convert the documents
1125 # Generate an index page if requested