[BACK]Return to main.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / yacc

Diff for /src/usr.bin/yacc/main.c between version 1.15 and 1.16

version 1.15, 2002/02/16 21:28:00 version 1.16, 2003/04/16 17:43:37
Line 67 
Line 67 
   
 char *symbol_prefix;  char *symbol_prefix;
 char *file_prefix = "y";  char *file_prefix = "y";
 char *temp_form = "yacc.XXXXXXXXXXX";  
   
 int lineno;  int lineno;
 int outline;  int outline;
Line 306 
Line 305 
     return (p);      return (p);
 }  }
   
   #define TEMPNAME(s, c, d, l)    \
           (asprintf(&(s), "%.*s/yacc.%xXXXXXXXXXX", (int)(l), (d), (c)))
   
 void  void
 create_file_names()  create_file_names()
 {  {
     int i, len;      size_t len;
     char *tmpdir;      char *tmpdir;
   
     if (!(tmpdir = getenv("TMPDIR")))      if ((tmpdir = getenv("TMPDIR")) == NULL || *tmpdir == '\0')
         tmpdir = _PATH_TMP;          tmpdir = _PATH_TMP;
   
     len = strlen(tmpdir);      len = strlen(tmpdir);
     i = len + strlen(temp_form) + 1;      if (tmpdir[len-1] == '/')
     if (len && tmpdir[len-1] != '/')          len--;
         ++i;  
   
     action_file_name = MALLOC(i);      if (TEMPNAME(action_file_name, 'a', tmpdir, len) == -1 ||
     if (action_file_name == 0) no_space();          TEMPNAME(text_file_name, 'r', tmpdir, len) == -1 ||
     text_file_name = MALLOC(i);          TEMPNAME(union_file_name, 'u', tmpdir, len) == -1)
     if (text_file_name == 0) no_space();          no_space();
     union_file_name = MALLOC(i);  
     if (union_file_name == 0) no_space();  
   
     strcpy(action_file_name, tmpdir);      if (output_file_name == NULL)
     strcpy(text_file_name, tmpdir);  
     strcpy(union_file_name, tmpdir);  
   
     if (len && tmpdir[len - 1] != '/')  
     {      {
         action_file_name[len] = '/';          if (asprintf(&output_file_name, "%s%s", file_prefix, OUTPUT_SUFFIX)
         text_file_name[len] = '/';              == -1)
         union_file_name[len] = '/';  
         ++len;  
     }  
   
     strcpy(action_file_name + len, temp_form);  
     strcpy(text_file_name + len, temp_form);  
     strcpy(union_file_name + len, temp_form);  
   
     action_file_name[len + 5] = 'a';  
     text_file_name[len + 5] = 't';  
     union_file_name[len + 5] = 'u';  
   
     len = strlen(file_prefix);  
   
     if (!output_file_name)  
     {  
         output_file_name = MALLOC(len + 7);  
         if (output_file_name == 0)  
             no_space();              no_space();
         strcpy(output_file_name, file_prefix);  
         strcpy(output_file_name + len, OUTPUT_SUFFIX);  
     }      }
   
     if (rflag)      if (rflag) {
     {          if (asprintf(&code_file_name, "%s%s", file_prefix, CODE_SUFFIX) == -1)
         code_file_name = MALLOC(len + 8);  
         if (code_file_name == 0)  
             no_space();              no_space();
         strcpy(code_file_name, file_prefix);      } else
         strcpy(code_file_name + len, CODE_SUFFIX);  
     }  
     else  
         code_file_name = output_file_name;          code_file_name = output_file_name;
   
     if (dflag)      if (dflag)
Line 375 
Line 345 
         {          {
             char *suffix;              char *suffix;
   
             defines_file_name = MALLOC(strlen(output_file_name)+1);              defines_file_name = strdup(output_file_name);
             if (defines_file_name == 0)              if (defines_file_name == 0)
                 no_space();                  no_space();
             strcpy(defines_file_name, output_file_name);  
   
             /* does the output_file_name have a known suffix */              /* does the output_file_name have a known suffix */
             if ((suffix = strrchr(output_file_name, '.')) != 0 &&              if ((suffix = strrchr(output_file_name, '.')) != 0 &&
Line 403 
Line 372 
         }          }
         else          else
         {          {
             defines_file_name = MALLOC(len + 7);              if (asprintf(&defines_file_name, "%s%s", file_prefix,
             if (defines_file_name == 0)                  DEFINES_SUFFIX) == -1)
                 no_space();                  no_space();
             strcpy(defines_file_name, file_prefix);  
             strcpy(defines_file_name + len, DEFINES_SUFFIX);  
         }          }
     }      }
   
     if (vflag)      if (vflag)
     {      {
         verbose_file_name = MALLOC(len + 8);          if (asprintf(&verbose_file_name, "%s%s", file_prefix,
         if (verbose_file_name == 0)              VERBOSE_SUFFIX) == -1)
             no_space();              no_space();
         strcpy(verbose_file_name, file_prefix);  
         strcpy(verbose_file_name + len, VERBOSE_SUFFIX);  
     }      }
 }  }
   

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16