summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChristoph Mallon <christoph.mallon@gmx.de>2012-11-09 09:38:10 +0100
committerChristoph Mallon <christoph.mallon@gmx.de>2012-11-13 16:08:30 +0100
commit8164f1bad7dc71e441c9b0abe66e828e78bcb2dc (patch)
tree314f171b17f0af366e9c2674f56d2659eca60564
parent6572d52d8dcc26052a68d640c29f2c0f16af133b (diff)
diagnostic: Allow passing no position or only a filename to diagnosticposvf().
-rw-r--r--diagnostic.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/diagnostic.c b/diagnostic.c
index 6bb53e9..0ca3df1 100644
--- a/diagnostic.c
+++ b/diagnostic.c
@@ -243,10 +243,16 @@ void diagnosticf(const char *const fmt, ...)
static void diagnosticposvf(source_position_t const *const pos, char const *const kind, char const *const fmt, va_list ap)
{
FILE *const out = stderr;
- fprintf(out, "%s:%u:", pos->input_name, pos->lineno);
- if (show_column)
- fprintf(out, "%u:", (unsigned)pos->colno);
- fprintf(out, " %s: ", kind);
+ if (pos) {
+ fprintf(out, "%s:", pos->input_name);
+ if (pos->lineno != 0) {
+ fprintf(out, "%u:", pos->lineno);
+ if (show_column)
+ fprintf(out, "%u:", (unsigned)pos->colno);
+ }
+ fputc(' ', out);
+ }
+ fprintf(out, "%s: ", kind);
curr_pos = pos;
diagnosticvf(fmt, ap);
}