From: Kenneth Graunke Date: Thu, 17 Jun 2010 19:03:25 +0000 (-0700) Subject: glcpp: Introduce new glcpp_error function. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f1e6c069fac93dd2b7b2026ccd24833a066c895a;p=mesa.git glcpp: Introduce new glcpp_error function. --- diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y index f26dd9a0dbc..d7a104893a0 100644 --- a/glcpp/glcpp-parse.y +++ b/glcpp/glcpp-parse.y @@ -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 * diff --git a/glcpp/glcpp.h b/glcpp/glcpp.h index 2d4c84796ba..45bbff3ad4a 100644 --- a/glcpp/glcpp.h +++ b/glcpp/glcpp.h @@ -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 diff --git a/glcpp/pp.c b/glcpp/pp.c index 04ea0a47972..5d1ff8c6823 100644 --- a/glcpp/pp.c +++ b/glcpp/pp.c @@ -23,6 +23,20 @@ #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) {