From: Joe Perches <joe@perches.com>
To: Dwaipayan Ray <dwaipayanray1@gmail.com>
Cc: linux-kernel-mentees@lists.linuxfoundation.org,
linux-kernel <linux-kernel@vger.kernel.org>,
Lukas Bulwahn <lukas.bulwahn@gmail.com>
Subject: Re: [PATCH v3] checkpatch: add new exception to repeated word check
Date: Sat, 17 Oct 2020 00:28:25 -0700 [thread overview]
Message-ID: <c2f40543564323a5dc3b632df8f1770d61b86633.camel@perches.com> (raw)
In-Reply-To: <CABJPP5CBh2TDwo9Z1hoaLPjk=d00N0r4VkLVdwAuMbWPyNbDYA@mail.gmail.com>
On Sat, 2020-10-17 at 11:32 +0530, Dwaipayan Ray wrote:
> > Why include a + character here?
> >
> Hi,
> I tried it without + first, but then lines like
> "The the repeated word."
> didn't register a warning.
>
> I think checkpatch adds a + to the line when used on
> files. Am not sure but my $rawline was:
> +The the repeated word.
The + is the first character of an added line in a
patch.
That's different from lines in a commit message so
there needs to be an additional mechanism to strip
the leading + when not !$in_commit_log.
Add:
pos($rawline) = 1 if (!$in_commit_log);
and test the start position too
---
scripts/checkpatch.pl | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index fab38b493cef..99563b3d5a3e 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3050,19 +3050,28 @@ sub process {
# check for repeated words separated by a single space
if ($rawline =~ /^\+/ || $in_commit_log) {
+ pos($rawline) = 1 if (!$in_commit_log);
while ($rawline =~ /\b($word_pattern) (?=($word_pattern))/g) {
-
my $first = $1;
my $second = $2;
+ my $start_pos = $-[1];
+ my $end_pos = $+[2];
if ($first =~ /(?:struct|union|enum)/) {
pos($rawline) += length($first) + length($second) + 1;
next;
}
- next if ($first ne $second);
+ next if (lc($first) ne lc($second));
next if ($first eq 'long');
+ my $start_char = "";
+ my $end_char = "";
+ $start_char = substr($rawline, $start_pos - 1, 1) if ($start_pos > ($in_commit_log ? 0 : 1));
+ $end_char = substr($rawline, $end_pos, 1) if (length($rawline) > $end_pos);
+ next if ($start_char =~ /^\S$/);
+ next if ($end_char !~ /^[\.\,\s]?$/);
+
if (WARN("REPEATED_WORD",
"Possible repeated word: '$first'\n" . $herecurr) &&
$fix) {
prev parent reply other threads:[~2020-10-17 7:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-17 5:22 Dwaipayan Ray
2020-10-17 5:41 ` Joe Perches
2020-10-17 6:02 ` Dwaipayan Ray
2020-10-17 7:28 ` Joe Perches [this message]
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=c2f40543564323a5dc3b632df8f1770d61b86633.camel@perches.com \
--to=joe@perches.com \
--cc=dwaipayanray1@gmail.com \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--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®