shithub: rgbds

Download patch

ref: 696feae32e87473811b59da174d7841a165ec42d
parent: 323738e7b8426e59aa753ca1f1d623d5c1f24368
author: ISSOtm <[email protected]>
date: Thu Sep 12 18:08:04 EDT 2019

Have RGBDS' `err` and `warn` output an error message
The stdlib functions specify the difference between `err` and `errx`
is that the former prints a message obtained with `strerror`.
However, RGBDS' implementation breaks that contract, and `warn`'s puts the
added semicolon in the wrong place.

--- a/src/extern/err.c
+++ b/src/extern/err.c
@@ -14,13 +14,12 @@
 
 void rgbds_vwarn(const char *fmt, va_list ap)
 {
-	fprintf(stderr, "warning");
+	fprintf(stderr, "warning: ");
 	if (fmt) {
-		fputs(": ", stderr);
 		vfprintf(stderr, fmt, ap);
+		fputs(": ", stderr);
 	}
-	putc('\n', stderr);
-	perror(0);
+	perror(NULL);
 }
 
 void rgbds_vwarnx(const char *fmt, va_list ap)
@@ -35,12 +34,12 @@
 
 noreturn_ void rgbds_verr(int status, const char *fmt, va_list ap)
 {
-	fprintf(stderr, "error");
+	fprintf(stderr, "error: ");
 	if (fmt) {
-		fputs(": ", stderr);
 		vfprintf(stderr, fmt, ap);
+		fputs(": ", stderr);
 	}
-	putc('\n', stderr);
+	perror(NULL);
 	exit(status);
 }