From c9529c4d7727e0ff9da71f0941746e4d213dd689 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 18 Jun 2010 19:54:25 -0700 Subject: [PATCH] glcpp: Add glcpp_warning for printing warnings to the info log. --- glcpp/glcpp.h | 5 +++++ glcpp/pp.c | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/glcpp/glcpp.h b/glcpp/glcpp.h index 8167a481d5e..bb0ac95aedf 100644 --- a/glcpp/glcpp.h +++ b/glcpp/glcpp.h @@ -167,9 +167,14 @@ glcpp_parser_parse (glcpp_parser_t *parser); void glcpp_parser_destroy (glcpp_parser_t *parser); +/* Functions for writing to the info log */ + void glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...); +void +glcpp_warning (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 846d35506fb..eaca4819ce5 100644 --- a/glcpp/pp.c +++ b/glcpp/pp.c @@ -40,6 +40,22 @@ glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...) parser->info_log = talloc_strdup_append(parser->info_log, "\n"); } +void +glcpp_warning (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...) +{ + parser->info_log = talloc_asprintf_append(parser->info_log, + "%u:%u(%u): " + "preprocessor warning: ", + locp->source, + locp->first_line, + locp->first_column); + va_list ap; + va_start(ap, fmt); + parser->info_log = talloc_vasprintf_append(parser->info_log, fmt, ap); + va_end(ap); + parser->info_log = talloc_strdup_append(parser->info_log, "\n"); +} + extern int preprocess(void *talloc_ctx, const char **shader, size_t *shader_len) { -- 2.30.2