summaryrefslogtreecommitdiff
path: root/src/sort.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1999-04-19 02:39:09 +0000
committerJim Meyering <jim@meyering.net>1999-04-19 02:39:09 +0000
commit95e8d410ffab515a56d8475a25f6bf64967c3791 (patch)
tree3b7cdc382749c39abdd363016f4dbb0674552c1c /src/sort.c
parentd3b1ca9174959a97a28ce9298d8b3631517ba052 (diff)
downloadcoreutils-95e8d410ffab515a56d8475a25f6bf64967c3791.tar.xz
(tempname): Wrap after 99999 only for length-impaired file systems.
Diffstat (limited to 'src/sort.c')
-rw-r--r--src/sort.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/sort.c b/src/sort.c
index 5918b6a6f..a0fb854c2 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -439,8 +439,6 @@ tempname (void)
int long_file_names = NAME_MAX_IN_DIR (temp_dir) > 12;
struct tempnode *node;
- node = (struct tempnode *) xmalloc (sizeof (struct tempnode));
-
/* If long filenames aren't supported, we cannot use filenames
longer than 8+3 and still assume they are unique. */
if (long_file_names)
@@ -450,21 +448,19 @@ tempname (void)
(len && temp_dir[len - 1] != '/') ? "/" : "",
(unsigned int) getpid () & 0xffff, seq);
else
- {
- sprintf (name, "%s%ss%5.5d%2.2d.%3.3d",
- temp_dir,
- (len && temp_dir[len - 1] != '/') ? "/" : "",
- (unsigned int) getpid () & 0xffff, seq / 1000, seq % 1000);
-
- /* FIXME: fail if seq exceeds 99999 -- at which point sort
- would start reusing temporary file names. */
- }
+ sprintf (name, "%s%ss%5.5d%2.2d.%3.3d",
+ temp_dir,
+ (len && temp_dir[len - 1] != '/') ? "/" : "",
+ (unsigned int) getpid () & 0xffff, seq / 1000, seq % 1000);
- /* Make sure that SEQ's value fits in 5 digits. */
++seq;
- if (seq >= 100000)
+
+ /* Make sure that SEQ's value fits in 5 digits if temp_dir is on
+ an 8.3 filesystem. */
+ if (!long_file_names && seq >= 100000)
seq = 0;
+ node = (struct tempnode *) xmalloc (sizeof (struct tempnode));
node->name = name;
node->next = temphead.next;
temphead.next = node;