aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-11-01 20:48:33 +0100
committerThomas Voss <mail@thomasvoss.com> 2024-11-01 20:48:33 +0100
commit849d39783113dab5f3130e3e59cd8b30f53b136e (patch)
tree48df1e0829fb7f0551329af9b236cb3250b01a65 /src/util.c
parentec5976bbd5a930e040a34b9e93bf9cc41d7230c1 (diff)
Print the compile error offset
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/util.c b/src/util.c
index bf18111..ae66bf9 100644
--- a/src/util.c
+++ b/src/util.c
@@ -1,3 +1,4 @@
+#include <stdarg.h>
#include <stddef.h>
#include <stdlib.h>
#include <errno.h>
@@ -9,10 +10,11 @@
#include "globals.h"
void
-pcre2_bitch_and_die(int ec, const char *fmt)
+pcre2_bitch_and_die(int ec, const char *fmt, ...)
{
/* If we’ve gotten here, we don’t care about writing efficient code */
ptrdiff_t bufsz = 512;
+
for (;;) {
char *buf = malloc(bufsz);
if (buf == nullptr)
@@ -20,8 +22,12 @@ pcre2_bitch_and_die(int ec, const char *fmt)
if (pcre2_get_error_message(ec, buf, bufsz) == PCRE2_ERROR_NOMEMORY) {
free(buf);
bufsz *= 2;
- } else
- cerr(EXIT_FATAL, fmt, buf);
+ } else {
+ va_list ap;
+ va_start(ap, fmt);
+ vwarn(fmt, ap);
+ exit(EXIT_FATAL);
+ }
}
}