Mesa (master): glsl/pp: Report correct error line for purify and tokeniser errors.

Michał Król michal at kemper.freedesktop.org
Sun Dec 20 12:21:24 PST 2009


Module: Mesa
Branch: master
Commit: e9aa65d2b751f81fecd365fd6a550562417a3ec2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e9aa65d2b751f81fecd365fd6a550562417a3ec2

Author: Michal Krol <michal at vmware.com>
Date:   Sat Dec 19 09:55:27 2009 +0100

glsl/pp: Report correct error line for purify and tokeniser errors.

---

 src/glsl/pp/sl_pp_context.c |   14 ++++++++++++++
 src/glsl/pp/sl_pp_context.h |    1 +
 src/glsl/pp/sl_pp_public.h  |    5 +++++
 src/glsl/pp/sl_pp_token.c   |    3 +--
 4 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/src/glsl/pp/sl_pp_context.c b/src/glsl/pp/sl_pp_context.c
index afc1b84..2ce5079 100644
--- a/src/glsl/pp/sl_pp_context.c
+++ b/src/glsl/pp/sl_pp_context.c
@@ -56,6 +56,7 @@ sl_pp_context_create(void)
    context->if_ptr = SL_PP_MAX_IF_NESTING;
    context->if_value = 1;
    memset(context->error_msg, 0, sizeof(context->error_msg));
+   context->error_line = 1;
    context->line = 1;
    context->file = 0;
 
@@ -79,6 +80,19 @@ sl_pp_context_error_message(const struct sl_pp_context *context)
    return context->error_msg;
 }
 
+void
+sl_pp_context_error_position(const struct sl_pp_context *context,
+                             unsigned int *file,
+                             unsigned int *line)
+{
+   if (file) {
+      *file = 0;
+   }
+   if (line) {
+      *line = context->error_line;
+   }
+}
+
 int
 sl_pp_context_add_predefined(struct sl_pp_context *context,
                              const char *name,
diff --git a/src/glsl/pp/sl_pp_context.h b/src/glsl/pp/sl_pp_context.h
index d95d29e..fa93914 100644
--- a/src/glsl/pp/sl_pp_context.h
+++ b/src/glsl/pp/sl_pp_context.h
@@ -71,6 +71,7 @@ struct sl_pp_context {
    unsigned int if_value;
 
    char error_msg[SL_PP_MAX_ERROR_MSG];
+   unsigned int error_line;
 
    unsigned int line;
    unsigned int file;
diff --git a/src/glsl/pp/sl_pp_public.h b/src/glsl/pp/sl_pp_public.h
index 0769036..9d0a08c 100644
--- a/src/glsl/pp/sl_pp_public.h
+++ b/src/glsl/pp/sl_pp_public.h
@@ -45,6 +45,11 @@ sl_pp_context_destroy(struct sl_pp_context *context);
 const char *
 sl_pp_context_error_message(const struct sl_pp_context *context);
 
+void
+sl_pp_context_error_position(const struct sl_pp_context *context,
+                             unsigned int *file,
+                             unsigned int *line);
+
 int
 sl_pp_context_add_extension(struct sl_pp_context *context,
                             const char *name,
diff --git a/src/glsl/pp/sl_pp_token.c b/src/glsl/pp/sl_pp_token.c
index e9a60b6..d1abbd5 100644
--- a/src/glsl/pp/sl_pp_token.c
+++ b/src/glsl/pp/sl_pp_token.c
@@ -39,13 +39,12 @@ static int
 _pure_getc(struct sl_pp_context *context)
 {
    char c;
-   unsigned int current_line;
 
    if (context->getc_buf_size) {
       return context->getc_buf[--context->getc_buf_size];
    }
 
-   if (sl_pp_purify_getc(&context->pure, &c, &current_line, context->error_msg, sizeof(context->error_msg)) == 0) {
+   if (sl_pp_purify_getc(&context->pure, &c, &context->error_line, context->error_msg, sizeof(context->error_msg)) == 0) {
       return PURE_ERROR;
    }
    return c;



More information about the mesa-commit mailing list