From patchwork Wed Feb 14 18:40:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Corbet X-Patchwork-Id: 128381 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp912721ljc; Wed, 14 Feb 2018 10:42:03 -0800 (PST) X-Google-Smtp-Source: AH8x227RvKonP/6YAfdJ6uB+EROnuDjUTqfozS6FyRxxnDjnX9AcqCRqUTJq3a3oQPqDh3KL3lht X-Received: by 10.98.12.1 with SMTP id u1mr24933pfi.192.1518633723581; Wed, 14 Feb 2018 10:42:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518633723; cv=none; d=google.com; s=arc-20160816; b=TN4HmB4OyxQnG7x3yr+E71qGaMCBIoNhyw8K1FIysPDs2WD6Ev4HpQt6ho+CjILKbt PYistlAoPwJILZG5sdk3H3w242gRxvLmTDdB0AZ93WDoKb0T1mhRuJy8huFJ93kl2+hO c2bamCFw0b/F9m3klTe+lY7GQcn22umkaZw4cC3j92aSEfYFVHPu3n2CYXYQEM5um9Kh lRnVFyEvuRwOKn03TrxGautuTfvnhjXboB8cFRVeJXOvH1ZnMDqR7WDh4rAHWLtzouu7 fRuRzeBlwDmqNCQUJWJUfxdWqO6LeBYMAtKGiZq5SSWThILH4xlcjuImfWUhlAfiif/I 8//w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=8l6tvX91MiZtlPQCAAZS+eP6nFXt0uJq33A/7NlUdzY=; b=lIxVKrqEN6yDOlqkvNWtBfyIobBTxoGBifGcvuLIS+XDAFXv5yxKSrnmLMXqUY/PF6 hi0scFpsoDF6S8eL/7qlyCAoRrIIDmxz9joPYE5ch10B/KojDn/7m+5XjpoYwZF/mKYu f/IaiL84YYyGRcGUONIEdzojOerbJpaUzS3wDYnBO5hfj9PlPSMi7/FaIGDx9YQqe3Qx GNCiaehDdzNsE1bhIDC4azBAap8Et+EHVzQxeMnI/1JE1xuniLzgWFqYev4xAYfkQm7Q ArpkGuRyocFhtuufa+J+hiEsVgvkgLAA6OiMAp/9DRBn45BpqJRUT+ca3b4/Y4o48jFf nwdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b89-v6si1562182plb.809.2018.02.14.10.42.03; Wed, 14 Feb 2018 10:42:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162220AbeBNSkc (ORCPT + 28 others); Wed, 14 Feb 2018 13:40:32 -0500 Received: from ms.lwn.net ([45.79.88.28]:54656 "EHLO ms.lwn.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162189AbeBNSka (ORCPT ); Wed, 14 Feb 2018 13:40:30 -0500 Received: from tpad.lan (localhost [127.0.0.1]) by ms.lwn.net (Postfix) with ESMTPA id 9679930A; Wed, 14 Feb 2018 18:40:29 +0000 (UTC) From: Jonathan Corbet To: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, mchehab@kernel.org, me@tobin.cc, jani.nikula@linux.intel.com, Jonathan Corbet Subject: [PATCH 2/8] docs: kernel-doc: Rename and split STATE_FIELD Date: Wed, 14 Feb 2018 11:40:03 -0700 Message-Id: <20180214184009.12657-3-corbet@lwn.net> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180214184009.12657-1-corbet@lwn.net> References: <20180214184009.12657-1-corbet@lwn.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Reviewed-by: Jani Nikula Signed-off-by: Jonathan Corbet --- scripts/kernel-doc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) -- 2.14.3 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;