From ab400c0be5577cab2a66d242183887ebbd61717f Mon Sep 17 00:00:00 2001 From: Nicholas Date: Wed, 17 Nov 2021 08:22:03 -0800 Subject: checkin --- src/libfmt/fprint.c | 2 +- src/libfmt/panic.c | 15 +++++++++++++++ src/libfmt/rules.mk | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 src/libfmt/panic.c (limited to 'src/libfmt') diff --git a/src/libfmt/fprint.c b/src/libfmt/fprint.c index 26343f7..5077359 100644 --- a/src/libfmt/fprint.c +++ b/src/libfmt/fprint.c @@ -1,7 +1,7 @@ #include "internal.h" int -fprint(int fd, char *fmt, ...) +fmt·fprint(int fd, char *fmt, ...) { int n; va_list args; diff --git a/src/libfmt/panic.c b/src/libfmt/panic.c new file mode 100644 index 0000000..25ee277 --- /dev/null +++ b/src/libfmt/panic.c @@ -0,0 +1,15 @@ +#include "internal.h" + +void +fmt·panic(char *fmt, ...) +{ + char buf[256]; + va_list arg; + + va_start(arg, fmt); + fmt·vesprint(buf, arrend(buf), fmt, arg); + va_end(arg); + + fmt·fprint(2, "%s: %s\n", argv0 ? argv0 : "", buf); + exits("fatal"); +} diff --git a/src/libfmt/rules.mk b/src/libfmt/rules.mk index 9080bba..75a7bc7 100644 --- a/src/libfmt/rules.mk +++ b/src/libfmt/rules.mk @@ -16,6 +16,7 @@ SRCS_$(d):=\ $(d)/vnsprint.c\ $(d)/vprint.c\ $(d)/vwrite.c\ + $(d)/panic.c\ $(d)/write.c LIBS_$(d):=\ -- cgit v1.2.1