make/scripts/normalizer.pl
author brutisso
Wed, 03 Feb 2016 18:21:43 +0100
changeset 35930 722866f5e209
parent 27595 cff167b3bfa2
permissions -rw-r--r--
8148951: Remove unused method Generation::performs_in_place_marking() Reviewed-by: david, jwilhelm
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11949
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
     1
#!/usr/bin/perl
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
     2
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
     3
#
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
     4
# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
     5
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
     6
#
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
     7
# This code is free software; you can redistribute it and/or modify it
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
     8
# under the terms of the GNU General Public License version 2 only, as
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
     9
# published by the Free Software Foundation.
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    10
#
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    15
# accompanied this code).
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    16
#
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    20
#
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    23
# questions.
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    24
#
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    25
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    26
#
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    27
# Parses java files:
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    28
#   1. Removes from the end of lines spaces and TABs
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    29
#   2. Replaces TABs by spaces
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    30
#   3. Replaces all NewLine separators by Unix NewLine separators
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    31
#   4. Makes one and only one empty line at the end of each file
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    32
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    33
if ($#ARGV < 0) {
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    34
    &usage;
27595
cff167b3bfa2 8065914: Various improvements and cleanup of build system
ihse
parents: 11949
diff changeset
    35
11949
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    36
    die;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    37
}
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    38
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    39
use Cwd 'abs_path';
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    40
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    41
my @extensions = ("java");
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    42
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    43
# Read options
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    44
my $dirpos = 0;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    45
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    46
while ($dirpos < $#ARGV) {
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    47
    if ($ARGV[$dirpos] eq "-e") {
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    48
        @extensions = split(/,/, $ARGV[$dirpos + 1]);
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    49
    } else {
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    50
        last;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    51
    }
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    52
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    53
    $dirpos += 2;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    54
}
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    55
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    56
if ($dirpos > $#ARGV) {
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    57
    &usage;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    58
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    59
    die;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    60
}
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    61
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    62
use Cwd;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    63
my $currdir = getcwd;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    64
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    65
my $allfiles = 0;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    66
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    67
my $filecount = 0;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    68
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    69
my @tabvalues;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    70
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    71
# Init tabvalues
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    72
push (@tabvalues, " ");
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    73
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    74
for (my $i = 1; $i < 8; $i++) {
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    75
    push(@tabvalues, $tabvalues[$i - 1] . " ");
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    76
}
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    77
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    78
open(FILELIST, ">$currdir/filelist") or die "Failed while open $currdir/filelist: $!\n";
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    79
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    80
while ($dirpos <= $#ARGV) {
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    81
    use File::Find;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    82
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    83
    find(\&parse_file, abs_path($ARGV[$dirpos]));
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    84
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    85
    $dirpos += 1;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    86
}
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    87
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    88
close(FILELIST);
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    89
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    90
use Cwd 'chdir';
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    91
chdir $currdir;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    92
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    93
print "Checked $allfiles file(s)\n";
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    94
print "Modified $filecount file(s)\n";
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    95
print "See results in the file $currdir/filelist\n";
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    96
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    97
sub parse_file {
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    98
    my $filename = $File::Find::name;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
    99
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   100
    # Skip directories
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   101
    return if -d;
27595
cff167b3bfa2 8065914: Various improvements and cleanup of build system
ihse
parents: 11949
diff changeset
   102
11949
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   103
    # Skip SCCS files
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   104
    return if ($filename =~ /\/SCCS\//);
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   105
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   106
    # Skip files with invalid extensions
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   107
    my $accepted = 0;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   108
    foreach my $ext (@extensions) {
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   109
        if ($_ =~ /\.$ext$/i) {
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   110
            $accepted = 1;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   111
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   112
            last;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   113
        }
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   114
    }
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   115
    return if ($accepted == 0);
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   116
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   117
    use File::Basename;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   118
    my $dirname = dirname($filename);
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   119
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   120
    use Cwd 'chdir';
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   121
    chdir $dirname;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   122
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   123
    open(FILE, $filename) or die "Failed while open $filename: $!\n";
27595
cff167b3bfa2 8065914: Various improvements and cleanup of build system
ihse
parents: 11949
diff changeset
   124
11949
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   125
    # Read file
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   126
    my @content;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   127
    my $line;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   128
    my $emptylinescount = 0;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   129
    my $modified = 0;
27595
cff167b3bfa2 8065914: Various improvements and cleanup of build system
ihse
parents: 11949
diff changeset
   130
11949
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   131
    while ($line = <FILE>) {
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   132
        my $originalline = $line;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   133
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   134
        # Process line
27595
cff167b3bfa2 8065914: Various improvements and cleanup of build system
ihse
parents: 11949
diff changeset
   135
11949
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   136
        # Remove from the end of the line spaces and return character
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   137
        while ($line =~ /\s$/) {
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   138
            chop($line);
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   139
        }
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   140
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   141
        # Replace TABs
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   142
        for (my $i = 0; $i < length($line); $i++) {
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   143
            if (substr($line, $i, 1) =~ /\t/) {
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   144
                $line = substr($line, 0, $i) . $tabvalues[7 - ($i % 8)] . substr($line, $i + 1);
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   145
            }
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   146
        }
27595
cff167b3bfa2 8065914: Various improvements and cleanup of build system
ihse
parents: 11949
diff changeset
   147
11949
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   148
        if (length($line) == 0) {
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   149
            $emptylinescount++;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   150
        } else {
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   151
            while ($emptylinescount > 0) {
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   152
                push(@content, "");
27595
cff167b3bfa2 8065914: Various improvements and cleanup of build system
ihse
parents: 11949
diff changeset
   153
11949
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   154
                $emptylinescount--;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   155
            }
27595
cff167b3bfa2 8065914: Various improvements and cleanup of build system
ihse
parents: 11949
diff changeset
   156
11949
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   157
            push(@content, $line);
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   158
        }
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   159
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   160
        if ($originalline ne ($line . "\n")) {
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   161
            $modified = 1;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   162
        }
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   163
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   164
    }
27595
cff167b3bfa2 8065914: Various improvements and cleanup of build system
ihse
parents: 11949
diff changeset
   165
11949
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   166
    $allfiles++;
27595
cff167b3bfa2 8065914: Various improvements and cleanup of build system
ihse
parents: 11949
diff changeset
   167
11949
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   168
    if ($emptylinescount > 0) {
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   169
        $modified = 1;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   170
    }
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   171
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   172
    close(FILE);
27595
cff167b3bfa2 8065914: Various improvements and cleanup of build system
ihse
parents: 11949
diff changeset
   173
11949
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   174
    if ($modified != 0) {
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   175
        # Write file
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   176
        open(FILE, ">$filename") or die "Failed while open $filename: $!\n";
27595
cff167b3bfa2 8065914: Various improvements and cleanup of build system
ihse
parents: 11949
diff changeset
   177
11949
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   178
        for (my $i = 0; $i <= $#content; $i++) {
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   179
            print FILE "$content[$i]\n";
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   180
        }
27595
cff167b3bfa2 8065914: Various improvements and cleanup of build system
ihse
parents: 11949
diff changeset
   181
11949
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   182
        close(FILE);
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   183
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   184
        # Print name from current dir
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   185
        if (index($filename, $currdir) == 0) {
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   186
           print FILELIST substr($filename, length($currdir) + 1);
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   187
        } else {
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   188
           print FILELIST $filename;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   189
        }
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   190
        print FILELIST "\n";
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   191
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   192
        $filecount++;
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   193
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   194
        print "$filename: modified\n";
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   195
    }
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   196
}
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   197
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   198
sub usage {
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   199
    print "Usage:\n";
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   200
    print "  normalizer.pl [-options] <dir> [dir2 dir3 ...]\n";
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   201
    print "  Available options:\n";
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   202
    print "    -e    comma separated files extensions. By default accepts only java files\n";
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   203
    print "\n";
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   204
    print "Examples:\n";
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   205
    print "  normalizer.pl -e c,cpp,h,hpp .\n";
90adc6874994 6625113: Add the normalize and rmkw perl script to the openjdk repository or openjdk site?
ohair
parents:
diff changeset
   206
}