misc/lemon.c
changeset 829 7b3c3ae9e5a9
parent 809 d0fcadcc93b4
child 830 b15b3c3b5c4a
equal deleted inserted replaced
828:32b964418dcc 829:7b3c3ae9e5a9
    36 
    36 
    37 #ifdef TEST
    37 #ifdef TEST
    38 #define MAXRHS 5       /* Set low to exercise exception code */
    38 #define MAXRHS 5       /* Set low to exercise exception code */
    39 #else
    39 #else
    40 #define MAXRHS 1000
    40 #define MAXRHS 1000
       
    41 #endif
       
    42 
       
    43 #if __MOJOSHADER__
       
    44 static const char **made_files = NULL;
       
    45 static int made_files_count = 0;
       
    46 static void lemon_exit(const int status)
       
    47 {
       
    48     /* if we failed, delete (most) files we made, to unconfuse build tools. */
       
    49     int i;
       
    50     for (i = 0; i < made_files_count; i++) {
       
    51         if (status != 0) {
       
    52             remove(made_files[i]);
       
    53         }
       
    54         free((void *) made_files[i]);
       
    55     }
       
    56     free(made_files);
       
    57     made_files_count = 0;
       
    58     made_files = NULL;
       
    59     exit(status);
       
    60 }
       
    61 #define exit(x) lemon_exit(x)
    41 #endif
    62 #endif
    42 
    63 
    43 static char *msort(char*,char**,int(*)(const char*,const char*));
    64 static char *msort(char*,char**,int(*)(const char*,const char*));
    44 
    65 
    45 /*
    66 /*
  2831   if( fp==0 && *mode=='w' ){
  2852   if( fp==0 && *mode=='w' ){
  2832     fprintf(stderr,"Can't open file \"%s\".\n",lemp->outname);
  2853     fprintf(stderr,"Can't open file \"%s\".\n",lemp->outname);
  2833     lemp->errorcnt++;
  2854     lemp->errorcnt++;
  2834     return 0;
  2855     return 0;
  2835   }
  2856   }
       
  2857 #if __MOJOSHADER__
       
  2858   /* don't include .out files: this is debug information, and you don't want
       
  2859      it deleted if there was an error you need to track down. */
       
  2860   if(( *mode=='w' ) && (strcmp(suffix, ".out") != 0)){
       
  2861     const char **ptr = (const char **)
       
  2862         realloc(made_files, sizeof (const char **) * (made_files_count + 1));
       
  2863     char *fname = strdup(lemp->outname);
       
  2864     if ((ptr == NULL) || (fname == NULL)) {
       
  2865         free(ptr);
       
  2866         free(fname);
       
  2867         memory_error();
       
  2868     }
       
  2869     made_files = ptr;
       
  2870     made_files[made_files_count++] = fname;
       
  2871   }
       
  2872 #endif
  2836   return fp;
  2873   return fp;
  2837 }
  2874 }
  2838 
  2875 
  2839 /* Duplicate the input file without comments and without actions 
  2876 /* Duplicate the input file without comments and without actions 
  2840 ** on rules */
  2877 ** on rules */