1998-06-11 23:56:23 +00:00
|
|
|
#!/usr/bonsaitools/bin/perl
|
1998-07-28 19:16:48 +00:00
|
|
|
# $Id: ident,v 1.5 1998/07/28 19:16:48 jwz%netscape.com Exp $
|
1998-06-11 23:56:23 +00:00
|
|
|
|
|
|
|
# ident -- Look up identifiers
|
|
|
|
#
|
|
|
|
# Arne Georg Gleditsch <argggh@ifi.uio.no>
|
|
|
|
# Per Kristian Gjermshus <pergj@ifi.uio.no>
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
use lib 'lib/';
|
|
|
|
use LXR::Common;
|
|
|
|
use LXR::Config;
|
|
|
|
use DB_File;
|
|
|
|
|
|
|
|
%ty = (('M', 'preprocessor macro'),
|
|
|
|
('V', 'variable'),
|
|
|
|
('f', 'function prototype'),
|
|
|
|
('F', 'function'),
|
|
|
|
('C', 'class'), # C++
|
|
|
|
('c', '(forwarded) class'), # C++
|
|
|
|
('T', 'type'),
|
|
|
|
('S', 'struct type'),
|
|
|
|
('E', 'enum type'),
|
|
|
|
('U', 'union type'));
|
|
|
|
|
|
|
|
|
|
|
|
sub ident {
|
1998-06-12 21:58:38 +00:00
|
|
|
|
|
|
|
print("<P ALIGN=CENTER>\n",
|
1998-06-13 18:26:54 +00:00
|
|
|
"Type the full name of an identifier to summarize",
|
|
|
|
"<BR>(a function name, variable name, typedef, etc.)\n",
|
|
|
|
"<BR>Matches are case-sensitive.\n");
|
1998-06-12 21:58:38 +00:00
|
|
|
|
1998-06-11 23:56:23 +00:00
|
|
|
print("<form method=get action=\"ident\">\n");
|
|
|
|
|
|
|
|
foreach ($Conf->allvariables) {
|
|
|
|
if ($Conf->variable($_) ne $Conf->vardefault($_)) {
|
|
|
|
print("<input type=hidden name=\"",$_, "\" ",
|
|
|
|
"value=\"", $Conf->variable($_), "\">\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-06-12 21:58:38 +00:00
|
|
|
print("<B>Identifier: </B><input type=text name=\"i\" ",
|
|
|
|
"value=\"",$identifier,"\" size=50>\n",
|
1998-06-11 23:56:23 +00:00
|
|
|
"<input type=submit value=\"Find\">\n",
|
|
|
|
"</form>\n");
|
|
|
|
|
|
|
|
|
|
|
|
if ($identifier) {
|
|
|
|
tie(%xref, "DB_File", $Conf->dbdir."/xref",
|
|
|
|
O_RDONLY, undef, $DB_HASH) ||
|
|
|
|
&fatal("Could not open \"".$Conf->dbdir."/xref\"");
|
|
|
|
|
|
|
|
@refs = split(/\t/,$xref{$identifier});
|
|
|
|
|
|
|
|
print("<h1>$identifier</h1>\n");
|
|
|
|
|
|
|
|
if (@refs) {
|
|
|
|
tie(%fileidx, "DB_File", $Conf->dbdir."/fileidx",
|
|
|
|
O_RDONLY, undef, $DB_HASH) ||
|
|
|
|
&fatal("Could not open \"".$Conf->dbdir."/fileidx\"");
|
|
|
|
|
|
|
|
foreach (@refs) {
|
|
|
|
$f{$1} .= "$2\t" if /^(.)(.*)/;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach $t (keys(%ty)) {
|
|
|
|
if ($f{$t}) {
|
|
|
|
print("Defined as a $ty{$t} in:<ul>\n");
|
|
|
|
|
|
|
|
@_ = split(/\t/, $f{$t});
|
|
|
|
unshift(@_);
|
|
|
|
foreach (@_) {
|
|
|
|
($fnum, $line, @clss) = split(/:/, $_);
|
|
|
|
|
|
|
|
print("<li>",
|
|
|
|
&fileref("$fileidx{$fnum}, line $line",
|
|
|
|
"/$fileidx{$fnum}", $line));
|
|
|
|
|
|
|
|
if (@clss) {
|
|
|
|
if ($t eq 'F' || $t eq 'f') {
|
|
|
|
print(", as member of ");
|
|
|
|
if ($xref{$clss[0]}) {
|
|
|
|
print(&idref("class $clss[0]", $clss[0]));
|
|
|
|
} else {
|
|
|
|
print("class $clss[0]");
|
|
|
|
}
|
|
|
|
} elsif ($t eq 'C') {
|
|
|
|
print(", inheriting <ul>\n");
|
|
|
|
foreach (@clss) {
|
|
|
|
print("<li>");
|
|
|
|
if ($xref{$_}) {
|
|
|
|
print(&idref("class $_", $clss[0]));
|
|
|
|
} else {
|
|
|
|
print("class $_");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print("</ul>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print("\n");
|
|
|
|
}
|
|
|
|
print("</ul>\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print("Referenced (in ",int(grep(/^R/, @refs))," files total) in:\n",
|
|
|
|
"<ul>\n");
|
|
|
|
$concise = 0;
|
|
|
|
foreach (@refs) {
|
|
|
|
if (/^R(.+):([\d,]+)/) {
|
|
|
|
$fnam = $fileidx{$1};
|
|
|
|
@fpos = split(/,/, $2);
|
|
|
|
if ($concise) {
|
|
|
|
print("<li>", &fileref("$fnam", "/$fnam"),
|
|
|
|
", ",$#fpos+1," times\n");
|
|
|
|
} else {
|
|
|
|
print("<li>$fnam:\n<ul>\n");
|
|
|
|
print(
|
|
|
|
"View "
|
1998-07-28 19:16:48 +00:00
|
|
|
."<a href=\"" . $Conf->bonsaihome ."/cvslog.cgi?file=/mozilla/"
|
1998-06-11 23:56:23 +00:00
|
|
|
.$fnam
|
|
|
|
."&root=/cvsroot\">change log </a> or Blame"
|
1998-07-28 19:16:48 +00:00
|
|
|
."<a href=\"" . $Conf->bonsaihome . "/cvsblame.cgi?&file=/mozilla/"
|
1998-06-11 23:56:23 +00:00
|
|
|
.$fnam
|
|
|
|
."&root=/cvsroot\">"
|
|
|
|
." annotations</a>"
|
|
|
|
."\n"
|
|
|
|
);
|
|
|
|
|
|
|
|
foreach (@fpos) {
|
|
|
|
print("<li>", &fileref("line $_",
|
|
|
|
"/$fnam", $_),"\n");
|
|
|
|
}
|
|
|
|
print("</ul>\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print("</ul>\n");
|
|
|
|
untie(%fileidx);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
print("<br><b>Not used</b>");
|
|
|
|
}
|
|
|
|
|
|
|
|
untie(%xref);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
($Conf, $HTTP, $Path) = &init;
|
|
|
|
$identifier = $HTTP->{'param'}->{'i'};
|
|
|
|
|
|
|
|
&makeheader('ident');
|
|
|
|
&ident;
|
|
|
|
&makefooter('ident');
|
|
|
|
|