commit 28222288732d233b05d456e6f92561559f41696d
parent 5dbc869c2bb349fbf4088abe45bcc2253450031c
Author: Drew DeVault <sir@cmpwn.com>
Date: Sun, 7 Oct 2018 11:11:54 -0400
Show origin of nested formatting issues
Diffstat:
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/include/util.h b/include/util.h
@@ -11,6 +11,7 @@ struct parser {
uint32_t queue[32];
uint32_t flags;
const char *str;
+ int fmt_line, fmt_col;
};
enum formatting {
diff --git a/src/main.c b/src/main.c
@@ -115,13 +115,20 @@ static void parse_format(struct parser *p, enum formatting fmt) {
[FORMAT_BOLD] = 'B',
[FORMAT_UNDERLINE] = 'I',
};
+ char error[512];
if (p->flags) {
if ((p->flags & ~fmt)) {
- parser_fatal(p, "Cannot nest inline formatting.");
+ snprintf(error, sizeof(error), "Cannot nest inline formatting "
+ "(began with %c at %d:%d)",
+ p->flags == FORMAT_BOLD ? '*' : '_',
+ p->fmt_line, p->fmt_col);
+ parser_fatal(p, error);
}
fprintf(p->output, "\\fR");
} else {
fprintf(p->output, "\\f%c", formats[fmt]);
+ p->fmt_line = p->line;
+ p->fmt_col = p->col;
}
p->flags ^= fmt;
}