Reject unknown long-named command line options in dis.

This commit is contained in:
Lei Zhang 2016-02-18 10:50:42 -05:00
parent e4853e8508
commit 8e5479335f

View File

@ -85,15 +85,21 @@ int main(int argc, char** argv) {
} break; } break;
case '-': { case '-': {
// Long options // Long options
if (0 == strcmp(argv[argi], "--no-color")) allow_color = false; if (0 == strcmp(argv[argi], "--no-color")) {
if (0 == strcmp(argv[argi], "--no-indent")) allow_indent = false; allow_color = false;
if (0 == strcmp(argv[argi], "--offsets")) show_byte_offsets = true; } else if (0 == strcmp(argv[argi], "--no-indent")) {
if (0 == strcmp(argv[argi], "--help")) { allow_indent = false;
} else if (0 == strcmp(argv[argi], "--offsets")) {
show_byte_offsets = true;
} else if (0 == strcmp(argv[argi], "--help")) {
print_usage(argv[0]); print_usage(argv[0]);
return 0; return 0;
} else {
print_usage(argv[0]);
return 1;
} }
} break; } break;
case 0: case 0: {
// Setting a filename of "-" to indicate stdin. // Setting a filename of "-" to indicate stdin.
if (!inFile) { if (!inFile) {
inFile = argv[argi]; inFile = argv[argi];
@ -101,7 +107,7 @@ int main(int argc, char** argv) {
fprintf(stderr, "error: More than one input file specified\n"); fprintf(stderr, "error: More than one input file specified\n");
return 1; return 1;
} }
break; } break;
default: default:
print_usage(argv[0]); print_usage(argv[0]);
return 1; return 1;