) {
local($tag, $lno, $filename) = split;
if ($filename =~ /\.[sS]$/) {
$'sflag = 1;
last;
}
}
close(CHECK);
#-------------------------------------------------------------------------
# MAKE FILES
#-------------------------------------------------------------------------
# HTML/help.html ... help file (2)
# HTML/funcs.html ... function index (3)
# HTML/$FUNCS/* ... function index (3)
# HTML/$REFS/* ... referencies (4)
# HTML/$DEFS/* ... definitions (4)
# HTML/files.html ... file index (5)
# HTML/$FILES/* ... file index (5)
# HTML/index.html ... index file (6)
# HTML/mains.html ... main index (7)
# HTML/$SRCS/ ... source files (8)
#-------------------------------------------------------------------------
print STDERR "[", &date, "] ", "Htags started\n" if ($vflag);
#
# (1) make directories
#
print STDERR "[", &date, "] ", "(1) making directories ...\n" if ($vflag);
mkdir($html, 0777) || &error("cannot make directory <$html>.\n") if (! -d $html);
foreach $d ($SRCS, $REFS, $DEFS, $FILES, $FUNCS) {
mkdir("$html/$d", 0775) || &error("cannot make HTML directory\n") if (! -d "$html/$d");
}
#
# (2) make help file
#
print STDERR "[", &date, "] ", "(2) making help.html ...\n" if ($vflag);
&makehelp("$html/help.html");
#
# (3) make function index (funcs.html and $FUNCS/*)
# PRODUCE @funcs
#
print STDERR "[", &date, "] ", "(3) making function index ...\n" if ($vflag);
$func_total = &makefuncindex("$html/funcs.html");
print STDERR "Total $func_total functions.\n" if ($vflag);
#
# (4) make function entries ($DEFS/* and $REFS/*)
# MAKING TAG CACHE
#
print STDERR "[", &date, "] ", "(4) making duplicate entries ...\n" if ($vflag);
sub suddenly { &clean(); exit 1}
$SIG{'INT'} = 'suddenly';
$SIG{'QUIT'} = 'suddenly';
$SIG{'TERM'} = 'suddenly';
&cache'open(100000);
$func_total = &makedupindex($func_total);
print STDERR "Total $func_total functions.\n" if ($vflag);
#
# (5) make file index (files.html and $FILES/*)
# PRODUCE @files
#
print STDERR "[", &date, "] ", "(5) making file index ...\n" if ($vflag);
$file_total = &makefileindex("$html/files.html");
print STDERR "Total $file_total files.\n" if ($vflag);
#
# [#] make a common part for mains.html and index.html
# USING @funcs @files
#
print STDERR "[", &date, "] ", "(#) making a common part ...\n" if ($vflag);
$index = &makecommonpart($title);
#
# (6)make index file (index.html)
#
print STDERR "[", &date, "] ", "(6) making index file ...\n" if ($vflag);
&makeindex("$html/index.html", $title, $index);
#
# (7) make main index (mains.html)
#
print STDERR "[", &date, "] ", "(7) making main index ...\n" if ($vflag);
&makemainindex("$html/mains.html", $index);
#
# (#) make anchor database
#
print STDERR "[", &date, "] ", "(#) making temporary database ...\n" if ($vflag);
&anchor'create();
#
# (8) make HTML files ($SRCS/*)
# USING TAG CACHE
#
print STDERR "[", &date, "] ", "(8) making hypertext from source code ...\n" if ($vflag);
&makehtml($file_total);
&clean();
print STDERR "[", &date, "] ", "Done.\n" if ($vflag);
exit 0;
#-------------------------------------------------------------------------
# SUBROUTINES
#-------------------------------------------------------------------------
#
# makehelp: make help file
#
sub makehelp {
local($file) = @_;
open(HELP, ">$file") || &error("cannot make help file.\n");
print HELP "\nHELP\n\n";
print HELP "Usage of Links
\n";
print HELP "/* [<][>][^][v] [top][bottom][index][help] */
\n";
print HELP "\n";
print HELP "- [<]
- Previous function.\n";
print HELP "
- [>]
- Next function.\n";
print HELP "
- [^]
- First function in this file.\n";
print HELP "
- [v]
- Last function in this file.\n";
print HELP "
- [top]
- Top of this file.\n";
print HELP "
- [bottom]
- Bottom of this file.\n";
print HELP "
- [index]
- Return to index page (mains.html).\n";
print HELP "
- [help]
- You are seeing now.\n";
print HELP "
\n";
print HELP "\n\n";
close(HELP);
}
#
# makefuncindex: make function index (including alphabetic index)
#
# i) file function index file
# go) @funcs
#
sub makefuncindex {
local($file) = @_;
local($count) = 0;
open(FUNCTIONS, ">$file") || &error("cannot make function index <$file>.\n");
print FUNCTIONS "\nFUNCTION INDEX\n";
print FUNCTIONS "$begin_script$defaultview$end_script\n\n";
print FUNCTIONS "FUNCTION INDEX
\n";
print FUNCTIONS "\n" if (!$aflag);
local($old) = select(FUNCTIONS);
open(TAGS, "btreeop $dbpath/GTAGS | awk '{print \$1}' | sort | uniq |") || &error("btreeop $dbpath/GTAGS failed.\n");
local($alpha) = '';
@funcs = (); # [A][B][C]...
while () {
$count++;
chop;
local($tag) = $_;
print STDERR " [$count] adding $tag\n" if ($vflag);
if ($aflag && $alpha ne substr($tag, 0, 1)) {
if ($alpha) {
print ALPHA "
\n";
print ALPHA "[index]\n";
print ALPHA "$begin_script$rewrite_href_funcs$end_script";
print ALPHA "\n\n";
close(ALPHA);
}
$alpha = substr($tag, 0, 1);
push(@funcs, "[$alpha]\n");
open(ALPHA, ">$html/$FUNCS/$alpha.html") || &error("cannot make alphabetical function index.\n");
print ALPHA "\n$alpha\n";
print ALPHA "$begin_script$defaultview$end_script";
print ALPHA "\n\n[$alpha]
\n";
print ALPHA "[index]\n";
print ALPHA "\n";
select(ALPHA);
}
open(LIST, "btreeop -K $tag $dbpath/GTAGS |") || &error("btreeop -K $tag $dbpath/GTAGS failed.\n");;
local($line1, $line2);
if ($line1 = ) {
$line2 = ;
}
close(LIST);
if ($line2) {
print "- $tag\n";
} else {
local($nouse, $lno, $filename) = split(/[ \t]+/, $line1);
$nouse = ''; # to make perl quiet
$filename =~ s/^\.\///;
$filename =~ s/\//$ESCSEP/g;
print "
- $tag\n";
}
close(LIST);
}
close(TAGS);
select($old);
if ($aflag) {
print ALPHA "
\n";
print ALPHA "[index]\n";
print ALPHA "$begin_script$rewrite_href_funcs$end_script";
print ALPHA "\n\n";
close(ALPHA);
print FUNCTIONS @funcs;
}
print FUNCTIONS "\n" if (!$aflag);
print FUNCTIONS "