summaryrefslogtreecommitdiff
path: root/err.c
diff options
context:
space:
mode:
Diffstat (limited to 'err.c')
-rw-r--r--err.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/err.c b/err.c
index a92a143..58279f5 100644
--- a/err.c
+++ b/err.c
@@ -123,7 +123,7 @@ static void err_print_(
va_list args;
if (!where.ctx->enabled) return;
#if ERR_SHOW_SOURCE_LOCATION
- if (file)
+ if (file)
err_fprint("Generated by line %d of %s:\n", line, file);
#endif
va_start(args, fmt);
@@ -147,9 +147,17 @@ static void info_print(Location where, const char *fmt, ...) {
va_end(args);
}
-static void warn_print(Location where, const char *fmt, ...) {
+static void warn_print_(
+#if ERR_SHOW_SOURCE_LOCATION
+ int line, const char *file,
+#endif
+ Location where, const char *fmt, ...) {
va_list args;
if (!where.ctx->enabled) return;
+#if ERR_SHOW_SOURCE_LOCATION
+ if (file)
+ err_fprint("Generated by line %d of %s:\n", line, file);
+#endif
va_start(args, fmt);
warn_print_header_(where);
err_vfprint(fmt, args);
@@ -157,6 +165,12 @@ static void warn_print(Location where, const char *fmt, ...) {
va_end(args);
}
+#if ERR_SHOW_SOURCE_LOCATION
+#define warn_print(...) warn_print_(__LINE__, __FILE__, __VA_ARGS__)
+#else
+#define warn_print warn_print_
+#endif
+
static void *err_malloc(size_t size) {
if (size == 0) return NULL;
void *ret = malloc(size);