5 eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac'
8 # ifnames - print the identifiers used in C preprocessor conditionals
10 # Copyright (C) 1994-1995, 1999-2003, 2005-2017, 2020-2024 Free Software
13 # This program is free software: you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation, either version 3 of the License, or
16 # (at your option) any later version.
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program. If not, see <https://www.gnu.org/licenses/>.
26 # Reads from stdin if no files are given.
29 # Written by David MacKenzie <djm@gnu.ai.mit.edu>
30 # and Paul Eggert <eggert@twinsun.com>.
34 use warnings FATAL => 'all';
38 my $pkgdatadir = $ENV{'autom4te_perllibdir'} || '@pkgdatadir@';
39 unshift @INC, $pkgdatadir;
41 # Override SHELL. On DJGPP SHELL may not be set to a shell
42 # that can handle redirection and quote arguments correctly,
43 # e.g.: COMMAND.COM. For DJGPP always use the shell that configure
45 $ENV{'SHELL'} = '@SHELL@' if ($^O eq 'dos');
48 use Autom4te::General;
50 use Autom4te::FileUtils;
54 $help = "Usage: $0 [OPTION]... [FILE]...
56 Scan all of the C source FILES (or the standard input, if none are
57 given) and write to the standard output a sorted list of all the
58 identifiers that appear in those files in '#if', '#ifdef', '#ifndef',
59 '#elif', '#elifdef', or '#elifndef' directives. Print each identifier
60 on a line, followed by a space-separated list of the files in which
61 that identifier occurs.
63 -h, --help print this help, then exit
64 -V, --version print version number, then exit
66 Report bugs to <bug-autoconf\@gnu.org>.
68 The full documentation for Autoconf can be read via 'info autoconf',
69 or on the Web at <https://www.gnu.org/software/autoconf/manual/>.
75 $version = "ifnames (@PACKAGE_NAME@) @VERSION@
76 Copyright (C) @RELEASE_YEAR@ Free Software Foundation, Inc.
77 License GPLv3+/Autoconf: GNU GPL version 3 or later
78 <https://gnu.org/licenses/gpl.html>, <https://gnu.org/licenses/exceptions.html>
79 This is free software: you are free to change and redistribute it.
80 There is NO WARRANTY, to the extent permitted by law.
82 Written by David J. MacKenzie and Paul Eggert.
88 # Process any command line arguments.
100 # &scan_file ($FILE-NAME)
101 # -----------------------
104 my ($file_name) = @_;
105 my $file = new Autom4te::XFile ($file_name, "<");
106 while ($_ = $file->getline)
108 # Continuation lines.
112 # Preprocessor directives.
113 if (s/^\s*\#\s*(el)?if(n?def)?\s+//)
115 # Remove comments. Not perfect, but close enough.
119 foreach my $word (split (/\W+/))
122 if $word eq 'defined' || $word !~ /^[a-zA-Z_]/;
123 $occurrence{$word}{$file_name} = 1;
139 foreach (sort keys %occurrence)
141 print "$_ ", join (' ', sort keys %{$occurrence{$_}}), "\n";
144 ### Setup "GNU" style for perl-mode and cperl-mode.
146 ## perl-indent-level: 2
147 ## perl-continued-statement-offset: 2
148 ## perl-continued-brace-offset: 0
149 ## perl-brace-offset: 0
150 ## perl-brace-imaginary-offset: 0
151 ## perl-label-offset: -2
152 ## cperl-indent-level: 2
153 ## cperl-brace-offset: 0
154 ## cperl-continued-brace-offset: 0
155 ## cperl-label-offset: -2
156 ## cperl-extra-newline-before-brace: t
157 ## cperl-merge-trailing-else: nil
158 ## cperl-continued-statement-offset: 2