/[texinfo]/texinfo/util/texindex.c
ViewVC logotype

Diff of /texinfo/util/texindex.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by karl, Tue Oct 15 21:48:42 2002 UTC revision 1.4 by karl, Fri Oct 25 00:32:51 2002 UTC
# Line 97  long nlines; Line 97  long nlines;
97  /* Directory to use for temporary files.  On Unix, it ends with a slash.  */  /* Directory to use for temporary files.  On Unix, it ends with a slash.  */
98  char *tempdir;  char *tempdir;
99    
 /* Start of filename to use for temporary files.  */  
 char *tempbase;  
   
100  /* Number of last temporary file.  */  /* Number of last temporary file.  */
101  int tempcount;  int tempcount;
102    
# Line 184  main (argc, argv) Line 181  main (argc, argv)
181    
182    decode_command (argc, argv);    decode_command (argc, argv);
183    
   tempbase = mktemp (concat ("txiXXXXXX", "", ""));  
   
184    /* Process input files completely, one by one.  */    /* Process input files completely, one by one.  */
185    
186    for (i = 0; i < num_infiles; i++)    for (i = 0; i < num_infiles; i++)
# Line 384  For more information about these matters Line 379  For more information about these matters
379      usage (1);      usage (1);
380  }  }
381    
382  /* Return a name for a temporary file. */  /* Return a name for temporary file COUNT. */
383    
384  static char *  static char *
385  maketempname (count)  maketempname (count)
386       int count;       int count;
387  {  {
388      static char *tempbase = NULL;
389    char tempsuffix[10];    char tempsuffix[10];
390    
391      if (!tempbase)
392        {
393          int fd;
394          char *tmpdir = getenv ("TEMPDIR");
395          if (!tmpdir)
396            tmpdir = "/tmp";
397          tempbase = concat (tmpdir, "/txidxXXXXXX");
398    
399          fd = mkstemp (tempbase);
400          if (fd == -1)
401            pfatal_with_name (tempbase);
402        }
403    
404    sprintf (tempsuffix, ".%d", count);    sprintf (tempsuffix, ".%d", count);
405    return concat (tempdir, tempbase, tempsuffix);    return concat (tempdir, tempbase, tempsuffix);
406  }  }
407    
408    
409  /* Delete all temporary files up to TO_COUNT. */  /* Delete all temporary files up to TO_COUNT. */
410    
411  void  void

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26