Skip to content

Commit 5eee4c2

Browse files
AntonioBorneoakpm00
authored andcommitted
checkpatch: use utf-8 match for spell checking
The current code that checks for misspelling verifies, in a more complex regex, if $rawline matches [^\w]($misspellings)[^\w] Being $rawline a byte-string, a utf-8 character in $rawline can match the non-word-char [^\w]. E.g.: ./scripts/checkpatch.pl --git 81c2f05 WARNING: 'ment' may be misspelled - perhaps 'meant'? torvalds#36: FILE: MAINTAINERS:14360: +M: Clément Léger <[email protected]> ^^^^ Use a utf-8 version of $rawline for spell checking. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Antonio Borneo <[email protected]> Signed-off-by: Clément Le Goffic <[email protected]> Cc: Andy Whitcroft <[email protected]> Cc: Dwaipayan Ray <[email protected]> Cc: Joe Perches <[email protected]> Cc: Lukas Bulwahn <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent e795000 commit 5eee4c2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

scripts/checkpatch.pl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3502,9 +3502,10 @@ sub process {
35023502
# Check for various typo / spelling mistakes
35033503
if (defined($misspellings) &&
35043504
($in_commit_log || $line =~ /^(?:\+|Subject:)/i)) {
3505-
while ($rawline =~ /(?:^|[^\w\-'`])($misspellings)(?:[^\w\-'`]|$)/gi) {
3505+
my $rawline_utf8 = decode("utf8", $rawline);
3506+
while ($rawline_utf8 =~ /(?:^|[^\w\-'`])($misspellings)(?:[^\w\-'`]|$)/gi) {
35063507
my $typo = $1;
3507-
my $blank = copy_spacing($rawline);
3508+
my $blank = copy_spacing($rawline_utf8);
35083509
my $ptr = substr($blank, 0, $-[1]) . "^" x length($typo);
35093510
my $hereptr = "$hereline$ptr\n";
35103511
my $typo_fix = $spelling_fix{lc($typo)};

0 commit comments

Comments
 (0)