summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2018-06-04 10:01:28 -0400
committerPikalaxALT <pikalaxalt@gmail.com>2018-06-04 10:01:28 -0400
commit51e7c4a5cb7870d9ee861543245a961bb7c70f6e (patch)
tree32077046691c2643a77298aa49d1cb9282b9acfb
parent54c8d02cd671ee1325a55d7784f19a255dfc6c9f (diff)
Make make_shim a little more user-friendly
-rw-r--r--tools/make_shim.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/tools/make_shim.c b/tools/make_shim.c
index e4019cf..c5b684e 100644
--- a/tools/make_shim.c
+++ b/tools/make_shim.c
@@ -54,11 +54,11 @@ size_t strrcspn(const char *s1, const char *s2) {
return _s1 - s1;
}
-#define RIP(errmsg) { \
- errno = EIO; \
- perror(errmsg); \
- if (file) fclose(file); \
- return 1; \
+#define RIP(errmsg) { \
+ if (errno == 0) errno = EIO; \
+ perror(errmsg); \
+ if (file) fclose(file); \
+ return 1; \
}
int main(int argc, char * argv[]) {
@@ -95,7 +95,7 @@ int main(int argc, char * argv[]) {
for (int arg_idx = optind; arg_idx < argc; arg_idx++) {
FILE * file = fopen(argv[arg_idx], "r");
if (file == NULL)
- RIP("file io");
+ RIP("Unable to open file");
while ((lineptr = fgets(line, sizeof(line), file)) != NULL) {
unsigned short bank = 0;
unsigned short pointer = 0;
@@ -115,18 +115,18 @@ int main(int argc, char * argv[]) {
end = lineptr + strcspn(lineptr, " \t\n");
symbol = end + strspn(end, " \t\n");
if (!*symbol)
- RIP("parse");
+ RIP("Declaration not in \"bank:addr Name\" format");
*end = 0;
addr_p = strchr(lineptr, ':');
if (!addr_p)
- RIP("parse");
+ RIP("Pointer not in bank:addr format");
*addr_p++ = 0;
pointer = strtoul(addr_p, &end, 16);
if (pointer == 0 && end == addr_p)
- RIP("parse");
+ RIP("Unable to parse symbol address");
bank = strtoul(lineptr, &end, 16);
if (bank == 0 && end == lineptr)
- RIP("parse");
+ RIP("Unable to parse bank number");
// Main loop
const char * section = NULL;