utils/testparse.c
changeset 902 cff5841d29e7
parent 901 a9f799b93150
child 1019 e8988ca01c6d
equal deleted inserted replaced
901:a9f799b93150 902:cff5841d29e7
    52 
    52 
    53     return NULL;  // shouldn't hit this.
    53     return NULL;  // shouldn't hit this.
    54 } // shader_type
    54 } // shader_type
    55 
    55 
    56 
    56 
    57 static int do_parse(const unsigned char *buf, const int len, const char *prof)
    57 static int do_parse(const char *fname, const unsigned char *buf,
       
    58                     const int len, const char *prof)
    58 {
    59 {
    59     const MOJOSHADER_parseData *pd;
    60     const MOJOSHADER_parseData *pd;
    60     int retval = 0;
    61     int retval = 0;
    61 
    62 
    62     pd = MOJOSHADER_parse(prof, buf, len, NULL, 0, Malloc, Free, NULL);
    63     pd = MOJOSHADER_parse(prof, buf, len, NULL, 0, Malloc, Free, NULL);
    65     {
    66     {
    66         int i;
    67         int i;
    67         for (i = 0; i < pd->error_count; i++)
    68         for (i = 0; i < pd->error_count; i++)
    68         {
    69         {
    69             printf("%s:%d: ERROR: %s\n",
    70             printf("%s:%d: ERROR: %s\n",
    70                     pd->errors[i].filename ? pd->errors[i].filename : "???",
    71                     pd->errors[i].filename ? pd->errors[i].filename : fname,
    71                     pd->errors[i].error_position,
    72                     pd->errors[i].error_position,
    72                     pd->errors[i].error);
    73                     pd->errors[i].error);
    73         } // for
    74         } // for
    74     } // if
    75     } // if
    75     else
    76     else
   226             else
   227             else
   227             {
   228             {
   228                 unsigned char *buf = (unsigned char *) malloc(1000000);
   229                 unsigned char *buf = (unsigned char *) malloc(1000000);
   229                 int rc = fread(buf, 1, 1000000, io);
   230                 int rc = fread(buf, 1, 1000000, io);
   230                 fclose(io);
   231                 fclose(io);
   231                 if (!do_parse(buf, rc, profile))
   232                 if (!do_parse(argv[i], buf, rc, profile))
   232                     retval = 1;
   233                     retval = 1;
   233                 free(buf);
   234                 free(buf);
   234             } // else
   235             } // else
   235         } // for
   236         } // for
   236     } // else
   237     } // else