From c04c29eb738367ad605adc00fa19a00ec092f01f Mon Sep 17 00:00:00 2001 From: icculus Date: Thu, 27 Mar 2008 23:22:33 -0400 Subject: [PATCH] [svn] More testparse tweakage. --HG-- branch : trunk --- testparse.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/testparse.c b/testparse.c index 62162fb2..7c6d206f 100644 --- a/testparse.c +++ b/testparse.c @@ -42,19 +42,22 @@ static const char *shader_type(const MOJOSHADER_shaderType s) } // shader_type -static void do_parse(unsigned char *buf, int len, const char *prof) +static void do_parse(const unsigned char *buf, const int len, const char *prof) { const MOJOSHADER_parseData *pd; pd = MOJOSHADER_parse(prof, buf, len, Malloc, Free); printf("PROFILE: %s\n", prof); - printf("SHADER TYPE: %s\n", shader_type(pd->shader_type)); - printf("VERSION: %d.%d\n", pd->major_ver, pd->minor_ver); - printf("INSTRUCTION COUNT: %d\n", (int) pd->instruction_count); if (pd->error != NULL) printf("ERROR: %s\n", pd->error); - if (pd->output != NULL) - printf("OUTPUT:\n%s\n", pd->output); + else + { + printf("SHADER TYPE: %s\n", shader_type(pd->shader_type)); + printf("VERSION: %d.%d\n", pd->major_ver, pd->minor_ver); + printf("INSTRUCTION COUNT: %d\n", (int) pd->instruction_count); + if (pd->output != NULL) + printf("OUTPUT:\n%s\n", pd->output); + } // else printf("\n\n"); MOJOSHADER_freeParseData(pd); } // do_parse @@ -62,30 +65,30 @@ static void do_parse(unsigned char *buf, int len, const char *prof) int main(int argc, char **argv) { - int i; - printf("MojoShader testparse\n"); printf("Compiled against version %d\n", MOJOSHADER_VERSION); printf("Linked against version %d\n", MOJOSHADER_version()); printf("\n"); - if (argc == 1) - printf("No files specified.\n"); + if (argc <= 2) + printf("\n\nUSAGE: %s [file1] ... [fileN]\n\n", argv[0]); else { - for (i = 1; i < argc; i++) + const char *profile = argv[1]; + int i; + + for (i = 2; i < argc; i++) { FILE *io = fopen(argv[i], "rb"); printf("FILE: %s\n", argv[i]); if (io == NULL) - printf("fopen('%s') failed.\n", argv[i]); + printf(" ... fopen('%s') failed.\n", argv[i]); else { unsigned char *buf = (unsigned char *) malloc(1000000); int rc = fread(buf, 1, 1000000, io); fclose(io); - do_parse(buf, rc, MOJOSHADER_PROFILE_D3D); - do_parse(buf, rc, MOJOSHADER_PROFILE_GLSL); + do_parse(buf, rc, profile); free(buf); } // else } // for