mirror of
https://github.com/torvalds/linux.git
synced 2026-01-24 23:16:46 +00:00
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 81c2f059ab
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>
This commit is contained in:
committed by
Andrew Morton
parent
e795000e75
commit
5eee4c2b2a
@@ -3502,9 +3502,10 @@ sub process {
|
||||
# Check for various typo / spelling mistakes
|
||||
if (defined($misspellings) &&
|
||||
($in_commit_log || $line =~ /^(?:\+|Subject:)/i)) {
|
||||
while ($rawline =~ /(?:^|[^\w\-'`])($misspellings)(?:[^\w\-'`]|$)/gi) {
|
||||
my $rawline_utf8 = decode("utf8", $rawline);
|
||||
while ($rawline_utf8 =~ /(?:^|[^\w\-'`])($misspellings)(?:[^\w\-'`]|$)/gi) {
|
||||
my $typo = $1;
|
||||
my $blank = copy_spacing($rawline);
|
||||
my $blank = copy_spacing($rawline_utf8);
|
||||
my $ptr = substr($blank, 0, $-[1]) . "^" x length($typo);
|
||||
my $hereptr = "$hereline$ptr\n";
|
||||
my $typo_fix = $spelling_fix{lc($typo)};
|
||||
|
||||
Reference in New Issue
Block a user