comparison check-module @ 6157:915739deda90

If more parameters are given, check each of them separately; add more exceptions, as noted by Jim Meyering. (check_module): New procedure. (%exempt_header): Now contains all exceptions.
author Jim Meyering <jim@meyering.net>
date Mon, 29 Aug 2005 11:57:17 +0000
parents 15be21aa30a4
children c7048f559336
comparison
equal deleted inserted replaced
6156:fb24defb72aa 6157:915739deda90
12 12
13 use strict; 13 use strict;
14 use Getopt::Long; 14 use Getopt::Long;
15 #use Coda; 15 #use Coda;
16 16
17 (my $VERSION = '$Revision: 1.2 $ ') =~ tr/[0-9].//cd; 17 (my $VERSION = '$Revision: 1.3 $ ') =~ tr/[0-9].//cd;
18 (my $ME = $0) =~ s|.*/||; 18 (my $ME = $0) =~ s|.*/||;
19 19
20 use constant ST_INIT => 1; 20 use constant ST_INIT => 1;
21 use constant ST_FILES => 2; 21 use constant ST_FILES => 2;
22 use constant ST_DEPENDENTS => 3; 22 use constant ST_DEPENDENTS => 3;
142 chomp $line; 142 chomp $line;
143 $line =~ s/".*//; 143 $line =~ s/".*//;
144 exists $inc{$line} && ! exists $special_non_dup{$line} 144 exists $inc{$line} && ! exists $special_non_dup{$line}
145 and warn "$ME: $file: duplicate inclusion of $line\n"; 145 and warn "$ME: $file: duplicate inclusion of $line\n";
146 146
147 # Some known exceptions.
148 $file =~ /\bfull-write\.c$/ && $line eq 'full-read.h'
149 and next;
150 $file =~ /\bsafe-read.c$/ && $line eq 'safe-write.h'
151 and next;
152 $file =~ /\bhash\.c$/ && $line eq 'obstack.h'
153 and next;
154 $file =~ /\bfts\.c$/ &&
155 ($line eq 'fts-cycle.c' || $line eq 'unistd-safer.h')
156 and next;
157
158 $inc{$line} = 1; 147 $inc{$line} = 1;
159 } 148 }
160 close FH; 149 close FH;
161 150
162 return \%inc; 151 return \%inc;
163 } 152 }
164 153
165 { 154 my %exempt_header =
166 GetOptions 155 (
167 ( 156 # Exempt headers like unlocked-io.h that are `#include'd
168 help => sub { usage 0 }, 157 # but not necessarily used.
169 version => sub { print "$ME version $VERSION\n"; exit }, 158 'unlocked-io.h' => 1,
170 ) or usage 1; 159
171 160 # Give gettext.h a free pass only when included from lib/error.c,
172 @ARGV < 1 161 # since we've made that exception solely to make the error
173 and (warn "$ME: missing FILE argument\n"), usage 1; 162 # module easier to use -- at RMS's request.
163 'lib/error.c:gettext.h' => 1,
164
165 # The full-read module shares code with the full-write module.
166 'lib/full-write.c:full-read.h' => 1,
167
168 # The safe-write module shares code with the safe-read module.
169 'lib/safe-read.c:safe-write.h' => 1,
170
171 # The use of obstack.h in the hash module is conditional, off by default.
172 'lib/hash.c:obstack.h' => 1,
173
174 # The fts-lgpl module doesn't actually use fts-cycle.c and unistd-safer.h.
175 'lib/fts.c:fts-cycle.c' => 1,
176 'lib/fts.c:unistd-safer.h' => 1,
177 );
178
179 sub check_module ($)
180 {
181 my @m = @_;
174 182
175 my %file; 183 my %file;
176 my %module_all_files; 184 my %module_all_files;
177 my %dep; 185 my %dep;
178 my %seen_module; 186 my %seen_module;
179
180 my @m = $ARGV[0];
181 187
182 while (@m) 188 while (@m)
183 { 189 {
184 my $m = pop @m; 190 my $m = pop @m;
185 # warn "M: $m\n"; 191 # warn "M: $m\n";
192 { 198 {
193 $module_all_files{$f} = 1; 199 $module_all_files{$f} = 1;
194 } 200 }
195 } 201 }
196 202
197 my %exempt_header =
198 (
199 # Exempt headers like unlocked-io.h that are `#include'd
200 # but not necessarily used.
201 'unlocked-io.h' => 1,
202
203 # Give gettext.h a free pass only when included from lib/error.c,
204 # since we've made that exception solely to make the error
205 # module easier to use -- at RMS's request.
206 'lib/error.c:gettext.h' => 1,
207 );
208
209 my @t = sort keys %module_all_files; 203 my @t = sort keys %module_all_files;
210 # warn "ALL files: @t\n"; 204 # warn "ALL files: @t\n";
211 205
212 # Derive from %module_all_files (by parsing the .c and .h files therein), 206 # Derive from %module_all_files (by parsing the .c and .h files therein),
213 # the list of all #include'd files that reside in lib/. 207 # the list of all #include'd files that reside in lib/.
228 . "listed in module's Files: section\n"; 222 . "listed in module's Files: section\n";
229 } 223 }
230 #my @t = sort keys %$inc; 224 #my @t = sort keys %$inc;
231 #print "** $f: @t\n"; 225 #print "** $f: @t\n";
232 } 226 }
227 }
228
229 {
230 GetOptions
231 (
232 help => sub { usage 0 },
233 version => sub { print "$ME version $VERSION\n"; exit },
234 ) or usage 1;
235
236 @ARGV < 1
237 and (warn "$ME: missing FILE argument\n"), usage 1;
238
239 foreach my $module (@ARGV)
240 {
241 check_module $module;
242 }
233 243
234 exit 0; 244 exit 0;
235 } 245 }