|
@@ -7,10 +7,11 @@
|
|
|
|
|
|
use strict;
|
|
|
use POSIX;
|
|
|
+use File::Basename;
|
|
|
+use Cwd 'abs_path';
|
|
|
|
|
|
my $P = $0;
|
|
|
-$P =~ s@(.*)/@@g;
|
|
|
-my $D = $1;
|
|
|
+my $D = dirname(abs_path($P));
|
|
|
|
|
|
my $V = '0.32';
|
|
|
|
|
@@ -438,26 +439,29 @@ our $allowed_asm_includes = qr{(?x:
|
|
|
|
|
|
# Load common spelling mistakes and build regular expression list.
|
|
|
my $misspellings;
|
|
|
-my @spelling_list;
|
|
|
my %spelling_fix;
|
|
|
-open(my $spelling, '<', $spelling_file)
|
|
|
- or die "$P: Can't open $spelling_file for reading: $!\n";
|
|
|
-while (<$spelling>) {
|
|
|
- my $line = $_;
|
|
|
|
|
|
- $line =~ s/\s*\n?$//g;
|
|
|
- $line =~ s/^\s*//g;
|
|
|
+if (open(my $spelling, '<', $spelling_file)) {
|
|
|
+ my @spelling_list;
|
|
|
+ while (<$spelling>) {
|
|
|
+ my $line = $_;
|
|
|
|
|
|
- next if ($line =~ m/^\s*#/);
|
|
|
- next if ($line =~ m/^\s*$/);
|
|
|
+ $line =~ s/\s*\n?$//g;
|
|
|
+ $line =~ s/^\s*//g;
|
|
|
|
|
|
- my ($suspect, $fix) = split(/\|\|/, $line);
|
|
|
+ next if ($line =~ m/^\s*#/);
|
|
|
+ next if ($line =~ m/^\s*$/);
|
|
|
+
|
|
|
+ my ($suspect, $fix) = split(/\|\|/, $line);
|
|
|
|
|
|
- push(@spelling_list, $suspect);
|
|
|
- $spelling_fix{$suspect} = $fix;
|
|
|
+ push(@spelling_list, $suspect);
|
|
|
+ $spelling_fix{$suspect} = $fix;
|
|
|
+ }
|
|
|
+ close($spelling);
|
|
|
+ $misspellings = join("|", @spelling_list);
|
|
|
+} else {
|
|
|
+ warn "No typos will be found - file '$spelling_file': $!\n";
|
|
|
}
|
|
|
-close($spelling);
|
|
|
-$misspellings = join("|", @spelling_list);
|
|
|
|
|
|
sub build_types {
|
|
|
my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)";
|
|
@@ -2246,7 +2250,7 @@ sub process {
|
|
|
}
|
|
|
|
|
|
# Check for various typo / spelling mistakes
|
|
|
- if ($in_commit_log || $line =~ /^\+/) {
|
|
|
+ if (defined($misspellings) && ($in_commit_log || $line =~ /^\+/)) {
|
|
|
while ($rawline =~ /(?:^|[^a-z@])($misspellings)(?:$|[^a-z@])/gi) {
|
|
|
my $typo = $1;
|
|
|
my $typo_fix = $spelling_fix{lc($typo)};
|