From: Akim Demaille Date: Mon, 26 Nov 2001 10:51:44 +0000 (+0000) Subject: * bin/autoscan.in (used): New. X-Git-Tag: AUTOCONF-2.52g~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1228cd752daa8cb64374caa32edd4f0857d68c9;p=thirdparty%2Fautoconf.git * bin/autoscan.in (used): New. Use it. --- diff --git a/ChangeLog b/ChangeLog index f6c1b52cc..1c57aaacb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-11-26 Akim Demaille + + * bin/autoscan.in (used): New. + Use it. + + 2001-11-26 Akim Demaille * bin/autoscan.in (&scan_c_file): Better parsing of CPP diff --git a/bin/autoscan.in b/bin/autoscan.in index 7927a3cb5..56960fe1d 100644 --- a/bin/autoscan.in +++ b/bin/autoscan.in @@ -187,6 +187,15 @@ sub init_tables () } +# used($KIND, $WORD, [$WHERE]) +# ---------------------------- +# $WORD is used in $KIND. +sub used ($$;$) +{ + my ($kind, $word, $where) = @_; + $where ||= "$File::Find::name:$."; + push (@{$used{$kind}{$word}}, $where); +} ## ----------------------- ## ## Scanning source files. ## @@ -198,8 +207,8 @@ sub init_tables () sub scan_c_file ($) { my ($filename) = @_; - - push (@cfiles, $File::Find::name); + my $filepath = $File::Find::name; + push (@cfiles, $filepath); # Nonzero if in a multiline comment. my $in_comment = 0; @@ -229,13 +238,13 @@ sub scan_c_file ($) { if (/^include\s*<([^>]*)>/) { - push (@{$used{'headers'}{$1}}, "$File::Find::name:$."); + used ('headers', $1); } if (s/^(if|ifdef|ifndef|elif)\s+//) { foreach my $word (split (/\W+/)) { - push (@{$used{'identifiers'}{$word}}, "$File::Find::name:$.") + used ('identifiers', $word) unless $word eq 'defined' || $word !~ /^[a-zA-Z_]/; } } @@ -251,12 +260,12 @@ sub scan_c_file ($) # Maybe we should ignore function definitions (in column 0)? while (s/\b([a-zA-Z_]\w*)\s*\(/ /) { - push (@{$used{'functions'}{$1}}, "$File::Find::name:$.") + used ('functions', $1) if !defined $c_keywords{$1}; } while (s/\b([a-zA-Z_]\w*)\b/ /) { - push (@{$used{'identifiers'}{$1}}, "$File::Find::name:$.") + used ('identifiers', $1) if !defined $c_keywords{$1}; } } @@ -270,7 +279,8 @@ sub scan_c_file ($) sub scan_makefile ($) { my ($filename) = @_; - push (@makefiles, $File::Find::name); + my $filepath = $File::Find::name; + push (@makefiles, $filepath); my $file = new Autom4te::XFile "<$filename"; @@ -285,17 +295,17 @@ sub scan_makefile ($) # Variable assignments. while (s/\b([a-zA-Z_]\w*)\s*=/ /) { - push (@{$used{'makevars'}{$1}}, "$File::Find::name:$."); + used ('makevars', $1); } # Libraries. while (s/\B-l([a-zA-Z_]\w*)\b/ /) { - push (@{$used{'libraries'}{$1}}, "$File::Find::name:$."); + used ('libraries', $1); } # Tokens in the code. while (s/(?