From: Jim Meyering Date: Mon, 19 Apr 1999 02:39:09 +0000 (+0000) Subject: (tempname): Wrap after 99999 only for length-impaired file systems. X-Git-Tag: TEXTUTILS-1_22j~11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=95e8d410ffab515a56d8475a25f6bf64967c3791;p=thirdparty%2Fcoreutils.git (tempname): Wrap after 99999 only for length-impaired file systems. --- diff --git a/src/sort.c b/src/sort.c index 5918b6a6fc..a0fb854c21 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;