summaryrefslogtreecommitdiff
path: root/srcpos.c
diff options
context:
space:
mode:
authorJohn Bonesio <bones@secretlab.ca>2010-10-20 14:44:58 -0700
committerGrant Likely <grant.likely@secretlab.ca>2010-10-20 22:36:53 -0600
commitc0fa2e6d4e59e62f2e9f23db1a2d94532fa4ae98 (patch)
tree9e465279a18f3a05bc314a0d20db3b3605a17556 /srcpos.c
parent8773e12fa9f5109172a779aa2a83b4464e5273cc (diff)
downloaddtc-c0fa2e6d4e59e62f2e9f23db1a2d94532fa4ae98.tar.gz
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>
Diffstat (limited to 'srcpos.c')
-rw-r--r--srcpos.c21
1 files changed, 13 insertions, 8 deletions
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);
}