aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJani Nikula <jani.nikula@intel.com>2016-05-12 09:15:42 -0400
committerJonathan Corbet <corbet@lwn.net>2016-05-14 11:56:49 -0400
commit1dcdad0aacb6d762b77f3e17167d131a14c0dbce (patch)
tree5e3fc4921d48f1c6b9059a67a86de01ad39f6ffc
parenta48dc45e9c02ebaebc79de5b3fec8e4f59a9fe9f (diff)
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>
-rw-r--r--scripts/docproc.c34
1 files 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)
430 } 430 }
431} 431}
432 432
433/*
434 * Terminate s at first space, if any. If there was a space, return pointer to
435 * the character after that. Otherwise, return pointer to the terminating NUL.
436 */
437static char *chomp(char *s)
438{
439 while (*s && !isspace(*s))
440 s++;
441
442 if (*s)
443 *s++ = '\0';
444
445 return s;
446}
447
433/* Return pointer to directive content, or NULL if not a directive. */ 448/* Return pointer to directive content, or NULL if not a directive. */
434static char *is_directive(char *line) 449static char *is_directive(char *line)
435{ 450{
@@ -460,27 +475,22 @@ static void parse_file(FILE *infile)
460 continue; 475 continue;
461 } 476 }
462 477
463 s = p + 1;
464 switch (*p++) { 478 switch (*p++) {
465 case 'E': 479 case 'E':
466 while (*s && !isspace(*s)) s++; 480 chomp(p);
467 *s = '\0';
468 externalfunctions(p); 481 externalfunctions(p);
469 break; 482 break;
470 case 'I': 483 case 'I':
471 while (*s && !isspace(*s)) s++; 484 chomp(p);
472 *s = '\0';
473 internalfunctions(p); 485 internalfunctions(p);
474 break; 486 break;
475 case 'D': 487 case 'D':
476 while (*s && !isspace(*s)) s++; 488 chomp(p);
477 *s = '\0';
478 symbolsonly(p); 489 symbolsonly(p);
479 break; 490 break;
480 case 'F': 491 case 'F':
481 /* filename */ 492 /* filename */
482 while (*s && !isspace(*s)) s++; 493 s = chomp(p);
483 *s++ = '\0';
484 /* function names */ 494 /* function names */
485 while (isspace(*s)) 495 while (isspace(*s))
486 s++; 496 s++;
@@ -488,16 +498,14 @@ static void parse_file(FILE *infile)
488 break; 498 break;
489 case 'P': 499 case 'P':
490 /* filename */ 500 /* filename */
491 while (*s && !isspace(*s)) s++; 501 s = chomp(p);
492 *s++ = '\0';
493 /* DOC: section name */ 502 /* DOC: section name */
494 while (isspace(*s)) 503 while (isspace(*s))
495 s++; 504 s++;
496 docsection(p, s); 505 docsection(p, s);
497 break; 506 break;
498 case 'C': 507 case 'C':
499 while (*s && !isspace(*s)) s++; 508 chomp(p);
500 *s = '\0';
501 if (findall) 509 if (findall)
502 findall(p); 510 findall(p);
503 break; 511 break;