Skip to content

Commit

Permalink
fix getopt code
Browse files Browse the repository at this point in the history
  • Loading branch information
codekitchen committed Nov 23, 2019
1 parent a5b3473 commit 1684f18
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"**/install-sh": true,
"**/missing": true,
"**/depcomp": true,
"**/config.h": true,
"**/config.h.in": true,
"**/config.status": true
}
Expand Down
11 changes: 9 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,23 @@ void usage(int status) {
exit(status);
}

void version() {
printf("%s\n", PACKAGE_STRING);
exit(EXIT_SUCCESS);
}

int main(int argc, char *const *argv) {
if (argc)
program_name = argv[0];
int c;
while ((c = getopt_long(argc, argv, "hv", long_options, NULL) != -1)) {
while ((c = getopt_long(argc, argv, "hv", long_options, NULL)) != -1) {
switch (c) {
case 'h':
case 'v':
usage(EXIT_SUCCESS);
break;
case 'v':
version();
break;
default:
usage(EXIT_FAILURE);
}
Expand Down

0 comments on commit 1684f18

Please sign in to comment.