db7fac3f24
git-svn-id: https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/trunk/Core/OpenFOAM-1.5-dev@1731 e4e07f05-0c2f-0410-a05a-b8ba57e0c909
46 lines
1 KiB
Perl
Executable file
46 lines
1 KiB
Perl
Executable file
#!/usr/bin/perl -w
|
|
use strict;
|
|
use File::Find ();
|
|
|
|
# -----------------------------------------------------------------------------
|
|
#
|
|
# Script
|
|
# find-longlines
|
|
#
|
|
# Description
|
|
# Search for *.[CH] files that exceed the 80-column width
|
|
#
|
|
# - print filename lineNumber and offending line (with truncation point)
|
|
#
|
|
# -----------------------------------------------------------------------------
|
|
|
|
my $maxlen = 80;
|
|
my $re_filespec = qr{^.+\.[CH]$};
|
|
my $count;
|
|
|
|
sub wanted {
|
|
unless ( lstat($_) and -f _ and -r _ and not -l _ and /$re_filespec/ ) {
|
|
return;
|
|
}
|
|
|
|
local @ARGV = $_;
|
|
while (<>) {
|
|
chomp;
|
|
s{\s+$}{}; # trim
|
|
|
|
if ( $maxlen < length ) {
|
|
$count++;
|
|
substr( $_, $maxlen, 0 ) = "||->>"; # show truncation point
|
|
print "$File::Find::name $. $_\n";
|
|
}
|
|
}
|
|
close ARGV;
|
|
}
|
|
|
|
## Traverse desired filesystems
|
|
for my $dir (@ARGV) {
|
|
no warnings 'File::Find';
|
|
warn "(**) checking '$dir' ...\n";
|
|
File::Find::find( { wanted => \&wanted }, $dir );
|
|
}
|
|
|