From eb0c48b789bbf41745287adb6b2949f84e7e9171 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 29 Mar 2012 03:19:50 +0200 Subject: Config parse: add location tracking for nice error messages --- src/config.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/config.c') diff --git a/src/config.c b/src/config.c index b63ade9..8ba8c0a 100644 --- a/src/config.c +++ b/src/config.c @@ -117,17 +117,18 @@ void fastd_read_config(fastd_context *ctx, fastd_config *conf, const char *filen int token; YYSTYPE token_val; + YYLTYPE loc = {1, 0, 1, 0}; if (peer_config) token = START_PEER_CONFIG; else token = START_CONFIG; - while(fastd_config_push_parse(ps, token, &token_val, ctx, conf, depth+1) == YYPUSH_MORE) { - token = fastd_config_yylex(&token_val, scanner); + while(fastd_config_push_parse(ps, token, &token_val, &loc, ctx, conf, filename, depth+1) == YYPUSH_MORE) { + token = fastd_config_yylex(&token_val, &loc, scanner); if (token < 0) - exit_error(ctx, "config error: %s", token_val.str); + exit_error(ctx, "config error: %s at %s:%i:%i", token_val.str, filename, loc.first_line, loc.first_column); } fastd_config_pstate_delete(ps); -- cgit v1.2.3