]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(tempname): Wrap after 99999 only for length-impaired file systems.
authorJim Meyering <jim@meyering.net>
Mon, 19 Apr 1999 02:39:09 +0000 (02:39 +0000)
committerJim Meyering <jim@meyering.net>
Mon, 19 Apr 1999 02:39:09 +0000 (02:39 +0000)
src/sort.c

index 5918b6a6fc107a961ee6bff28e2209a6018bb0f6..a0fb854c2178d0c1db01298a39aa0009fb500050 100644 (file)
@@ -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;