37 |
|
|
38 |
use vars qw(@cfiles @makefiles @shfiles %printed); |
use vars qw(@cfiles @makefiles @shfiles %printed); |
39 |
|
|
40 |
# The list of C keywords. |
# The kind of the words we are looking for. |
|
my %c_keywords = map { $_ => 1} |
|
|
qw (int char float double struct union long short unsigned |
|
|
auto extern register typedef static goto return sizeof break |
|
|
continue if else for do while switch case default); |
|
|
|
|
41 |
my @kinds = qw (functions headers identifiers programs |
my @kinds = qw (functions headers identifiers programs |
42 |
makevars libraries); |
makevars libraries); |
43 |
|
|
197 |
} |
} |
198 |
|
|
199 |
|
|
200 |
# used($KIND, $WORD, [$WHERE]) |
# used ($KIND, $WORD, [$WHERE]) |
201 |
# ---------------------------- |
# ----------------------------- |
202 |
# $WORD is used as a $KIND. |
# $WORD is used as a $KIND. |
203 |
sub used ($$;$) |
sub used ($$;$) |
204 |
{ |
{ |
205 |
my ($kind, $word, $where) = @_; |
my ($kind, $word, $where) = @_; |
206 |
$where ||= "$File::Find::name:$."; |
$where ||= "$File::Find::name:$."; |
207 |
push (@{$used{$kind}{$word}}, $where); |
if ( |
208 |
|
# Check for all the libraries. But `-links' is certainly a |
209 |
|
# `find' argument, and `-le', a `test' argument. |
210 |
|
($kind eq 'libraries' && $word !~ /^e|inks$/) |
211 |
|
# Other than libraries are to be checked only if listed in |
212 |
|
# the Autoscan library files. |
213 |
|
|| defined $macro{$kind}{$word} |
214 |
|
) |
215 |
|
{ |
216 |
|
push (@{$used{$kind}{$word}}, $where); |
217 |
|
} |
218 |
} |
} |
219 |
|
|
220 |
|
|
221 |
|
|
222 |
## ----------------------- ## |
## ----------------------- ## |
223 |
## Scanning source files. ## |
## Scanning source files. ## |
224 |
## ----------------------- ## |
## ----------------------- ## |
225 |
|
|
226 |
|
|
227 |
# scan_c_file($FILENAME) |
# scan_c_file ($FILENAME) |
228 |
# ---------------------- |
# ----------------------- |
229 |
sub scan_c_file ($) |
sub scan_c_file ($) |
230 |
{ |
{ |
231 |
my ($filename) = @_; |
my ($filename) = @_; |
281 |
# Maybe we should ignore function definitions (in column 0)? |
# Maybe we should ignore function definitions (in column 0)? |
282 |
while (s/\b([a-zA-Z_]\w*)\s*\(/ /) |
while (s/\b([a-zA-Z_]\w*)\s*\(/ /) |
283 |
{ |
{ |
284 |
used ('functions', $1) |
used ('functions', $1); |
|
if !$c_keywords{$1}; |
|
285 |
} |
} |
286 |
while (s/\b([a-zA-Z_]\w*)\b/ /) |
while (s/\b([a-zA-Z_]\w*)\b/ /) |
287 |
{ |
{ |
288 |
used ('identifiers', $1) |
used ('identifiers', $1); |
|
if !$c_keywords{$1}; |
|
289 |
} |
} |
290 |
} |
} |
291 |
|
|
444 |
if exists $kind_comment{$kind}; |
if exists $kind_comment{$kind}; |
445 |
foreach my $word (sort keys %{$used{$kind}}) |
foreach my $word (sort keys %{$used{$kind}}) |
446 |
{ |
{ |
|
# Words that were caught, but not to be checked according to the |
|
|
# autoscan library files. |
|
|
next |
|
|
if ! exists $macro{$kind}{$word}; |
|
|
|
|
447 |
# Output the needed macro invocations in $configure_scan if not |
# Output the needed macro invocations in $configure_scan if not |
448 |
# already printed, and remember these macros are needed. |
# already printed, and remember these macros are needed. |
449 |
foreach my $macro (@{$macro{$kind}{$word}}) |
foreach my $macro (@{$macro{$kind}{$word}}) |
625 |
# at END. It results in a truncated file. |
# at END. It results in a truncated file. |
626 |
$log->close; |
$log->close; |
627 |
exit 0; |
exit 0; |
628 |
|
|
629 |
|
### Setup "GNU" style for perl-mode and cperl-mode. |
630 |
|
## Local Variables: |
631 |
|
## perl-indent-level: 2 |
632 |
|
## perl-continued-statement-offset: 2 |
633 |
|
## perl-continued-brace-offset: 0 |
634 |
|
## perl-brace-offset: 0 |
635 |
|
## perl-brace-imaginary-offset: 0 |
636 |
|
## perl-label-offset: -2 |
637 |
|
## cperl-indent-level: 2 |
638 |
|
## cperl-brace-offset: 0 |
639 |
|
## cperl-continued-brace-offset: 0 |
640 |
|
## cperl-label-offset: -2 |
641 |
|
## cperl-extra-newline-before-brace: t |
642 |
|
## cperl-merge-trailing-else: nil |
643 |
|
## cperl-continued-statement-offset: 2 |
644 |
|
## End: |