shithub: rgbds

Download patch

ref: 8406fd84d66523cd77d769b86bf0afc36aeb3f6f
parent: 5694d6907cdcf2d79792e00dc75f416eb7793a52
author: bentley <[email protected]>
date: Fri Jan 15 14:42:17 EST 2010

rgbasm: return EX_USAGE for option errors

--- a/src/asm/main.c
+++ b/src/asm/main.c
@@ -10,6 +10,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sysexits.h>
 #include <time.h>
 #include <unistd.h>
 
@@ -136,7 +137,7 @@
 			newopt.gbgfx[2] = s[3];
 			newopt.gbgfx[3] = s[4];
 		} else {
-			errx(5, "Must specify exactly 4 characters for option 'g'");
+			errx(EX_USAGE, "Must specify exactly 4 characters for option 'g'");
 		}
 		break;
 	case 'b':
@@ -242,7 +243,7 @@
 	printf
 	    ("\t-z<hx>\t\tSet the byte value (hex format) used for uninitialised\n"
 	    "\t\t\tdata (default is 0x00)\n");
-	exit(0);
+	exit(EX_USAGE);
 }
 /*
  * RGBAsm - MAIN.C
@@ -285,7 +286,7 @@
 				newopt.binary[0] = optarg[1];
 				newopt.binary[1] = optarg[2];
 			} else {
-				errx(5, "Must specify exactly 2 characters for option 'b'");
+				errx(EX_USAGE, "Must specify exactly 2 characters for option 'b'");
 			}
 		case 'g':
 			if (strlen(optarg) == 4) {
@@ -294,7 +295,7 @@
 				newopt.gbgfx[2] = optarg[3];
 				newopt.gbgfx[3] = optarg[4];
 			} else {
-				errx(5, "Must specify exactly 4 characters for option 'g'");
+				errx(EX_USAGE, "Must specify exactly 4 characters for option 'g'");
 			}
 			break;
 		case 'i':
@@ -306,9 +307,9 @@
 		case 'z':
 			newopt.fillchar = strtoul(optarg, &ep, 0);
 			if (optarg[0] == '\0' || *ep != '\0')
-				errx(5, "Invalid argument for option 'z'");
+				errx(EX_USAGE, "Invalid argument for option 'z'");
 			if (newopt.fillchar < 0 || newopt.fillchar > 0xFF)
-				errx(5, "Argument for option 'z' must be between 0 and 0xFF");
+				errx(EX_USAGE, "Argument for option 'z' must be between 0 and 0xFF");
 			break;
 		default:
 			PrintUsage();