Mesa (glsl-pp-rework-2): glsl/apps: Always write out error condition.

Michał Król michal at kemper.freedesktop.org
Wed Sep 16 20:04:33 UTC 2009


Module: Mesa
Branch: glsl-pp-rework-2
Commit: cc629940d4a47c998d0ed5dbcc0f396025932e0e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=cc629940d4a47c998d0ed5dbcc0f396025932e0e

Author: Michal Krol <michal at vmware.com>
Date:   Wed Sep 16 22:04:22 2009 +0200

glsl/apps: Always write out error condition.

---

 src/glsl/apps/process.c |   31 ++++++++++++++++++++++++-------
 1 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/src/glsl/apps/process.c b/src/glsl/apps/process.c
index a11f974..678b100 100644
--- a/src/glsl/apps/process.c
+++ b/src/glsl/apps/process.c
@@ -64,14 +64,26 @@ main(int argc,
    size = ftell(in);
    fseek(in, 0, SEEK_SET);
 
+   out = fopen(argv[2], "wb");
+   if (!out) {
+      fclose(in);
+      return 1;
+   }
+
    inbuf = malloc(size + 1);
    if (!inbuf) {
+      fprintf(out, "$OOMERROR\n");
+
+      fclose(out);
       fclose(in);
       return 1;
    }
 
    if (fread(inbuf, 1, size, in) != size) {
+      fprintf(out, "$READERROR\n");
+
       free(inbuf);
+      fclose(out);
       fclose(in);
       return 1;
    }
@@ -82,36 +94,41 @@ main(int argc,
    memset(&options, 0, sizeof(options));
 
    if (sl_pp_purify(inbuf, &options, &outbuf)) {
+      fprintf(out, "$PURIFYERROR\n");
+
       free(inbuf);
+      fclose(out);
       return 1;
    }
 
    free(inbuf);
 
    if (sl_pp_context_init(&context)) {
+      fprintf(out, "$CONTEXERROR\n");
+
       free(outbuf);
+      fclose(out);
       return 1;
    }
 
    if (sl_pp_tokenise(&context, outbuf, &tokens)) {
+      fprintf(out, "$ERROR: `%s'\n", context.error_msg);
+
       sl_pp_context_destroy(&context);
       free(outbuf);
+      fclose(out);
       return 1;
    }
 
    free(outbuf);
 
    if (sl_pp_version(&context, tokens, &version, &tokens_eaten)) {
-      sl_pp_context_destroy(&context);
-      free(tokens);
-      return -1;
-   }
+      fprintf(out, "$ERROR: `%s'\n", context.error_msg);
 
-   out = fopen(argv[2], "wb");
-   if (!out) {
       sl_pp_context_destroy(&context);
       free(tokens);
-      return 1;
+      fclose(out);
+      return -1;
    }
 
    if (sl_pp_process(&context, &tokens[tokens_eaten], &outtokens)) {




More information about the mesa-commit mailing list