cosmetic change: rearrange getopt() switch for easier reading

cases are put in alphabetical order, to match the getopt string.
This commit is contained in:
bentley
2010-01-13 10:08:23 -07:00
parent 0b647c5a25
commit 2da63e2f7d

View File

@@ -190,20 +190,30 @@ main(int argc, char *argv[])
while ((ch = getopt(argc, argv, "Ccdjk:m:p:qr:st:v")) != -1) { while ((ch = getopt(argc, argv, "Ccdjk:m:p:qr:st:v")) != -1) {
switch (ch) { switch (ch) {
case 'c':
if (ulOptions & OPTF_GBCMODE) {
errx(EX_USAGE, "-c and -C can't be used together");
}
ulOptions |= OPTF_GBCMODE;
gbc_mode = 0xC0;
break;
case 'C':
if (ulOptions & OPTF_GBCMODE) {
errx(EX_USAGE, "-c and -C can't be used together");
}
ulOptions |= OPTF_GBCMODE;
gbc_mode = 0x80;
break;
case 'd': case 'd':
ulOptions |= OPTF_DEBUG; ulOptions |= OPTF_DEBUG;
break; break;
case 'r':
ulOptions |= OPTF_RAMSIZE;
ram_size = strtoul(optarg, &ep, 0);
if (optarg[0] == '\0' || *ep != '\0')
errx(EX_USAGE, "Invalid argument for option 'r'");
if (ram_size < 0 || ram_size > 0xFF)
errx(EX_USAGE, "Argument for option 'r' must be between 0 and 0xFF");
break;
case 'j': case 'j':
ulOptions |= OPTF_JAPAN; ulOptions |= OPTF_JAPAN;
break; break;
case 'k':
strncpy(nlicensee, optarg, 2);
ulOptions |= OPTF_NLICENSEE;
break;
case 'm': case 'm':
ulOptions |= OPTF_MBCTYPE; ulOptions |= OPTF_MBCTYPE;
mbc_type = strtoul(optarg, &ep, 0); mbc_type = strtoul(optarg, &ep, 0);
@@ -220,36 +230,26 @@ main(int argc, char *argv[])
if (pad_value < 0 || pad_value > 0xFF) if (pad_value < 0 || pad_value > 0xFF)
errx(EX_USAGE, "Argument for option 'p' must be between 0 and 0xFF"); errx(EX_USAGE, "Argument for option 'p' must be between 0 and 0xFF");
break; break;
case 'v': case 'q':
ulOptions |= OPTF_VALIDATE; ulOptions |= OPTF_QUIET;
break;
case 'r':
ulOptions |= OPTF_RAMSIZE;
ram_size = strtoul(optarg, &ep, 0);
if (optarg[0] == '\0' || *ep != '\0')
errx(EX_USAGE, "Invalid argument for option 'r'");
if (ram_size < 0 || ram_size > 0xFF)
errx(EX_USAGE, "Argument for option 'r' must be between 0 and 0xFF");
break;
case 's':
ulOptions |= OPTF_SGBMODE;
break; break;
case 't': case 't':
strncpy(cartname, optarg, 16); strncpy(cartname, optarg, 16);
ulOptions |= OPTF_TITLE; ulOptions |= OPTF_TITLE;
break; break;
case 'k': case 'v':
strncpy(nlicensee, optarg, 2); ulOptions |= OPTF_VALIDATE;
ulOptions |= OPTF_NLICENSEE;
break;
case 'q':
ulOptions |= OPTF_QUIET;
break;
case 'c':
if (ulOptions & OPTF_GBCMODE) {
errx(EX_USAGE, "-c and -C can't be used together");
}
ulOptions |= OPTF_GBCMODE;
gbc_mode = 0xC0;
break;
case 'C':
if (ulOptions & OPTF_GBCMODE) {
errx(EX_USAGE, "-c and -C can't be used together");
}
ulOptions |= OPTF_GBCMODE;
gbc_mode = 0x80;
break;
case 's':
ulOptions |= OPTF_SGBMODE;
break; break;
default: default:
usage(); usage();