Commit a48dc45e authored by Jani Nikula's avatar Jani Nikula Committed by Jonathan Corbet

docproc: abstract docproc directive detection

Helps follow-up work. No functional changes.
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
parent 868fb192
...@@ -430,6 +430,15 @@ static void find_all_symbols(char *filename) ...@@ -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: * Parse file, calling action specific functions for:
* 1) Lines containing !E * 1) Lines containing !E
...@@ -443,29 +452,30 @@ static void find_all_symbols(char *filename) ...@@ -443,29 +452,30 @@ static void find_all_symbols(char *filename)
static void parse_file(FILE *infile) static void parse_file(FILE *infile)
{ {
char line[MAXLINESZ]; char line[MAXLINESZ];
char * s; char *p, *s;
while (fgets(line, MAXLINESZ, infile)) { while (fgets(line, MAXLINESZ, infile)) {
if (line[0] != '!') { p = is_directive(line);
if (!p) {
defaultline(line); defaultline(line);
continue; continue;
} }
s = line + 2; s = p + 1;
switch (line[1]) { switch (*p++) {
case 'E': case 'E':
while (*s && !isspace(*s)) s++; while (*s && !isspace(*s)) s++;
*s = '\0'; *s = '\0';
externalfunctions(line+2); externalfunctions(p);
break; break;
case 'I': case 'I':
while (*s && !isspace(*s)) s++; while (*s && !isspace(*s)) s++;
*s = '\0'; *s = '\0';
internalfunctions(line+2); internalfunctions(p);
break; break;
case 'D': case 'D':
while (*s && !isspace(*s)) s++; while (*s && !isspace(*s)) s++;
*s = '\0'; *s = '\0';
symbolsonly(line+2); symbolsonly(p);
break; break;
case 'F': case 'F':
/* filename */ /* filename */
...@@ -474,7 +484,7 @@ static void parse_file(FILE *infile) ...@@ -474,7 +484,7 @@ static void parse_file(FILE *infile)
/* function names */ /* function names */
while (isspace(*s)) while (isspace(*s))
s++; s++;
singlefunctions(line +2, s); singlefunctions(p, s);
break; break;
case 'P': case 'P':
/* filename */ /* filename */
...@@ -483,13 +493,13 @@ static void parse_file(FILE *infile) ...@@ -483,13 +493,13 @@ static void parse_file(FILE *infile)
/* DOC: section name */ /* DOC: section name */
while (isspace(*s)) while (isspace(*s))
s++; s++;
docsection(line + 2, s); docsection(p, s);
break; break;
case 'C': case 'C':
while (*s && !isspace(*s)) s++; while (*s && !isspace(*s)) s++;
*s = '\0'; *s = '\0';
if (findall) if (findall)
findall(line+2); findall(p);
break; break;
default: default:
defaultline(line); defaultline(line);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment