Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1400075
| From | Jani Nikula <jani.nikula@intel.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 7/9] docproc: abstract terminating lines at first space |
| Date | 2016-05-12 15:20 +0200 |
| Message-ID | <rxYH0-6wa-39@gated-at.bofh.it> (permalink) |
| References | <rxYH0-6wa-19@gated-at.bofh.it> |
| Organization | Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo |
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>
---
scripts/docproc.c | 34 +++++++++++++++++++++-------------
1 file changed, 21 insertions(+), 13 deletions(-)
diff --git a/scripts/docproc.c b/scripts/docproc.c
index bc900310b431..a933e054402d 100644
--- a/scripts/docproc.c
+++ b/scripts/docproc.c
@@ -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. */
static char *is_directive(char *line)
{
@@ -460,27 +475,22 @@ static void parse_file(FILE *infile)
continue;
}
- s = p + 1;
switch (*p++) {
case 'E':
- while (*s && !isspace(*s)) s++;
- *s = '\0';
+ chomp(p);
externalfunctions(p);
break;
case 'I':
- while (*s && !isspace(*s)) s++;
- *s = '\0';
+ chomp(p);
internalfunctions(p);
break;
case 'D':
- while (*s && !isspace(*s)) s++;
- *s = '\0';
+ chomp(p);
symbolsonly(p);
break;
case 'F':
/* filename */
- while (*s && !isspace(*s)) s++;
- *s++ = '\0';
+ s = chomp(p);
/* function names */
while (isspace(*s))
s++;
@@ -488,16 +498,14 @@ static void parse_file(FILE *infile)
break;
case 'P':
/* filename */
- while (*s && !isspace(*s)) s++;
- *s++ = '\0';
+ s = chomp(p);
/* DOC: section name */
while (isspace(*s))
s++;
docsection(p, s);
break;
case 'C':
- while (*s && !isspace(*s)) s++;
- *s = '\0';
+ chomp(p);
if (findall)
findall(p);
break;
--
2.1.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/9] kernel-doc/docproc prep work for reStructuredText Jani Nikula <jani.nikula@intel.com> - 2016-05-12 15:20 +0200 [PATCH 5/9] docproc: reduce unnecessary indentation Jani Nikula <jani.nikula@intel.com> - 2016-05-12 15:20 +0200 [PATCH 2/9] kernel-doc: produce RestructuredText output Jani Nikula <jani.nikula@intel.com> - 2016-05-12 15:20 +0200 [PATCH 4/9] docproc: add variables for subcommand and filename Jani Nikula <jani.nikula@intel.com> - 2016-05-12 15:20 +0200 [PATCH 9/9] docproc: print a comment about autogeneration for rst output Jani Nikula <jani.nikula@intel.com> - 2016-05-12 15:20 +0200 [PATCH 3/9] kernel-doc: use rst C domain directives and references for types Jani Nikula <jani.nikula@intel.com> - 2016-05-12 15:20 +0200 [PATCH 7/9] docproc: abstract terminating lines at first space Jani Nikula <jani.nikula@intel.com> - 2016-05-12 15:20 +0200 [PATCH 6/9] docproc: abstract docproc directive detection Jani Nikula <jani.nikula@intel.com> - 2016-05-12 15:20 +0200 [PATCH 1/9] kernel-doc: rewrite usage description, remove duplicated comments Jani Nikula <jani.nikula@intel.com> - 2016-05-12 15:20 +0200 Re: [PATCH 0/9] kernel-doc/docproc prep work for reStructuredText Jonathan Corbet <corbet@lwn.net> - 2016-05-14 18:10 +0200
csiph-web