rgbfix: deal with options and arguments in the right order.

This commit is contained in:
Anthony J. Bentley
2015-01-07 23:07:09 -07:00
parent 21d0b402d3
commit bdc6401eba

View File

@@ -40,17 +40,6 @@ main(int argc, char *argv[])
int ch;
char *ep;
/*
* Open the ROM file
*/
if (argc < 2)
usage();
if ((rom = fopen(argv[argc - 1], "rb+")) == NULL) {
err(1, "Error opening file %s", argv[argc - 1]);
}
/*
* Parse command-line options
*/
@@ -197,6 +186,20 @@ main(int argc, char *argv[])
}
}
argc -= optind;
argv += optind;
if (argc == 0)
usage();
/*
* Open the ROM file
*/
if ((rom = fopen(argv[argc - 1], "rb+")) == NULL) {
err(1, "Error opening file %s", argv[argc - 1]);
}
/*
* Write changes to ROM
*/