From 696feae32e87473811b59da174d7841a165ec42d Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Thu, 12 Sep 2019 22:08:04 +0200 Subject: [PATCH] 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. --- src/extern/err.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/extern/err.c b/src/extern/err.c index f1625132..8731ca4f 100644 --- 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 @@ void rgbds_vwarnx(const char *fmt, va_list ap) 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); }