Renamed extern-squish -> var-checker.
[rsync/rsync.git] / packaging / var-checker
CommitLineData
c5d77e96
WD
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
5use strict;
6
7my @files = glob('*.c');
8
9foreach 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}