diff options
author | Jani Nikula <jani.nikula@intel.com> | 2016-05-12 09:15:41 -0400 |
---|---|---|
committer | Jonathan Corbet <corbet@lwn.net> | 2016-05-14 11:56:45 -0400 |
commit | a48dc45e9c02ebaebc79de5b3fec8e4f59a9fe9f (patch) | |
tree | 22de7253dbd8ecd33ff08f5ff8c4e34bf5d37313 | |
parent | 868fb19212ca5bdbfa765a97a4bf6d2439b89056 (diff) |
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>
-rw-r--r-- | scripts/docproc.c | 30 |
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) | |||
430 | } | 430 | } |
431 | } | 431 | } |
432 | 432 | ||
433 | /* Return pointer to directive content, or NULL if not a directive. */ | ||
434 | static char *is_directive(char *line) | ||
435 | { | ||
436 | if (line[0] == '!') | ||
437 | return line + 1; | ||
438 | |||
439 | return NULL; | ||
440 | } | ||
441 | |||
433 | /* | 442 | /* |
434 | * Parse file, calling action specific functions for: | 443 | * Parse file, calling action specific functions for: |
435 | * 1) Lines containing !E | 444 | * 1) Lines containing !E |
@@ -443,29 +452,30 @@ static void find_all_symbols(char *filename) | |||
443 | static void parse_file(FILE *infile) | 452 | static void parse_file(FILE *infile) |
444 | { | 453 | { |
445 | char line[MAXLINESZ]; | 454 | char line[MAXLINESZ]; |
446 | char * s; | 455 | char *p, *s; |
447 | while (fgets(line, MAXLINESZ, infile)) { | 456 | while (fgets(line, MAXLINESZ, infile)) { |
448 | if (line[0] != '!') { | 457 | p = is_directive(line); |
458 | if (!p) { | ||
449 | defaultline(line); | 459 | defaultline(line); |
450 | continue; | 460 | continue; |
451 | } | 461 | } |
452 | 462 | ||
453 | s = line + 2; | 463 | s = p + 1; |
454 | switch (line[1]) { | 464 | switch (*p++) { |
455 | case 'E': | 465 | case 'E': |
456 | while (*s && !isspace(*s)) s++; | 466 | while (*s && !isspace(*s)) s++; |
457 | *s = '\0'; | 467 | *s = '\0'; |
458 | externalfunctions(line+2); | 468 | externalfunctions(p); |
459 | break; | 469 | break; |
460 | case 'I': | 470 | case 'I': |
461 | while (*s && !isspace(*s)) s++; | 471 | while (*s && !isspace(*s)) s++; |
462 | *s = '\0'; | 472 | *s = '\0'; |
463 | internalfunctions(line+2); | 473 | internalfunctions(p); |
464 | break; | 474 | break; |
465 | case 'D': | 475 | case 'D': |
466 | while (*s && !isspace(*s)) s++; | 476 | while (*s && !isspace(*s)) s++; |
467 | *s = '\0'; | 477 | *s = '\0'; |
468 | symbolsonly(line+2); | 478 | symbolsonly(p); |
469 | break; | 479 | break; |
470 | case 'F': | 480 | case 'F': |
471 | /* filename */ | 481 | /* filename */ |
@@ -474,7 +484,7 @@ static void parse_file(FILE *infile) | |||
474 | /* function names */ | 484 | /* function names */ |
475 | while (isspace(*s)) | 485 | while (isspace(*s)) |
476 | s++; | 486 | s++; |
477 | singlefunctions(line +2, s); | 487 | singlefunctions(p, s); |
478 | break; | 488 | break; |
479 | case 'P': | 489 | case 'P': |
480 | /* filename */ | 490 | /* filename */ |
@@ -483,13 +493,13 @@ static void parse_file(FILE *infile) | |||
483 | /* DOC: section name */ | 493 | /* DOC: section name */ |
484 | while (isspace(*s)) | 494 | while (isspace(*s)) |
485 | s++; | 495 | s++; |
486 | docsection(line + 2, s); | 496 | docsection(p, s); |
487 | break; | 497 | break; |
488 | case 'C': | 498 | case 'C': |
489 | while (*s && !isspace(*s)) s++; | 499 | while (*s && !isspace(*s)) s++; |
490 | *s = '\0'; | 500 | *s = '\0'; |
491 | if (findall) | 501 | if (findall) |
492 | findall(line+2); | 502 | findall(p); |
493 | break; | 503 | break; |
494 | default: | 504 | default: |
495 | defaultline(line); | 505 | defaultline(line); |