aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-02-15 21:42:10 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-02-15 21:42:10 +0100
commit67ee4c2d36be976bb5e86d988a0339b5f9c5825d (patch)
treefaae6b854064e2387bf4f92d6fe0436e76a86482
parentLinkedList O(1) length. (diff)
downloadcalp-67ee4c2d36be976bb5e86d988a0339b5f9c5825d.tar.gz
calp-67ee4c2d36be976bb5e86d988a0339b5f9c5825d.tar.xz
Add ERR_P macro.
-rw-r--r--err.h4
-rw-r--r--parse.c5
2 files changed, 6 insertions, 3 deletions
diff --git a/err.h b/err.h
index 39e3cc74..d9d19ec7 100644
--- a/err.h
+++ b/err.h
@@ -19,6 +19,10 @@
#define ERR_F(fmt, ...) fprintf(stderr, _RED "ERR" _RESET " (%s:%i) " fmt "\n", \
__FILE__, __LINE__, ##__VA_ARGS__)
+/* Parse error */
+#define ERR_P(ctx, fmt, ...) fprintf(stderr, _RED "PARSE" _RESET " (%s:%i) %i:%i " fmt "\n", \
+ __FILE__, __LINE__, (ctx)->pline, (ctx)->pcolumn, ##__VA_ARGS__)
+
#define INFO(msg) fprintf(stderr, _BLUE "INFO" _RESET " (%s:%i) %s\n", __FILE__, __LINE__, #msg)
#define INFO_F(fmt, ...) fprintf(stderr, _BLUE "INFO" _RESET " (%s:%i) " fmt "\n", \
__FILE__, __LINE__, ##__VA_ARGS__)
diff --git a/parse.c b/parse.c
index f531671a..430855ef 100644
--- a/parse.c
+++ b/parse.c
@@ -196,11 +196,10 @@ int handle_kv (
} else if (strbuf_c(&cline->key, "END")) {
strbuf* s = POP(LLIST(strbuf))(&ctx->key_stack);
if (strbuf_cmp(s, CLINE_CUR_VAL(cline)) != 0) {
- ERR_F("Expected END:%s, got END:%s.\n%s line %i",
+ ERR_P(ctx, "Expected END:%s, got END:%s.\n%s line",
s->mem,
CLINE_CUR_VAL(cline)->mem,
- PEEK(LLIST(vcomponent))(&ctx->comp_stack)->filename,
- ctx->line);
+ PEEK(LLIST(vcomponent))(&ctx->comp_stack)->filename);
PUSH(LLIST(strbuf))(&ctx->key_stack, s);
return -1;