From c0fa2e6d4e59e62f2e9f23db1a2d94532fa4ae98 Mon Sep 17 00:00:00 2001 From: John Bonesio Date: Wed, 20 Oct 2010 14:44:58 -0700 Subject: 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 Acked-by: David Gibson Signed-off-by: Grant Likely --- srcpos.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'srcpos.c') diff --git a/srcpos.c b/srcpos.c index 87d7f17..2dbc874 100644 --- a/srcpos.c +++ b/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"); + va_start(va, fmt); + srcpos_verror(pos, fmt, va); va_end(va); } -- cgit v1.2.1