]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
checkpatch: use utf-8 match for spell checking
authorAntonio Borneo <antonio.borneo@foss.st.com>
Mon, 16 Jun 2025 07:59:13 +0000 (09:59 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 10 Jul 2025 05:57:53 +0000 (22:57 -0700)
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 81c2f059ab9
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>
scripts/checkpatch.pl

index 664f7b7a622c2d1292069f34ec3fde14545117c9..489b74d52abe7c1c7b6a8236f6fa1f35336b7582 100755 (executable)
@@ -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)};