143 |
# Put values in the tables of what to do with each token. |
# Put values in the tables of what to do with each token. |
144 |
sub init_tables () |
sub init_tables () |
145 |
{ |
{ |
|
# Initialize a table of C keywords (to ignore). |
|
|
# Taken from K&R 1st edition p. 180. |
|
|
# ANSI C, GNU C, and C++ keywords can introduce portability problems, |
|
|
# so don't ignore them. |
|
|
|
|
146 |
# The data file format supports only one line of macros per function. |
# The data file format supports only one line of macros per function. |
147 |
# If more than that is required for a common portability problem, |
# If more than that is required for a common portability problem, |
148 |
# a new Autoconf macro should probably be written for that case, |
# a new Autoconf macro should probably be written for that case, |
149 |
# instead of duplicating the code in lots of configure.ac files. |
# instead of duplicating the code in lots of configure.ac files. |
150 |
|
my $file = find_file ("autoscan/autoscan.list", |
151 |
|
reverse (@prepend_include), @include); |
152 |
|
my $table = new Autom4te::XFile $file; |
153 |
my $tables_are_consistent = 1; |
my $tables_are_consistent = 1; |
154 |
foreach my $kind (@kinds) |
|
155 |
|
while ($_ = $table->getline) |
156 |
{ |
{ |
157 |
my $file = find_file ("autoscan/$kind", |
# Ignore blank lines and comments. |
158 |
reverse(@prepend_include), @include); |
next |
159 |
my $table = new Autom4te::XFile $file; |
if /^\s*$/ || /^\s*\#/; |
160 |
while ($_ = $table->getline) |
|
161 |
|
# '<kind>: <word> <macro invocation>' or... |
162 |
|
# '<kind>: <word> warn: <message>'. |
163 |
|
if (/^(\S+):\s+(\S+)\s+(\S.*)$/) |
164 |
{ |
{ |
165 |
# Ignore blank lines and comments. |
my ($kind, $word, $macro) = ("$1s", $2, $3); |
166 |
next |
error "$file:$.: invalid kind: $_" |
167 |
if /^\s*$/ || /^\s*\#/; |
unless grep { $_ eq $kind } @kinds; |
168 |
|
push @{$macro{$kind}{$word}}, $macro; |
169 |
# '<kind>: <word> <macro invocation>' or... |
} |
170 |
# '<kind>: <word> warn: <message>'. |
else |
171 |
if (/^(\S+):\s+(\S+)\s+(\S.*)$/) |
{ |
172 |
{ |
error "$file:$.: invalid definition: $_"; |
|
my ($mkind, $word, $macro) = ($1, $2, $3); |
|
|
die "$mkind:$kind\n" |
|
|
unless "${mkind}s" eq $kind; |
|
|
# The default macro must be explicitly listed for words |
|
|
# which have a specific macros. This allows to enforce |
|
|
# consistency checks. |
|
|
if (!defined $word && exists $macro{$kind}{$word}) |
|
|
{ |
|
|
warn ("$file:$.: " |
|
|
. "ignoring implicit call to the generic macro for $word\n"); |
|
|
$tables_are_consistent = 0; |
|
|
} |
|
|
else |
|
|
{ |
|
|
push @{$macro{$kind}{$word}}, $macro; |
|
|
} |
|
|
next; |
|
|
} |
|
|
|
|
|
error "cannot parse definition in $file:\n$_"; |
|
173 |
} |
} |
|
$table->close; |
|
174 |
} |
} |
175 |
|
|
|
error "some tables are inconsistent" |
|
|
if !$tables_are_consistent; |
|
176 |
} |
} |
177 |
|
|
178 |
|
|
186 |
if ( |
if ( |
187 |
# Check for all the libraries. But `-links' is certainly a |
# Check for all the libraries. But `-links' is certainly a |
188 |
# `find' argument, and `-le', a `test' argument. |
# `find' argument, and `-le', a `test' argument. |
189 |
($kind eq 'libraries' && $word !~ /^e|inks$/) |
($kind eq 'libraries' && $word !~ /^(e|inks)$/) |
190 |
# Other than libraries are to be checked only if listed in |
# Other than libraries are to be checked only if listed in |
191 |
# the Autoscan library files. |
# the Autoscan library files. |
192 |
|| defined $macro{$kind}{$word} |
|| defined $macro{$kind}{$word} |