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 (@_);
184 # Colorization generates invalid HTML. Common browsers display it
185 # correctly, but we don't claim it adheres to some standard ...
186 print $OUT "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n";
191 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
192 <meta name="GENERATOR" content="ca65html">
195 <body bgcolor="$BGColor" text="$TextColor" link="#0000d0" vlink="#000060" alink="#00d0d0">
197 <center><h1>$Asm</h1></center>
198 <hr size="1" noshade><p><br><p>
202 # Print the document footer
204 my $OUT = shift (@_);
205 my $Name = shift (@_);
207 # Get the current date and time
208 my $Today = localtime;
211 print $OUT "<p><br><p>\n";
212 print $OUT "<hr size=\"1\" noshade>\n";
213 print $OUT "<address>\n";
215 print $OUT "<a href=\"http://validator.w3.org/check/referer\"><img border=\"0\" src=\"http://www.w3.org/Icons/valid-html401\" alt=\"Valid HTML 4.01!\" height=\"31\" width=\"88\" align=\"right\"></a>\n";
217 print $OUT "$Name; generated on $Today by ca65html<br>\n";
218 print $OUT "<a href=\"mailto:uz@cc65.org\">uz@cc65.org</a>\n";
219 print $OUT "</address>\n";
220 print $OUT "</body>\n";
221 print $OUT "</html>\n";
226 #-----------------------------------------------------------------------------#
228 #-----------------------------------------------------------------------------#
232 sub ColorizeComment {
233 if ($Colorize && $_[0] ne "") {
234 return "<font color=\"$CommentColor\">$_[0]</font>";
244 return "<font color=\"$CtrlColor\">$_[0]</font>";
252 sub ColorizeKeyword {
254 return "<font color=\"$KeywordColor\">$_[0]</font>";
264 return "<font color=\"$StringColor\">$_[0]</font>";
272 #-----------------------------------------------------------------------------#
273 # File list management #
274 #-----------------------------------------------------------------------------#
280 # Argument is file to add
281 my $FileName = $_[0];
283 # Get just the name (remove a path if there is one)
284 my $Name = StripPath ($FileName);
286 # Check if we have the file already
287 if (exists ($Files{$Name})) {
288 Gabble ("File \"$FileName\" already known");
292 # Check with the full pathname. If we don't find it, search in the current
294 if (-f $FileName && -r _) {
295 $Files{$Name} = $FileName;
297 } elsif (-f $Name && -r _) {
298 $Files{$Name} = $Name;
301 Abort ("$FileName not found or not readable");
307 #-----------------------------------------------------------------------------#
308 # Referencing and defining labels #
309 #-----------------------------------------------------------------------------#
313 # Get a label reference
316 # Arguments are: Filename, identifier, item that should be tagged
317 my $FileName = $_[0];
321 # Search for the identifier in the list of labels
322 if (exists ($Labels{$FileName}{$Id})) {
323 # It is a label (in this file)
324 return sprintf ("<a href=\"#%s\">%s</a>", $Labels{$FileName}{$Id}, $Item);
325 } elsif (exists ($Imports{$FileName}{$Id})) {
326 # It is an import. If LinkStyle is 1, or if the file exporting the
327 # identifier is not visible, we link to the .import statement in the
328 # current file. Otherwise we link directly to the referenced symbol
329 # in the file that exports it.
330 if ($LinkStyle == 1 or not exists ($Exports{$Id})) {
331 return sprintf ("<a href=\"#%s\">%s</a>", $Imports{$FileName}{$Id}, $Item);
333 # Get the filename from the export
335 ($FileName, $Label) = split (/#/, $Exports{$Id});
336 if (not defined ($Labels{$FileName}{$Id})) {
337 # This may currently happen because we don't see .include
338 # statements, so we may have an export but no definition.
339 # Link to the .export statement instead
340 $Label = $Exports{$Id};
342 # Link to the definition in the file
343 $Label = sprintf ("%s#%s", $FileName, $Labels{$FileName}{$Id});
345 return sprintf ("<a href=\"%s\">%s</a>", $Label, $Item);
348 # The symbol is unknown, return as is
355 #-----------------------------------------------------------------------------#
357 # ----------------------------------------------------------------------------#
361 # Process1: Read one file for the first time.
368 # Filename is parameter
369 my $InName = shift(@_);
371 # Create the output file name from the input file name
372 my $OutName = GetOutName ($InName);
374 # Current cheap local label prefix is empty
375 my $CheapPrefix = "";
377 # Open a the input file
378 my $FileName = $Files{$InName}; # Includes path if needed
379 open (INPUT, "<$FileName") or Abort ("Cannot open $FileName: $!");
381 # Keep the user happy
382 Gabble ("$FileName => $OutName");
384 # Read and process all lines from the file
385 while ($Line = <INPUT>) {
391 if ($Line =~ /^\s*(\@?)([_a-zA-Z]\w*)(:(?!=)|\s*:?=)/) {
393 # Is this a local label?
396 $Id = "$CheapPrefix$1$2";
400 # Remember the id as new cheap local prefix
405 $Labels{$OutName}{$Id} = GenLabel();
407 # Check for an import statement
408 } elsif ($Line =~ /^\s*(\.import|\.importzp)\s+(.*?)(\s*)(;.*$|$)/) {
410 # Split into a list of identifiers
411 my @Ids = split (/\s*,\s*/, $2);
413 $Imports{$OutName}{$Id} = GenLabel();
416 # Check for an export statement
417 } elsif ($Line =~ /^\s*(\.export|\.exportzp)\s+(.*?)(\s*)(;.*$|$)/) {
419 # Split into a list of identifiers
420 my @Ids = split (/\s*,\s*/, $2);
422 $Exports{$Id} = sprintf ("%s#%s", $OutName, GenLabel());
425 # Check for a .proc statement
426 } elsif ($Line =~ /^\s*\.proc\s+([_a-zA-Z]\w*)?.*$/) {
431 $Labels{$OutName}{$Id} = GenLabel();
437 # Close the input file
443 # Pass1: Read all files for the first time.
446 # Keep the user happy
449 # Walk over the files
450 for my $InName (keys (%Files)) {
458 #-----------------------------------------------------------------------------#
460 # ----------------------------------------------------------------------------#
464 # Process2: Read one file the second time.
478 # Input file is parameter
479 my $InName = shift(@_);
481 # Create the output file name from the input file name
482 my $OutName = GetOutName ($InName);
484 # Current cheap local label prefix is empty
485 my $CheapPrefix = "";
487 # Open a the input file
488 my $FileName = $Files{$InName}; # Includes path if needed
489 open (INPUT, "<$FileName") or Abort ("Cannot open $FileName: $!");
491 # Open the output file and print the HTML header
492 open (OUTPUT, ">$HTMLDir$OutName") or Abort ("Cannot open $OutName: $!");
493 DocHeader (OUTPUT, $InName);
494 print OUTPUT "<pre>\n";
496 # Keep the user happy
497 Gabble ("$FileName => $OutName");
499 # The instructions that will have hyperlinks if a label is used
500 my $LabelIns = "adc|add|and|asl|bcc|bcs|beq|bit|bmi|bne|bpl|bra|bvc|bvs|".
501 "cmp|cpx|cpy|dec|eor|inc|jmp|jsr|lda|ldx|ldy|lsr|ora|rol|".
502 "ror|sbc|sta|stx|sty|stz|sub|";
504 # The instructions that will have hyperlinks if a label is used
505 my $AllIns = "adc|add|and|asl|bcc|bcs|beq|bge|bit|blt|bmi|bne|bpl|bvc|".
506 "bra|brk|brl|bvs|clc|cld|cli|clv|cmp|cop|cpa|cpx|cpy|dea|".
507 "dec|dex|dey|eor|ina|inc|inx|iny|jml|jmp|jsl|jsr|lda|ldx|".
508 "ldy|lsr|mvn|mvp|nop|ora|pea|pei|per|pha|phb|phd|phk|php|".
509 "phx|phy|pla|plb|pld|plp|plx|ply|rep|rol|ror|rti|rtl|rts|".
510 "sbc|sec|sed|sei|sep|sta|stx|sty|stz|sub|swa|tad|tax|tay|".
511 "tcd|tcs|tda|tdc|trb|tsa|tsb|tsc|tsx|txa|txs|txy|tya|tyx|".
514 # Read the input file, replacing references by hyperlinks and mark
515 # labels as link targets.
517 while ($Line = <INPUT>) {
525 # If requested, convert tabs to spaces
527 # Don't ask me - this is from the perl manual page
528 1 while ($Line =~ s/\t+/' ' x (length($&)*8 - length($`)%8)/e) ;
531 # Clear the output line
534 # If requested, add a html label to each line with a name "linexxx",
535 # so it can be referenced from the outside (this is the same convention
536 # that is used by c2html). If we have line numbers enabled, add them.
537 if ($LineLabels && $LineNumbers) {
538 $OutLine .= sprintf ("<a name=\"line%d\">%6d</a>: ", $LineNo, $LineNo);
539 } elsif ($LineLabels) {
540 $OutLine .= sprintf ("<a name=\"line%d\"></a>", $LineNo);
541 } elsif ($LineNumbers) {
542 $OutLine .= sprintf ("%6d: ", $LineNo);
545 # Cut off a comment from the input line. Beware: We have to check for
546 # strings, since these may contain a semicolon that is no comment
548 ($Line, $Comment) = $Line =~ /^((?:[^"';]+|".*?"|'.*?')*)(.*)$/;
549 if ($Comment =~ /^["']/) {
550 # Line with invalid syntax - there's a string start but
552 Abort (sprintf ("Invalid input at %s(%d)", $FileName, $LineNo));
555 # Remove trailing whitespace and move it together with the comment
556 # into the $Trailer variable.
558 $Trailer = $& . ColorizeComment (Cleanup ($Comment));
560 # Check for a label at the start of the line. If we have one, process
561 # it and remove it from the line
562 if ($Line =~ s/^\s*?(\@?)([_a-zA-Z]\w*)(:(?!=)|\s*:?=)//) {
564 # Is this a local label?
567 $Id = "$CheapPrefix$1$2";
571 # Remember the id as new cheap local prefix
575 # Get the label for the id
576 $Label = $Labels{$OutName}{$Id};
578 # Print the label with a tag
579 $OutLine .= sprintf ("<a name=\"%s\">%s%s</a>%s%s", $Label, $1, $2, $3, $4);
582 # Print any leading whitespace and remove it, so we don't have to
583 # care about whitespace below.
584 if ($Line =~ s/^\s+//) {
588 # Handle the import statements
589 if ($Line =~ s/^(\.import|\.importzp)\s+//) {
591 # Print any fixed stuff from the line and remove it
594 # Print all identifiers if there are any
595 while ($Line =~ s/^[_a-zA-Z]\w*//) {
597 # Remember the identifier
600 # Variable to assemble HTML representation
603 # Make this import a link target
604 if (exists ($Imports{$OutName}{$Id})) {
605 $Label = $Imports{$OutName}{$Id};
606 $Contents .= sprintf (" name=\"%s\"", $Label);
609 # If we have an export for this import, add a link to this
611 if (exists ($Exports{$Id})) {
612 $Label = $Exports{$Id};
613 $Contents .= sprintf (" href=\"%s\"", $Label);
616 # Add the HTML stuff to the output line
617 if ($Contents ne "") {
618 $OutLine .= sprintf ("<a%s>%s</a>", $Contents, $Id);
623 # Check if another identifier follows
624 if ($Line =~ s/^\s*,\s*//) {
631 # Add an remainder if there is one
632 $OutLine .= Cleanup ($Line);
634 # Handle export statements
635 } elsif ($Line =~ s/^(\.export|\.exportzp)\s+//) {
637 # Print the command the and white space
640 # Print all identifiers if there are any
641 while ($Line =~ s/^[_a-zA-Z]\w*//) {
643 # Remember the identifier
646 # Variable to assemble HTML representation
649 # If we have a definition for this export in this file, add
650 # a link to the definition.
651 if (exists ($Labels{$OutName}{$Id})) {
652 $Label = $Labels{$OutName}{$Id};
653 $Contents = sprintf (" href=\"#%s\"", $Label);
656 # If we have this identifier in the list of exports, add a
657 # jump target for the export.
658 if (exists ($Exports{$Id})) {
659 $Label = $Exports{$Id};
660 # Be sure to use only the label part
662 $Contents .= sprintf (" name=\"%s\"", $Label);
665 # Add the HTML stuff to the output line
666 if ($Contents ne "") {
667 $OutLine .= sprintf ("<a%s>%s</a>", $Contents, $Id);
672 # Check if another identifier follows
673 if ($Line =~ s/^\s*,\s*//) {
680 # Add an remainder if there is one
681 $OutLine .= Cleanup ($Line);
683 # Check for .addr and .word
684 } elsif ($Line =~ s/^(\.addr|\.word)\s+//) {
686 # Print the command and the white space
689 # Print all identifiers if there are any
690 while ($Line =~ /^([^_a-zA-Z]*)([_a-zA-Z]\w*)(.*)$/) {
691 # Add the non label stuff
692 $OutLine .= Cleanup ($1);
694 # If the identifier is a known label, add a link
695 if (exists ($Labels{$OutName}{$2})) {
696 $Label = $Labels{$OutName}{$2};
697 $OutLine .= sprintf ("<a href=\"#%s\">%s</a>", $Label, $2);
702 # Proceed with the remainder of the line
706 # Add an remainder if there is one
707 $OutLine .= Cleanup ($Line);
710 } elsif ($Line =~ /^(\.proc)(\s+)([_a-zA-Z]\w*)?(.*)$/) {
712 # Do we have an identifier?
714 # Get the label for the id
715 $Label = $Labels{$OutName}{$3};
717 # Print the label with a tag
718 $OutLine .= "$1$2<a name=\"$Label\">$3</a>";
723 $OutLine .= "$1$2$3";
728 $OutLine .= Cleanup ($4);
731 } elsif ($Line =~ /^(\.include)(\s+)\"((?:[^\"]+?|\\\")+)(\".*)$/) {
733 # Add the fixed stuff to the output line
734 $OutLine .= "$1$2"";
736 # Get the filename into a named variable
737 my $FileName = Cleanup ($3);
739 # Get the name without a path
740 my $Name = StripPath ($3);
742 # If the include file is among the list of our files, add a link,
743 # otherwise just add the name as is.
744 if (exists ($Files{$Name})) {
745 $OutLine .= sprintf ("<a href=\"%s\">%s</a>", GetOutName ($Name), $FileName);
747 $OutLine .= $FileName;
751 $OutLine .= Cleanup ($4);
754 } elsif ($CRefs && $Line =~ s/^\.dbg\s+//) {
756 # Add the fixed stuff to the output line
759 # Check for the type of the .dbg directive
760 if ($Line =~ /^(line,\s*)\"((?:[^\"]+?|\\\")+)\"(,\s*)(\d+)(.*)$/) {
762 # Add the fixed stuff to the output line
763 $OutLine .= "$1"";
765 # Get the filename and line number into named variables
769 # Remember the remainder
772 # Get the name without a path
773 my $Name = StripPath ($DbgFile);
775 # We don't need FileName any longer as is, so clean it up
776 $DbgFile = Cleanup ($DbgFile);
778 # Add a link to the source file
779 $OutLine .= sprintf ("<a href=\"%s.html#line%d\">%s</a>", $Name, $DbgLine, $DbgFile);
782 $OutLine .= Cleanup ($Line);
784 } elsif ($Line =~ /^(file,\s*)\"((?:[^\"]+?|\\\")+)\"(.*)$/) { #pf FIXME: doesn't handle \" correctly!
786 # Get the filename into a named variables
787 my $DbgFile = Cleanup ($2);
789 # Get the name without a path
790 my $Name = Cleanup (StripPath ($2));
792 # Add the fixed stuff to the output line
793 $OutLine .= sprintf ("%s\"<a href=\"%s.html\">%s</a>\"%s",
794 $1, $Name, $DbgFile, $3);
799 $OutLine .= Cleanup ($Line);
803 } elsif ($CRefs && $Line =~ /^(\.dbg)(\s+line,\s*)\"((?:[^\"]+?|\\\")+)\"(,\s*)(\d+)(.*$)/) {
805 # Add the fixed stuff to the output line
806 $OutLine .= "$1$2"";
808 # Get the filename and line number into named variables
812 # Remember the remainder
815 # Get the name without a path
816 my $Name = StripPath ($FileName);
818 # We don't need FileName any longer as is, so clean it up
819 $FileName = Cleanup ($FileName);
821 # Add a link to the source file
822 $OutLine .= sprintf ("<a href=\"%s.html#line%d\">%s</a>", $Name, $LineNo, $FileName);
825 $OutLine .= Cleanup ($Line);
827 # Check for instructions with labels
828 } elsif ($Line =~ /^($LabelIns)\b(\s+)(.*)$/) {
830 # Print the instruction and white space
831 $OutLine .= ColorizeKeyword ($1) . $2;
833 # Remember the remaining parts
836 # Check for the first identifier in the operand and replace it
838 if ($Operand =~ /^([^_a-zA-Z]*?)(\@?)([_a-zA-Z]\w*)(.*)$/) {
840 # Is this a local label?
843 $Id = "$CheapPrefix$2$3";
849 # Get the reference to this label if we find it
850 $Operand = Cleanup($1) . RefLabel($OutName, $Id, $2 . $3) . Cleanup($4);
853 # Reassemble and print the line
854 $OutLine .= $Operand;
856 # Check for all other instructions
857 } elsif ($Line =~ /^($AllIns)\b(.*)$/) {
860 $OutLine .= ColorizeKeyword ($1) . Cleanup ($2);
864 # Nothing known - print the line
865 $OutLine .= Cleanup ($Line);
869 # Colorize all keywords
870 $OutLine =~ s/(?<![\w;])\.[_a-zA-Z]\w*/ColorizeCtrl ($&)/ge;
873 $OutLine .= $Trailer;
876 print OUTPUT "$OutLine\n";
879 # Print the HTML footer
880 print OUTPUT "</pre>\n";
881 DocFooter (OUTPUT, $OutName);
890 # Pass2: Read all files the second time.
893 # Keep the user happy
896 # Walk over the files
897 for my $InName (keys (%Files)) {
905 #-----------------------------------------------------------------------------#
906 # Create an index page #
907 # ----------------------------------------------------------------------------#
911 # Print a list of all files
917 # Print the file list in a table
918 print $INDEX "<h2>Files</h2><p>\n";
919 print $INDEX "<table border=\"0\" width=\"100%\">\n";
921 for my $File (sort (keys (%Files))) {
924 if (($Count % $IndexCols) == 0) {
925 print $INDEX "<tr>\n";
927 printf $INDEX "<td><a href=\"%s\">%s</a></td>\n", GetOutName ($File), $File;
928 if (($Count % $IndexCols) == $IndexCols-1) {
929 print $INDEX "</tr>\n";
933 if (($Count % $IndexCols) != 0) {
934 print $INDEX "</tr>\n";
936 print $INDEX "</table><p><br><p>\n";
941 # Print a list of all exports
947 # Print the file list in a table
948 print $INDEX "<h2>Exports</h2><p>\n";
949 print $INDEX "<table border=\"0\" width=\"100%\">\n";
951 for my $Export (sort (keys (%Exports))) {
956 ($File, $Label) = split (/#/, $Exports{$Export});
958 # The label is the label of the export statement. If we can find the
959 # actual label, use this instead.
960 if (exists ($Labels{$File}{$Export})) {
961 $Label = $Labels{$File}{$Export};
965 if (($Count % $IndexCols) == 0) {
966 print $INDEX "<tr>\n";
968 printf $INDEX "<td><a href=\"%s#%s\">%s</a></td>\n", $File, $Label, $Export;
969 if (($Count % $IndexCols) == $IndexCols-1) {
970 print $INDEX "</tr>\n";
974 if (($Count % $IndexCols) != 0) {
975 print $INDEX "</tr>\n";
977 print $INDEX "</table><p><br><p>\n";
984 # Open the index page file
985 open (INDEX, ">$HTMLDir$IndexName") or Abort ("Cannot open $IndexName: $!");
988 DocHeader (INDEX, $IndexTitle, 0);
990 # Print the file list in a table
994 # Print the document footer
995 DocFooter (INDEX, $IndexName);
997 # Close the index file
1003 #-----------------------------------------------------------------------------#
1004 # Print usage information #
1005 # ----------------------------------------------------------------------------#
1010 print "Usage: ca65html [options] file ...\n";
1012 print " --bgcolor c Use background color c instead of $BGColor\n";
1013 print " --colorize Colorize the output (generates non standard HTML)\n";
1014 print " --commentcolor c Use color c for comments instead of $CommentColor\n";
1015 print " --crefs Generate references to the C source file(s)\n";
1016 print " --ctrlcolor c Use color c for directives instead of $CtrlColor\n";
1017 print " --cvttabs Convert tabs to spaces in the output\n";
1018 print " --help This text\n";
1019 print " --htmldir dir Specify directory for HTML files\n";
1020 print " --indexcols n Use n columns on index page (default $IndexCols)\n";
1021 print " --indexname file Use file for the index file instead of $IndexName\n";
1022 print " --indexpage Create an index page\n";
1023 print " --indextitle title Use title as the index title instead of $IndexTitle\n";
1024 print " --keywordcolor c Use color c for keywords instead of $KeywordColor\n";
1025 print " --linelabels Generate a linexxx HTML label for each line\n";
1026 print " --linenumbers Add line numbers to the output\n";
1027 print " --linkstyle style Use the given link style\n";
1028 print " --replaceext Replace source extension instead of appending .html\n";
1029 print " --textcolor c Use text color c instead of $TextColor\n";
1030 print " --verbose Be more verbose\n";
1035 #-----------------------------------------------------------------------------#
1037 # ----------------------------------------------------------------------------#
1041 # Get program options
1042 GetOptions ("bgcolor=s" => \$BGColor,
1043 "colorize" => \$Colorize,
1044 "commentcolor=s" => \$CommentColor,
1046 "ctrlcolor=s" => \$CtrlColor,
1047 "cvttabs" => \$CvtTabs,
1048 "debug!" => \$Debug,
1050 "htmldir=s" => \$HTMLDir,
1051 "indexcols=i" => \$IndexCols,
1052 "indexname=s" => \$IndexName,
1053 "indexpage" => \$IndexPage,
1054 "indextitle=s" => \$IndexTitle,
1055 "keywordcolor=s" => \$KeywordColor,
1056 "linelabels" => \$LineLabels,
1057 "linenumbers" => \$LineNumbers,
1058 "linkstyle=i" => \$LinkStyle,
1059 "replaceext" => \$ReplaceExt,
1060 "textcolor=s" => \$TextColor,
1061 "verbose!" => \$Verbose,
1064 # Check some arguments
1065 if ($IndexCols <= 0 || $IndexCols >= 20) {
1066 Abort ("Invalid value for --indexcols option");
1068 if ($HTMLDir ne "" && $HTMLDir =~ /[^\/]$/) {
1069 # Add a trailing path separator
1075 # Print help if requested
1080 # Check if we have input files given
1081 if ($FileCount == 0) {
1082 Abort ("No input files");
1085 # Convert the documents
1089 # Generate an index page if requested