docproc: abstract terminating lines at first space
Cleaner code. Also fixes a bug when F or P directives didn't in fact have space. Signed-off-by: Jani Nikula <jani.nikula@intel.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
This commit is contained in:
parent
a48dc45e9c
commit
1dcdad0aac
@ -430,6 +430,21 @@ static void find_all_symbols(char *filename)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Terminate s at first space, if any. If there was a space, return pointer to
|
||||||
|
* the character after that. Otherwise, return pointer to the terminating NUL.
|
||||||
|
*/
|
||||||
|
static char *chomp(char *s)
|
||||||
|
{
|
||||||
|
while (*s && !isspace(*s))
|
||||||
|
s++;
|
||||||
|
|
||||||
|
if (*s)
|
||||||
|
*s++ = '\0';
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
/* Return pointer to directive content, or NULL if not a directive. */
|
/* Return pointer to directive content, or NULL if not a directive. */
|
||||||
static char *is_directive(char *line)
|
static char *is_directive(char *line)
|
||||||
{
|
{
|
||||||
@ -460,27 +475,22 @@ static void parse_file(FILE *infile)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
s = p + 1;
|
|
||||||
switch (*p++) {
|
switch (*p++) {
|
||||||
case 'E':
|
case 'E':
|
||||||
while (*s && !isspace(*s)) s++;
|
chomp(p);
|
||||||
*s = '\0';
|
|
||||||
externalfunctions(p);
|
externalfunctions(p);
|
||||||
break;
|
break;
|
||||||
case 'I':
|
case 'I':
|
||||||
while (*s && !isspace(*s)) s++;
|
chomp(p);
|
||||||
*s = '\0';
|
|
||||||
internalfunctions(p);
|
internalfunctions(p);
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
while (*s && !isspace(*s)) s++;
|
chomp(p);
|
||||||
*s = '\0';
|
|
||||||
symbolsonly(p);
|
symbolsonly(p);
|
||||||
break;
|
break;
|
||||||
case 'F':
|
case 'F':
|
||||||
/* filename */
|
/* filename */
|
||||||
while (*s && !isspace(*s)) s++;
|
s = chomp(p);
|
||||||
*s++ = '\0';
|
|
||||||
/* function names */
|
/* function names */
|
||||||
while (isspace(*s))
|
while (isspace(*s))
|
||||||
s++;
|
s++;
|
||||||
@ -488,16 +498,14 @@ static void parse_file(FILE *infile)
|
|||||||
break;
|
break;
|
||||||
case 'P':
|
case 'P':
|
||||||
/* filename */
|
/* filename */
|
||||||
while (*s && !isspace(*s)) s++;
|
s = chomp(p);
|
||||||
*s++ = '\0';
|
|
||||||
/* DOC: section name */
|
/* DOC: section name */
|
||||||
while (isspace(*s))
|
while (isspace(*s))
|
||||||
s++;
|
s++;
|
||||||
docsection(p, s);
|
docsection(p, s);
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
while (*s && !isspace(*s)) s++;
|
chomp(p);
|
||||||
*s = '\0';
|
|
||||||
if (findall)
|
if (findall)
|
||||||
findall(p);
|
findall(p);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user