Group :: Publishing
RPM: texinfo
Main Changelog Spec Patches Sources Download Gear Bugs and FR Repocop
Patch: texinfo-4.7-owl-alt-texindex-tmp.patch
Download
Download
--- texinfo-4.7/util/texindex.c.orig 2004-03-19 01:26:53 +0300
+++ texinfo-4.7/util/texindex.c 2004-12-30 16:43:21 +0300
@@ -37,8 +37,6 @@ static char *program_name = "texindex";
#define memset(ptr, ignore, count) bzero (ptr, count)
#endif
-char *mktemp (char *);
-
#if !defined (SEEK_SET)
# define SEEK_SET 0
# define SEEK_CUR 1
@@ -146,6 +144,7 @@ void error (const char *format, const ch
void *xmalloc (), *xrealloc ();
char *concat (char *s1, char *s2);
void flush_tempfiles (int to_count);
+void flush_tempfiles_atexit ();
#define MAX_IN_CORE_SORT 500000
@@ -232,7 +231,6 @@ main (int argc, char **argv)
sort_offline (infiles[i], ptr, outfile);
}
- flush_tempfiles (tempcount);
xexit (0);
return 0; /* Avoid bogus warnings. */
}
@@ -310,18 +308,10 @@ decode_command (int argc, char **argv)
/* Store default values into parameter variables. */
- tempdir = getenv ("TMPDIR");
- if (tempdir == NULL)
- tempdir = getenv ("TEMP");
- if (tempdir == NULL)
- tempdir = getenv ("TMP");
- if (tempdir == NULL)
- tempdir = DEFAULT_TMPDIR;
- else
- tempdir = concat (tempdir, "/");
-
keep_tempfiles = 0;
+ atexit(flush_tempfiles_atexit);
+
/* Allocate ARGC input files, which must be enough. */
infiles = (char **) xmalloc (argc * sizeof (char *));
@@ -389,21 +379,17 @@ For more information about these matters
static char *
maketempname (int count)
{
- static char *tempbase = NULL;
- char tempsuffix[10];
+ char tempsuffix[sizeof(int)*3 + 2];
- if (!tempbase)
+ if (!tempdir)
{
- int fd;
- tempbase = concat (tempdir, "txidxXXXXXX");
-
- fd = mkstemp (tempbase);
- if (fd == -1)
- pfatal_with_name (tempbase);
+ tempdir = concat(getenv ("TMPDIR") ?: P_tmpdir, "/txi.XXXXXX");
+ if (!mkdtemp (tempdir))
+ fatal ("mkdtemp failed for %s", tempdir);
}
- sprintf (tempsuffix, ".%d", count);
- return concat (tempbase, tempsuffix);
+ sprintf (tempsuffix, "/%d", count);
+ return concat (tempdir, tempsuffix);
}
@@ -416,6 +402,13 @@ flush_tempfiles (int to_count)
return;
while (last_deleted_tempcount < to_count)
unlink (maketempname (++last_deleted_tempcount));
+ if (tempdir) rmdir (tempdir);
+}
+
+void
+flush_tempfiles_atexit (void)
+{
+ flush_tempfiles (tempcount);
}
@@ -1622,7 +1615,7 @@ concat (char *s1, char *s2)
strcpy (result, s1);
strcpy (result + len1, s2);
- *(result + len1 + len2) = 0;
+ result[len1 + len2] = 0;
return result;
}