aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl38
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
8use strict; 8use strict;
9use POSIX; 9use POSIX;
10use File::Basename;
11use Cwd 'abs_path';
10 12
11my $P = $0; 13my $P = $0;
12$P =~ s@(.*)/@@g; 14my $D = dirname(abs_path($P));
13my $D = $1;
14 15
15my $V = '0.32'; 16my $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.
440my $misspellings; 441my $misspellings;
441my @spelling_list;
442my %spelling_fix; 442my %spelling_fix;
443open(my $spelling, '<', $spelling_file)
444 or die "$P: Can't open $spelling_file for reading: $!\n";
445while (<$spelling>) {
446 my $line = $_;
447 443
448 $line =~ s/\s*\n?$//g; 444if (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}
459close($spelling);
460$misspellings = join("|", @spelling_list);
461 465
462sub build_types { 466sub 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)};