Including my extern-squishing script, which just found an
authorWayne Davison <wayned@samba.org>
Mon, 12 Nov 2007 06:51:50 +0000 (22:51 -0800)
committerWayne Davison <wayned@samba.org>
Mon, 12 Nov 2007 06:51:50 +0000 (22:51 -0800)
extraneous extern in exclude.c.

exclude.c
support/extern-squish [new file with mode: 0755]

index f1c4fdf..467731c 100644 (file)
--- a/exclude.c
+++ b/exclude.c
@@ -26,7 +26,6 @@ extern int verbose;
 extern int am_server;
 extern int am_sender;
 extern int eol_nulls;
-extern int recurse;
 extern int io_error;
 extern int local_server;
 extern int prune_empty_dirs;
diff --git a/support/extern-squish b/support/extern-squish
new file mode 100755 (executable)
index 0000000..eb8b32e
--- /dev/null
@@ -0,0 +1,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;
+    }
+}