From d65b102950068badc12a990cb39ba285db0a056a Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 12 Dec 2008 00:58:10 -0500 Subject: [PATCH] Let finderrors work on assembly programs. --- finderrors.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/finderrors.c b/finderrors.c index b364570d..ef9e0642 100644 --- a/finderrors.c +++ b/finderrors.c @@ -51,7 +51,12 @@ static int do_file(const char *profile, const char *dname, const char *fn, int * return 0; } // if - if (strstr(fn, ".bytecode") == NULL) + int assembly = 0; + if (strstr(fn, ".bytecode") != NULL) + assembly = 0; + else if (strstr(fn, ".disasm") != NULL) + assembly = 1; + else return 1; (*total)++; @@ -74,6 +79,28 @@ static int do_file(const char *profile, const char *dname, const char *fn, int * return 1; } // if + if (assembly) + { + const MOJOSHADER_parseData *a; + + a = MOJOSHADER_assemble((char *) buf, 0, 0, 0); + if (a->error) + { + report("FAIL: %s %s\n", fname, a->error); + return 1; + } // if + + else if (a->output_len > sizeof (buf)) + { + report("FAIL: %s buffer overflow in finderrors.c\n", fname); + return 1; + } // if + + rc = a->output_len; + memcpy(buf, a->output, rc); + MOJOSHADER_freeParseData(a); + } // if + #if FINDERRORS_COMPILE_SHADERS MOJOSHADER_glShader *shader = MOJOSHADER_glCompileShader(buf, rc, NULL, 0); if (shader == NULL) @@ -175,7 +202,7 @@ int main(int argc, char **argv) for (i = 2; i < argc; i++) total += do_dir(argv[i], profile); - printf("Saw %d bytecode files.\n", total); + printf("Saw %d files.\n", total); #if FINDERRORS_COMPILE_SHADERS MOJOSHADER_glDestroyContext(ctx);