Skip to content

Commit bb827bd

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'? #36: FILE: MAINTAINERS:14360: +M: Clément Léger <clement.leger@bootlin.com> ^^^^ Use a utf-8 version of $rawline for spell checking. Link: https://lkml.kernel.org/r/20250616-b4-checkpatch-upstream-v2-1-5600ce4a3b43@foss.st.com Signed-off-by: Antonio Borneo <antonio.borneo@foss.st.com> Signed-off-by: Clément Le Goffic <clement.legoffic@foss.st.com> Cc: Andy Whitcroft <apw@canonical.com> Cc: Dwaipayan Ray <dwaipayanray1@gmail.com> Cc: Joe Perches <joe@perches.com> Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent b74e523 commit bb827bd

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)