From: Matthew Wilcox <willy@infradead.org>
To: Jonathan Corbet <corbet@lwn.net>
Cc: Aditya Srivastava <yashsri421@gmail.com>,
lukas.bulwahn@gmail.com,
linux-kernel-mentees@lists.linuxfoundation.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC v2] scripts: kernel-doc: reduce repeated regex expressions into variables
Date: Tue, 27 Apr 2021 17:56:33 +0100 [thread overview]
Message-ID: <20210427165633.GA235567@casper.infradead.org> (raw)
In-Reply-To: <87wnsnd8nc.fsf@meer.lwn.net>
On Tue, Apr 27, 2021 at 09:55:35AM -0600, Jonathan Corbet wrote:
> The use of the variables here doesn't really make those expressions more
> readable.
>
> > $members =~ s/\s*CRYPTO_MINALIGN_ATTR/ /gos;
> > - $members =~ s/\s*____cacheline_aligned_in_smp/ /gos;
> > - $members =~ s/\s*____cacheline_aligned/ /gos;
> > + $members =~ s/\s*$cacheline_aligned_in_smp/ /gos;
> > + $members =~ s/\s*$cacheline_aligned/ /gos;
> >
> > + my $args = qr{([^,)]+)};
> > # replace DECLARE_BITMAP
> > $members =~ s/__ETHTOOL_DECLARE_LINK_MODE_MASK\s*\(([^\)]+)\)/DECLARE_BITMAP($1, __ETHTOOL_LINK_MODE_MASK_NBITS)/gos;
> > - $members =~ s/DECLARE_BITMAP\s*\(([^,)]+),\s*([^,)]+)\)/unsigned long $1\[BITS_TO_LONGS($2)\]/gos;
> > + $members =~ s/DECLARE_BITMAP\s*\($args,\s*$args\)/unsigned long $1\[BITS_TO_LONGS($2)\]/gos;
>
> Here too ... this is the kind of stuff that makes me glad that Colorado
> is a legal-weed state, and the new version, while better, doesn't change
> that basic fact.
I'm going to have to disagree with you on this one (I agree with you on all
the others). I find this much easier to read ...
"DECLARE_BITMAP followed by any amount of whitespace, literal open bracket,
an argument, literal comma, whitespace, another argument, literal close bracket"
Before, I get to "DECLARE_BITMAP followed by any amount of whitespace,
then some line noise".
Obviously I'm less experienced at reading regexes than you are, but this
simplification really does help me.
> I think I'll stop here; hopefully I've gotten my point across. I really
> like where this work is heading; focusing just a bit more on pulling the
> regexes together and making the whole thing more readable would be
> wonderful.
Amen.
next prev parent reply other threads:[~2021-04-27 16:57 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 [this message]
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 ` [RFC v3] " Matthew Wilcox
2021-05-14 16:17 ` 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=20210427165633.GA235567@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).