diff options
-rwxr-xr-x | scripts/checkpatch.pl | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 10ad5ab571dc..853dc7f9f751 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -7,10 +7,11 @@ | |||
7 | 7 | ||
8 | use strict; | 8 | use strict; |
9 | use POSIX; | 9 | use POSIX; |
10 | use File::Basename; | ||
11 | use Cwd 'abs_path'; | ||
10 | 12 | ||
11 | my $P = $0; | 13 | my $P = $0; |
12 | $P =~ s@(.*)/@@g; | 14 | my $D = dirname(abs_path($P)); |
13 | my $D = $1; | ||
14 | 15 | ||
15 | my $V = '0.32'; | 16 | my $V = '0.32'; |
16 | 17 | ||
@@ -438,26 +439,29 @@ our $allowed_asm_includes = qr{(?x: | |||
438 | 439 | ||
439 | # Load common spelling mistakes and build regular expression list. | 440 | # Load common spelling mistakes and build regular expression list. |
440 | my $misspellings; | 441 | my $misspellings; |
441 | my @spelling_list; | ||
442 | my %spelling_fix; | 442 | my %spelling_fix; |
443 | open(my $spelling, '<', $spelling_file) | ||
444 | or die "$P: Can't open $spelling_file for reading: $!\n"; | ||
445 | while (<$spelling>) { | ||
446 | my $line = $_; | ||
447 | 443 | ||
448 | $line =~ s/\s*\n?$//g; | 444 | if (open(my $spelling, '<', $spelling_file)) { |
449 | $line =~ s/^\s*//g; | 445 | my @spelling_list; |
446 | while (<$spelling>) { | ||
447 | my $line = $_; | ||
450 | 448 | ||
451 | next if ($line =~ m/^\s*#/); | 449 | $line =~ s/\s*\n?$//g; |
452 | next if ($line =~ m/^\s*$/); | 450 | $line =~ s/^\s*//g; |
453 | 451 | ||
454 | my ($suspect, $fix) = split(/\|\|/, $line); | 452 | next if ($line =~ m/^\s*#/); |
453 | next if ($line =~ m/^\s*$/); | ||
454 | |||
455 | my ($suspect, $fix) = split(/\|\|/, $line); | ||
455 | 456 | ||
456 | push(@spelling_list, $suspect); | 457 | push(@spelling_list, $suspect); |
457 | $spelling_fix{$suspect} = $fix; | 458 | $spelling_fix{$suspect} = $fix; |
459 | } | ||
460 | close($spelling); | ||
461 | $misspellings = join("|", @spelling_list); | ||
462 | } else { | ||
463 | warn "No typos will be found - file '$spelling_file': $!\n"; | ||
458 | } | 464 | } |
459 | close($spelling); | ||
460 | $misspellings = join("|", @spelling_list); | ||
461 | 465 | ||
462 | sub build_types { | 466 | sub build_types { |
463 | my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)"; | 467 | my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)"; |
@@ -2246,7 +2250,7 @@ sub process { | |||
2246 | } | 2250 | } |
2247 | 2251 | ||
2248 | # Check for various typo / spelling mistakes | 2252 | # Check for various typo / spelling mistakes |
2249 | if ($in_commit_log || $line =~ /^\+/) { | 2253 | if (defined($misspellings) && ($in_commit_log || $line =~ /^\+/)) { |
2250 | while ($rawline =~ /(?:^|[^a-z@])($misspellings)(?:$|[^a-z@])/gi) { | 2254 | while ($rawline =~ /(?:^|[^a-z@])($misspellings)(?:$|[^a-z@])/gi) { |
2251 | my $typo = $1; | 2255 | my $typo = $1; |
2252 | my $typo_fix = $spelling_fix{lc($typo)}; | 2256 | my $typo_fix = $spelling_fix{lc($typo)}; |