2 # ifnames - print the identifiers used in C preprocessor conditionals
3 # Copyright (C) 1994, 1995 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 # Reads from stdin if no files are given.
23 # Written by David MacKenzie <djm@gnu.ai.mit.edu>
24 # and Paul Eggert <eggert@twinsun.com>.
27 Usage: ifnames [-h] [--help] [-m dir] [--macrodir=dir] [--version] [file...]"
30 : ${AC_MACRODIR=@datadir@}
32 while test $# -gt 0; do
35 echo "$usage"; exit 0 ;;
36 --macrodir=* | --m*=* )
37 AC_MACRODIR="`echo \"$1\" | sed -e 's/^[^=]*=//'`"
39 -m | --macrodir | --m* )
41 test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
44 --version | --versio | --versi | --vers)
45 show_version=yes; shift ;;
46 --) # Stop option processing.
48 -*) echo "$usage" 1>&2; exit 1 ;;
53 if test $show_version = yes; then
54 version=`sed -n 's/define.AC_ACVERSION.[ ]*\([0-9.]*\).*/\1/p' \
55 $AC_MACRODIR/acgeneral.m4`
56 echo "Autoconf version $version"
61 # Record that sym was found in FILENAME.
62 function file_sym(sym, i, fs) {
63 if (sym ~ /^[A-Za-z_]/) {
64 if (!found[sym,FILENAME]) {
65 found[sym,FILENAME] = 1
67 # Insert FILENAME into files[sym], keeping the list sorted.
70 while (match(substr(fs, i), /^ [^ ]*/) \
71 && substr(fs, i + 1, RLENGTH - 1) < FILENAME) {
74 files[sym] = substr(fs, 1, i - 1) " " FILENAME substr(fs, i)
80 if (sub(/^[\t ]*#[\t ]*ifn?def[\t ]+/, "", $0)) {
81 sub(/[^A-Za-z_0-9].*/, "", $0)
84 if (sub(/^[\t ]*#[\t ]*(el)?if[\t ]+/, "", $0)) {
85 # Remove comments. Not perfect, but close enough.
86 gsub(/\/\*[^\/]*(\*\/)?/, "", $0)
88 for (i = split($0, field, /[^A-Za-z_0-9]+/); 1 <= i; i--) {
89 if (field[i] != "defined") {