ox

The Ox programming language, compiler and tools (WIP)
Log | Files | Refs | README | LICENSE

commit f53ba79759fbe2d635fda36ef3d18b46ac956798
parent b80810f39a342f176f46b3090757eef62ed4684e
Author: citbl <citbl@citbl.org>
Date:   Fri, 10 Oct 2025 20:56:09 +1000

minor

Diffstat:
Mutils.c | 16++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/utils.c b/utils.c @@ -1,30 +1,34 @@ #include "utils.h" +#include <errno.h> #include <stdio.h> #include <stdlib.h> #include <stdarg.h> +#include <string.h> void -panic(const char *fmt, ...) { +panic(const char *fmt, ...) +{ va_list args; + int saved_errno; + saved_errno = errno; va_start(args, fmt); fprintf(stderr, "Error: "); - // fprintf(stderr, "\e[0;31mError: "); vfprintf(stderr, fmt, args); - // fprintf(stderr, "\e[0m\n"); fprintf(stderr, "\n"); va_end(args); + if (fmt[0] && fmt[strlen(fmt) - 1] == ':') fprintf(stderr, " %s", strerror(saved_errno)); + fputc('\n', stderr); exit(1); } void -softpanic(const char *fmt, ...) { +softpanic(const char *fmt, ...) +{ va_list args; va_start(args, fmt); fprintf(stderr, "Error: "); - // fprintf(stderr, "\e[0;31mError: "); vfprintf(stderr, fmt, args); - // fprintf(stderr, "\e[0m\n"); fprintf(stderr, "\n"); va_end(args); exit(0);