diff options
author | Jani Nikula <jani.nikula@intel.com> | 2016-05-12 09:15:39 -0400 |
---|---|---|
committer | Jonathan Corbet <corbet@lwn.net> | 2016-05-14 11:56:37 -0400 |
commit | 568fb2dec9c68bb38c2a1ad01fb3d4dd41488115 (patch) | |
tree | 40f773190580708d4fc9d99b849e05cb4305c173 | |
parent | 6285097654725f39357527b553d03b70bfbaf4d2 (diff) |
docproc: add variables for subcommand and filename
Improves clarity. 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 | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/scripts/docproc.c b/scripts/docproc.c index e267e621431a..48abc01a920e 100644 --- a/scripts/docproc.c +++ b/scripts/docproc.c | |||
@@ -500,6 +500,7 @@ static void parse_file(FILE *infile) | |||
500 | 500 | ||
501 | int main(int argc, char *argv[]) | 501 | int main(int argc, char *argv[]) |
502 | { | 502 | { |
503 | const char *subcommand, *filename; | ||
503 | FILE * infile; | 504 | FILE * infile; |
504 | int i; | 505 | int i; |
505 | 506 | ||
@@ -513,15 +514,19 @@ int main(int argc, char *argv[]) | |||
513 | usage(); | 514 | usage(); |
514 | exit(1); | 515 | exit(1); |
515 | } | 516 | } |
517 | |||
518 | subcommand = argv[1]; | ||
519 | filename = argv[2]; | ||
520 | |||
516 | /* Open file, exit on error */ | 521 | /* Open file, exit on error */ |
517 | infile = fopen(argv[2], "r"); | 522 | infile = fopen(filename, "r"); |
518 | if (infile == NULL) { | 523 | if (infile == NULL) { |
519 | fprintf(stderr, "docproc: "); | 524 | fprintf(stderr, "docproc: "); |
520 | perror(argv[2]); | 525 | perror(filename); |
521 | exit(2); | 526 | exit(2); |
522 | } | 527 | } |
523 | 528 | ||
524 | if (strcmp("doc", argv[1]) == 0) { | 529 | if (strcmp("doc", subcommand) == 0) { |
525 | /* Need to do this in two passes. | 530 | /* Need to do this in two passes. |
526 | * First pass is used to collect all symbols exported | 531 | * First pass is used to collect all symbols exported |
527 | * in the various files; | 532 | * in the various files; |
@@ -557,10 +562,10 @@ int main(int argc, char *argv[]) | |||
557 | fprintf(stderr, "Warning: didn't use docs for %s\n", | 562 | fprintf(stderr, "Warning: didn't use docs for %s\n", |
558 | all_list[i]); | 563 | all_list[i]); |
559 | } | 564 | } |
560 | } else if (strcmp("depend", argv[1]) == 0) { | 565 | } else if (strcmp("depend", subcommand) == 0) { |
561 | /* Create first part of dependency chain | 566 | /* Create first part of dependency chain |
562 | * file.tmpl */ | 567 | * file.tmpl */ |
563 | printf("%s\t", argv[2]); | 568 | printf("%s\t", filename); |
564 | defaultline = noaction; | 569 | defaultline = noaction; |
565 | internalfunctions = adddep; | 570 | internalfunctions = adddep; |
566 | externalfunctions = adddep; | 571 | externalfunctions = adddep; |
@@ -571,7 +576,7 @@ int main(int argc, char *argv[]) | |||
571 | parse_file(infile); | 576 | parse_file(infile); |
572 | printf("\n"); | 577 | printf("\n"); |
573 | } else { | 578 | } else { |
574 | fprintf(stderr, "Unknown option: %s\n", argv[1]); | 579 | fprintf(stderr, "Unknown option: %s\n", subcommand); |
575 | exit(1); | 580 | exit(1); |
576 | } | 581 | } |
577 | fclose(infile); | 582 | fclose(infile); |