Including my extern-squishing script, which just found an
[rsync/rsync.git] / support / extern-squish
1 #!/usr/bin/perl
2 # This script finds extraneous "extern" variables in the *.c files.
3 # Run it from inside the main rsync directory.
4
5 use strict;
6
7 my @files = glob('*.c');
8
9 foreach my $fn (@files) {
10     open(IN, '<', $fn) or die;
11     undef $/; $_ = <IN>; $/ = "\n";
12     close IN;
13     my @externs = /^extern .*?([^[\s(*;&.]+)(?:\[.*?\])?;/mg;
14     foreach my $find (@externs) {
15         my @matches = /(?<!\sstruct )\b(\Q$find\E)\b/g;
16         print $fn, ': ', $find, "\n" if @matches == 1;
17     }
18 }