[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 25fde89: Verify file modifications by other program
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] master 25fde89: Verify file modifications by other programs |
Date: |
Fri, 08 May 2015 09:21:27 +0000 |
branch: master
commit 25fde89819f9b782646ee4edd2f32d382ef1b2b1
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>
Verify file modifications by other programs
* src/filelock.c (lock_file): Check whether the file was modified
since it was visited even if 'create-lockfiles' is nil. (Bug#18828)
---
src/filelock.c | 49 +++++++++++++++++++++++++------------------------
1 files changed, 25 insertions(+), 24 deletions(-)
diff --git a/src/filelock.c b/src/filelock.c
index 89d3e35..4ee7a01 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -669,10 +669,6 @@ lock_file (Lisp_Object fn)
struct gcpro gcpro1;
USE_SAFE_ALLOCA;
- /* Don't do locking if the user has opted out. */
- if (! create_lockfiles)
- return;
-
/* Don't do locking while dumping Emacs.
Uncompressing wtmp files uses call-process, which does not work
in an uninitialized Emacs. */
@@ -690,9 +686,6 @@ lock_file (Lisp_Object fn)
#endif
encoded_fn = ENCODE_FILE (fn);
- /* Create the name of the lock-file for file fn */
- MAKE_LOCK_NAME (lfname, encoded_fn);
-
/* See if this file is visited and has changed on disk since it was
visited. */
{
@@ -707,27 +700,35 @@ lock_file (Lisp_Object fn)
}
- /* Try to lock the lock. */
- if (0 < lock_if_free (&lock_info, lfname))
+ /* Don't do locking if the user has opted out. */
+ if (create_lockfiles)
{
- /* Someone else has the lock. Consider breaking it. */
- Lisp_Object attack;
- char *dot = lock_info.dot;
- ptrdiff_t pidlen = lock_info.colon - (dot + 1);
- static char const replacement[] = " (pid ";
- int replacementlen = sizeof replacement - 1;
- memmove (dot + replacementlen, dot + 1, pidlen);
- strcpy (dot + replacementlen + pidlen, ")");
- memcpy (dot, replacement, replacementlen);
- attack = call2 (intern ("ask-user-about-lock"), fn,
- build_string (lock_info.user));
- /* Take the lock if the user said so. */
- if (!NILP (attack))
- lock_file_1 (lfname, 1);
+
+ /* Create the name of the lock-file for file fn */
+ MAKE_LOCK_NAME (lfname, encoded_fn);
+
+ /* Try to lock the lock. */
+ if (0 < lock_if_free (&lock_info, lfname))
+ {
+ /* Someone else has the lock. Consider breaking it. */
+ Lisp_Object attack;
+ char *dot = lock_info.dot;
+ ptrdiff_t pidlen = lock_info.colon - (dot + 1);
+ static char const replacement[] = " (pid ";
+ int replacementlen = sizeof replacement - 1;
+ memmove (dot + replacementlen, dot + 1, pidlen);
+ strcpy (dot + replacementlen + pidlen, ")");
+ memcpy (dot, replacement, replacementlen);
+ attack = call2 (intern ("ask-user-about-lock"), fn,
+ build_string (lock_info.user));
+ /* Take the lock if the user said so. */
+ if (!NILP (attack))
+ lock_file_1 (lfname, 1);
+ }
+ SAFE_FREE ();
}
UNGCPRO;
- SAFE_FREE ();
}
void
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 25fde89: Verify file modifications by other programs,
Eli Zaretskii <=