X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fliboconfig%2Fparser.y;h=49cd139dbd76bd1e4505b3184194d6066a1be11b;hb=b92c090faa534fd75ab184afe425331e06b74d0b;hp=8df2c6e5fb230eaed09db85d73e6ad8d5294a819;hpb=6e855e6ab3bc654a3d6238c75102c66785de8bda;p=collectd.git diff --git a/src/liboconfig/parser.y b/src/liboconfig/parser.y index 8df2c6e5..49cd139d 100644 --- a/src/liboconfig/parser.y +++ b/src/liboconfig/parser.y @@ -30,6 +30,7 @@ extern int yylineno; extern char *yytext; extern oconfig_item_t *ci_root; +extern char *c_file; %} %start entire_file @@ -64,6 +65,9 @@ extern oconfig_item_t *ci_root; %type statement_list %type entire_file +/* pass an verbose, specific error message to yyerror() */ +%error-verbose + %% string: QUOTED_STRING {$$ = unquote ($1);} @@ -192,7 +196,15 @@ entire_file: %% static int yyerror (const char *s) { - fprintf (stderr, "Error in line %i near `%s': %s\n", yylineno, yytext, s); + char *text; + + if (*yytext == '\n') + text = ""; + else + text = yytext; + + fprintf (stderr, "Parse error in file `%s', line %i near `%s': %s\n", + c_file, yylineno, text, s); return (-1); } /* int yyerror */