From: Matthew Wilcox <willy@infradead.org>
To: Aditya Srivastava <yashsri421@gmail.com>
Cc: corbet@lwn.net, lukas.bulwahn@gmail.com,
linux-kernel-mentees@lists.linuxfoundation.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC v3] scripts: kernel-doc: reduce repeated regex expressions into variables
Date: Sat, 1 May 2021 16:43:36 +0100 [thread overview]
Message-ID: <20210501154336.GS1847222@casper.infradead.org> (raw)
In-Reply-To: <20210429063729.8144-1-yashsri421@gmail.com>
On Thu, Apr 29, 2021 at 12:07:29PM +0530, Aditya Srivastava wrote:
> + my $name = qr{[a-zA-Z0-9_~:]+};
> + my $prototype_end1 = qr{[^\(]*};
> + my $prototype_end2 = qr{[^\{]*};
> + my $prototype_end = qr{\(($prototype_end1|$prototype_end2)\)};
Would this be better written as:
my $prototype_end = qr{\([^\(\{]*\)}
And now that I look at the whole thing, doesn't this fail to parse
a function declared as:
int f(void (*g)(long));
(that is, f takes a single argument, which is a pointer to a function
which takes a long argument and returns void)
Still, I don't think this was parsed correctly before, so it's not an
argument against this patch, just something to take care of later.
> + my $type1 = qr{[\w\s]+};
> + my $type2 = qr{$type1\*+};
> +
> + if ($define && $prototype =~ m/^()($name)\s+/) {
> # This is an object-like macro, it has no return type and no parameter
> # list.
> # Function-like macros are not allowed to have spaces between
> @@ -1817,23 +1828,9 @@ sub dump_function($$) {
> $return_type = $1;
> $declaration_name = $2;
> $noret = 1;
> - } elsif ($prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
> - $prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
> - $prototype =~ m/^(\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
> - $prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
> - $prototype =~ m/^(\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
> - $prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
> - $prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
> - $prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
> - $prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
> - $prototype =~ m/^(\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
> - $prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
> - $prototype =~ m/^(\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
> - $prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
> - $prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
> - $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
> - $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
> - $prototype =~ m/^(\w+\s+\w+\s*\*+\s*\w+\s*\*+\s*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/) {
> + } elsif ($prototype =~ m/^()($name)\s*$prototype_end/ ||
> + $prototype =~ m/^($type1)\s+($name)\s*$prototype_end/ ||
> + $prototype =~ m/^($type2)+\s*($name)\s*$prototype_end/) {
> $return_type = $1;
> $declaration_name = $2;
> my $args = $3;
next prev parent reply other threads:[~2021-05-01 15:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-22 19:18 [RFC] scripts: kernel-doc: reduce repeated regex expressions into variables Aditya Srivastava
[not found] ` <CAKXUXMx9q57cWXkcezKKo-uuh21Sd-Si9M9KydzFEMQ0ELYEng@mail.gmail.com>
2021-04-23 12:20 ` Aditya Srivastava
2021-04-23 13:21 ` Matthew Wilcox
2021-04-24 11:57 ` Aditya Srivastava
2021-04-24 12:47 ` [RFC v2] " Aditya Srivastava
2021-04-27 15:55 ` Jonathan Corbet
2021-04-27 16:56 ` Matthew Wilcox
2021-04-29 6:37 ` [RFC v3] " Aditya Srivastava
2021-04-29 23:39 ` Jonathan Corbet
2021-04-30 2:03 ` Joe Perches
2021-05-01 9:30 ` Aditya Srivastava
2021-05-01 15:03 ` Jonathan Corbet
2021-05-14 14:42 ` [RFC v4] " Aditya Srivastava
2021-05-14 15:10 ` Aditya Srivastava
2021-05-17 17:49 ` Jonathan Corbet
2021-05-01 15:43 ` Matthew Wilcox [this message]
2021-05-14 16:17 ` [RFC v3] " Aditya Srivastava
2021-04-26 17:31 ` [RFC] " Matthew Wilcox
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=20210501154336.GS1847222@casper.infradead.org \
--to=willy@infradead.org \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas.bulwahn@gmail.com \
--cc=yashsri421@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;
as well as URLs for NNTP newsgroup(s).