linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [DTC PATCH 1/2] Add yyerrorf() for formatted error messages.
@ 2007-12-20 16:48 Scott Wood
  2007-12-21  0:04 ` David Gibson
  0 siblings, 1 reply; 4+ messages in thread
From: Scott Wood @ 2007-12-20 16:48 UTC (permalink / raw)
  To: jdl; +Cc: linuxppc-dev, u-boot-users

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 dtc-parser.y |   16 ++++++++++++++++
 srcpos.h     |    1 +
 2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/dtc-parser.y b/dtc-parser.y
index 002ea7f..4a0181d 100644
--- a/dtc-parser.y
+++ b/dtc-parser.y
@@ -318,6 +318,22 @@ void yyerror (char const *s)
 		fname, yylloc.first_line, s);
 }
 
+void yyerrorf(char const *s, ...)
+{
+	const char *fname = srcpos_filename_for_num(yylloc.filenum);
+	va_list va;
+	va_start(va, s);
+
+	if (strcmp(fname, "-") == 0)
+		fname = "stdin";
+
+	fprintf(stderr, "%s:%d ", fname, yylloc.first_line);
+	vfprintf(stderr, s, va);
+	fprintf(stderr, "\n");
+	
+	va_end(va);
+}
+
 unsigned long long eval_literal(const char *s, int base, int bits)
 {
 	unsigned long long val;
diff --git a/srcpos.h b/srcpos.h
index ce7ab5b..e59c788 100644
--- a/srcpos.h
+++ b/srcpos.h
@@ -63,6 +63,7 @@ typedef struct YYLTYPE {
 
 
 extern void yyerror(char const *);
+extern void yyerrorf(char const *, ...) __attribute__((format(printf, 1, 2)));
 
 extern int srcpos_filenum;
 
-- 
1.5.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-12-22  2:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-20 16:48 [DTC PATCH 1/2] Add yyerrorf() for formatted error messages Scott Wood
2007-12-21  0:04 ` David Gibson
2007-12-21 21:28   ` Scott Wood
2007-12-22  2:43     ` David Gibson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).