glcpp: Introduce new glcpp_error function.
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 17 Jun 2010 19:03:25 +0000 (12:03 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 21 Jun 2010 19:31:02 +0000 (12:31 -0700)
glcpp/glcpp-parse.y
glcpp/glcpp.h
glcpp/pp.c

index f26dd9a0dbc4718295d34ae9fb5169d62be6d888..d7a104893a03bd619e092ecee6118f96083a99b9 100644 (file)
@@ -879,8 +879,7 @@ _token_list_print (glcpp_parser_t *parser, token_list_t *list)
 void
 yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error)
 {
-       glcpp_printf(parser->errors, "%u:%u(%u): preprocessor error: %s\n",
-                    locp->source, locp->first_line, locp->first_column, error);
+       glcpp_error(locp, parser, "%s", error);
 }
 
 glcpp_parser_t *
index 2d4c84796bacf2c815a7d46f7af3e2d8f3e685ce..45bbff3ad4ab970d23f5c286dd4997d9ad03a805 100644 (file)
@@ -165,6 +165,9 @@ glcpp_parser_parse (glcpp_parser_t *parser);
 void
 glcpp_parser_destroy (glcpp_parser_t *parser);
 
+void
+glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...);
+
 /* Generated by glcpp-lex.l to glcpp-lex.c */
 
 int
index 04ea0a479725969a1ac748e5b59b495960a0fc28..5d1ff8c6823c4cd780bf2060291e88c8cf91ec6c 100644 (file)
 
 #include "glcpp.h"
 
+void
+glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...)
+{
+        parser->errors = talloc_asprintf_append(parser->errors, "%u:%u(%u): "
+                                               "preprocessor error: ",
+                                               locp->source, locp->first_line,
+                                               locp->first_column);
+        va_list ap;
+        va_start(ap, fmt);
+        parser->errors = talloc_vasprintf_append(parser->errors, fmt, ap);
+        va_end(ap);
+        parser->errors = talloc_strdup_append(parser->errors, "\n");
+}
+
 extern int
 preprocess(void *talloc_ctx, const char **shader, size_t *shader_len)
 {