From: Antonio Borneo <antonio.borneo@foss.st.com>
To: Joe Perches <joe@perches.com>, Andy Whitcroft <apw@canonical.com>,
Dwaipayan Ray <dwaipayanray1@gmail.com>,
Lukas Bulwahn <lukas.bulwahn@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org,
"Clément Léger" <clement.leger@bootlin.com>,
"Clément Le Goffic" <clement.legoffic@foss.st.com>,
linux-stm32@st-md-mailman.stormreply.com
Subject: Re: [PATCH] checkpatch: use utf-8 match for spell checking
Date: Tue, 2 Jan 2024 17:04:11 +0100 [thread overview]
Message-ID: <ee4d31698bc8dfdc6e89045dff57f3e3164b33f7.camel@foss.st.com> (raw)
In-Reply-To: <74126e6e301d2f4a0e5a546caa54961dbc2d492c.camel@perches.com>
On Tue, 2023-12-12 at 11:07 -0800, Joe Perches wrote:
> On Tue, 2023-12-12 at 10:43 +0100, Antonio Borneo wrote:
> > 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.:
> > ./script/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.
> >
> > Signed-off-by: Antonio Borneo <antonio.borneo@foss.st.com>
> > Reported-by: Clément Le Goffic <clement.legoffic@foss.st.com>
>
> Seems sensible, thanks, but:
>
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
> > @@ -3477,7 +3477,8 @@ 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);
>
> Maybe this needs to use $rawline_utf8 ?
Correct, I will send a v2!
>
> > my $ptr = substr($blank, 0, $-[1]) . "^" x length($typo);
>
> And may now the $fix bit will not always work properly
I have run some test and it looks ok with current ASCII file scripts/spelling.txt.
I have also tested adding some utf-8 string in the spelling file, but checkpatch reads it as
ASCII and extending it to utf-8 will require further modifications in checkpatch, way beyond
this simple fix.
Thanks for the review.
Antonio
next prev parent reply other threads:[~2024-01-02 16:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-12 9:43 Antonio Borneo
2023-12-12 19:07 ` Joe Perches
2024-01-02 16:04 ` Antonio Borneo [this message]
2024-01-02 16:10 ` [PATCH v2] " Antonio Borneo
2024-05-06 12:07 ` Clement LE GOFFIC
2025-05-20 13:14 ` Clement LE GOFFIC
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ee4d31698bc8dfdc6e89045dff57f3e3164b33f7.camel@foss.st.com \
--to=antonio.borneo@foss.st.com \
--cc=akpm@linux-foundation.org \
--cc=apw@canonical.com \
--cc=clement.leger@bootlin.com \
--cc=clement.legoffic@foss.st.com \
--cc=dwaipayanray1@gmail.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=lukas.bulwahn@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®