summaryrefslogtreecommitdiff
path: root/lib/tempname.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-11-19 11:06:32 +0000
committerJim Meyering <jim@meyering.net>2001-11-19 11:06:32 +0000
commit81ca387201f58ac63280d4176fc4a1dd8a08f64a (patch)
tree593c5128a53da396d69e5552942b87edb3ae01b0 /lib/tempname.c
parent2afb97d4f46b018a55a0bd30c832ef186d7e3b76 (diff)
downloadcoreutils-81ca387201f58ac63280d4176fc4a1dd8a08f64a.tar.xz
(TMP_MAX): Remove; no longer needed.
(TEMPORARIES): New macro. (__gen_tempname): Use TEMPORARIES rather than TMP_MAX. This removes an artificial limitation (e.g. HP-UX 10.20, where TMP_MAX is 17576).
Diffstat (limited to 'lib/tempname.c')
-rw-r--r--lib/tempname.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/tempname.c b/lib/tempname.c
index 0c9853e3b..deae318cf 100644
--- a/lib/tempname.c
+++ b/lib/tempname.c
@@ -32,9 +32,6 @@
#ifndef P_tmpdir
# define P_tmpdir "/tmp"
#endif
-#ifndef TMP_MAX
-# define TMP_MAX 238328
-#endif
#ifndef __GT_FILE
# define __GT_FILE 0
# define __GT_BIGFILE 1
@@ -123,6 +120,11 @@ char *getenv ();
# define uint64_t uintmax_t
#endif
+/* The total number of temporary file names that can exist for a given
+ template is 62**6. On ancient hosts where uint64_t is really 32
+ bits, TEMPORARIES evaluates to 965660736, which is good enough. */
+#define TEMPORARIES ((uint64_t) 62 * 62 * 62 * 62 * 62 * 62)
+
/* Return nonzero if DIR is an existent directory. */
static int
direxists (const char *dir)
@@ -219,7 +221,8 @@ __gen_tempname (char *tmpl, int kind)
char *XXXXXX;
static uint64_t value;
uint64_t random_time_bits;
- int count, fd = -1;
+ uint64_t count;
+ int fd = -1;
int save_errno = errno;
struct_stat64 st;
@@ -245,7 +248,7 @@ __gen_tempname (char *tmpl, int kind)
#endif
value += random_time_bits ^ __getpid ();
- for (count = 0; count < TMP_MAX; value += 7777, ++count)
+ for (count = 0; count < TEMPORARIES; value += 7777, ++count)
{
uint64_t v = value;