Skip to content

Commit d4faa2f

Browse files
Antonio Borneothom24
Antonio Borneo
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. Change-Id: I8dcd93979cd1c39186c750e588038f4a1e374bf1 Signed-off-by: Antonio Borneo <[email protected]> Reported-by: Clément Le Goffic <[email protected]> Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/linux-stm32/+/372873 Tested-by: Clement LE GOFFIC <[email protected]> ACI: CIBUILD <[email protected]> Reviewed-by: Clement LE GOFFIC <[email protected]> Domain-Review: Amelie DELAUNAY <[email protected]>
1 parent da470c3 commit d4faa2f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: scripts/checkpatch.pl

+3-2
Original file line numberDiff line numberDiff line change
@@ -3490,9 +3490,10 @@ sub process {
34903490
# Check for various typo / spelling mistakes
34913491
if (defined($misspellings) &&
34923492
($in_commit_log || $line =~ /^(?:\+|Subject:)/i)) {
3493-
while ($rawline =~ /(?:^|[^\w\-'`])($misspellings)(?:[^\w\-'`]|$)/gi) {
3493+
my $rawline_utf8 = decode("utf8", $rawline);
3494+
while ($rawline_utf8 =~ /(?:^|[^\w\-'`])($misspellings)(?:[^\w\-'`]|$)/gi) {
34943495
my $typo = $1;
3495-
my $blank = copy_spacing($rawline);
3496+
my $blank = copy_spacing($rawline_utf8);
34963497
my $ptr = substr($blank, 0, $-[1]) . "^" x length($typo);
34973498
my $hereptr = "$hereline$ptr\n";
34983499
my $typo_fix = $spelling_fix{lc($typo)};

0 commit comments

Comments
 (0)