finderrors.c
changeset 503 ec8e7739cf5d
parent 475 ea119c8ce5cd
child 507 0dd7a913f498
equal deleted inserted replaced
502:3cb501248990 503:ec8e7739cf5d
    49     {
    49     {
    50         report("FAIL: user requested quit!\n");
    50         report("FAIL: user requested quit!\n");
    51         return 0;
    51         return 0;
    52     } // if
    52     } // if
    53 
    53 
    54     if (strstr(fn, ".bytecode") == NULL)
    54     int assembly = 0;
       
    55     if (strstr(fn, ".bytecode") != NULL)
       
    56         assembly = 0;
       
    57     else if (strstr(fn, ".disasm") != NULL)
       
    58         assembly = 1;
       
    59     else
    55         return 1;
    60         return 1;
    56 
    61 
    57     (*total)++;
    62     (*total)++;
    58 
    63 
    59     char *fname = (char *) alloca(strlen(fn) + strlen(dname) + 1);
    64     char *fname = (char *) alloca(strlen(fn) + strlen(dname) + 1);
    70     fclose(io);
    75     fclose(io);
    71     if (rc == -1)
    76     if (rc == -1)
    72     {
    77     {
    73         report("FAIL: %s %s\n", fname, strerror(errno));
    78         report("FAIL: %s %s\n", fname, strerror(errno));
    74         return 1;
    79         return 1;
       
    80     } // if
       
    81 
       
    82     if (assembly)
       
    83     {
       
    84         const MOJOSHADER_parseData *a;
       
    85 
       
    86         a = MOJOSHADER_assemble((char *) buf, 0, 0, 0);
       
    87         if (a->error)
       
    88         {
       
    89             report("FAIL: %s %s\n", fname, a->error);
       
    90             return 1;
       
    91         } // if
       
    92 
       
    93         else if (a->output_len > sizeof (buf))
       
    94         {
       
    95             report("FAIL: %s buffer overflow in finderrors.c\n", fname);
       
    96             return 1;
       
    97         } // if
       
    98 
       
    99         rc = a->output_len;
       
   100         memcpy(buf, a->output, rc);
       
   101         MOJOSHADER_freeParseData(a);
    75     } // if
   102     } // if
    76 
   103 
    77     #if FINDERRORS_COMPILE_SHADERS
   104     #if FINDERRORS_COMPILE_SHADERS
    78     MOJOSHADER_glShader *shader = MOJOSHADER_glCompileShader(buf, rc, NULL, 0);
   105     MOJOSHADER_glShader *shader = MOJOSHADER_glCompileShader(buf, rc, NULL, 0);
    79     if (shader == NULL)
   106     if (shader == NULL)
   173         #endif
   200         #endif
   174 
   201 
   175         for (i = 2; i < argc; i++)
   202         for (i = 2; i < argc; i++)
   176             total += do_dir(argv[i], profile);
   203             total += do_dir(argv[i], profile);
   177 
   204 
   178         printf("Saw %d bytecode files.\n", total);
   205         printf("Saw %d files.\n", total);
   179 
   206 
   180         #if FINDERRORS_COMPILE_SHADERS
   207         #if FINDERRORS_COMPILE_SHADERS
   181         MOJOSHADER_glDestroyContext(ctx);
   208         MOJOSHADER_glDestroyContext(ctx);
   182         SDL_Quit();
   209         SDL_Quit();
   183         #endif
   210         #endif