From 1645fb3816d7792d9f1844e38eed01682bc41e37 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 15 Sep 2011 16:36:13 +0200 Subject: Add check_comp helper --- helpers/check_comp | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 helpers/check_comp (limited to 'helpers') 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:]]+ ' + \( (? \S+) \s (? \S+) (?: \s [^)]+ )? \) ' + \{ (? \S+) , (? \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; +} -- cgit v1.2.3