index 5d7b98dfc7e63b7f828de38f7d948a226149450d..49cd139dbd76bd1e4505b3184194d6066a1be11b 100644 (file)
--- a/src/liboconfig/parser.y
+++ b/src/liboconfig/parser.y
extern char *yytext;
extern oconfig_item_t *ci_root;
+extern char *c_file;
%}
%start entire_file
%type <sl> statement_list
%type <ci> entire_file
+/* pass an verbose, specific error message to yyerror() */
+%error-verbose
+
%%
string:
QUOTED_STRING {$$ = unquote ($1);}
%%
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 = "<newline>";
+ 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 */
if ((len < 2) || (ret[0] != '"') || (ret[len - 1] != '"'))
return (ret);
- ret++;
len -= 2;
+ memmove (ret, ret + 1, len);
ret[len] = '\0';
for (i = 0; i < len; i++)