#!/usr/bonsaitools/bin/perl # $Id: ident,v 1.5 1998/07/28 19:16:48 jwz%netscape.com Exp $ # ident -- Look up identifiers # # Arne Georg Gleditsch # Per Kristian Gjermshus # # # 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 { print("

\n", "Type the full name of an identifier to summarize", "
(a function name, variable name, typedef, etc.)\n", "
Matches are case-sensitive.\n"); print("

\n"); foreach ($Conf->allvariables) { if ($Conf->variable($_) ne $Conf->vardefault($_)) { print("variable($_), "\">\n"); } } print("Identifier: \n", "\n", "
\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("

$identifier

\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:\n"); } } print("Referenced (in ",int(grep(/^R/, @refs))," files total) in:\n", "\n"); untie(%fileidx); } else { print("
Not used"); } untie(%xref); } } ($Conf, $HTTP, $Path) = &init; $identifier = $HTTP->{'param'}->{'i'}; &makeheader('ident'); &ident; &makefooter('ident');