From: Jani Nikula <jani.nikula@linux.intel.com>
To: Jonathan Corbet <corbet@lwn.net>, linux-doc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, mchehab@kernel.org, me@tobin.cc,
Jonathan Corbet <corbet@lwn.net>
Subject: Re: [PATCH 2/8] docs: kernel-doc: Rename and split STATE_FIELD
Date: Fri, 09 Feb 2018 11:20:41 +0200 [thread overview]
Message-ID: <87fu6aa592.fsf@intel.com> (raw)
In-Reply-To: <20180207172624.24555-3-corbet@lwn.net>
On Wed, 07 Feb 2018, Jonathan Corbet <corbet@lwn.net> wrote:
> STATE_FIELD describes a parser state that can handle any part of a
> kerneldoc comment body; rename it to STATE_BODY to reflect that.
>
> The $in_purpose variable was a hidden substate of STATE_FIELD; get rid of
> it and make a proper state (STATE_BODY_MAYBE) instead. This will make the
> subsequent process_file() splitup easier.
>
> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
I really wanted to avoid leaving behind any evidence that I've ever
reviewed perl, but my sympathy for you updating the script won. But just
barely.
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> ---
> scripts/kernel-doc | 22 +++++++++++-----------
> 1 file changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/scripts/kernel-doc b/scripts/kernel-doc
> index 5aa4ce211fc6..ad30c52f91ef 100755
> --- a/scripts/kernel-doc
> +++ b/scripts/kernel-doc
> @@ -328,10 +328,11 @@ my $lineprefix="";
> use constant {
> STATE_NORMAL => 0, # normal code
> STATE_NAME => 1, # looking for function name
> - STATE_FIELD => 2, # scanning field start
> - STATE_PROTO => 3, # scanning prototype
> - STATE_DOCBLOCK => 4, # documentation block
> - STATE_INLINE => 5, # gathering documentation outside main block
> + STATE_BODY_MAYBE => 2, # body - or maybe more description
> + STATE_BODY => 3, # the body of the comment
> + STATE_PROTO => 4, # scanning prototype
> + STATE_DOCBLOCK => 5, # documentation block
> + STATE_INLINE => 6, # gathering documentation outside main block
> };
> my $state;
> my $in_doc_sect;
> @@ -1784,7 +1785,6 @@ sub process_file($) {
> my $identifier;
> my $func;
> my $descr;
> - my $in_purpose = 0;
> my $initial_section_counter = $section_counter;
> my ($orig_file) = @_;
> my $leading_space;
> @@ -1830,7 +1830,7 @@ sub process_file($) {
> $identifier = $1;
> }
>
> - $state = STATE_FIELD;
> + $state = STATE_BODY;
> # if there's no @param blocks need to set up default section
> # here
> $contents = "";
> @@ -1843,7 +1843,7 @@ sub process_file($) {
> $descr =~ s/\s*$//;
> $descr =~ s/\s+/ /g;
> $declaration_purpose = $descr;
> - $in_purpose = 1;
> + $state = STATE_BODY_MAYBE;
> } else {
> $declaration_purpose = "";
> }
> @@ -1875,7 +1875,7 @@ sub process_file($) {
> ++$warnings;
> $state = STATE_NORMAL;
> }
> - } elsif ($state == STATE_FIELD) { # look for head: lines, and include content
> + } elsif ($state == STATE_BODY || $state == STATE_BODY_MAYBE) {
> if (/$doc_sect/i) { # case insensitive for supported section names
> $newsection = $1;
> $newcontents = $2;
> @@ -1902,7 +1902,7 @@ sub process_file($) {
> }
>
> $in_doc_sect = 1;
> - $in_purpose = 0;
> + $state = STATE_BODY;
> $contents = $newcontents;
> $new_start_line = $.;
> while (substr($contents, 0, 1) eq " ") {
> @@ -1941,8 +1941,8 @@ sub process_file($) {
> } else {
> $contents .= "\n";
> }
> - $in_purpose = 0;
> - } elsif ($in_purpose == 1) {
> + $state = STATE_BODY;
> + } elsif ($state == STATE_BODY_MAYBE) {
> # Continued declaration purpose
> chomp($declaration_purpose);
> $declaration_purpose .= " " . $1;
--
Jani Nikula, Intel Open Source Technology Center
next prev parent reply other threads:[~2018-02-09 9:20 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-07 17:26 [PATCH 0/8] Clean up kernel-doc and fix literal-block handling Jonathan Corbet
2018-02-07 17:26 ` [PATCH 1/8] docs: kernel-doc: Get rid of xml_escape() and friends Jonathan Corbet
2018-02-09 9:09 ` Jani Nikula
2018-02-09 13:32 ` Jonathan Corbet
2018-02-07 17:26 ` [PATCH 2/8] docs: kernel-doc: Rename and split STATE_FIELD Jonathan Corbet
2018-02-09 9:20 ` Jani Nikula [this message]
2018-02-07 17:26 ` [PATCH 3/8] docs: kernel-doc: Move STATE_NORMAL processing into its own function Jonathan Corbet
2018-02-09 9:23 ` Jani Nikula
2018-02-07 17:26 ` [PATCH 4/8] docs: kernel-doc: Move STATE_NAME " Jonathan Corbet
2018-02-09 9:27 ` Jani Nikula
2018-02-07 17:26 ` [PATCH 5/8] docs: kernel-doc: Move STATE_BODY processing to a separate function Jonathan Corbet
2018-02-09 9:32 ` Jani Nikula
2018-02-09 17:30 ` Linus Torvalds
2018-02-13 10:01 ` Jani Nikula
2018-02-07 17:26 ` [PATCH 6/8] docs: kernel-doc: Move STATE_PROTO processing into its own function Jonathan Corbet
2018-02-09 9:33 ` Jani Nikula
2018-02-07 17:26 ` [PATCH 7/8] docs: kernel-doc: Finish moving STATE_* code out of process_file() Jonathan Corbet
2018-02-08 2:29 ` Tobin C. Harding
2018-02-08 19:58 ` Jonathan Corbet
2018-02-09 9:36 ` Jani Nikula
2018-02-07 17:26 ` [PATCH 8/8] docs: kernel-doc: Don't mangle literal code blocks in comments Jonathan Corbet
2018-02-08 2:30 ` Tobin C. Harding
2018-02-09 9:47 ` Jani Nikula
2018-02-14 16:53 ` Markus Heiser
2018-02-08 2:26 ` [PATCH 0/8] Clean up kernel-doc and fix literal-block handling Tobin C. Harding
-- strict thread matches above, loose matches on Subject: below --
2018-02-14 18:40 [PATCH v2 0/8] docs: Cleanup kernel-doc and fix literal block handling Jonathan Corbet
2018-02-14 18:40 ` [PATCH 2/8] docs: kernel-doc: Rename and split STATE_FIELD Jonathan Corbet
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=87fu6aa592.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=me@tobin.cc \
/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).