Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / bin / doubleNewlines.pl
blobc1f66e57ea17de5288b51b5d7bb316b82b6b0d43
1 #!/usr/bin/perl
2 ################################################################################
3 # Version: MPL 1.1 / GPLv3+ / LGPLv3+
5 # The contents of this file are subject to the Mozilla Public License Version
6 # 1.1 (the "License"); you may not use this file except in compliance with
7 # the License or as specified alternatively below. You may obtain a copy of
8 # the License at http://www.mozilla.org/MPL/
10 # Software distributed under the License is distributed on an "AS IS" basis,
11 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 # for the specific language governing rights and limitations under the
13 # License.
15 # The Initial Developer of the Original Code is
16 # Michael Koch <miko@gmx.ch>
18 # Major Contributor(s):
19 # <name>
21 # For minor contributions see the git repository.
23 # Alternatively, the contents of this file may be used under the terms of
24 # either the GNU General Public License Version 3 or later (the "GPLv3+"), or
25 # the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
26 # in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
27 # instead of those above.
28 ################################################################################
29 # Usage: "Usage: doubleNewlines.pl <directory>"
30 # It is possible to enter more than one directory separated by spaces.
31 # Instead of a directory you can also use one or more files as arguments.
32 ################################################################################
34 use strict;
35 use warnings;
37 use File::Find;
38 use Cwd 'abs_path';
40 my $total = 0;
42 die "Usage: doubleNewlines.pl <directory>\n" unless (@ARGV);
44 # if path is relative, make it absolute
45 foreach (@ARGV){
46 $_ = abs_path($_);
49 print "Following code files (.hxx and .cxx) are suspicious:\n";
50 find(\&processFile, @ARGV); # processes all files in dir and subdirs
51 print "Found $total suspicious files.\n";
53 sub processFile {
54 my $file = $File::Find::name;
55 return unless $file =~ /(.cxx$)|(.hxx$)/;
56 open FILE, $file or die "Can't open '$file': $!";
57 my $lines = join '', <FILE>;
58 if ($lines =~ /(\n{2,}.+){10}/) { # ten consecutive occurrences of [empty line(s) - code line)]
59 my $relPath = substr($file, index($file, "clone")+6); # relative path beginning with repo name
60 print "$relPath\n";
61 $total++;