|
Packit Service |
9646c7 |
#! @PERL@ -w
|
|
Packit Service |
9646c7 |
# -*- perl -*-
|
|
Packit Service |
9646c7 |
# @configure_input@
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac'
|
|
Packit Service |
9646c7 |
if 0;
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# ifnames - print the identifiers used in C preprocessor conditionals
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Copyright (C) 1994-1995, 1999-2003, 2005-2012 Free Software
|
|
Packit Service |
9646c7 |
# Foundation, Inc.
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# This program is free software: you can redistribute it and/or modify
|
|
Packit Service |
9646c7 |
# it under the terms of the GNU General Public License as published by
|
|
Packit Service |
9646c7 |
# the Free Software Foundation, either version 3 of the License, or
|
|
Packit Service |
9646c7 |
# (at your option) any later version.
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# This program is distributed in the hope that it will be useful,
|
|
Packit Service |
9646c7 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
9646c7 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
9646c7 |
# GNU General Public License for more details.
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# You should have received a copy of the GNU General Public License
|
|
Packit Service |
9646c7 |
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Reads from stdin if no files are given.
|
|
Packit Service |
9646c7 |
# Writes to stdout.
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Written by David MacKenzie <djm@gnu.ai.mit.edu>
|
|
Packit Service |
9646c7 |
# and Paul Eggert <eggert@twinsun.com>.
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
BEGIN
|
|
Packit Service |
9646c7 |
{
|
|
Packit Service |
9646c7 |
my $pkgdatadir = $ENV{'autom4te_perllibdir'} || '@pkgdatadir@';
|
|
Packit Service |
9646c7 |
unshift @INC, $pkgdatadir;
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Override SHELL. On DJGPP SHELL may not be set to a shell
|
|
Packit Service |
9646c7 |
# that can handle redirection and quote arguments correctly,
|
|
Packit Service |
9646c7 |
# e.g.: COMMAND.COM. For DJGPP always use the shell that configure
|
|
Packit Service |
9646c7 |
# has detected.
|
|
Packit Service |
9646c7 |
$ENV{'SHELL'} = '@SHELL@' if ($^O eq 'dos');
|
|
Packit Service |
9646c7 |
}
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
use Autom4te::General;
|
|
Packit Service |
9646c7 |
use Autom4te::XFile;
|
|
Packit Service |
9646c7 |
use Autom4te::FileUtils;
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# $HELP
|
|
Packit Service |
9646c7 |
# -----
|
|
Packit Service |
9646c7 |
$help = "Usage: $0 [OPTION]... [FILE]...
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
Scan all of the C source FILES (or the standard input, if none are
|
|
Packit Service |
9646c7 |
given) and write to the standard output a sorted list of all the
|
|
Packit Service |
9646c7 |
identifiers that appear in those files in `#if', `#elif', `#ifdef', or
|
|
Packit Service |
9646c7 |
`#ifndef' directives. Print each identifier on a line, followed by a
|
|
Packit Service |
9646c7 |
space-separated list of the files in which that identifier occurs.
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
-h, --help print this help, then exit
|
|
Packit Service |
9646c7 |
-V, --version print version number, then exit
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
Report bugs to <bug-autoconf\@gnu.org>.
|
|
Packit Service |
9646c7 |
GNU Autoconf home page: <http://www.gnu.org/software/autoconf/>.
|
|
Packit Service |
9646c7 |
General help using GNU software: <http://www.gnu.org/gethelp/>.
|
|
Packit Service |
9646c7 |
";
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# $VERSION
|
|
Packit Service |
9646c7 |
# --------
|
|
Packit Service |
9646c7 |
$version = "ifnames (@PACKAGE_NAME@) @VERSION@
|
|
Packit Service |
9646c7 |
Copyright (C) @RELEASE_YEAR@ Free Software Foundation, Inc.
|
|
Packit Service |
9646c7 |
License GPLv3+/Autoconf: GNU GPL version 3 or later
|
|
Packit Service |
9646c7 |
<http://gnu.org/licenses/gpl.html>, <http://gnu.org/licenses/exceptions.html>
|
|
Packit Service |
9646c7 |
This is free software: you are free to change and redistribute it.
|
|
Packit Service |
9646c7 |
There is NO WARRANTY, to the extent permitted by law.
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
Written by David J. MacKenzie and Paul Eggert.
|
|
Packit Service |
9646c7 |
";
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# &parse_args ()
|
|
Packit Service |
9646c7 |
# --------------
|
|
Packit Service |
9646c7 |
# Process any command line arguments.
|
|
Packit Service |
9646c7 |
sub parse_args ()
|
|
Packit Service |
9646c7 |
{
|
|
Packit Service |
9646c7 |
getopt ();
|
|
Packit Service |
9646c7 |
}
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# %OCCURRENCE
|
|
Packit Service |
9646c7 |
# -----------
|
|
Packit Service |
9646c7 |
my %occurrence;
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# &scan_file ($FILE-NAME)
|
|
Packit Service |
9646c7 |
# -----------------------
|
|
Packit Service |
9646c7 |
sub scan_file ($)
|
|
Packit Service |
9646c7 |
{
|
|
Packit Service |
9646c7 |
my ($file_name) = @_;
|
|
Packit Service |
9646c7 |
my $file = new Autom4te::XFile ("< " . open_quote ($file_name));
|
|
Packit Service |
9646c7 |
while ($_ = $file->getline)
|
|
Packit Service |
9646c7 |
{
|
|
Packit Service |
9646c7 |
# Continuation lines.
|
|
Packit Service |
9646c7 |
$_ .= $file->getline
|
|
Packit Service |
9646c7 |
while (s/\\$//);
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Preprocessor directives.
|
|
Packit Service |
9646c7 |
if (s/^\s*\#\s*(if|ifdef|ifndef|elif)\s+//)
|
|
Packit Service |
9646c7 |
{
|
|
Packit Service |
9646c7 |
# Remove comments. Not perfect, but close enough.
|
|
Packit Service |
9646c7 |
s(/\*.*?\*/)();
|
|
Packit Service |
9646c7 |
s(/\*.*)();
|
|
Packit Service |
9646c7 |
s(//.*)();
|
|
Packit Service |
9646c7 |
foreach my $word (split (/\W+/))
|
|
Packit Service |
9646c7 |
{
|
|
Packit Service |
9646c7 |
next
|
|
Packit Service |
9646c7 |
if $word eq 'defined' || $word !~ /^[a-zA-Z_]/;
|
|
Packit Service |
9646c7 |
$occurrence{$word}{$file_name} = 1;
|
|
Packit Service |
9646c7 |
}
|
|
Packit Service |
9646c7 |
}
|
|
Packit Service |
9646c7 |
}
|
|
Packit Service |
9646c7 |
}
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
## ------ ##
|
|
Packit Service |
9646c7 |
## Main. ##
|
|
Packit Service |
9646c7 |
## ------ ##
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
parse_args();
|
|
Packit Service |
9646c7 |
foreach (@ARGV)
|
|
Packit Service |
9646c7 |
{
|
|
Packit Service |
9646c7 |
scan_file ($_);
|
|
Packit Service |
9646c7 |
}
|
|
Packit Service |
9646c7 |
foreach (sort keys %occurrence)
|
|
Packit Service |
9646c7 |
{
|
|
Packit Service |
9646c7 |
print "$_ ", join (' ', sort keys %{$occurrence{$_}}), "\n";
|
|
Packit Service |
9646c7 |
}
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
### Setup "GNU" style for perl-mode and cperl-mode.
|
|
Packit Service |
9646c7 |
## Local Variables:
|
|
Packit Service |
9646c7 |
## perl-indent-level: 2
|
|
Packit Service |
9646c7 |
## perl-continued-statement-offset: 2
|
|
Packit Service |
9646c7 |
## perl-continued-brace-offset: 0
|
|
Packit Service |
9646c7 |
## perl-brace-offset: 0
|
|
Packit Service |
9646c7 |
## perl-brace-imaginary-offset: 0
|
|
Packit Service |
9646c7 |
## perl-label-offset: -2
|
|
Packit Service |
9646c7 |
## cperl-indent-level: 2
|
|
Packit Service |
9646c7 |
## cperl-brace-offset: 0
|
|
Packit Service |
9646c7 |
## cperl-continued-brace-offset: 0
|
|
Packit Service |
9646c7 |
## cperl-label-offset: -2
|
|
Packit Service |
9646c7 |
## cperl-extra-newline-before-brace: t
|
|
Packit Service |
9646c7 |
## cperl-merge-trailing-else: nil
|
|
Packit Service |
9646c7 |
## cperl-continued-statement-offset: 2
|
|
Packit Service |
9646c7 |
## End:
|