checkpatch: fix use via symlink, make missing spelling file non-fatal
Commit 66b47b4a9d
("checkpatch: look for common misspellings") made it
difficult to use checkpatch via a symlink.
Fix that and make a missing spelling.txt file non-fatal. Emit a warning
when the spelling.txt file can not be opened.
Reference: http://xkcd.com/1172/
Signed-off-by: Joe Perches <joe@perches.com>
Reported-by: Jani Nikula <jani.nikula@intel.com>
Tested-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Acked-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
15160f90b8
commit
36061e3806
@@ -7,10 +7,11 @@
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use POSIX;
|
use POSIX;
|
||||||
|
use File::Basename;
|
||||||
|
use Cwd 'abs_path';
|
||||||
|
|
||||||
my $P = $0;
|
my $P = $0;
|
||||||
$P =~ s@(.*)/@@g;
|
my $D = dirname(abs_path($P));
|
||||||
my $D = $1;
|
|
||||||
|
|
||||||
my $V = '0.32';
|
my $V = '0.32';
|
||||||
|
|
||||||
@@ -438,10 +439,10 @@ our $allowed_asm_includes = qr{(?x:
|
|||||||
|
|
||||||
# Load common spelling mistakes and build regular expression list.
|
# Load common spelling mistakes and build regular expression list.
|
||||||
my $misspellings;
|
my $misspellings;
|
||||||
my @spelling_list;
|
|
||||||
my %spelling_fix;
|
my %spelling_fix;
|
||||||
open(my $spelling, '<', $spelling_file)
|
|
||||||
or die "$P: Can't open $spelling_file for reading: $!\n";
|
if (open(my $spelling, '<', $spelling_file)) {
|
||||||
|
my @spelling_list;
|
||||||
while (<$spelling>) {
|
while (<$spelling>) {
|
||||||
my $line = $_;
|
my $line = $_;
|
||||||
|
|
||||||
@@ -458,6 +459,9 @@ while (<$spelling>) {
|
|||||||
}
|
}
|
||||||
close($spelling);
|
close($spelling);
|
||||||
$misspellings = join("|", @spelling_list);
|
$misspellings = join("|", @spelling_list);
|
||||||
|
} else {
|
||||||
|
warn "No typos will be found - file '$spelling_file': $!\n";
|
||||||
|
}
|
||||||
|
|
||||||
sub build_types {
|
sub build_types {
|
||||||
my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)";
|
my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)";
|
||||||
@@ -2246,7 +2250,7 @@ sub process {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Check for various typo / spelling mistakes
|
# 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) {
|
while ($rawline =~ /(?:^|[^a-z@])($misspellings)(?:$|[^a-z@])/gi) {
|
||||||
my $typo = $1;
|
my $typo = $1;
|
||||||
my $typo_fix = $spelling_fix{lc($typo)};
|
my $typo_fix = $spelling_fix{lc($typo)};
|
||||||
|
Reference in New Issue
Block a user