From 49c6428c5ae82d26262e3b67fec8c5bc45bab306 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 14 Apr 1998 16:09:02 +0000 Subject: Added Ada support by copying the script from Avenger. --- doc/tools/src2html1.4a/src2html | 195 +++++++++++++++++++++++++++++++--------- 1 file changed, 155 insertions(+), 40 deletions(-) diff --git a/doc/tools/src2html1.4a/src2html b/doc/tools/src2html1.4a/src2html index df238ba76c..98d9d83d7f 100644 --- a/doc/tools/src2html1.4a/src2html +++ b/doc/tools/src2html1.4a/src2html @@ -1,4 +1,4 @@ -#!/usr/local/bin/perl +#!/usr/bin/perl # Src2html: Take a source tree and generate Html documents that have hyperlinks # to the definition of structures, variables, functions, and preprocessor # definitions. Read the manual page for details on how to use the program. @@ -7,6 +7,8 @@ # # 19th January 1996 # +# $Id$ +# if ($#ARGV <= 0 || $#ARGV > 4) { # Check arg count print(STDERR "Usage: $0 [-na] [-nl] [-d num] input_description\n"); @@ -30,14 +32,19 @@ for ($i=0; $i<= $#ARGV; $i++) { if ($ARGV[$i] eq "-d") { $i++; $Debug= $ARGV[$i]; next; } } -$Title{"m"}= "Macros"; -$Title{"d"}= "Defines"; -$Title{"f"}= "Functions"; -$Title{"v"}= "Variables"; -$Title{"s"}= "Structs"; -$Title{"u"}= "Unions"; -$Title{"t"}= "Typedefs"; -$Title{"e"}= "Enums"; +$Title{"m"}= "C Macros"; +$Title{"d"}= "C Defines"; +$Title{"f"}= "C Functions"; +$Title{"v"}= "C Variables"; +$Title{"s"}= "C Structs"; +$Title{"u"}= "C Unions"; +$Title{"t"}= "C Typedefs"; +$Title{"e"}= "C Enums"; +$Title{"AdaType"}= "Ada Types"; +$Title{"AdaProcedure"}= "Ada Procedures"; +$Title{"AdaFunction"}= "Ada Functions"; +$Title{"AdaPackage"}= "Ada Packages"; +$Title{"AdaTask"}= "Ada Tasks"; $Title{"g"}= "All symbols"; &get_s2h; # Read the description file @@ -164,7 +171,7 @@ sub make_ctags { foreach $i (keys(%Dirinfo)) { $Ctagsfile{$i}= "$Htmltree/ctags/$Dotdir{$i}.ctags"; if ($Debug > 0 ) { print "Generating ctags for $Ctagsfile{$i}\n"; } - system("(cd $Srctree; ctags-new -d -t -w -y $i/*) > $Ctagsfile{$i}") + system("(cd $Srctree; /usr1/rtems/rtemsdoc-work/tools/src2html/ctags-wr $i) > $Ctagsfile{$i}") && print "$0: ctags failed on $Srctree/$i\n"; } } @@ -186,42 +193,105 @@ sub make_ctags { sub parse_ctags { local($i); local($low); + local($count); + + $count = 0; foreach $i (keys(%Dirinfo)) { open(CTAGS,$Ctagsfile{$i}) || die "$0: Can't open $Ctagsfile{$i}, $!\n"; if ($Debug > 0) { print "Parsing $Ctagsfile{$i} to build ptr files\n"; } while () { + $count ++; if ( /^(\w+)\s+(\d+)\s+(\S+)\s+Preprocessor macro/ ) { - ($low=$1)=~tr/A-Z_/a-z/d; $Macro{$low}=$1; - $Nfile{$1}= $3; $Nline{$1}= $2; next; + ($low=$1)=~tr/A-Z_/a-z/d; $k="$low$count"; + $Macro{$k}=$1; $Nline{$k}= $2; + $Nfile{$k}= $3; next; } if ( /^(\w+)\s+(\d+)\s+(\S+)\s+Preprocessor define/ ) { - ($low=$1)=~tr/A-Z_/a-z/d; $Def{$low}=$1; - $Nfile{$1}= $3; $Nline{$1}= $2; next; + ($low=$1)=~tr/A-Z_/a-z/d; $k="$low$count"; + $Def{$k}=$1; $Nline{$k}= $2; + $Nfile{$k}= $3; next; } if ( /^(\w+)\s+(\d+)\s+(\S+)\s+C struct/ ) { - ($low=$1)=~tr/A-Z_/a-z/d; $Struct{$low}=$1; - $Nfile{$1}= $3; $Nline{$1}= $2; next; + ($low=$1)=~tr/A-Z_/a-z/d; $k="$low$count"; + $Struct{$k}=$1; $Nline{$k}= $2; + $Nfile{$k}= $3; next; } if ( /^(\w+)\s+(\d+)\s+(\S+)\s+C union/ ) { - ($low=$1)=~tr/A-Z_/a-z/d; $Union{$low}=$1; - $Nfile{$1}= $3; $Nline{$1}= $2; next; + ($low=$1)=~tr/A-Z_/a-z/d; $k="$low$count"; + $Union{$k}=$1; $Nline{$k}= $2; + $Nfile{$k}= $3; next; } if ( /^(\w+)\s+(\d+)\s+(\S+)\s+C typedef/ ) { - ($low=$1)=~tr/A-Z_/a-z/d; $Type{$low}=$1; - $Nfile{$1}= $3; $Nline{$1}= $2; next; + ($low=$1)=~tr/A-Z_/a-z/d; $k="$low$count"; + $Type{$k}=$1; $Nline{$k}= $2; + $Nfile{$k}= $3; next; } if ( /^(\w+)\s+(\d+)\s+(\S+)\s+C enum/ ) { - ($low=$1)=~tr/A-Z_/a-z/d; $Enum{$low}=$1; - $Nfile{$1}= $3; $Nline{$1}= $2; next; + ($low=$1)=~tr/A-Z_/a-z/d; $k="$low$count"; + $Enum{$k}=$1; $Nline{$k}= $2; + $Nfile{$k}= $3; next; } if ( /^(\w+)\s+(\d+)\s+(\S+)\s+C function/ ) { - ($low=$1)=~tr/A-Z_/a-z/d; $Func{$low}=$1; - $Nfile{$1}= $3; $Nline{$1}= $2; next; + ($low=$1)=~tr/A-Z_/a-z/d; $k="$low$count"; + $Func{$k}=$1; $Nline{$k}= $2; + $Nfile{$k}= $3; next; } if ( /^(\w+)\s+(\d+)\s+(\S+)\s+C variable/ ) { - ($low=$1)=~tr/A-Z_/a-z/d; $Var{$low}=$1; - $Nfile{$1}= $3; $Nline{$1}= $2; next; + ($low=$1)=~tr/A-Z_/a-z/d; $k="$low$count"; + $Var{$k}=$1; $Nline{$k}= $2; + $Nfile{$k}= $3; next; + } + if ( /^(return)\/.\s+(\d+)\s+(\S+)\s+.*/ ) { + next; + # Code like the following line results in "return" as ctag + # "type Action is access function return Boolean; + } + if ( /^(\w+)\/.\s+(\d+)\s+(\S+)\s+use .*/ ) { + next; + # throw away lines like "use type System" + } + + if ( /^(\w+)\/.\s+(\d+)\s+(\S+)\s+type .*/ ) { + ($low=$1)=~tr/A-Z_/a-z/d; $k="$low$count"; + $AdaType{$k}=$1; $Nline{$k}= $2; + $Nfile{$k}= $3; next; + } + if ( /^(\w+)\/.+\s+(\d+)\s+(\S+)\s+procedure .*/ ) { + ($low=$1)=~tr/A-Z_/a-z/d; $k="$low$count"; + $AdaProcedure{$k}=$1; $Nline{$k}= $2; + $Nfile{$k}= $3; next; + } + if ( /^(\w+)\/.+\s+(\d+)\s+(\S+)\s+function .*/ ) { + ($low=$1)=~tr/A-Z_/a-z/d; $k="$low$count"; + $AdaFunction{$k}=$1; $Nline{$k}= $2; + $Nfile{$k}= $3; next; + } + if ( /^(\".+)\/.+\s+(\d+)\s+(\S+)\s+function .*/ ) { + next; + # throw away functions like "*" + } + if ( /^(\w+)\/.\s+(\d+)\s+(\S+)\s+package .*/ ) { + ($low=$1)=~tr/A-Z_/a-z/d; $k="$low$count"; + $AdaPackage{$k}=$1; $Nline{$k}= $2; + $Nfile{$k}= $3; next; + } + if ( /^(\w+)\/.\s+(\d+)\s+(\S+)\s+task .*/ ) { + ($low=$1)=~tr/A-Z_/a-z/d; $k="$low$count"; + $AdaTask{$k}=$1; $Nline{$k}= $2; + $Nfile{$k}= $3; next; + } + if ( /^([\w\/]+)\s+(\d+)\s+(\S+)\s+use type .*/ ) { + next; + } + if ( /^([\w\/\(]+)\s+(\d+)\s+(\S+)\s+type .*/ ) { + next; + } + if ( /^;([\w\/\(]+)\s+(\d+)\s+(\S+)\s+type .*/ ) { + next; + } + if ( /^\(([\w\/\(]+)\s+(\d+)\s+(\S+)\s+procedure .*/ ) { + next; } print "$0: In Ctagsfile{$i}, don't recognise $_"; } @@ -229,6 +299,8 @@ sub parse_ctags { &make_dir_html($i); undef %Macro; undef %Def; undef %Func; undef %Var; undef %Struct; undef %Union; undef %Type; undef %Enum; + undef %AdaType; undef %AdaProcedure; undef %AdaFunction; + undef %AdaPackage; undef %AdaTask; } &make_top_html; } @@ -246,7 +318,10 @@ sub make_letters_html { local($htmlfile); local($let)="@"; - foreach $i ( "a".."z" ) { $Exists{$i}=0; } + foreach $i ( "a".."z", + "AdaType", "AdaProcedure", "AdaFunction", "AdaPackage", "AdaTask" ) { + $Exists{$i}=0; + } foreach $name (sort keys( %type )) { if (substr($name,0,1) ne $let) { if ($let ne "@") { @@ -264,9 +339,13 @@ sub make_letters_html { print HTML "`$let' in $dir

\n"; print HTML "

\n"; close(HTML); @@ -303,9 +382,13 @@ sub make_type_html { print HTML "

$title in $dir

\n"; print HTML "\n"; close(HTML); @@ -320,7 +403,8 @@ sub make_type_html { print HTML "

$title in $dir

\n"; print HTML "