3 #-----------------------------------------------------------------------------
5 #- GNAT COMPILER COMPONENTS --
9 #- Copyright (C) 1998-2008, Free Software Foundation, Inc. --
11 #- GNAT is free software; you can redistribute it and/or modify it under --
12 #- terms of the GNU General Public License as published by the Free Soft- --
13 #- ware Foundation; either version 2, or (at your option) any later ver- --
14 #- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 #- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 #- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 #- for more details. You should have received a copy of the GNU General --
18 #- Public License distributed with GNAT; see file COPYING. If not, write --
19 #- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 #- MA 02111-1307, USA. --
22 #- GNAT was originally developed by the GNAT team at New York University. --
23 #- Extensive contributions were provided by Ada Core Technologies Inc. --
25 #-----------------------------------------------------------------------------
27 ## This script converts an Ada file (and its dependency files) to Html.
28 ## Keywords, comments and strings are color-hilighted. If the cross-referencing
29 ## information provided by Gnat (when not using the -gnatx switch) is found,
30 ## the html files will also have some cross-referencing features, i.e. if you
31 ## click on a type, its declaration will be displayed.
33 ## To find more about the switches provided by this script, please use the
34 ## following command :
35 ## perl gnathtml.pl -h
36 ## You may also change the first line of this script to indicates where Perl is
37 ## installed on your machine, so that you can just type
40 ## Unless you supply another directory with the -odir switch, the html files
41 ## will be saved saved in a html subdirectory
46 ### Print help if necessary
50 print " $0 [switches] main_file[.adb] main_file2[.adb] ...\n";
51 print " -83 : Use Ada83 keywords only (default is Ada95)\n";
52 print " -cc color : Choose the color for comments\n";
53 print " -d : Convert also the files which main_file depends on\n";
54 print " -D : same as -d, also looks for files in the standard library\n";
55 print " -f : Include cross-references for local entities too\n";
56 print " -absolute : Display absolute filenames in the headers\n";
57 print " -h : Print this help page\n";
58 print " -lnb : Display line numbers every nb lines\n";
59 print " -Idir : Specify library/object files search path\n";
60 print " -odir : Name of the directory where the html files will be\n";
61 print " saved. Default is 'html/'\n";
62 print " -pfile : Use file as a project file (.adp file)\n";
63 print " -sc color : Choose the color for symbol definitions\n";
64 print " -Tfile : Read the name of the files from file rather than the\n";
65 print " command line\n";
66 print " -ext ext : Choose the generated file names extension (default\n";
68 print "This program attemps to generate an html file from an Ada file\n";
72 ### Parse the command line
73 local ($ada83_mode) = 0;
74 local ($prjfile) = "";
75 local (@list_files) = ();
76 local ($line_numbers) = 0;
77 local ($dependencies) = 0;
78 local ($standard_library) = 0;
79 local ($output_dir) = "html";
80 local ($xref_variable) = 0;
81 local (@search_dir) = ('.');
82 local ($tab_size) = 8;
83 local ($comment_color) = "green";
84 local ($symbol_color) = "red";
85 local ($absolute) = 0;
86 local ($fileext) = "htm";
88 while ($_ = shift @ARGV)
90 /^-83$/ && do { $ada83_mode = 1; };
91 /^-d$/ && do { $dependencies = 1; };
92 /^-D$/ && do { $dependencies = 1;
93 $standard_library = 1; };
94 /^-f$/ && do { $xref_variable = 1; };
95 /^-absolute$/ && do {$absolute = 1; };
96 /^-h$/ && do { &print_usage; };
97 /^[^-]/ && do { $_ .= ".adb" if (! /\.ad[bs]$/);
98 push (@list_files, $_); };
102 $output_dir = ($1 eq "") ? shift @ARGV : $1;
103 chop $output_dir if ($output_dir =~ /\/$/);
104 &print_usage if ($output_dir =~ /^-/ || $output_dir eq "");
109 my ($source_file) = ($1 eq "") ? shift @ARGV : $1;
111 open (SOURCE, "$source_file") || die "file not found: $source_file";
115 $_ .= ".adb" if (! /\.ad[bs]$/);
116 push (@list_files, $_);
123 $comment_color = ($1 eq "") ? shift @ARGV : $1;
124 &print_usage if ($comment_color =~ /^-/ || $comment_color eq "");
129 $symbol_color = ($1 eq "") ? shift @ARGV : $1;
130 &print_usage if ($symbol_color =~ /^-/ || $symbol_color eq "");
135 push (@search_dir, ($1 eq "") ? scalar (shift @ARGV) : $1);
140 $prjfile = ($1 eq "") ? shift @ARGV : $1;
141 &print_usage if ($prjfile =~ /^-/ || $prjfile eq "");
146 $line_numbers = ($1 eq "") ? shift @ARGV : $1;
147 &print_usage if ($line_numbers =~ /^-/ || $line_numbers eq "");
152 $fileext = ($1 eq "") ? shift @ARGV : $1;
153 &print_usage if ($fileext =~ /^-/ || $fileext eq "");
157 &print_usage if ($#list_files == -1);
158 local (@original_list) = @list_files;
160 ## This regexp should match all the files from the standard library (and only them)
161 ## Note that at this stage the '.' in the file names has been replaced with __
162 $standard_file_regexp="^([agis]-|ada__|gnat__|system__|interface__).*\$";
164 local (@src_dir) = ();
165 local (@obj_dir) = ();
167 if ($standard_library) {
168 open (PIPE, "gnatls -v | ");
170 while (defined ($_ = <PIPE>)) {
173 $_ = './' if (/<Current_Directory>/);
176 if (/Source Search Path:/) {
179 elsif (/Object Search Path:/) {
182 elsif ($mode eq 's') {
185 elsif ($mode eq 'o') {
193 push (@src_dir, "./");
194 push (@obj_dir, "./");
197 foreach (@list_files) {
199 $dir =~ s/\/([^\/]+)$//;
200 push (@src_dir, $dir. '/');
201 push (@obj_dir, $dir. '/');
204 ### Defines and compiles the Ada key words :
205 local (@Ada_keywords) = ('abort', 'abs', 'accept', 'access', 'all', 'and',
206 'array', 'at', 'begin', 'body', 'case', 'constant',
207 'declare', 'delay', 'delta', 'digits', 'do', 'else',
208 'elsif', 'end', 'entry', 'exception', 'exit', 'for',
209 'function', 'generic', 'goto', 'if', 'in', 'is',
210 'limited', 'loop', 'mod', 'new', 'not', 'null', 'of',
211 'or', 'others', 'out', 'package', 'pragma', 'private',
212 'procedure', 'raise', 'range', 'record', 'rem',
213 'renames', 'return', 'reverse', 'select', 'separate',
214 'subtype', 'task', 'terminate', 'then', 'type',
215 'until', 'use', 'when', 'while', 'with', 'xor');
216 local (@Ada95_keywords) = ('abstract', 'aliased', 'protected', 'requeue',
219 local (%keywords) = ();
220 grep (++ $keywords{$_}, @Ada_keywords);
221 grep (++ $keywords{$_}, @Ada95_keywords) unless ($ada83_mode);
223 ### Symbols declarations for the current file
224 ### format is (line_column => 1, ...)
227 ### Symbols usage for the current file
228 ### format is ($adafile#$line_$column => $htmlfile#$linedecl_$columndecl, ...)
229 local (%symbols_used);
231 ### the global index of all symbols
232 ### format is ($name => [[file, line, column], [file, line, column], ...])
233 local (%global_index);
236 ## This function create the header of every html file.
237 ## These header is returned as a string
238 ## Params: - Name of the Ada file associated with this html file
242 local ($adafile) = shift;
243 local ($string) = "<HEAD><TITLE>$adafile</TITLE></HEAD>
248 $string .= "<HR><DIV ALIGN=\"center\"><H1> File : $adafile "
249 . "</H1></DIV><HR>\n<PRE>";
255 ## Protect a string (or character) from the Html parser
256 ## Params: - the string to protect
257 ## Out: - the protected string
261 local ($string) = shift;
262 $string =~ s/&/&/g;
263 $string =~ s/</</g;
264 $string =~ s/>/>/g;
269 ## This function creates the footer of the html file
270 ## The footer is returned as a string
271 ## Params : - Name of the Ada file associated with this html file
275 local ($adafile) = shift;
276 local ($string) = "";
277 $string = "</PRE>" if ($adafile ne "");
278 return $string . "</BODY></HTML>\n";
282 ## This function creates the string to use for comment output
283 ## Params : - the comment itself
287 local ($comment) = &protect_string (shift);
288 return "<FONT COLOR=$comment_color><EM>--$comment</EM></FONT>";
292 ## This function creates the string to use for symbols output
293 ## Params : - the symbol to output
294 ## - the current line
295 ## - the current column
299 local ($symbol) = &protect_string (shift);
300 local ($lineno) = shift;
301 local ($column) = shift;
302 return "<FONT COLOR=$symbol_color><A NAME=\"$lineno\_$column\">$symbol</A></FONT>";
306 ## This function creates the string to use for keyword output
307 ## Params : - the keyword to output
311 local ($keyw) = shift;
312 return "<b>$keyw</b>";
316 ## This function outputs a line number
317 ## Params : - the line number to generate
319 sub output_line_number
324 return "<EM><FONT SIZE=-1>" . sprintf ("%4d ", $no) . "</FONT></EM>";
328 return "<FONT SIZE=-1> </FONT>";
333 ## Converts a character into the corresponding Ada type
334 ## This is based on the ali format (see lib-xref.adb) in the GNAT sources
335 ## Note: 'f' or 'K' should be returned in case a link from the body to the
336 ## spec needs to be generated.
337 ## Params : - the character to convert
341 local ($char) = shift;
342 $char =~ tr/a-z/A-Z/;
344 return 'array' if ($char eq 'A');
345 return 'boolean' if ($char eq 'B');
346 return 'class' if ($char eq 'C');
347 return 'decimal' if ($char eq 'D');
348 return 'enumeration' if ($char eq 'E');
349 return 'floating point' if ($char eq 'F');
350 return 'signed integer' if ($char eq 'I');
351 # return 'generic package' if ($char eq 'K');
352 return 'block' if ($char eq 'L');
353 return 'modular integer' if ($char eq 'M');
354 return 'enumeration litteral' if ($char eq 'N');
355 return 'ordinary fixed point' if ($char eq 'O');
356 return 'access' if ($char eq 'P');
357 return 'label' if ($char eq 'Q');
358 return 'record' if ($char eq 'R');
359 return 'string' if ($char eq 'S');
360 return 'task' if ($char eq 'T');
361 return 'f' if ($char eq 'U');
362 return 'f' if ($char eq 'V');
363 return 'exception' if ($char eq 'X');
364 return 'entry' if ($char eq 'Y');
369 ## Changes a file name to be http compatible
373 local ($str) = shift;
382 ## Creates the complete file-name, with directory
383 ## use the variables read in the .prj file
384 ## Params : - file name
385 ## RETURNS : the relative path_name to the file
387 sub get_real_file_name
389 local ($filename) = shift;
390 local ($path) = $filename;
394 if ( -r "$_$filename")
396 $path = "$_$filename";
402 return $path if (substr ($path, 0, 1) ne '/');
404 ## We want to return relative paths only, so that the name of the HTML files
405 ## can easily be generated
406 local ($pwd) = `pwd`;
408 local (@pwd) = split (/\//, $pwd);
409 local (@path) = split (/\//, $path);
413 if ($pwd [0] ne $path [0])
415 return '../' x ($#pwd + 1) . join ("/", @path);
420 return join ('/', @path);
424 ## Reads and parses .adp files
425 ## Params : - adp file name
429 local ($filename) = shift;
433 print "Parsing project file : $filename\n";
435 open (PRJ, $filename) || do { print " ... sorry, file not found\n";
442 push (@src, $1 . "/") if (/^src_dir=(.*)/);
443 push (@obj, $1 . "/") if (/^obj_dir=(.*)/);
445 unshift (@src_dir, @src);
446 unshift (@obj_dir, @obj);
451 ## Finds a file in the search path
452 ## Params : - the name of the file
453 ## RETURNS : - the directory/file_name
457 local ($filename) = shift;
459 foreach (@search_dir) {
460 if (-f "$_/$filename") {
461 return "$_/$filename";
468 ## Inserts a new reference in the list of references
469 ## Params: - Ref as it appears in the .ali file ($line$type$column)
470 ## - Current file for the reference
471 ## - Current offset to be added from the line (handling of
472 ## pragma Source_Reference)
473 ## - Current entity reference
474 ## Modifies: - %symbols_used
476 sub create_new_reference
478 local ($ref) = shift;
479 local ($lastfile) = shift;
480 local ($offset) = shift;
481 local ($currentref) = shift;
482 local ($refline, $type, $refcol);
484 ## Do not generate references to the standard library files if we
485 ## do not generate the corresponding html files
486 return if (! $standard_library && $lastfile =~ /$standard_file_regexp/);
488 ($refline, $type, $extern, $refcol) = /(\d+)(.)(<[^>]+>)?(\d+)/;
491 ## If we have a body, then we only generate the cross-reference from
492 ## the spec to the body if we have a subprogram (or a package)
496 # && ($symbols {$currentref} eq 'f' || $symbols {$currentref} eq 'K'))
498 local ($cref_file, $cref) = ($currentref =~ /([^\#]+).$fileext\#(.+)/);
500 $symbols_used {"$cref_file#$cref"} = "$lastfile.$fileext#$refline\_$refcol";
501 $symbols_used {"$lastfile#$refline\_$refcol"} = $currentref;
502 $symbols {"$lastfile.$fileext#$refline\_$refcol"} = "body";
505 ## Do not generate cross-references for "e" and "t", since these point to the
506 ## semicolon that terminates the block -- irrelevant for gnathtml
507 ## "p" is also removed, since it is used for primitive subprograms
508 ## "d" is also removed, since it is used for discriminants
509 ## "i" is removed since it is used for implicit references
510 ## "z" is used for generic formals
511 ## "k" is for references to parent package
512 ## "=", "<", ">", "^" is for subprogram parameters
514 elsif ($type !~ /[eztpid=<>^k]/)
516 $symbols_used {"$lastfile#$refline\_$refcol"} = $currentref;
521 ## Parses the ali file associated with the current Ada file
522 ## Params : - the complete ali file name
526 local ($filename) = shift;
527 local ($currentfile);
531 # A file | line type column reference
532 local ($reference) = "(?:(?:\\d+\\|)?\\d+.\\d+|\\w+)";
534 # The following variable is used to represent the possible xref information
535 # output by GNAT when -gnatdM is used. It includes renaming references, and
536 # references to the parent type, as well as references to the generic parent
538 local ($typeref) = "(?:=$reference|<$reference>|\\{$reference\\}|\\($reference\\)|\\[$reference\\])?";
540 # The beginning of an entity declaration line in the ALI file
541 local ($decl_line) = "^(\\d+)(.)(\\d+)[ *]([\\w\\d.-]+|\"..?\")$typeref\\s+(\\S.*)?\$";
543 # Contains entries of the form [ filename source_reference_offset]
544 # Offset needs to be added to the lines read in the cross-references, and are
545 # used when the source comes from a gnatchop-ed file. See lib-write.ads, lines
546 # with ^D in the ALI file.
547 local (@reffiles) = ();
549 open (ALI, &find_file ($filename)) || do {
550 print "no ", &find_file ($filename), " file...\n";
553 local (@ali) = <ALI>;
561 ## The format of D lines is
562 ## D source-name time-stamp checksum [subunit-name] line:file-name
564 if (/^D\s+([\w\d.-]+)\s+\S+ \S+(\s+\D[^: ]+)?( (\d+):(.*))?/)
566 # The offset will be added to each cross-reference line. If it is
567 # greater than 1, this means that we have a pragma Source_Reference,
568 # and this must not be counted in the xref information.
569 my ($file, $offset) = ($1, (defined $4) ? 2 - $4 : 0);
573 push (@list_files, $1) unless (grep (/$file/, @list_files));
575 push (@reffiles, [&http_string (&get_real_file_name ($file)), $offset]);
580 $currentfile = $lastfile = $1 - 1;
583 elsif (defined $currentfile && /$decl_line/)
585 my ($line) = $1 + $reffiles[$currentfile][1];
586 next if (! $standard_library
587 && $reffiles[$currentfile][0] =~ /$standard_file_regexp/);
588 if ($xref_variable || $2 eq &uppercases ($2))
590 $currentref = $reffiles[$currentfile][0] . ".$fileext#$line\_$3";
591 $symbols {$currentref} = &to_type ($2);
592 $lastfile = $currentfile;
594 local ($endofline) = $5;
596 foreach (split (" ", $endofline))
598 (s/^(\d+)\|//) && do { $lastfile = $1 - 1; };
599 &create_new_reference
600 ($_, $reffiles[$lastfile][0],
601 $reffiles[$lastfile][1], $currentref);
609 elsif (/^\.\s(.*)/ && $reffiles[$currentfile][0] ne "" && $currentref ne "")
611 next if (! $standard_library
612 && $reffiles[$currentfile][0] =~ /$standard_file_regexp/);
613 foreach (split (" ", $1))
615 (s/^(\d+)\|//) && do { $lastfile = $1 - 1; };
616 &create_new_reference
617 ($_, $reffiles[$lastfile][0], $reffiles[$lastfile][1],
625 ## Return the name of the ALI file to use for a given source
626 ## Params: - Name of the source file
627 ## return: Name and location of the ALI file
631 local ($source) = shift;
632 local ($alifilename, $unitname);
633 local ($in_separate) = 0;
635 $source =~ s/\.ad[sb]$//;
636 $alifilename = $source;
637 $unitname = $alifilename;
638 $unitname =~ s/-/./g;
640 ## There are two reasons why we might not find the ALI file: either the
641 ## user did not generate them at all, or we are working on a separate unit.
642 ## Thus, we search in the parent's ALI file.
644 while ($alifilename ne "") {
646 ## Search in the object path
649 ## Check if the ALI file does apply to the source file
650 ## We check the ^D lines, which have the following format:
651 ## D source-name time-stamp checksum [subunit-name] line:file-name
653 if (-r "$_$alifilename.ali") {
655 open (FILE, "$_$alifilename.ali");
657 if (grep (/^D \S+\s+\S+\s+\S+ $unitname/, <FILE>)) {
659 return "$_$alifilename.ali";
662 ## If the ALI file doesn't apply to the source file, we can
663 ## return now, since there won't be a parent ALI file above
666 return "$source.ali";
669 return "$_$alifilename.ali";
674 ## Get the parent's ALI file name
676 if (! ($alifilename =~ s/-[^-]+$//)) {
682 return "$source.ali";
686 ## Convert a path to an absolute path
691 local ($path) = shift;
692 local ($name, $suffix, $separator);
693 ($name,$path,$suffix) = fileparse ($path, ());
694 $path = &abs_path ($path);
695 $separator = substr ($path, 0, 1);
696 return $path . $separator . $name;
700 ## This function outputs the html version of the file FILE
701 ## The output is send to FILE.htm.
702 ## Params : - Name of the file to convert (ends with .ads or .adb)
706 local ($filename_param) = shift;
711 local ($alifilename) = &ali_file_name ($filename_param);
713 $filename = &get_real_file_name ($filename_param);
714 $found = &find_file ($filename);
716 ## Read the whole file
717 open (FILE, $found) || do {
718 print $found, " not found ... skipping.\n";
721 local (@file) = <FILE>;
724 ## Parse the .ali file to find the cross-references
725 print "converting ", $filename, "\n";
726 &parse_ali ($alifilename);
728 ## Create and initialize the html file
729 open (OUTPUT, ">$output_dir/" . &http_string ($filename) . ".$fileext")
730 || die "Couldn't write $output_dir/" . &http_string ($filename)
734 print OUTPUT &create_header (&to_absolute ($found)), "\n";
736 print OUTPUT &create_header ($filename_param), "\n";
740 $filename = &http_string ($filename);
750 ## Print either the line number or a space if required
753 if ($lineno % $line_numbers == 0)
755 print OUTPUT &output_line_number ($lineno);
759 print OUTPUT &output_line_number (-1);
763 ## First, isolate any comment on the line
765 $index = index ($line, '--');
767 $comment = substr ($line, $index + 2);
770 $line = substr ($line, 0, $index);
778 ## Then print the line
782 while ($index < length ($line))
784 local ($substring) = substr ($line, $index);
786 if ($substring =~ /^\t/)
788 print OUTPUT ' ' x ($tab_size - (($column - 1) % $tab_size));
789 $column += $tab_size - (($column - 1) % $tab_size);
792 elsif ($substring =~ /^(\w+)/
793 || $substring =~ /^("[^\"]*")/
794 || $substring =~ /^(\W)/)
797 $index += length ($word);
799 local ($lowercase) = $word;
800 $lowercase =~ tr/A-Z/a-z/;
802 if ($keywords{$lowercase})
804 print OUTPUT &output_keyword ($word);
806 elsif ($symbols {"$filename.$fileext#$lineno\_$column"})
808 ## A symbol can both have a link and be a reference for
809 ## another link, as is the case for bodies and
812 if ($symbols_used{"$filename#$lineno\_$column"})
814 print OUTPUT "<A HREF=\"",
815 $symbols_used{"$filename#$lineno\_$column"},
816 "\">", &protect_string ($word), "</A>";
817 print OUTPUT &output_symbol ('', $lineno, $column);
821 print OUTPUT &output_symbol ($word, $lineno, $column);
824 ## insert only functions into the global index
826 if ($symbols {"$filename.$fileext#$lineno\_$column"} eq 'f')
828 push (@{$global_index {$word}},
829 [$filename_param, $filename, $lineno, $column]);
832 elsif ($symbols_used{"$filename#$lineno\_$column"})
834 print OUTPUT "<A HREF=\"",
835 $symbols_used{"$filename#$lineno\_$column"},
836 "\">", &protect_string ($word), "</A>";
840 print OUTPUT &protect_string ($word);
842 $column += length ($word);
848 print OUTPUT &protect_string (substr ($substring, 0, 1));
853 ## Then output the comment
854 print OUTPUT &output_comment ($comment) if (defined $comment);
860 print OUTPUT &create_footer ($filename);
866 ## This function generates the global index
868 sub create_index_file
870 open (INDEX, ">$output_dir/index.$fileext") || die "couldn't write $output_dir/index.$fileext";
874 <HEAD><TITLE>Source Browser</TITLE></HEAD>
875 <FRAMESET COLS='250,*'>
880 local (@files) = &create_file_index;
881 print INDEX join ("\n", @files), "\n";
883 print INDEX "<HR>\n";
884 local (@functions) = &create_function_index;
885 print INDEX join ("\n", @functions), "\n";
889 <FRAMESET ROWS='50%,50%'>
890 <FRAME NAME=files SRC=files.$fileext>
891 <FRAME NAME=funcs SRC=funcs.$fileext>
893 <FRAME NAME=main SRC=main.$fileext>
900 open (MAIN, ">$output_dir/main.$fileext") || die "couldn't write $output_dir/main.$fileext";
901 print MAIN &create_header (""),
903 "<A HREF=main.$fileext TARGET=_top>[No frame version is here]</A>",
905 join ("\n", @files), "\n<HR>",
906 join ("\n", @functions), "\n";
910 print MAIN "You should start your browsing with one of these files:\n";
912 foreach (@original_list) {
913 print MAIN "<LI><A HREF=", &http_string (&get_real_file_name ($_)),
914 ".$fileext>$_</A>\n";
917 print MAIN &create_footer ("");
922 ## Convert to upper cases (did not exist in Perl 4)
926 local ($tmp) = shift;
932 ## This function generates the file_index
933 ## RETURN : - table with the html lines to be printed
935 sub create_file_index
937 local (@output) = ("<H2 ALIGN=CENTER>Files</H2>");
940 open (FILES, ">$output_dir/files.$fileext") || die "couldn't write $output_dir/files.$fileext";
941 print FILES &create_header (""), join ("\n", @output), "\n";
944 if ($#list_files > 20)
946 local ($last_letter) = '';
947 foreach (sort {&uppercases ($a) cmp &uppercases ($b)} @list_files)
950 if (&uppercases (substr ($_, 0, 1)) ne $last_letter)
952 if ($last_letter ne '')
954 print INDEX_FILE "</UL></BODY></HTML>\n";
957 $last_letter = &uppercases (substr ($_, 0, 1));
958 open (INDEX_FILE, ">$output_dir/files/$last_letter.$fileext")
959 || die "couldn't write $output_dir/files/$last_letter.$fileext";
960 print INDEX_FILE <<"EOF";
961 <HTML><HEAD><TITLE>$last_letter</TITLE></HEAD>
963 <H2>Files - $last_letter</H2>
964 <A HREF=../files.$fileext TARGET=_self>[index]</A>
965 <UL COMPACT TYPE=DISC>
968 local ($str) = "<A HREF=files/$last_letter.$fileext>[$last_letter]</A>";
969 push (@output, $str);
970 print FILES "$str\n";
972 print INDEX_FILE "<LI><A HREF=../",
973 &http_string (&get_real_file_name ($_)),
974 ".$fileext TARGET=main>$_</A>\n"; ## Problem with TARGET when in no_frame mode!
977 print INDEX_FILE "</UL></BODY></HTML>\n";
982 push (@output, "<UL COMPACT TYPE=DISC>");
983 print FILES "<UL COMPACT TYPE=DISC>";
984 foreach (sort {&uppercases ($a) cmp &uppercases ($b)} @list_files)
987 local ($ref) = &http_string (&get_real_file_name ($_));
988 push (@output, "<LI><A HREF=$ref.$fileext>$_</A>");
989 print FILES "<LI><A HREF=$ref.$fileext TARGET=main>$_</A>\n";
993 print FILES &create_footer ("");
996 push (@output, "</UL>");
1001 ## This function generates the function_index
1002 ## RETURN : - table with the html lines to be printed
1004 sub create_function_index
1006 local (@output) = ("<H2 ALIGN=CENTER>Functions/Procedures</H2>");
1007 local ($initial) = "";
1009 open (FUNCS, ">$output_dir/funcs.$fileext") || die "couldn't write $output_dir/funcs.$fileext";
1010 print FUNCS &create_header (""), join ("\n", @output), "\n";
1012 ## If there are more than 20 entries, we just want to create some
1014 if (scalar (keys %global_index) > 20)
1016 local ($last_letter) = '';
1017 foreach (sort {&uppercases ($a) cmp &uppercases ($b)} keys %global_index)
1019 if (&uppercases (substr ($_, 0, 1)) ne $last_letter)
1021 if ($last_letter ne '')
1023 print INDEX_FILE "</UL></BODY></HTML>\n";
1027 $last_letter = &uppercases (substr ($_, 0, 1));
1028 $initial = $last_letter;
1029 if ($initial eq '"')
1031 $initial = "operators";
1033 if ($initial ne '.')
1035 open (INDEX_FILE, ">$output_dir/funcs/$initial.$fileext")
1036 || die "couldn't write $output_dir/funcs/$initial.$fileext";
1037 print INDEX_FILE <<"EOF";
1038 <HTML><HEAD><TITLE>$initial</TITLE></HEAD>
1040 <H2>Functions - $initial</H2>
1041 <A HREF=../funcs.$fileext TARGET=_self>[index]</A>
1042 <UL COMPACT TYPE=DISC>
1045 local ($str) = "<A HREF=funcs/$initial.$fileext>[$initial]</A>";
1046 push (@output, $str);
1047 print FUNCS "$str\n";
1051 local ($is_overloaded) = ($#{$global_index {$_}} > 0 ? 1 : 0);
1052 foreach $ref (@{$global_index {$_}})
1054 ($file, $full_file, $lineno, $column) = @{$ref};
1055 local ($symbol) = ($is_overloaded ? "$_ - $file:$lineno" : $_);
1056 print INDEX_FILE "<LI><A HREF=../$full_file.$fileext#$lineno\_$column TARGET=main>$symbol</A>";
1060 print INDEX_FILE "</UL></BODY></HTML>\n";
1065 push (@output, "<UL COMPACT TYPE=DISC>");
1066 print FUNCS "<UL COMPACT TYPE=DISC>";
1067 foreach (sort {&uppercases ($a) cmp &uppercases ($b)} keys %global_index)
1070 local ($is_overloaded) = ($#{$global_index {$_}} > 0 ? 1 : 0);
1071 foreach $ref (@{$global_index {$_}})
1073 ($file, $full_file, $lineno, $column) = @{$ref};
1074 local ($symbol) = ($is_overloaded ? "$_ - $file:$lineno" : $_);
1075 push (@output, "<LI><A HREF=$full_file.$fileext#$lineno\_$column>$symbol</A>");
1076 print FUNCS "<LI><A HREF=$full_file.$fileext#$lineno\_$column TARGET=main>$symbol</A>";
1081 print FUNCS &create_footer ("");
1084 push (@output, "</UL>");
1092 local ($index_file) = 0;
1094 mkdir ($output_dir, 0777) if (! -d $output_dir);
1095 mkdir ($output_dir."/files", 0777) if (! -d $output_dir."/files");
1096 mkdir ($output_dir."/funcs", 0777) if (! -d $output_dir."/funcs");
1098 &parse_prj_file ($prjfile) if ($prjfile);
1100 while ($index_file <= $#list_files)
1102 local ($file) = $list_files [$index_file];
1104 if (&output_file ($file) == 0)
1106 $list_files [$index_file] = "";
1112 $indexfile = "$output_dir/index.$fileext";
1113 $indexfile =~ s!//!/!g;
1114 print "You can now download the $indexfile file to see the ",