/* Lock files for editing.
-Copyright (C) 1985-1987, 1993-1994, 1996, 1998-2015 Free Software
+Copyright (C) 1985-1987, 1993-1994, 1996, 1998-2016 Free Software
Foundation, Inc.
Author: Richard King
GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
#include <c-ctype.h>
#include "lisp.h"
-#include "character.h"
#include "buffer.h"
#include "coding.h"
-#include "systime.h"
#ifdef WINDOWSNT
#include <share.h>
#include <sys/socket.h> /* for fcntl */
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. */
return;
orig_fn = fn;
- GCPRO1 (fn);
fn = Fexpand_file_name (fn, Qnil);
#ifdef WINDOWSNT
/* Ensure we have only '/' separators, to avoid problems with
#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. */
{
}
- /* 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