aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorHimbeer <himbeer@disroot.org>2025-05-08 14:56:34 +0200
committerHimbeer <himbeer@disroot.org>2025-05-08 14:56:34 +0200
commit999491d046547dafa7238163d6231a5b3257c250 (patch)
treed414e5fb1ff538a80a049953227c70b87671f383 /src/util.c
parent973812e4720912e9e326eb494c9e506e642d7afe (diff)
Move error function to util.c
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 6cc9425..e4d827b 100644
--- a/src/util.c
+++ b/src/util.c
@@ -1,3 +1,4 @@
+#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include "util.h"
@@ -33,3 +34,17 @@ must_realloc(void *ptr, size_t size)
}
return ret;
}
+
+void
+error(struct location loc, const char *fmt, ...)
+{
+ fprintf(stderr, "%s:%d:%d: ", loc.file, loc.line, loc.column);
+
+ va_list ap;
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+
+ fprintf(stderr, "\n");
+ exit(EXIT_PARSE);
+}