Merge branch 'master' of github.com:OpenFOAM/OpenFOAM-2.0.x
[OpenFOAM-2.0.x.git] / doc / tools / find-longlines
blob424cd91cd289c283f928e2297ec4268d8cb2f052
1 #!/usr/bin/perl -w
2 use strict;
3 use File::Find ();
5 # -----------------------------------------------------------------------------
7 # Script
8 # find-longlines
10 # Description
11 # Search for *.[CH] files that exceed the 80-column width
13 # - print filename lineNumber and offending line (with truncation point)
15 # -----------------------------------------------------------------------------
17 my $maxlen = 80;
18 my $re_filespec = qr{^.+\.[CH]$};
19 my $count;
21 sub wanted {
22 unless ( lstat($_) and -f _ and -r _ and not -l _ and /$re_filespec/ ) {
23 return;
26 local @ARGV = $_;
27 while (<>) {
28 chomp;
29 s{\s+$}{}; # trim
31 if ( $maxlen < length ) {
32 $count++;
33 substr( $_, $maxlen, 0 ) = "||->>"; # show truncation point
34 print "$File::Find::name $. $_\n";
37 close ARGV;
40 ## Traverse desired filesystems
41 for my $dir (@ARGV) {
42 no warnings 'File::Find';
43 warn "(**) checking '$dir' ...\n";
44 File::Find::find( { wanted => \&wanted }, $dir );