Mercurial > irccd
changeset 1016:c02a5c9cdde4
irccd: improve configuration error reporting
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 17 Feb 2021 22:56:50 +0100 |
parents | d55e98383ad0 |
children | c30f0dc9d614 |
files | irccd/conf.y irccd/lex.l |
diffstat | 2 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/irccd/conf.y Wed Feb 17 22:50:50 2021 +0100 +++ b/irccd/conf.y Wed Feb 17 22:56:50 2021 +0100 @@ -19,6 +19,7 @@ %{ #include <err.h> +#include <limits.h> #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -33,6 +34,7 @@ #include "transport.h" extern FILE *yyin; +extern int yylineno; struct pair { char *key; @@ -109,6 +111,8 @@ free(list); } +static char confpath[PATH_MAX]; + int yylex(void); @@ -596,7 +600,7 @@ void yyerror(const char *err) { - errx(1, "%s", err); + errx(1, "%s:%d: %s", confpath, yylineno, err); } void @@ -605,6 +609,7 @@ if (!(yyin = fopen(path, "r"))) err(1, "%s", path); + strlcpy(confpath, path, sizeof (confpath)); yyparse(); fclose(yyin); }