1#! /bin/sh 2exec perl -n -w -x $0 ${1+"$@"} 3#! perl -n 4#line 5 5 6# Purpose: list all files (from the list given on the command line) with 7# inconsistent or wrong indentation (which would harm readability and hence 8# maintainability of that file). 9 10if (eof) { close ARGV; $in_paren=$in_cout=''; } 11next if (m/^#/ || m/^\s*$/); 12s+\\.+X+g; 13s+\".*?\"+X+g; 14s+\'.\'+X+g; 15s+//.*++; 16next if (m/^\s*$/); 17m/^( *)(.?)(.?)/; $indent=length($1); $in_cout = '' unless ($2.$3 eq '<<'); 18++$indent if ($2 eq ')'); 19print "vi +$. $ARGV\n" if (($in_paren && $paren_indent != $indent) || ($in_cout && $cout_indent != $indent)); 20$paren_indent=$indent; 21 22if ($in_paren) 23{ 24 $in_paren = m/^([^()]*(\([^()]*\))*)*$/; 25} 26elsif (m/^([^()]*\( *)(([^()]*(\([^()]*\))*)*)$/ && length($2) > 1) 27{ 28 $paren_indent=length($1); $in_paren=1; 29} 30 31if (m/^( *\w+ *)<</) 32{ 33 $cout_indent=length($1); $in_cout=1; 34} 35