Create new and use new print_error that uses printf style formatting.

yyerror is meant to be called by the parser internal code, and it's interface
is limited. Instead create and call a new error message routine that allows
formatted strings to be used.

yyerror uses the new routine so error formatting remains consistent.

Signed-of-by: John Bonesio <bones@secretlab.ca>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
This commit is contained in:
John Bonesio 2010-10-20 14:44:58 -07:00 committed by Grant Likely
parent 8773e12fa9
commit c0fa2e6d4e
3 changed files with 33 additions and 18 deletions

View file

@ -208,20 +208,25 @@ srcpos_string(struct srcpos *pos)
return pos_str;
}
void
srcpos_verror(struct srcpos *pos, char const *fmt, va_list va)
{
const char *srcstr;
srcstr = srcpos_string(pos);
fprintf(stdout, "Error: %s ", srcstr);
vfprintf(stdout, fmt, va);
fprintf(stdout, "\n");
}
void
srcpos_error(struct srcpos *pos, char const *fmt, ...)
{
const char *srcstr;
va_list va;
va_start(va, fmt);
srcstr = srcpos_string(pos);
fprintf(stderr, "Error: %s ", srcstr);
vfprintf(stderr, fmt, va);
fprintf(stderr, "\n");
srcpos_verror(pos, fmt, va);
va_end(va);
}