History

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 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.

Antonio Borneo committed 1 year ago

Commit 5eee4c21 parent e7950001 file · +3 −2Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/checkpatch.pl+3−2
@@ -3502,9 +3502,10 @@ sub process { · 3501 unmodified lines
3502# Check for various typo / spelling mistakes3502# Check for various typo / spelling mistakes
3503 if (defined($misspellings) &&3503 if (defined($misspellings) &&
3504 ($in_commit_log || $line =~ /^(?:\+|Subject:)/i)) {3504 ($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) {
3506 my $typo = $1;3507 my $typo = $1;
3507 my $blank = copy_spacing($rawline);3508 my $blank = copy_spacing($rawline_utf8);
3508 my $ptr = substr($blank, 0, $-[1]) . "^" x length($typo);3509 my $ptr = substr($blank, 0, $-[1]) . "^" x length($typo);
3509 my $hereptr = "$hereline$ptr\n";3510 my $hereptr = "$hereline$ptr\n";
3510 my $typo_fix = $spelling_fix{lc($typo)};3511 my $typo_fix = $spelling_fix{lc($typo)};