From: Joe Perches <joe@perches.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Whitcroft <apw@canonical.com>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] scripts/checkpatch.pl: Dramatically improve #define parse times
Date: Mon, 08 Feb 2010 17:42:55 -0800 [thread overview]
Message-ID: <1265679775.2135.74.camel@Joe-Laptop.home> (raw)
In-Reply-To: <20100208151550.15796cad.akpm@linux-foundation.org>
On Mon, 2010-02-08 at 15:15 -0800, Andrew Morton wrote:
> This patch triggers lots of warnings:
Yeah, I've played with it a bit more but Andy Whitcroft
is better able to do something about this.
This is what I've come up with, which doesn't fail your
example and gives the same output as current on a bunch
of collected patches, but it only handles:
#define foo bar
not
#define foo (bar)
#define foo (bar * n)
Andy?
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 3257d3d..940fe82 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -378,13 +378,13 @@ sub sanitise_line {
if ($sanitise_quote eq '' && substr($line, $off, 2) eq '/*') {
$sanitise_quote = '*/';
- substr($res, $off, 2, "$;$;");
+ substr($res, $off, 2, " ");
$off++;
next;
}
if ($sanitise_quote eq '*/' && substr($line, $off, 2) eq '*/') {
$sanitise_quote = '';
- substr($res, $off, 2, "$;$;");
+ substr($res, $off, 2, " ");
$off++;
next;
}
@@ -417,9 +417,9 @@ sub sanitise_line {
#print "c<$c> SQ<$sanitise_quote>\n";
if ($off != 0 && $sanitise_quote eq '*/' && $c ne "\t") {
- substr($res, $off, 1, $;);
+ substr($res, $off, 1, ' ');
} elsif ($off != 0 && $sanitise_quote eq '//' && $c ne "\t") {
- substr($res, $off, 1, $;);
+ substr($res, $off, 1, ' ');
} elsif ($off != 0 && $sanitise_quote && $c ne "\t") {
substr($res, $off, 1, 'X');
} else {
@@ -507,6 +507,12 @@ sub ctx_statement_block {
last;
}
+ # single line "#define foo" and "#define foo bar" at level 0 are complete
+ if ($level == 0 &&
+ ($remainder =~ /^\s*#\s*define\s+\w+\s*$/ || $remainder =~ /^\s*#\s*define\s+\w+\s+\w+\s*$/)) {
+ last;
+ }
+
# An else is really a conditional as long as its not else if
if ($level == 0 && $coff_set == 0 &&
(!defined($p) || $p =~ /(?:\s|\}|\+)/) &&
@@ -2352,7 +2358,9 @@ sub process {
^\"|\"$
}x;
#print "REST<$rest> dstat<$dstat>\n";
- if ($rest ne '') {
+ if ($rest =~ /^\s*define\s+\w+\s*$/ || $rest =~ /^\s*define\s+\w+\s+\w+\s*$/) {
+ ;
+ } elsif ($rest ne '') {
if ($rest !~ /while\s*\(/ &&
$dstat !~ /$exceptions/)
{
prev parent reply other threads:[~2010-02-09 1:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-03 3:18 [PATCH] scripts/checkpatch.pl: Dramatically improve #define parse times Joe Perches
2010-02-08 23:15 ` Andrew Morton
2010-02-09 1:42 ` 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=1265679775.2135.74.camel@Joe-Laptop.home \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=apw@canonical.com \
--cc=linux-kernel@vger.kernel.org \
/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