File: extern-squish

package info (click to toggle)
rsync 3.0.3-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,472 kB
  • ctags: 3,518
  • sloc: ansic: 35,122; sh: 4,882; perl: 1,415; makefile: 267; python: 83
file content (18 lines) | stat: -rwxr-xr-x 479 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/perl
# This script finds extraneous "extern" variables in the *.c files.
# Run it from inside the main rsync directory.

use strict;

my @files = glob('*.c');

foreach my $fn (@files) {
    open(IN, '<', $fn) or die;
    undef $/; $_ = <IN>; $/ = "\n";
    close IN;
    my @externs = /^extern .*?([^[\s(*;&.]+)(?:\[.*?\])?;/mg;
    foreach my $find (@externs) {
	my @matches = /(?<!\sstruct )\b(\Q$find\E)\b/g;
	print $fn, ': ', $find, "\n" if @matches == 1;
    }
}