summaryrefslogtreecommitdiff
path: root/helpers/check_comp
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-09-15 16:36:13 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-09-15 16:36:13 +0200
commit1645fb3816d7792d9f1844e38eed01682bc41e37 (patch)
tree3cc41d235fbb6ec97ad51fff77147d01877f777f /helpers/check_comp
parent748b33439593141d923b7c5079b6f53e301a0e44 (diff)
Add check_comp helper
Diffstat (limited to 'helpers/check_comp')
-rw-r--r--helpers/check_comp60
1 files changed, 60 insertions, 0 deletions
diff --git a/helpers/check_comp b/helpers/check_comp
new file mode 100644
index 0000000..58d61cd
--- /dev/null
+++ b/helpers/check_comp
@@ -0,0 +1,60 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use 5.012;
+
+my ($file) = @ARGV;
+my $in_arguments = 0;
+
+open( my $fh, '<', $file ) or die("Cannot open $file: $!\n");
+
+while ( my $line = <$fh> ) {
+ chomp $line;
+
+ if ( $line =~ m{ ^ [[:space:]]+ _arguments }x ) {
+ $in_arguments = 1;
+ next;
+ }
+ if ( not $in_arguments ) {
+ next;
+ }
+
+ check_line($line);
+
+ if ( not( $line =~ m{ \\ $ }x ) ) {
+ $in_arguments = 0;
+ }
+}
+
+close($fh);
+
+sub check_line {
+ my ($line) = @_;
+
+ my $re_pair = qr{
+ ^ [[:space:]]+ '
+ \( (?<ex_one> \S+) \s (?<ex_two> \S+) (?: \s [^)]+ )? \) '
+ \{ (?<in_one> \S+) , (?<in_two> \S+) (?: , [^)]+ )? \} '
+ }x;
+
+ $line =~ $re_pair or return;
+
+ my @ex = @+{qw{ex_one ex_two}};
+ my @in = @+{qw{in_one in_two}};
+
+ for my $param (@ex) {
+ if ( not( $param ~~ \@in ) ) {
+ printf( "Possible typo: %s not included in {%s,%s}\n", $param,
+ @in );
+ }
+ }
+
+ for my $param (@in) {
+ if ( not( $param ~~ \@ex ) ) {
+ printf( "Possible typo: %s not included in (%s %s)\n", $param,
+ @ex );
+ }
+ }
+
+ return;
+}