3 # checkconfig: find uses of CONFIG_* names without matching definitions.
4 # Copyright abandoned, 1998, Michael Elizabeth Chastain <mailto:mec@shout.net>.
13 open(FILE
, $file) || die "Can't open $file: $!\n";
15 # Initialize variables.
22 LINE
: while ( <FILE
> )
25 $fInComment && (s
+^.*?\
*/+ +o ?
($fInComment = 0) : next);
26 m
+/\*+o && (s+/\
*.*?\
*/+ +go, (s+/\
*.*$+ +o
&& ($fInComment = 1)));
28 # Pick up definitions.
31 $iLinuxConfig = $. if m/^\s*#\s*include\s*"linux\/config\
.h
"/o;
32 $configList{uc $1} = 1 if m/^\s*#\s*include\s*"config\/(\S*)\.h"/o
;
36 $fInString && (s
+^.*?
"+ +o ? ($fInString = 0) : next);
37 m+"+o
&& (s
+".*?"+ +go
, (s
+".*$+ +o && ($fInString = 1)));
39 # Pick up definitions.
42 $iLinuxConfig = $. if m/^\s*#\s*include\s*<linux\/config\.h>/o;
43 $configList{uc $1} = 1 if m/^\s*#\s*include\s*<config\/(\S*)\.h>/o;
44 $configList{$1} = 1 if m/^\s*#\s*define\s+CONFIG_(\w*)/o;
45 $configList{$1} = 1 if m/^\s*#\s*undef\s+CONFIG_(\w*)/o;
49 next unless m/CONFIG_/o;
50 WORD: while ( m/\bCONFIG_(\w+)/og )
53 last LINE if $iLinuxConfig;
54 next WORD if exists $configList{$1};
55 print "$file: $.: need CONFIG_
$1.\n";
60 # Report superfluous includes.
61 if ( $iLinuxConfig && ! $fUseConfig )
62 { print "$file: $iLinuxConfig: linux
/config
.h
not needed
.\n"; }