Include /.gitignore in the installer
[msysgit/historical-msysgit.git] / bin / ifnames
blobb4e784b4a551c65207ed1d43449b63205fda8ccf
1 #! /bin/perl -w
2 # -*- perl -*-
3 # @configure_input@
5 eval 'case $# in 0) exec /bin/perl -S "$0";; *) exec /bin/perl -S "$0" "$@";; esac'
6 if 0;
8 # ifnames - print the identifiers used in C preprocessor conditionals
10 # Copyright (C) 1994, 1995, 1999, 2000, 2001, 2002 Free Software
11 # Foundation, Inc.
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)
16 # 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, write to the Free Software
25 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 # 02111-1307, USA.
28 # Reads from stdin if no files are given.
29 # Writes to stdout.
31 # Written by David MacKenzie <djm@gnu.ai.mit.edu>
32 # and Paul Eggert <eggert@twinsun.com>.
34 BEGIN
36 my $datadir = ($ENV{'autom4te_perllibdir'} || '/usr/share/autoconf');
37 unshift @INC, "$datadir";
40 use Autom4te::General;
41 use Autom4te::XFile;
43 # $HELP
44 # -----
45 $help = "Usage: $0 [OPTION] ... [FILE] ...
47 Scan all of the C source FILES (or the standard input, if none are
48 given) and write to the standard output a sorted list of all the
49 identifiers that appear in those files in `#if', `#elif', `#ifdef', or
50 `#ifndef' directives. Print each identifier on a line, followed by a
51 space-separated list of the files in which that identifier occurs.
53 -h, --help print this help, then exit
54 -V, --version print version number, then exit
56 Report bugs to <bug-autoconf\@gnu.org>.";
59 # $VERSION
60 # --------
61 $version = "\
62 ifnames (GNU Autoconf) 2.56
63 Written by David J. MacKenzie and Paul Eggert.
65 Copyright 2002 Free Software Foundation, Inc.
66 This is free software; see the source for copying conditions. There is NO
67 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.";
70 # &parse_args ()
71 # --------------
72 # Process any command line arguments.
73 sub parse_args ()
75 getopt ();
79 # %OCCURRENCE
80 # -----------
81 my %occurrence;
84 # &scan_file ($FILENAME)
85 # ----------------------
86 sub scan_file ($)
88 my ($filename) = @_;
89 my $file = new Autom4te::XFile ($filename);
90 while ($_ = $file->getline)
92 # Continuation lines.
93 $_ .= $file->getline
94 while (s/\\$//);
96 # Preprocessor directives.
97 if (s/^\s*\#\s*(if|ifdef|ifndef|elif)\s+//)
99 # Remove comments. Not perfect, but close enough.
100 s(/\*.*?\*/)();
101 s(/\*.*)();
102 foreach my $word (split (/\W+/))
104 next
105 if $word eq 'defined' || $word !~ /^[a-zA-Z_]/;
106 $occurrence{$word}{$filename} = 1;
113 ## ------ ##
114 ## Main. ##
115 ## ------ ##
117 parse_args();
118 foreach (@ARGV)
120 scan_file ($_);
122 foreach (sort keys %occurrence)
124 print "$_ ", join (' ', sort keys %{$occurrence{$_}}), "\n";
127 ### Setup "GNU" style for perl-mode and cperl-mode.
128 ## Local Variables:
129 ## perl-indent-level: 2
130 ## perl-continued-statement-offset: 2
131 ## perl-continued-brace-offset: 0
132 ## perl-brace-offset: 0
133 ## perl-brace-imaginary-offset: 0
134 ## perl-label-offset: -2
135 ## cperl-indent-level: 2
136 ## cperl-brace-offset: 0
137 ## cperl-continued-brace-offset: 0
138 ## cperl-label-offset: -2
139 ## cperl-extra-newline-before-brace: t
140 ## cperl-merge-trailing-else: nil
141 ## cperl-continued-statement-offset: 2
142 ## End: