From 67ee4c2d36be976bb5e86d988a0339b5f9c5825d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Fri, 15 Feb 2019 21:42:10 +0100 Subject: Add ERR_P macro. --- err.h | 4 ++++ parse.c | 5 ++--- 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; -- cgit v1.2.3