# HG changeset patch # User Gerd Moellmann # Date 955717400 0 # Node ID f10b492946d2f2aef95bb4f0942539389261973d # Parent 5ab6194573ed7b83e14be3299dfb717a244c357a (MAKE_LOCK_NAME): Allocate 2 more bytes. (fill_in_lock_file_name): Avoid existing files that aren't links. diff -r 5ab6194573ed -r f10b492946d2 src/filelock.c --- a/src/filelock.c Fri Apr 14 12:47:38 2000 +0000 +++ b/src/filelock.c Fri Apr 14 13:03:20 2000 +0000 @@ -311,9 +311,11 @@ /* Write the name of the lock file for FN into LFNAME. Length will be - that of FN plus two more for the leading `.#' plus one for the null. */ + that of FN plus two more for the leading `.#' plus 1 for the + trailing period plus one for the digit after it plus one for the + null. */ #define MAKE_LOCK_NAME(lock, file) \ - (lock = (char *) alloca (STRING_BYTES (XSTRING (file)) + 2 + 1), \ + (lock = (char *) alloca (STRING_BYTES (XSTRING (file)) + 2 + 1 + 1 + 1), \ fill_in_lock_file_name (lock, (file))) static void @@ -322,6 +324,8 @@ register Lisp_Object fn; { register char *p; + struct stat st; + int count = 0; strcpy (lockfile, XSTRING (fn)->data); @@ -334,6 +338,18 @@ /* Insert the `.#'. */ p[1] = '.'; p[2] = '#'; + + p = p + strlen (p); + + while (lstat (lockfile, &st) == 0 && !S_ISLNK (st.st_mode)) + { + if (count > 9) + { + *p = '\0'; + return; + } + sprintf (p, ".%d", count++); + } } /* Lock the lock file named LFNAME.