mirror of
https://github.com/dgibson/dtc.git
synced 2025-10-13 16:27:39 -04:00
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:
parent
8773e12fa9
commit
c0fa2e6d4e
3 changed files with 33 additions and 18 deletions
21
srcpos.c
21
srcpos.c
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue