summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJani Nikula <jani.nikula@intel.com>2016-05-12 16:15:41 +0300
committerJonathan Corbet <corbet@lwn.net>2016-05-14 09:56:45 -0600
commita48dc45e9c02ebaebc79de5b3fec8e4f59a9fe9f (patch)
tree22de7253dbd8ecd33ff08f5ff8c4e34bf5d37313 /scripts
parent868fb19212ca5bdbfa765a97a4bf6d2439b89056 (diff)
downloadlinux-a48dc45e9c02ebaebc79de5b3fec8e4f59a9fe9f.tar.bz2
docproc: abstract docproc directive detection
Helps follow-up work. No functional changes. Signed-off-by: Jani Nikula <jani.nikula@intel.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/docproc.c30
1 files 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);