Commit 568fb2de authored by Jani Nikula's avatar Jani Nikula Committed by Jonathan Corbet

docproc: add variables for subcommand and filename

Improves clarity. No functional changes.
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
parent 62850976
...@@ -500,6 +500,7 @@ static void parse_file(FILE *infile) ...@@ -500,6 +500,7 @@ static void parse_file(FILE *infile)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
const char *subcommand, *filename;
FILE * infile; FILE * infile;
int i; int i;
...@@ -513,15 +514,19 @@ int main(int argc, char *argv[]) ...@@ -513,15 +514,19 @@ int main(int argc, char *argv[])
usage(); usage();
exit(1); exit(1);
} }
subcommand = argv[1];
filename = argv[2];
/* Open file, exit on error */ /* Open file, exit on error */
infile = fopen(argv[2], "r"); infile = fopen(filename, "r");
if (infile == NULL) { if (infile == NULL) {
fprintf(stderr, "docproc: "); fprintf(stderr, "docproc: ");
perror(argv[2]); perror(filename);
exit(2); exit(2);
} }
if (strcmp("doc", argv[1]) == 0) { if (strcmp("doc", subcommand) == 0) {
/* Need to do this in two passes. /* Need to do this in two passes.
* First pass is used to collect all symbols exported * First pass is used to collect all symbols exported
* in the various files; * in the various files;
...@@ -557,10 +562,10 @@ int main(int argc, char *argv[]) ...@@ -557,10 +562,10 @@ int main(int argc, char *argv[])
fprintf(stderr, "Warning: didn't use docs for %s\n", fprintf(stderr, "Warning: didn't use docs for %s\n",
all_list[i]); all_list[i]);
} }
} else if (strcmp("depend", argv[1]) == 0) { } else if (strcmp("depend", subcommand) == 0) {
/* Create first part of dependency chain /* Create first part of dependency chain
* file.tmpl */ * file.tmpl */
printf("%s\t", argv[2]); printf("%s\t", filename);
defaultline = noaction; defaultline = noaction;
internalfunctions = adddep; internalfunctions = adddep;
externalfunctions = adddep; externalfunctions = adddep;
...@@ -571,7 +576,7 @@ int main(int argc, char *argv[]) ...@@ -571,7 +576,7 @@ int main(int argc, char *argv[])
parse_file(infile); parse_file(infile);
printf("\n"); printf("\n");
} else { } else {
fprintf(stderr, "Unknown option: %s\n", argv[1]); fprintf(stderr, "Unknown option: %s\n", subcommand);
exit(1); exit(1);
} }
fclose(infile); fclose(infile);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment