HCoop
/
bpt
/
emacs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* font.c (font_delete_unmatched): Now static.
[bpt/emacs.git]
/
src
/
filelock.c
diff --git
a/src/filelock.c
b/src/filelock.c
index
15ed546
..
2138eaa
100644
(file)
--- a/
src/filelock.c
+++ b/
src/filelock.c
@@
-1,6
+1,5
@@
/* Lock files for editing.
/* Lock files for editing.
- Copyright (C) 1985, 1986, 1987, 1993, 1994, 1996, 1998, 1999, 2000, 2001,
- 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+ Copyright (C) 1985-1987, 1993-1994, 1996, 1998-2011
Free Software Foundation, Inc.
This file is part of GNU Emacs.
Free Software Foundation, Inc.
This file is part of GNU Emacs.
@@
-31,14
+30,8
@@
along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#endif
#include <sys/file.h>
#endif
#include <sys/file.h>
-#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#include <fcntl.h>
-#endif
-#include <string.h>
-
-#ifdef HAVE_UNISTD_H
#include <unistd.h>
#include <unistd.h>
-#endif
#ifdef __FreeBSD__
#include <sys/sysctl.h>
#ifdef __FreeBSD__
#include <sys/sysctl.h>
@@
-52,20
+45,12
@@
along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "coding.h"
#include "systime.h"
#include "coding.h"
#include "systime.h"
-/* The directory for writing temporary files. */
-
-Lisp_Object Vtemporary_file_directory;
-
#ifdef CLASH_DETECTION
#ifdef HAVE_UTMP_H
#include <utmp.h>
#endif
#ifdef CLASH_DETECTION
#ifdef HAVE_UTMP_H
#include <utmp.h>
#endif
-#if !defined (S_ISLNK) && defined (S_IFLNK)
-#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
-#endif
-
/* A file whose last-modified time is just after the most recent boot.
Define this to be NULL to disable checking for this file. */
#ifndef BOOT_TIME_FILE
/* A file whose last-modified time is just after the most recent boot.
Define this to be NULL to disable checking for this file. */
#ifndef BOOT_TIME_FILE
@@
-225,9
+210,9
@@
get_boot_time (void)
if (! NILP (filename))
{
if (! NILP (filename))
{
- get_boot_time_1 (SDATA (filename), 1);
+ get_boot_time_1 (S
S
DATA (filename), 1);
if (delete_flag)
if (delete_flag)
- unlink (SDATA (filename));
+ unlink (S
S
DATA (filename));
}
}
}
}
@@
-326,7
+311,7
@@
fill_in_lock_file_name (register char *lockfile, register Lisp_Object fn)
struct stat st;
int count = 0;
struct stat st;
int count = 0;
- strcpy (lockfile, SDATA (fn));
+ strcpy (lockfile, S
S
DATA (fn));
/* Shift the nondirectory part of the file name (including the null)
right two characters. Here is one of the places where we'd have to
/* Shift the nondirectory part of the file name (including the null)
right two characters. Here is one of the places where we'd have to
@@
-359,28
+344,28
@@
static int
lock_file_1 (char *lfname, int force)
{
register int err;
lock_file_1 (char *lfname, int force)
{
register int err;
- time_t boot
_time
;
+ time_t boot;
const char *user_name;
const char *host_name;
char *lock_info_str;
/* Call this first because it can GC. */
const char *user_name;
const char *host_name;
char *lock_info_str;
/* Call this first because it can GC. */
- boot
_time
= get_boot_time ();
+ boot = get_boot_time ();
if (STRINGP (Fuser_login_name (Qnil)))
if (STRINGP (Fuser_login_name (Qnil)))
- user_name =
(char *)
SDATA (Fuser_login_name (Qnil));
+ user_name =
S
SDATA (Fuser_login_name (Qnil));
else
user_name = "";
if (STRINGP (Fsystem_name ()))
else
user_name = "";
if (STRINGP (Fsystem_name ()))
- host_name =
(char *)
SDATA (Fsystem_name ());
+ host_name =
S
SDATA (Fsystem_name ());
else
host_name = "";
lock_info_str = (char *)alloca (strlen (user_name) + strlen (host_name)
+ LOCK_PID_MAX + 30);
else
host_name = "";
lock_info_str = (char *)alloca (strlen (user_name) + strlen (host_name)
+ LOCK_PID_MAX + 30);
- if (boot
_time
)
+ if (boot)
sprintf (lock_info_str, "%s@%s.%lu:%lu", user_name, host_name,
sprintf (lock_info_str, "%s@%s.%lu:%lu", user_name, host_name,
- (unsigned long) getpid (), (unsigned long) boot
_time
);
+ (unsigned long) getpid (), (unsigned long) boot);
else
sprintf (lock_info_str, "%s@%s.%lu", user_name, host_name,
(unsigned long) getpid ());
else
sprintf (lock_info_str, "%s@%s.%lu", user_name, host_name,
(unsigned long) getpid ());
@@
-397,7
+382,7
@@
lock_file_1 (char *lfname, int force)
/* Return 1 if times A and B are no more than one second apart. */
/* Return 1 if times A and B are no more than one second apart. */
-int
+
static
int
within_one_second (time_t a, time_t b)
{
return (a - b >= -1 && a - b <= 1);
within_one_second (time_t a, time_t b)
{
return (a - b >= -1 && a - b <= 1);
@@
-486,7
+471,7
@@
current_lock_owner (lock_info_type *owner, char *lfname)
/* On current host? */
if (STRINGP (Fsystem_name ())
/* On current host? */
if (STRINGP (Fsystem_name ())
- && strcmp (owner->host, SDATA (Fsystem_name ())) == 0)
+ && strcmp (owner->host, S
S
DATA (Fsystem_name ())) == 0)
{
if (owner->pid == getpid ())
ret = 2; /* We own it. */
{
if (owner->pid == getpid ())
ret = 2; /* We own it. */
@@
-648,9
+633,9
@@
unlock_all_files (void)
for (tail = Vbuffer_alist; CONSP (tail); tail = XCDR (tail))
{
b = XBUFFER (XCDR (XCAR (tail)));
for (tail = Vbuffer_alist; CONSP (tail); tail = XCDR (tail))
{
b = XBUFFER (XCDR (XCAR (tail)));
- if (STRINGP (
b->file_truename
) && BUF_SAVE_MODIFF (b) < BUF_MODIFF (b))
+ if (STRINGP (
BVAR (b, file_truename)
) && BUF_SAVE_MODIFF (b) < BUF_MODIFF (b))
{
{
- unlock_file(
b->file_truename
);
+ unlock_file(
BVAR (b, file_truename)
);
}
}
}
}
}
}
@@
-663,7
+648,7
@@
or else nothing is done if current buffer isn't visiting a file. */)
(Lisp_Object file)
{
if (NILP (file))
(Lisp_Object file)
{
if (NILP (file))
- file =
current_buffer->file_truename
;
+ file =
BVAR (current_buffer, file_truename)
;
else
CHECK_STRING (file);
if (SAVE_MODIFF < MODIFF
else
CHECK_STRING (file);
if (SAVE_MODIFF < MODIFF
@@
-680,8
+665,8
@@
should not be locked in that case. */)
(void)
{
if (SAVE_MODIFF < MODIFF
(void)
{
if (SAVE_MODIFF < MODIFF
- && STRINGP (
current_buffer->file_truename
))
- unlock_file (
current_buffer->file_truename
);
+ && STRINGP (
BVAR (current_buffer, file_truename)
))
+ unlock_file (
BVAR (current_buffer, file_truename)
);
return Qnil;
}
return Qnil;
}
@@
-691,8
+676,8
@@
void
unlock_buffer (struct buffer *buffer)
{
if (BUF_SAVE_MODIFF (buffer) < BUF_MODIFF (buffer)
unlock_buffer (struct buffer *buffer)
{
if (BUF_SAVE_MODIFF (buffer) < BUF_MODIFF (buffer)
- && STRINGP (
buffer->file_truename
))
- unlock_file (
buffer->file_truename
);
+ && STRINGP (
BVAR (buffer, file_truename)
))
+ unlock_file (
BVAR (buffer, file_truename)
);
}
DEFUN ("file-locked-p", Ffile_locked_p, Sfile_locked_p, 1, 1, 0,
}
DEFUN ("file-locked-p", Ffile_locked_p, Sfile_locked_p, 1, 1, 0,
@@
-733,19
+718,18
@@
init_filelock (void)
boot_time_initialized = 0;
}
boot_time_initialized = 0;
}
+#endif /* CLASH_DETECTION */
+
void
syms_of_filelock (void)
{
void
syms_of_filelock (void)
{
- DEFVAR_LISP ("temporary-file-directory",
&
Vtemporary_file_directory,
+ DEFVAR_LISP ("temporary-file-directory", Vtemporary_file_directory,
doc: /* The directory for writing temporary files. */);
Vtemporary_file_directory = Qnil;
doc: /* The directory for writing temporary files. */);
Vtemporary_file_directory = Qnil;
+#ifdef CLASH_DETECTION
defsubr (&Sunlock_buffer);
defsubr (&Slock_buffer);
defsubr (&Sfile_locked_p);
defsubr (&Sunlock_buffer);
defsubr (&Slock_buffer);
defsubr (&Sfile_locked_p);
+#endif
}
}
-
-#endif /* CLASH_DETECTION */
-
-/* arch-tag: e062676d-50b2-4be0-ab96-197c81b181a1
- (do not change this comment) */