Mesa (master): glsl/apps: Print error line number in compile.

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


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

Author: Michal Krol <michal at vmware.com>
Date:   Sun Dec 20 13:51:38 2009 +0100

glsl/apps: Print error line number in compile.

---

 src/glsl/apps/compile.c |   36 +++++++++++++-----------------------
 1 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/src/glsl/apps/compile.c b/src/glsl/apps/compile.c
index b116542..4181281 100644
--- a/src/glsl/apps/compile.c
+++ b/src/glsl/apps/compile.c
@@ -50,9 +50,7 @@ main(int argc,
    struct sl_pp_purify_options options;
    char errmsg[100] = "";
    struct sl_pp_context *context;
-   struct sl_pp_token_info *tokens;
    unsigned int version;
-   unsigned int tokens_eaten;
    struct sl_pp_token_info *outtokens;
    FILE *out;
    unsigned int i, j;
@@ -118,7 +116,7 @@ main(int argc,
 
    memset(&options, 0, sizeof(options));
 
-   context = sl_pp_context_create();
+   context = sl_pp_context_create(inbuf, &options);
    if (!context) {
       fprintf(out, "$CONTEXERROR\n");
 
@@ -128,24 +126,12 @@ main(int argc,
       return 0;
    }
 
-   if (sl_pp_tokenise(context, inbuf, &options, &tokens)) {
-      fprintf(out, "$ERROR: `%s'\n", sl_pp_context_error_message(context));
-
-      printf("Error: %s.\n", sl_pp_context_error_message(context));
-      sl_pp_context_destroy(context);
-      free(inbuf);
-      fclose(out);
-      return 0;
-   }
-
-   free(inbuf);
-
-   if (sl_pp_version(context, tokens, &version, &tokens_eaten)) {
+   if (sl_pp_version(context, &version)) {
       fprintf(out, "$ERROR: `%s'\n", sl_pp_context_error_message(context));
 
       printf("Error: %s\n", sl_pp_context_error_message(context));
       sl_pp_context_destroy(context);
-      free(tokens);
+      free(inbuf);
       fclose(out);
       return 0;
    }
@@ -156,22 +142,26 @@ main(int argc,
 
       printf("Error: %s\n", sl_pp_context_error_message(context));
       sl_pp_context_destroy(context);
-      free(tokens);
+      free(inbuf);
       fclose(out);
       return 0;
    }
 
-   if (sl_pp_process(context, &tokens[tokens_eaten], &outtokens)) {
-      fprintf(out, "$ERROR: `%s'\n", sl_pp_context_error_message(context));
+   if (sl_pp_process(context, &outtokens)) {
+      unsigned int errline;
 
-      printf("Error: %s\n", sl_pp_context_error_message(context));
+      sl_pp_context_error_position(context, NULL, &errline);
+
+      fprintf(out, "$ERROR: (%u) `%s'\n", errline, sl_pp_context_error_message(context));
+
+      printf("Error: (%u) %s\n", errline, sl_pp_context_error_message(context));
       sl_pp_context_destroy(context);
-      free(tokens);
+      free(inbuf);
       fclose(out);
       return 0;
    }
 
-   free(tokens);
+   free(inbuf);
 
    for (i = j = 0; outtokens[i].token != SL_PP_EOF; i++) {
       switch (outtokens[i].token) {



More information about the mesa-commit mailing list