X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/177f020f122827214159c46dcfe7ded1e3c8d1c3..865cc1bd7e146d8a3fe44ede30d834f7ab0c195c:/sbr/error.c?ds=sidebyside diff --git a/sbr/error.c b/sbr/error.c index 031ed2a5..fc5c6afa 100644 --- a/sbr/error.c +++ b/sbr/error.c @@ -5,15 +5,17 @@ * complete copyright information. */ -#include +#include "h/mh.h" +#include "error.h" #include #include - +#include "h/done.h" /* inform calls advertise() with no what and no tail. * Thus the simple "[invo_name: ]fmt\n" results. */ -void inform(char *fmt, ...) +void +inform(char *fmt, ...) { va_list ap; @@ -45,7 +47,7 @@ advise (const char *what, const char *fmt, ...) * straightforward, e.g. longjmp(3), but it must not return to adios(). * If it does then it's a bug and adios() will abort(3) as callers do * not expect execution to continue. */ -void +void NORETURN adios (const char *what, const char *fmt, ...) { va_list ap; @@ -58,6 +60,21 @@ adios (const char *what, const char *fmt, ...) } +/* die is the same as adios(), but without the what as that's commonly + * NULL. */ +void NORETURN +die(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + advertise(NULL, NULL, fmt, ap); + va_end(ap); + done(1); + abort(); +} + + /* admonish calls advertise() with a tail indicating the program * continues. * Thus "[invo_name: ]fmt[[ what]: errno], continuing...\n" results. */