X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/518eab2f7db71929e4877daa5ebd06b1416e69e6..a00634c20988215a47ec6c00cea85a2eac162597:/src/filelock.c diff --git a/src/filelock.c b/src/filelock.c index 89d3e35021..cad6f83c1d 100644 --- a/src/filelock.c +++ b/src/filelock.c @@ -666,13 +666,8 @@ lock_file (Lisp_Object fn) Lisp_Object orig_fn, encoded_fn; char *lfname; lock_info_type lock_info; - 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. */ @@ -680,7 +675,6 @@ lock_file (Lisp_Object fn) return; orig_fn = fn; - GCPRO1 (fn); fn = Fexpand_file_name (fn, Qnil); #ifdef WINDOWSNT /* Ensure we have only '/' separators, to avoid problems with @@ -690,9 +684,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 +698,33 @@ 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); - } - UNGCPRO; - SAFE_FREE (); + /* 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 (); + } } void