summaryrefslogtreecommitdiffstats
path: root/dimension/utility.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-04-18 21:43:24 -0400
committerTavian Barnes <tavianator@gmail.com>2010-04-18 22:29:41 -0400
commit85c5f17dcd09540e31dc879166502984e483609d (patch)
tree6bc4c9ea1f265756e8b563885dabcdc0af09b0cf /dimension/utility.c
parent6437ab96674accfb5d5d85066e58d20887c926d7 (diff)
downloaddimension-85c5f17dcd09540e31dc879166502984e483609d.tar.xz
Have dmnsn_diagnostic() take a dmnsn_parse_location.
Diffstat (limited to 'dimension/utility.c')
-rw-r--r--dimension/utility.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/dimension/utility.c b/dimension/utility.c
index 54dd78a..17a7bba 100644
--- a/dimension/utility.c
+++ b/dimension/utility.c
@@ -22,16 +22,24 @@
#include <stdio.h>
void
-dmnsn_diagnostic(const char *filename, int line, int col, const char *format,
- ...)
+dmnsn_diagnostic(dmnsn_parse_location location, const char *format, ...)
{
va_list ap;
va_start(ap, format);
- if (line >= 0 && col >= 0) {
- fprintf(stderr, "%s:%d:%d: ", filename, line, col);
+ if (location.first_line >= 0 && location.first_column >= 0) {
+ if (location.first_line != location.last_line) {
+ fprintf(stderr, "%s:%d-%d: ", location.first_filename,
+ location.first_line, location.last_line);
+ } else if (location.first_column != location.last_column - 1) {
+ fprintf(stderr, "%s:%d:%d-%d: ", location.first_filename,
+ location.first_line, location.first_column, location.last_column);
+ } else {
+ fprintf(stderr, "%s:%d:%d: ", location.first_filename,
+ location.first_line, location.first_column);
+ }
} else {
- fprintf(stderr, "%s: ", filename);
+ fprintf(stderr, "%s: ", location.first_filename);
}
vfprintf(stderr, format, ap);
fprintf(stderr, "\n");