From: Jani Nikula <jani.nikula@intel.com>
To: Jonathan Corbet <corbet@lwn.net>,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org
Cc: jani.nikula@intel.com
Subject: [PATCH 6/9] docproc: abstract docproc directive detection
Date: Thu, 12 May 2016 16:15:41 +0300 [thread overview]
Message-ID: <4906036e861ca3ce3ff290e303abc8acdf5a6f1a.1463058396.git.jani.nikula@intel.com> (raw)
In-Reply-To: <cover.1463058396.git.jani.nikula@intel.com>
In-Reply-To: <cover.1463058396.git.jani.nikula@intel.com>
Helps follow-up work. No functional changes.
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
scripts/docproc.c | 30 ++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/scripts/docproc.c b/scripts/docproc.c
index fb195f0ed0ef..bc900310b431 100644
--- a/scripts/docproc.c
+++ b/scripts/docproc.c
@@ -430,6 +430,15 @@ static void find_all_symbols(char *filename)
}
}
+/* Return pointer to directive content, or NULL if not a directive. */
+static char *is_directive(char *line)
+{
+ if (line[0] == '!')
+ return line + 1;
+
+ return NULL;
+}
+
/*
* Parse file, calling action specific functions for:
* 1) Lines containing !E
@@ -443,29 +452,30 @@ static void find_all_symbols(char *filename)
static void parse_file(FILE *infile)
{
char line[MAXLINESZ];
- char * s;
+ char *p, *s;
while (fgets(line, MAXLINESZ, infile)) {
- if (line[0] != '!') {
+ p = is_directive(line);
+ if (!p) {
defaultline(line);
continue;
}
- s = line + 2;
- switch (line[1]) {
+ s = p + 1;
+ switch (*p++) {
case 'E':
while (*s && !isspace(*s)) s++;
*s = '\0';
- externalfunctions(line+2);
+ externalfunctions(p);
break;
case 'I':
while (*s && !isspace(*s)) s++;
*s = '\0';
- internalfunctions(line+2);
+ internalfunctions(p);
break;
case 'D':
while (*s && !isspace(*s)) s++;
*s = '\0';
- symbolsonly(line+2);
+ symbolsonly(p);
break;
case 'F':
/* filename */
@@ -474,7 +484,7 @@ static void parse_file(FILE *infile)
/* function names */
while (isspace(*s))
s++;
- singlefunctions(line +2, s);
+ singlefunctions(p, s);
break;
case 'P':
/* filename */
@@ -483,13 +493,13 @@ static void parse_file(FILE *infile)
/* DOC: section name */
while (isspace(*s))
s++;
- docsection(line + 2, s);
+ docsection(p, s);
break;
case 'C':
while (*s && !isspace(*s)) s++;
*s = '\0';
if (findall)
- findall(line+2);
+ findall(p);
break;
default:
defaultline(line);
--
2.1.4
next prev parent reply other threads:[~2016-05-12 13:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-12 13:15 [PATCH 0/9] kernel-doc/docproc prep work for reStructuredText Jani Nikula
2016-05-12 13:15 ` [PATCH 1/9] kernel-doc: rewrite usage description, remove duplicated comments Jani Nikula
2016-05-12 13:15 ` [PATCH 2/9] kernel-doc: produce RestructuredText output Jani Nikula
2016-05-12 13:15 ` [PATCH 3/9] kernel-doc: use rst C domain directives and references for types Jani Nikula
2016-05-12 13:15 ` [PATCH 4/9] docproc: add variables for subcommand and filename Jani Nikula
2016-05-12 13:15 ` [PATCH 5/9] docproc: reduce unnecessary indentation Jani Nikula
2016-05-12 13:15 ` Jani Nikula [this message]
2016-05-12 13:15 ` [PATCH 7/9] docproc: abstract terminating lines at first space Jani Nikula
2016-05-12 13:15 ` [PATCH 8/9] docproc: add support for reStructuredText format via --rst option Jani Nikula
2016-05-12 13:15 ` [PATCH 9/9] docproc: print a comment about autogeneration for rst output Jani Nikula
2016-05-14 16:01 ` [PATCH 0/9] kernel-doc/docproc prep work for reStructuredText 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=4906036e861ca3ce3ff290e303abc8acdf5a6f1a.1463058396.git.jani.nikula@intel.com \
--to=jani.nikula@intel.com \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--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
all inboxes | Powered by JetHome®