commit: change name of lock file to avoid problems with etags, byte-recompile-directory, etc.

Ben Wing ben at xemacs.org
Thu Feb 4 06:58:52 EST 2010


changeset:   4972:c448f4c38d65
tag:         tip
user:        Ben Wing <ben at xemacs.org>
date:        Thu Feb 04 05:58:40 2010 -0600
files:       src/ChangeLog src/filelock.c
description:
change name of lock file to avoid problems with etags, byte-recompile-directory, etc.

-------------------- ChangeLog entries follow: --------------------

src/ChangeLog addition:

2010-02-04  Ben Wing  <ben at xemacs.org>

	* filelock.c:
	* filelock.c (fill_in_lock_file_name):
	Name the lock symlink file .#FN# instead of .#FN for file FN, so
	that the link file doesn't have a .c or .el or whatever extension,
	which confuses programs/functions that search by extension (e.g.
	etags, byte-recompile-directory, etc.).


diff -r bcdf496e49d0 -r c448f4c38d65 src/ChangeLog
--- a/src/ChangeLog	Thu Feb 04 05:55:25 2010 -0600
+++ b/src/ChangeLog	Thu Feb 04 05:58:40 2010 -0600
@@ -1,3 +1,12 @@
+2010-02-04  Ben Wing  <ben at xemacs.org>
+
+	* filelock.c:
+	* filelock.c (fill_in_lock_file_name):
+	Name the lock symlink file .#FN# instead of .#FN for file FN, so
+	that the link file doesn't have a .c or .el or whatever extension,
+	which confuses programs/functions that search by extension (e.g.
+	etags, byte-recompile-directory, etc.).
+
 2010-02-04  Ben Wing  <ben at xemacs.org>
 
 	* symbols.c (defsymbol_massage_name_1):
diff -r bcdf496e49d0 -r c448f4c38d65 src/filelock.c
--- a/src/filelock.c	Thu Feb 04 05:55:25 2010 -0600
+++ b/src/filelock.c	Thu Feb 04 05:58:40 2010 -0600
@@ -1,5 +1,5 @@
 /* Copyright (C) 1985, 86, 87, 93, 94, 96 Free Software Foundation, Inc.
-   Copyright (C) 2001 Ben Wing.
+   Copyright (C) 2001, 2010 Ben Wing.
 
 This file is part of XEmacs.
 
@@ -38,7 +38,7 @@
 
 #ifdef CLASH_DETECTION
 
-/* The strategy: to lock a file FN, create a symlink .#FN in FN's
+/* The strategy: to lock a file FN, create a symlink .#FN# in FN's
    directory, with link data `user at host.pid'.  This avoids a single
    mount (== failure) point for lock files.
 
@@ -67,11 +67,17 @@
    file names, because those are all the same systems that don't have
    symlinks.
 
-   This is compatible with the locking scheme used by Interleaf (which
-   has contributed this implementation for Emacs), and was designed by
-   Ethan Jacobson, Kimbo Mundy, and others.
+   Originally we used a name .#FN without the final #; this may have been
+   compatible with the locking scheme used by Interleaf (which has
+   contributed this implementation for Emacs), and was designed by Ethan
+   Jacobson, Kimbo Mundy, and others.
 
    --karl at cs.umb.edu/karl at hq.ileaf.com.  */
+
+/* NOTE:  We added the final # in the name .#FN# so that programs
+   that e.g. search for all .c files, such as etags, or try to
+   byte-compile all .el files in a directory (byte-recompile-directory),
+   won't get tripped up by the bogus symlink file. --ben */
 
 
 /* Here is the structure that stores information about a lock.  */
@@ -93,10 +99,11 @@
     xfree ((i).host, Ibyte *);			\
   } while (0)
 
-/* 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.  */
+/* 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 trailing #
+   plus one for the null.  */
 #define MAKE_LOCK_NAME(lock, file) \
-  (lock = alloca_ibytes (XSTRING_LENGTH (file) + 2 + 1), \
+  (lock = alloca_ibytes (XSTRING_LENGTH (file) + 2 + 1 + 1), \
    fill_in_lock_file_name (lock, file))
 
 static void
@@ -116,7 +123,10 @@
   p = lockfile + dirlen;
   *(p++) = '.';
   *(p++) = '#';
-  memcpy (p, file_name + dirlen, XSTRING_LENGTH (fn) - dirlen + 1);
+  memcpy (p, file_name + dirlen, XSTRING_LENGTH (fn) - dirlen);
+  p += XSTRING_LENGTH (fn) - dirlen;
+  *(p++) = '#';
+  *p = '\0';
 }
 
 /* Lock the lock file named LFNAME.



More information about the XEmacs-Patches mailing list