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, 2000, 2001, 2002, 2003 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 2, or (at your option)
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, write to the Free Software
25 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
28 # Reads from stdin if no files are given.
31 # Written by David MacKenzie <djm@gnu.ai.mit.edu>
32 # and Paul Eggert <eggert@twinsun.com>.
36 my $datadir = $ENV{'autom4te_perllibdir'} || '@datadir@';
37 unshift @INC, $datadir;
39 # Override SHELL. On DJGPP SHELL may not be set to a shell
40 # that can handle redirection and quote arguments correctly,
41 # e.g.: COMMAND.COM. For DJGPP always use the shell that configure
43 $ENV{'SHELL'} = '@SHELL@' if ($^O eq 'dos');
46 use Autom4te::General;
51 $help = "Usage: $0 [OPTION] ... [FILE] ...
53 Scan all of the C source FILES (or the standard input, if none are
54 given) and write to the standard output a sorted list of all the
55 identifiers that appear in those files in `#if', `#elif', `#ifdef', or
56 `#ifndef' directives. Print each identifier on a line, followed by a
57 space-separated list of the files in which that identifier occurs.
59 -h, --help print this help, then exit
60 -V, --version print version number, then exit
62 Report bugs to <bug-autoconf\@gnu.org>.
68 $version = "ifnames (@PACKAGE_NAME@) @VERSION@
69 Written by David J. MacKenzie and Paul Eggert.
71 Copyright (C) 2005 Free Software Foundation, Inc.
72 This is free software; see the source for copying conditions. There is NO
73 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
79 # Process any command line arguments.
91 # &scan_file ($FILE-NAME)
92 # -----------------------
96 my $file = new Autom4te::XFile ($file_name);
97 while ($_ = $file->getline)
103 # Preprocessor directives.
104 if (s/^\s*\#\s*(if|ifdef|ifndef|elif)\s+//)
106 # Remove comments. Not perfect, but close enough.
110 foreach my $word (split (/\W+/))
113 if $word eq 'defined' || $word !~ /^[a-zA-Z_]/;
114 $occurrence{$word}{$file_name} = 1;
130 foreach (sort keys %occurrence)
132 print "$_ ", join (' ', sort keys %{$occurrence{$_}}), "\n";
135 ### Setup "GNU" style for perl-mode and cperl-mode.
137 ## perl-indent-level: 2
138 ## perl-continued-statement-offset: 2
139 ## perl-continued-brace-offset: 0
140 ## perl-brace-offset: 0
141 ## perl-brace-imaginary-offset: 0
142 ## perl-label-offset: -2
143 ## cperl-indent-level: 2
144 ## cperl-brace-offset: 0
145 ## cperl-continued-brace-offset: 0
146 ## cperl-label-offset: -2
147 ## cperl-extra-newline-before-brace: t
148 ## cperl-merge-trailing-else: nil
149 ## cperl-continued-statement-offset: 2