* process.c (allocate_pty): Let PTY_ITERATION declare iteration vars.
[bpt/emacs.git] / src / fileio.c
index 7c0921a..5d33fb9 100644 (file)
@@ -1,7 +1,6 @@
 /* File IO for GNU Emacs.
 /* File IO for GNU Emacs.
-   Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, 1996,
-                 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-                 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+
+Copyright (C) 1985-1988, 1993-2011  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
 
 This file is part of GNU Emacs.
 
@@ -20,31 +19,12 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 #include <limits.h>
 
 #include <config.h>
 #include <limits.h>
-
-#ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #include <fcntl.h>
-#endif
-
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <setjmp.h>
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <setjmp.h>
-
-#ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #include <unistd.h>
-#endif
-
-#if !defined (S_ISLNK) && defined (S_IFLNK)
-#  define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
-#endif
-
-#if !defined (S_ISFIFO) && defined (S_IFIFO)
-#  define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
-#endif
-
-#if !defined (S_ISREG) && defined (S_IFREG)
-#  define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
-#endif
 
 #ifdef HAVE_PWD_H
 #include <pwd.h>
 
 #ifdef HAVE_PWD_H
 #include <pwd.h>
@@ -71,7 +51,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #ifdef WINDOWSNT
 #define NOMINMAX 1
 #include <windows.h>
 #ifdef WINDOWSNT
 #define NOMINMAX 1
 #include <windows.h>
-#include <stdlib.h>
 #include <fcntl.h>
 #endif /* not WINDOWSNT */
 
 #include <fcntl.h>
 #endif /* not WINDOWSNT */
 
@@ -79,7 +58,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "msdos.h"
 #include <sys/param.h>
 #include <fcntl.h>
 #include "msdos.h"
 #include <sys/param.h>
 #include <fcntl.h>
-#include <string.h>
 #endif
 
 #ifdef DOS_NT
 #endif
 
 #ifdef DOS_NT
@@ -89,12 +67,12 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #define IS_DRIVE(x) ((x) >= 'A' && (x) <= 'z')
 #endif
 #ifdef WINDOWSNT
 #define IS_DRIVE(x) ((x) >= 'A' && (x) <= 'z')
 #endif
 #ifdef WINDOWSNT
-#define IS_DRIVE(x) isalpha (x)
+#define IS_DRIVE(x) isalpha ((unsigned char) (x))
 #endif
 /* Need to lower-case the drive letter, or else expanded
    filenames will sometimes compare inequal, because
    `expand-file-name' doesn't always down-case the drive letter.  */
 #endif
 /* Need to lower-case the drive letter, or else expanded
    filenames will sometimes compare inequal, because
    `expand-file-name' doesn't always down-case the drive letter.  */
-#define DRIVE_LETTER(x) (tolower (x))
+#define DRIVE_LETTER(x) (tolower ((unsigned char) (x)))
 #endif
 
 #include "systime.h"
 #endif
 
 #include "systime.h"
@@ -104,20 +82,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #endif
 
 #include "commands.h"
 #endif
 
 #include "commands.h"
-extern int use_dialog_box;
-extern int use_file_dialog;
-
-#ifndef O_WRONLY
-#define O_WRONLY 1
-#endif
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#endif
-
-#ifndef S_ISLNK
-#  define lstat stat
-#endif
 
 #ifndef FILE_SYSTEM_CASE
 #define FILE_SYSTEM_CASE(filename)  (filename)
 
 #ifndef FILE_SYSTEM_CASE
 #define FILE_SYSTEM_CASE(filename)  (filename)
@@ -140,17 +104,6 @@ int auto_save_error_occurred;
    auto saving and recovering a file.  */
 Lisp_Object Qauto_save_coding;
 
    auto saving and recovering a file.  */
 Lisp_Object Qauto_save_coding;
 
-/* Coding system for file names, or nil if none.  */
-Lisp_Object Vfile_name_coding_system;
-
-/* Coding system for file names used only when
-   Vfile_name_coding_system is nil.  */
-Lisp_Object Vdefault_file_name_coding_system;
-
-/* Alist of elements (REGEXP . HANDLER) for file names
-   whose I/O is done with a special handler.  */
-Lisp_Object Vfile_name_handler_alist;
-
 /* Property name of a file name handler,
    which gives a list of operations it handles..  */
 Lisp_Object Qoperations;
 /* Property name of a file name handler,
    which gives a list of operations it handles..  */
 Lisp_Object Qoperations;
@@ -158,51 +111,18 @@ Lisp_Object Qoperations;
 /* Lisp functions for translating file formats */
 Lisp_Object Qformat_decode, Qformat_annotate_function;
 
 /* Lisp functions for translating file formats */
 Lisp_Object Qformat_decode, Qformat_annotate_function;
 
-/* Function to be called to decide a coding system of a reading file.  */
-Lisp_Object Vset_auto_coding_function;
-
-/* Functions to be called to process text properties in inserted file.  */
-Lisp_Object Vafter_insert_file_functions;
-
 /* Lisp function for setting buffer-file-coding-system and the
    multibyteness of the current buffer after inserting a file.  */
 Lisp_Object Qafter_insert_file_set_coding;
 
 /* Lisp function for setting buffer-file-coding-system and the
    multibyteness of the current buffer after inserting a file.  */
 Lisp_Object Qafter_insert_file_set_coding;
 
-/* Functions to be called to create text property annotations for file.  */
-Lisp_Object Vwrite_region_annotate_functions;
 Lisp_Object Qwrite_region_annotate_functions;
 Lisp_Object Qwrite_region_annotate_functions;
-Lisp_Object Vwrite_region_post_annotation_function;
-
-/* During build_annotations, each time an annotation function is called,
-   this holds the annotations made by the previous functions.  */
-Lisp_Object Vwrite_region_annotations_so_far;
-
 /* Each time an annotation function changes the buffer, the new buffer
    is added here.  */
 Lisp_Object Vwrite_region_annotation_buffers;
 
 /* Each time an annotation function changes the buffer, the new buffer
    is added here.  */
 Lisp_Object Vwrite_region_annotation_buffers;
 
-/* File name in which we write a list of all our auto save files.  */
-Lisp_Object Vauto_save_list_file_name;
-
-/* Whether or not files are auto-saved into themselves.  */
-Lisp_Object Vauto_save_visited_file_name;
-
-/* Whether or not to continue auto-saving after a large deletion.  */
-Lisp_Object Vauto_save_include_big_deletions;
-
-/* On NT, specifies the directory separator character, used (eg.) when
-   expanding file names.  This can be bound to / or \. */
-Lisp_Object Vdirectory_sep_char;
-
 #ifdef HAVE_FSYNC
 #ifdef HAVE_FSYNC
-/* Nonzero means skip the call to fsync in Fwrite-region.  */
-int write_region_inhibit_fsync;
 #endif
 
 #endif
 
-/* Non-zero means call move-file-to-trash in Fdelete_file or
-   Fdelete_directory_internal.  */
-int delete_by_moving_to_trash;
-
 Lisp_Object Qdelete_by_moving_to_trash;
 
 /* Lisp function for moving files to trash.  */
 Lisp_Object Qdelete_by_moving_to_trash;
 
 /* Lisp function for moving files to trash.  */
@@ -214,26 +134,9 @@ Lisp_Object Qcopy_directory;
 /* Lisp function for recursively deleting directories.  */
 Lisp_Object Qdelete_directory;
 
 /* Lisp function for recursively deleting directories.  */
 Lisp_Object Qdelete_directory;
 
-extern Lisp_Object Vuser_login_name;
-
 #ifdef WINDOWSNT
 #ifdef WINDOWSNT
-extern Lisp_Object Vw32_get_true_file_attributes;
 #endif
 
 #endif
 
-extern int minibuf_level;
-
-extern int minibuffer_auto_raise;
-
-/* These variables describe handlers that have "already" had a chance
-   to handle the current operation.
-
-   Vinhibit_file_name_handlers is a list of file name handlers.
-   Vinhibit_file_name_operation is the operation being handled.
-   If we try to handle that operation, we ignore those handlers.  */
-
-static Lisp_Object Vinhibit_file_name_handlers;
-static Lisp_Object Vinhibit_file_name_operation;
-
 Lisp_Object Qfile_error, Qfile_already_exists, Qfile_date_error;
 Lisp_Object Qexcl;
 Lisp_Object Qfile_name_history;
 Lisp_Object Qfile_error, Qfile_already_exists, Qfile_date_error;
 Lisp_Object Qexcl;
 Lisp_Object Qfile_name_history;
@@ -273,9 +176,9 @@ report_file_error (const char *string, Lisp_Object data)
          {
            int c;
 
          {
            int c;
 
-           str = (char *) SDATA (errstring);
-           c = STRING_CHAR (str);
-           Faset (errstring, make_number (0), make_number (DOWNCASE (c)));
+           str = SSDATA (errstring);
+           c = STRING_CHAR ((unsigned char *) str);
+           Faset (errstring, make_number (0), make_number (downcase (c)));
          }
 
        xsignal (Qfile_error,
          }
 
        xsignal (Qfile_error,
@@ -405,11 +308,11 @@ Given a Unix syntax file name, returns a string ending in slash.  */)
   (Lisp_Object filename)
 {
 #ifndef DOS_NT
   (Lisp_Object filename)
 {
 #ifndef DOS_NT
-  register const unsigned char *beg;
+  register const char *beg;
 #else
 #else
-  register unsigned char *beg;
+  register char *beg;
 #endif
 #endif
-  register const unsigned char *p;
+  register const char *p;
   Lisp_Object handler;
 
   CHECK_STRING (filename);
   Lisp_Object handler;
 
   CHECK_STRING (filename);
@@ -422,10 +325,10 @@ Given a Unix syntax file name, returns a string ending in slash.  */)
 
   filename = FILE_SYSTEM_CASE (filename);
 #ifdef DOS_NT
 
   filename = FILE_SYSTEM_CASE (filename);
 #ifdef DOS_NT
-  beg = (unsigned char *) alloca (SBYTES (filename) + 1);
-  memcpy (beg, SDATA (filename), SBYTES (filename) + 1);
+  beg = (char *) alloca (SBYTES (filename) + 1);
+  memcpy (beg, SSDATA (filename), SBYTES (filename) + 1);
 #else
 #else
-  beg = SDATA (filename);
+  beg = SSDATA (filename);
 #endif
   p = beg + SBYTES (filename);
 
 #endif
   p = beg + SBYTES (filename);
 
@@ -446,8 +349,8 @@ Given a Unix syntax file name, returns a string ending in slash.  */)
   if (p[-1] == ':')
     {
       /* MAXPATHLEN+1 is guaranteed to be enough space for getdefdir.  */
   if (p[-1] == ':')
     {
       /* MAXPATHLEN+1 is guaranteed to be enough space for getdefdir.  */
-      unsigned char *res = alloca (MAXPATHLEN + 1);
-      unsigned char *r = res;
+      char *res = alloca (MAXPATHLEN + 1);
+      char *r = res;
 
       if (p == beg + 4 && IS_DIRECTORY_SEP (*beg) && beg[1] == ':')
        {
 
       if (p == beg + 4 && IS_DIRECTORY_SEP (*beg) && beg[1] == ':')
        {
@@ -456,7 +359,7 @@ Given a Unix syntax file name, returns a string ending in slash.  */)
          r += 2;
        }
 
          r += 2;
        }
 
-      if (getdefdir (toupper (*beg) - 'A' + 1, r))
+      if (getdefdir (toupper ((unsigned char) *beg) - 'A' + 1, r))
        {
          if (!IS_DIRECTORY_SEP (res[strlen (res) - 1]))
            strcat (res, "/");
        {
          if (!IS_DIRECTORY_SEP (res[strlen (res) - 1]))
            strcat (res, "/");
@@ -478,7 +381,7 @@ this is everything after the last slash,
 or the entire name if it contains no slash.  */)
   (Lisp_Object filename)
 {
 or the entire name if it contains no slash.  */)
   (Lisp_Object filename)
 {
-  register const unsigned char *beg, *p, *end;
+  register const char *beg, *p, *end;
   Lisp_Object handler;
 
   CHECK_STRING (filename);
   Lisp_Object handler;
 
   CHECK_STRING (filename);
@@ -489,7 +392,7 @@ or the entire name if it contains no slash.  */)
   if (!NILP (handler))
     return call2 (handler, Qfile_name_nondirectory, filename);
 
   if (!NILP (handler))
     return call2 (handler, Qfile_name_nondirectory, filename);
 
-  beg = SDATA (filename);
+  beg = SSDATA (filename);
   end = p = beg + SBYTES (filename);
 
   while (p != beg && !IS_DIRECTORY_SEP (p[-1])
   end = p = beg + SBYTES (filename);
 
   while (p != beg && !IS_DIRECTORY_SEP (p[-1])
@@ -530,8 +433,8 @@ get a current directory to run processes in.  */)
 }
 
 \f
 }
 
 \f
-char *
-file_name_as_directory (char *out, char *in)
+static char *
+file_name_as_directory (char *out, const char *in)
 {
   int size = strlen (in) - 1;
 
 {
   int size = strlen (in) - 1;
 
@@ -581,7 +484,7 @@ For a Unix-syntax file name, just appends a slash.  */)
     return call2 (handler, Qfile_name_as_directory, file);
 
   buf = (char *) alloca (SBYTES (file) + 10);
     return call2 (handler, Qfile_name_as_directory, file);
 
   buf = (char *) alloca (SBYTES (file) + 10);
-  file_name_as_directory (buf, SDATA (file));
+  file_name_as_directory (buf, SSDATA (file));
   return make_specified_string (buf, -1, strlen (buf),
                                STRING_MULTIBYTE (file));
 }
   return make_specified_string (buf, -1, strlen (buf),
                                STRING_MULTIBYTE (file));
 }
@@ -593,7 +496,7 @@ For a Unix-syntax file name, just appends a slash.  */)
  * Value is nonzero if the string output is different from the input.
  */
 
  * Value is nonzero if the string output is different from the input.
  */
 
-int
+static int
 directory_file_name (char *src, char *dst)
 {
   long slen;
 directory_file_name (char *src, char *dst)
 {
   long slen;
@@ -640,7 +543,7 @@ In Unix-syntax, this function just removes the final slash.  */)
     return call2 (handler, Qdirectory_file_name, directory);
 
   buf = (char *) alloca (SBYTES (directory) + 20);
     return call2 (handler, Qdirectory_file_name, directory);
 
   buf = (char *) alloca (SBYTES (directory) + 20);
-  directory_file_name (SDATA (directory), buf);
+  directory_file_name (SSDATA (directory), buf);
   return make_specified_string (buf, -1, strlen (buf),
                                STRING_MULTIBYTE (directory));
 }
   return make_specified_string (buf, -1, strlen (buf),
                                STRING_MULTIBYTE (directory));
 }
@@ -681,7 +584,7 @@ make_temp_name (Lisp_Object prefix, int base64_p)
   Lisp_Object val;
   int len, clen;
   int pid;
   Lisp_Object val;
   int len, clen;
   int pid;
-  unsigned char *p, *data;
+  char *p, *data;
   char pidbuf[20];
   int pidlen;
 
   char pidbuf[20];
   int pidlen;
 
@@ -718,8 +621,8 @@ make_temp_name (Lisp_Object prefix, int base64_p)
   val = make_uninit_multibyte_string (clen + 3 + pidlen, len + 3 + pidlen);
   if (!STRING_MULTIBYTE (prefix))
     STRING_SET_UNIBYTE (val);
   val = make_uninit_multibyte_string (clen + 3 + pidlen, len + 3 + pidlen);
   if (!STRING_MULTIBYTE (prefix))
     STRING_SET_UNIBYTE (val);
-  data = SDATA (val);
-  memcpy (data, SDATA (prefix), len);
+  data = SSDATA (val);
+  memcpy (data, SSDATA (prefix), len);
   p = data + len;
 
   memcpy (p, pidbuf, pidlen);
   p = data + len;
 
   memcpy (p, pidbuf, pidlen);
@@ -765,17 +668,13 @@ make_temp_name (Lisp_Object prefix, int base64_p)
               as bad as (and in many cases worse than) throwing the
               error, or to ignore the error, which will likely result
               in looping through 225307 stat's, which is not only
               as bad as (and in many cases worse than) throwing the
               error, or to ignore the error, which will likely result
               in looping through 225307 stat's, which is not only
-              dog-slow, but also useless since it will fallback to
-              the errow below, anyway.  */
+              dog-slow, but also useless since eventually nil would
+              have to be returned anyway.  */
            report_file_error ("Cannot create temporary name for prefix",
                               Fcons (prefix, Qnil));
          /* not reached */
        }
     }
            report_file_error ("Cannot create temporary name for prefix",
                               Fcons (prefix, Qnil));
          /* not reached */
        }
     }
-
-  error ("Cannot create temporary name for prefix `%s'",
-        SDATA (prefix));
-  return Qnil;
 }
 
 
 }
 
 
@@ -807,10 +706,15 @@ DEFUN ("expand-file-name", Fexpand_file_name, Sexpand_file_name, 1, 2, 0,
 Second arg DEFAULT-DIRECTORY is directory to start with if NAME is relative
 \(does not start with slash or tilde); if DEFAULT-DIRECTORY is nil or missing,
 the current buffer's value of `default-directory' is used.
 Second arg DEFAULT-DIRECTORY is directory to start with if NAME is relative
 \(does not start with slash or tilde); if DEFAULT-DIRECTORY is nil or missing,
 the current buffer's value of `default-directory' is used.
+NAME should be a string that is a valid file name for the underlying
+filesystem.
 File name components that are `.' are removed, and
 so are file name components followed by `..', along with the `..' itself;
 note that these simplifications are done without checking the resulting
 file names in the file system.
 File name components that are `.' are removed, and
 so are file name components followed by `..', along with the `..' itself;
 note that these simplifications are done without checking the resulting
 file names in the file system.
+Multiple consecutive slashes are collapsed into a single slash,
+except at the beginning of the file name when they are significant (e.g.,
+UNC file names on MS-Windows.)
 An initial `~/' expands to your home directory.
 An initial `~USER/' expands to USER's home directory.
 See also the function `substitute-in-file-name'.
 An initial `~/' expands to your home directory.
 An initial `~USER/' expands to USER's home directory.
 See also the function `substitute-in-file-name'.
@@ -818,15 +722,16 @@ See also the function `substitute-in-file-name'.
 For technical reasons, this function can return correct but
 non-intuitive results for the root directory; for instance,
 \(expand-file-name ".." "/") returns "/..".  For this reason, use
 For technical reasons, this function can return correct but
 non-intuitive results for the root directory; for instance,
 \(expand-file-name ".." "/") returns "/..".  For this reason, use
-(directory-file-name (file-name-directory dirname)) to traverse a
+\(directory-file-name (file-name-directory dirname)) to traverse a
 filesystem tree, not (expand-file-name ".."  dirname).  */)
   (Lisp_Object name, Lisp_Object default_directory)
 {
   /* These point to SDATA and need to be careful with string-relocation
      during GC (via DECODE_FILE).  */
 filesystem tree, not (expand-file-name ".."  dirname).  */)
   (Lisp_Object name, Lisp_Object default_directory)
 {
   /* These point to SDATA and need to be careful with string-relocation
      during GC (via DECODE_FILE).  */
-  unsigned char *nm, *newdir;
+  char *nm;
+  const char *newdir;
   /* This should only point to alloca'd data.  */
   /* This should only point to alloca'd data.  */
-  unsigned char *target;
+  char *target;
 
   int tlen;
   struct passwd *pw;
 
   int tlen;
   struct passwd *pw;
@@ -850,7 +755,7 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
 
   /* Use the buffer's default-directory if DEFAULT_DIRECTORY is omitted.  */
   if (NILP (default_directory))
 
   /* Use the buffer's default-directory if DEFAULT_DIRECTORY is omitted.  */
   if (NILP (default_directory))
-    default_directory = current_buffer->directory;
+    default_directory = BVAR (current_buffer, directory);
   if (! STRINGP (default_directory))
     {
 #ifdef DOS_NT
   if (! STRINGP (default_directory))
     {
 #ifdef DOS_NT
@@ -862,8 +767,6 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
 
         To avoid this, we set default_directory to the root of the
         current drive.  */
 
         To avoid this, we set default_directory to the root of the
         current drive.  */
-      extern char *emacs_root_dir (void);
-
       default_directory = build_string (emacs_root_dir ());
 #else
       default_directory = build_string ("/");
       default_directory = build_string (emacs_root_dir ());
 #else
       default_directory = build_string ("/");
@@ -878,7 +781,7 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
     }
 
   {
     }
 
   {
-    unsigned char *o = SDATA (default_directory);
+    char *o = SSDATA (default_directory);
 
     /* Make sure DEFAULT_DIRECTORY is properly expanded.
        It would be better to do this down below where we actually use
 
     /* Make sure DEFAULT_DIRECTORY is properly expanded.
        It would be better to do this down below where we actually use
@@ -930,8 +833,8 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
     }
 
   /* Make a local copy of nm[] to protect it from GC in DECODE_FILE below. */
     }
 
   /* Make a local copy of nm[] to protect it from GC in DECODE_FILE below. */
-  nm = (unsigned char *) alloca (SBYTES (name) + 1);
-  memcpy (nm, SDATA (name), SBYTES (name) + 1);
+  nm = (char *) alloca (SBYTES (name) + 1);
+  memcpy (nm, SSDATA (name), SBYTES (name) + 1);
 
 #ifdef DOS_NT
   /* Note if special escape prefix is present, but remove for now.  */
 
 #ifdef DOS_NT
   /* Note if special escape prefix is present, but remove for now.  */
@@ -946,7 +849,7 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
      drive specifier at the beginning.  */
   if (IS_DRIVE (nm[0]) && IS_DEVICE_SEP (nm[1]))
     {
      drive specifier at the beginning.  */
   if (IS_DRIVE (nm[0]) && IS_DEVICE_SEP (nm[1]))
     {
-      drive = nm[0];
+      drive = (unsigned char) nm[0];
       nm += 2;
     }
 
       nm += 2;
     }
 
@@ -985,7 +888,7 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
         non-zero value, that means we've discovered that we can't do
         that cool trick.  */
       int lose = 0;
         non-zero value, that means we've discovered that we can't do
         that cool trick.  */
       int lose = 0;
-      unsigned char *p = nm;
+      char *p = nm;
 
       while (*p)
        {
 
       while (*p)
        {
@@ -1017,13 +920,13 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
 #ifdef WINDOWSNT
          if (IS_DIRECTORY_SEP (nm[1]))
            {
 #ifdef WINDOWSNT
          if (IS_DIRECTORY_SEP (nm[1]))
            {
-             if (strcmp (nm, SDATA (name)) != 0)
+             if (strcmp (nm, SSDATA (name)) != 0)
                name = make_specified_string (nm, -1, strlen (nm), multibyte);
            }
          else
 #endif
          /* drive must be set, so this is okay */
                name = make_specified_string (nm, -1, strlen (nm), multibyte);
            }
          else
 #endif
          /* drive must be set, so this is okay */
-         if (strcmp (nm - 2, SDATA (name)) != 0)
+         if (strcmp (nm - 2, SSDATA (name)) != 0)
            {
              char temp[] = " :";
 
            {
              char temp[] = " :";
 
@@ -1033,7 +936,7 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
            }
          return name;
 #else /* not DOS_NT */
            }
          return name;
 #else /* not DOS_NT */
-         if (strcmp (nm, SDATA (name)) == 0)
+         if (strcmp (nm, SSDATA (name)) == 0)
            return name;
          return make_specified_string (nm, -1, strlen (nm), multibyte);
 #endif /* not DOS_NT */
            return name;
          return make_specified_string (nm, -1, strlen (nm), multibyte);
 #endif /* not DOS_NT */
@@ -1065,8 +968,8 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
        {
          Lisp_Object tem;
 
        {
          Lisp_Object tem;
 
-         if (!(newdir = (unsigned char *) egetenv ("HOME")))
-           newdir = (unsigned char *) "";
+         if (!(newdir = egetenv ("HOME")))
+           newdir = "";
          nm++;
          /* egetenv may return a unibyte string, which will bite us since
             we expect the directory to be multibyte.  */
          nm++;
          /* egetenv may return a unibyte string, which will bite us since
             we expect the directory to be multibyte.  */
@@ -1074,7 +977,7 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
          if (!STRING_MULTIBYTE (tem))
            {
              hdir = DECODE_FILE (tem);
          if (!STRING_MULTIBYTE (tem))
            {
              hdir = DECODE_FILE (tem);
-             newdir = SDATA (hdir);
+             newdir = SSDATA (hdir);
            }
 #ifdef DOS_NT
          collapse_newdir = 0;
            }
 #ifdef DOS_NT
          collapse_newdir = 0;
@@ -1082,7 +985,7 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
        }
       else                     /* ~user/filename */
        {
        }
       else                     /* ~user/filename */
        {
-         unsigned char *o, *p;
+         char *o, *p;
          for (p = nm; *p && (!IS_DIRECTORY_SEP (*p)); p++);
          o = alloca (p - nm + 1);
          memcpy (o, nm, p - nm);
          for (p = nm; *p && (!IS_DIRECTORY_SEP (*p)); p++);
          o = alloca (p - nm + 1);
          memcpy (o, nm, p - nm);
@@ -1093,7 +996,7 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
          UNBLOCK_INPUT;
          if (pw)
            {
          UNBLOCK_INPUT;
          if (pw)
            {
-             newdir = (unsigned char *) pw -> pw_dir;
+             newdir = pw->pw_dir;
              nm = p;
 #ifdef DOS_NT
              collapse_newdir = 0;
              nm = p;
 #ifdef DOS_NT
              collapse_newdir = 0;
@@ -1111,21 +1014,23 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
   if (!newdir && drive)
     {
       /* Get default directory if needed to make nm absolute. */
   if (!newdir && drive)
     {
       /* Get default directory if needed to make nm absolute. */
+      char *adir = NULL;
       if (!IS_DIRECTORY_SEP (nm[0]))
        {
       if (!IS_DIRECTORY_SEP (nm[0]))
        {
-         newdir = alloca (MAXPATHLEN + 1);
-         if (!getdefdir (toupper (drive) - 'A' + 1, newdir))
-           newdir = NULL;
+         adir = alloca (MAXPATHLEN + 1);
+         if (!getdefdir (toupper (drive) - 'A' + 1, adir))
+           adir = NULL;
        }
        }
-      if (!newdir)
+      if (!adir)
        {
          /* Either nm starts with /, or drive isn't mounted. */
        {
          /* Either nm starts with /, or drive isn't mounted. */
-         newdir = alloca (4);
-         newdir[0] = DRIVE_LETTER (drive);
-         newdir[1] = ':';
-         newdir[2] = '/';
-         newdir[3] = 0;
+         adir = alloca (4);
+         adir[0] = DRIVE_LETTER (drive);
+         adir[1] = ':';
+         adir[2] = '/';
+         adir[3] = 0;
        }
        }
+      newdir = adir;
     }
 #endif /* DOS_NT */
 
     }
 #endif /* DOS_NT */
 
@@ -1142,7 +1047,7 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
 #endif
       && !newdir)
     {
 #endif
       && !newdir)
     {
-      newdir = SDATA (default_directory);
+      newdir = SSDATA (default_directory);
 #ifdef DOS_NT
       /* Note if special escape prefix is present, but remove for now.  */
       if (newdir[0] == '/' && newdir[1] == ':')
 #ifdef DOS_NT
       /* Note if special escape prefix is present, but remove for now.  */
       if (newdir[0] == '/' && newdir[1] == ':')
@@ -1172,10 +1077,10 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
             when we have pointers into lisp strings, we accomplish this
             indirectly by prepending newdir to nm if necessary, and using
             cwd (or the wd of newdir's drive) as the new newdir. */
             when we have pointers into lisp strings, we accomplish this
             indirectly by prepending newdir to nm if necessary, and using
             cwd (or the wd of newdir's drive) as the new newdir. */
-
+         char *adir;
          if (IS_DRIVE (newdir[0]) && IS_DEVICE_SEP (newdir[1]))
            {
          if (IS_DRIVE (newdir[0]) && IS_DEVICE_SEP (newdir[1]))
            {
-             drive = newdir[0];
+             drive = (unsigned char) newdir[0];
              newdir += 2;
            }
          if (!IS_DIRECTORY_SEP (nm[0]))
              newdir += 2;
            }
          if (!IS_DIRECTORY_SEP (nm[0]))
@@ -1185,14 +1090,15 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
              strcat (tmp, nm);
              nm = tmp;
            }
              strcat (tmp, nm);
              nm = tmp;
            }
-         newdir = alloca (MAXPATHLEN + 1);
+         adir = alloca (MAXPATHLEN + 1);
          if (drive)
            {
          if (drive)
            {
-             if (!getdefdir (toupper (drive) - 'A' + 1, newdir))
+             if (!getdefdir (toupper (drive) - 'A' + 1, adir))
                newdir = "/";
            }
          else
                newdir = "/";
            }
          else
-           getwd (newdir);
+           getwd (adir);
+         newdir = adir;
        }
 
       /* Strip off drive name from prefix, if present. */
        }
 
       /* Strip off drive name from prefix, if present. */
@@ -1209,13 +1115,13 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
 #ifdef WINDOWSNT
          if (IS_DIRECTORY_SEP (newdir[0]) && IS_DIRECTORY_SEP (newdir[1]))
            {
 #ifdef WINDOWSNT
          if (IS_DIRECTORY_SEP (newdir[0]) && IS_DIRECTORY_SEP (newdir[1]))
            {
-             unsigned char *p;
-             newdir = strcpy (alloca (strlen (newdir) + 1), newdir);
-             p = newdir + 2;
+             char *adir = strcpy (alloca (strlen (newdir) + 1), newdir);
+             char *p = adir + 2;
              while (*p && !IS_DIRECTORY_SEP (*p)) p++;
              p++;
              while (*p && !IS_DIRECTORY_SEP (*p)) p++;
              *p = 0;
              while (*p && !IS_DIRECTORY_SEP (*p)) p++;
              p++;
              while (*p && !IS_DIRECTORY_SEP (*p)) p++;
              *p = 0;
+             newdir = adir;
            }
          else
 #endif
            }
          else
 #endif
@@ -1235,7 +1141,7 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
 #endif
          )
        {
 #endif
          )
        {
-         unsigned char *temp = (unsigned char *) alloca (length);
+         char *temp = (char *) alloca (length);
          memcpy (temp, newdir, length - 1);
          temp[length - 1] = 0;
          newdir = temp;
          memcpy (temp, newdir, length - 1);
          temp[length - 1] = 0;
          newdir = temp;
@@ -1251,10 +1157,10 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
   /* Reserve space for drive specifier and escape prefix, since either
      or both may need to be inserted.  (The Microsoft x86 compiler
      produces incorrect code if the following two lines are combined.)  */
   /* Reserve space for drive specifier and escape prefix, since either
      or both may need to be inserted.  (The Microsoft x86 compiler
      produces incorrect code if the following two lines are combined.)  */
-  target = (unsigned char *) alloca (tlen + 4);
+  target = (char *) alloca (tlen + 4);
   target += 4;
 #else  /* not DOS_NT */
   target += 4;
 #else  /* not DOS_NT */
-  target = (unsigned char *) alloca (tlen);
+  target = (char *) alloca (tlen);
 #endif /* not DOS_NT */
   *target = 0;
 
 #endif /* not DOS_NT */
   *target = 0;
 
@@ -1282,8 +1188,8 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
   /* Now canonicalize by removing `//', `/.' and `/foo/..' if they
      appear.  */
   {
   /* Now canonicalize by removing `//', `/.' and `/foo/..' if they
      appear.  */
   {
-    unsigned char *p = target;
-    unsigned char *o = target;
+    char *p = target;
+    char *o = target;
 
     while (*p)
       {
 
     while (*p)
       {
@@ -1315,7 +1221,7 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
                 && (IS_DIRECTORY_SEP (p[3]) || p[3] == 0))
          {
 #ifdef WINDOWSNT
                 && (IS_DIRECTORY_SEP (p[3]) || p[3] == 0))
          {
 #ifdef WINDOWSNT
-           unsigned char *prev_o = o;
+           char *prev_o = o;
 #endif
            while (o != target && (--o) && !IS_DIRECTORY_SEP (*o))
              ;
 #endif
            while (o != target && (--o) && !IS_DIRECTORY_SEP (*o))
              ;
@@ -1455,7 +1361,7 @@ See also the function `substitute-in-file-name'.")
        /* Get past ~ to user */
        unsigned char *user = nm + 1;
        /* Find end of name. */
        /* Get past ~ to user */
        unsigned char *user = nm + 1;
        /* Find end of name. */
-       unsigned char *ptr = (unsigned char *) index (user, '/');
+       unsigned char *ptr = (unsigned char *) strchr (user, '/');
        int len = ptr ? ptr - user : strlen (user);
        /* Copy the user name into temp storage. */
        o = (unsigned char *) alloca (len + 1);
        int len = ptr ? ptr - user : strlen (user);
        /* Copy the user name into temp storage. */
        o = (unsigned char *) alloca (len + 1);
@@ -1542,7 +1448,7 @@ See also the function `substitute-in-file-name'.")
 \f
 /* If /~ or // appears, discard everything through first slash.  */
 static int
 \f
 /* If /~ or // appears, discard everything through first slash.  */
 static int
-file_name_absolute_p (const unsigned char *filename)
+file_name_absolute_p (const char *filename)
 {
   return
     (IS_DIRECTORY_SEP (*filename) || *filename == '~'
 {
   return
     (IS_DIRECTORY_SEP (*filename) || *filename == '~'
@@ -1553,10 +1459,10 @@ file_name_absolute_p (const unsigned char *filename)
      );
 }
 
      );
 }
 
-static unsigned char *
-search_embedded_absfilename (unsigned char *nm, unsigned char *endp)
+static char *
+search_embedded_absfilename (char *nm, char *endp)
 {
 {
-  unsigned char *p, *s;
+  char *p, *s;
 
   for (p = nm + 1; p < endp; p++)
     {
 
   for (p = nm + 1; p < endp; p++)
     {
@@ -1573,7 +1479,7 @@ search_embedded_absfilename (unsigned char *nm, unsigned char *endp)
          for (s = p; *s && (!IS_DIRECTORY_SEP (*s)); s++);
          if (p[0] == '~' && s > p + 1) /* we've got "/~something/" */
            {
          for (s = p; *s && (!IS_DIRECTORY_SEP (*s)); s++);
          if (p[0] == '~' && s > p + 1) /* we've got "/~something/" */
            {
-             unsigned char *o = alloca (s - p + 1);
+             char *o = alloca (s - p + 1);
              struct passwd *pw;
              memcpy (o, p, s - p);
              o [s - p] = 0;
              struct passwd *pw;
              memcpy (o, p, s - p);
              o [s - p] = 0;
@@ -1607,14 +1513,14 @@ If `//' appears, everything up to and including the first of
 those `/' is discarded.  */)
   (Lisp_Object filename)
 {
 those `/' is discarded.  */)
   (Lisp_Object filename)
 {
-  unsigned char *nm;
+  char *nm;
 
 
-  register unsigned char *s, *p, *o, *x, *endp;
-  unsigned char *target = NULL;
+  register char *s, *p, *o, *x, *endp;
+  char *target = NULL;
   int total = 0;
   int substituted = 0;
   int multibyte;
   int total = 0;
   int substituted = 0;
   int multibyte;
-  unsigned char *xnm;
+  char *xnm;
   Lisp_Object handler;
 
   CHECK_STRING (filename);
   Lisp_Object handler;
 
   CHECK_STRING (filename);
@@ -1630,7 +1536,7 @@ those `/' is discarded.  */)
   /* Always work on a copy of the string, in case GC happens during
      decode of environment variables, causing the original Lisp_String
      data to be relocated.  */
   /* Always work on a copy of the string, in case GC happens during
      decode of environment variables, causing the original Lisp_String
      data to be relocated.  */
-  nm = (unsigned char *) alloca (SBYTES (filename) + 1);
+  nm = (char *) alloca (SBYTES (filename) + 1);
   memcpy (nm, SDATA (filename), SBYTES (filename) + 1);
 
 #ifdef DOS_NT
   memcpy (nm, SDATA (filename), SBYTES (filename) + 1);
 
 #ifdef DOS_NT
@@ -1682,7 +1588,7 @@ those `/' is discarded.  */)
          }
 
        /* Copy out the variable name */
          }
 
        /* Copy out the variable name */
-       target = (unsigned char *) alloca (s - o + 1);
+       target = (char *) alloca (s - o + 1);
        strncpy (target, o, s - o);
        target[s - o] = 0;
 #ifdef DOS_NT
        strncpy (target, o, s - o);
        target[s - o] = 0;
 #ifdef DOS_NT
@@ -1690,7 +1596,7 @@ those `/' is discarded.  */)
 #endif /* DOS_NT */
 
        /* Get variable value */
 #endif /* DOS_NT */
 
        /* Get variable value */
-       o = (unsigned char *) egetenv (target);
+       o = egetenv (target);
        if (o)
          {
            /* Don't try to guess a maximum length - UTF8 can use up to
        if (o)
          {
            /* Don't try to guess a maximum length - UTF8 can use up to
@@ -1713,7 +1619,7 @@ those `/' is discarded.  */)
 
   /* If substitution required, recopy the string and do it */
   /* Make space in stack frame for the new copy */
 
   /* If substitution required, recopy the string and do it */
   /* Make space in stack frame for the new copy */
-  xnm = (unsigned char *) alloca (SBYTES (filename) + total + 1);
+  xnm = (char *) alloca (SBYTES (filename) + total + 1);
   x = xnm;
 
   /* Copy the rest of the name through, replacing $ constructs with values */
   x = xnm;
 
   /* Copy the rest of the name through, replacing $ constructs with values */
@@ -1745,7 +1651,7 @@ those `/' is discarded.  */)
          }
 
        /* Copy out the variable name */
          }
 
        /* Copy out the variable name */
-       target = (unsigned char *) alloca (s - o + 1);
+       target = (char *) alloca (s - o + 1);
        strncpy (target, o, s - o);
        target[s - o] = 0;
 #ifdef DOS_NT
        strncpy (target, o, s - o);
        target[s - o] = 0;
 #ifdef DOS_NT
@@ -1753,7 +1659,7 @@ those `/' is discarded.  */)
 #endif /* DOS_NT */
 
        /* Get variable value */
 #endif /* DOS_NT */
 
        /* Get variable value */
-       o = (unsigned char *) egetenv (target);
+       o = egetenv (target);
        if (!o)
          {
            *x++ = '$';
        if (!o)
          {
            *x++ = '$';
@@ -1767,13 +1673,13 @@ those `/' is discarded.  */)
            orig = make_unibyte_string (o, orig_length);
            decoded = DECODE_FILE (orig);
            decoded_length = SBYTES (decoded);
            orig = make_unibyte_string (o, orig_length);
            decoded = DECODE_FILE (orig);
            decoded_length = SBYTES (decoded);
-           strncpy (x, SDATA (decoded), decoded_length);
+           strncpy (x, SSDATA (decoded), decoded_length);
            x += decoded_length;
 
            /* If environment variable needed decoding, return value
               needs to be multibyte.  */
            if (decoded_length != orig_length
            x += decoded_length;
 
            /* If environment variable needed decoding, return value
               needs to be multibyte.  */
            if (decoded_length != orig_length
-               || strncmp (SDATA (decoded), o, orig_length))
+               || strncmp (SSDATA (decoded), o, orig_length))
              multibyte = 1;
          }
       }
              multibyte = 1;
          }
       }
@@ -1832,8 +1738,9 @@ expand_and_dir_to_file (Lisp_Object filename, Lisp_Object defdir)
 
    If QUICK is nonzero, we ask for y or n, not yes or no.  */
 
 
    If QUICK is nonzero, we ask for y or n, not yes or no.  */
 
-void
-barf_or_query_if_file_exists (Lisp_Object absname, unsigned char *querystring, int interactive, struct stat *statptr, int quick)
+static void
+barf_or_query_if_file_exists (Lisp_Object absname, const char *querystring,
+                             int interactive, struct stat *statptr, int quick)
 {
   register Lisp_Object tem, encoded_filename;
   struct stat statbuf;
 {
   register Lisp_Object tem, encoded_filename;
   struct stat statbuf;
@@ -1843,7 +1750,7 @@ barf_or_query_if_file_exists (Lisp_Object absname, unsigned char *querystring, i
 
   /* stat is a good way to tell whether the file exists,
      regardless of what access permissions it has.  */
 
   /* stat is a good way to tell whether the file exists,
      regardless of what access permissions it has.  */
-  if (lstat (SDATA (encoded_filename), &statbuf) >= 0)
+  if (lstat (SSDATA (encoded_filename), &statbuf) >= 0)
     {
       if (! interactive)
        xsignal2 (Qfile_already_exists,
     {
       if (! interactive)
        xsignal2 (Qfile_already_exists,
@@ -1852,7 +1759,7 @@ barf_or_query_if_file_exists (Lisp_Object absname, unsigned char *querystring, i
       tem = format2 ("File %s already exists; %s anyway? ",
                     absname, build_string (querystring));
       if (quick)
       tem = format2 ("File %s already exists; %s anyway? ",
                     absname, build_string (querystring));
       if (quick)
-       tem = Fy_or_n_p (tem);
+       tem = call1 (intern ("y-or-n-p"), tem);
       else
        tem = do_yes_or_no_p (tem);
       UNGCPRO;
       else
        tem = do_yes_or_no_p (tem);
       UNGCPRO;
@@ -1941,7 +1848,7 @@ on the system, we copy the SELinux context of FILE to NEWNAME.  */)
       || INTEGERP (ok_if_already_exists))
     barf_or_query_if_file_exists (newname, "copy to it",
                                  INTEGERP (ok_if_already_exists), &out_st, 0);
       || INTEGERP (ok_if_already_exists))
     barf_or_query_if_file_exists (newname, "copy to it",
                                  INTEGERP (ok_if_already_exists), &out_st, 0);
-  else if (stat (SDATA (encoded_newname), &out_st) < 0)
+  else if (stat (SSDATA (encoded_newname), &out_st) < 0)
     out_st.st_mode = 0;
 
 #ifdef WINDOWSNT
     out_st.st_mode = 0;
 
 #ifdef WINDOWSNT
@@ -1974,7 +1881,7 @@ on the system, we copy the SELinux context of FILE to NEWNAME.  */)
     }
 #else /* not WINDOWSNT */
   immediate_quit = 1;
     }
 #else /* not WINDOWSNT */
   immediate_quit = 1;
-  ifd = emacs_open (SDATA (encoded_file), O_RDONLY, 0);
+  ifd = emacs_open (SSDATA (encoded_file), O_RDONLY, 0);
   immediate_quit = 0;
 
   if (ifd < 0)
   immediate_quit = 0;
 
   if (ifd < 0)
@@ -2003,7 +1910,6 @@ on the system, we copy the SELinux context of FILE to NEWNAME.  */)
                         Fcons (file, Fcons (newname, Qnil)));
     }
 
                         Fcons (file, Fcons (newname, Qnil)));
     }
 
-#if defined (S_ISREG) && defined (S_ISLNK)
   if (input_file_statable_p)
     {
       if (!(S_ISREG (st.st_mode)) && !(S_ISLNK (st.st_mode)))
   if (input_file_statable_p)
     {
       if (!(S_ISREG (st.st_mode)) && !(S_ISLNK (st.st_mode)))
@@ -2015,7 +1921,6 @@ on the system, we copy the SELinux context of FILE to NEWNAME.  */)
          report_file_error ("Non-regular file", Fcons (file, Qnil));
        }
     }
          report_file_error ("Non-regular file", Fcons (file, Qnil));
        }
     }
-#endif /* S_ISREG && S_ISLNK */
 
 #ifdef MSDOS
   /* System's default file type was set to binary by _fmode in emacs.c.  */
 
 #ifdef MSDOS
   /* System's default file type was set to binary by _fmode in emacs.c.  */
@@ -2024,7 +1929,7 @@ on the system, we copy the SELinux context of FILE to NEWNAME.  */)
                    | (NILP (ok_if_already_exists) ? O_EXCL : 0),
                    S_IREAD | S_IWRITE);
 #else  /* not MSDOS */
                    | (NILP (ok_if_already_exists) ? O_EXCL : 0),
                    S_IREAD | S_IWRITE);
 #else  /* not MSDOS */
-  ofd = emacs_open (SDATA (encoded_newname),
+  ofd = emacs_open (SSDATA (encoded_newname),
                    O_WRONLY | O_TRUNC | O_CREAT
                    | (NILP (ok_if_already_exists) ? O_EXCL : 0),
                    0666);
                    O_WRONLY | O_TRUNC | O_CREAT
                    | (NILP (ok_if_already_exists) ? O_EXCL : 0),
                    0666);
@@ -2075,7 +1980,7 @@ on the system, we copy the SELinux context of FILE to NEWNAME.  */)
          EMACS_TIME atime, mtime;
          EMACS_SET_SECS_USECS (atime, st.st_atime, 0);
          EMACS_SET_SECS_USECS (mtime, st.st_mtime, 0);
          EMACS_TIME atime, mtime;
          EMACS_SET_SECS_USECS (atime, st.st_atime, 0);
          EMACS_SET_SECS_USECS (mtime, st.st_mtime, 0);
-         if (set_file_times (SDATA (encoded_newname),
+         if (set_file_times (SSDATA (encoded_newname),
                              atime, mtime))
            xsignal2 (Qfile_date_error,
                      build_string ("Cannot set file date"), newname);
                              atime, mtime))
            xsignal2 (Qfile_date_error,
                      build_string ("Cannot set file date"), newname);
@@ -2109,7 +2014,7 @@ DEFUN ("make-directory-internal", Fmake_directory_internal,
        doc: /* Create a new directory named DIRECTORY.  */)
   (Lisp_Object directory)
 {
        doc: /* Create a new directory named DIRECTORY.  */)
   (Lisp_Object directory)
 {
-  const unsigned char *dir;
+  const char *dir;
   Lisp_Object handler;
   Lisp_Object encoded_dir;
 
   Lisp_Object handler;
   Lisp_Object encoded_dir;
 
@@ -2122,7 +2027,7 @@ DEFUN ("make-directory-internal", Fmake_directory_internal,
 
   encoded_dir = ENCODE_FILE (directory);
 
 
   encoded_dir = ENCODE_FILE (directory);
 
-  dir = SDATA (encoded_dir);
+  dir = SSDATA (encoded_dir);
 
 #ifdef WINDOWSNT
   if (mkdir (dir) != 0)
 
 #ifdef WINDOWSNT
   if (mkdir (dir) != 0)
@@ -2139,14 +2044,13 @@ DEFUN ("delete-directory-internal", Fdelete_directory_internal,
        doc: /* Delete the directory named DIRECTORY.  Does not follow symlinks.  */)
   (Lisp_Object directory)
 {
        doc: /* Delete the directory named DIRECTORY.  Does not follow symlinks.  */)
   (Lisp_Object directory)
 {
-  const unsigned char *dir;
-  Lisp_Object handler;
+  const char *dir;
   Lisp_Object encoded_dir;
 
   CHECK_STRING (directory);
   directory = Fdirectory_file_name (Fexpand_file_name (directory, Qnil));
   encoded_dir = ENCODE_FILE (directory);
   Lisp_Object encoded_dir;
 
   CHECK_STRING (directory);
   directory = Fdirectory_file_name (Fexpand_file_name (directory, Qnil));
   encoded_dir = ENCODE_FILE (directory);
-  dir = SDATA (encoded_dir);
+  dir = SSDATA (encoded_dir);
 
   if (rmdir (dir) != 0)
     report_file_error ("Removing directory", list1 (directory));
 
   if (rmdir (dir) != 0)
     report_file_error ("Removing directory", list1 (directory));
@@ -2191,7 +2095,7 @@ With a prefix argument, TRASH is nil.  */)
 
   encoded_file = ENCODE_FILE (filename);
 
 
   encoded_file = ENCODE_FILE (filename);
 
-  if (0 > unlink (SDATA (encoded_file)))
+  if (0 > unlink (SSDATA (encoded_file)))
     report_file_error ("Removing old name", list1 (filename));
   return Qnil;
 }
     report_file_error ("Removing old name", list1 (filename));
   return Qnil;
 }
@@ -2272,19 +2176,16 @@ This is what happens in interactive use with M-x.  */)
       || INTEGERP (ok_if_already_exists))
     barf_or_query_if_file_exists (newname, "rename to it",
                                  INTEGERP (ok_if_already_exists), 0, 0);
       || INTEGERP (ok_if_already_exists))
     barf_or_query_if_file_exists (newname, "rename to it",
                                  INTEGERP (ok_if_already_exists), 0, 0);
-  if (0 > rename (SDATA (encoded_file), SDATA (encoded_newname)))
+  if (0 > rename (SSDATA (encoded_file), SSDATA (encoded_newname)))
     {
       if (errno == EXDEV)
        {
           int count;
     {
       if (errno == EXDEV)
        {
           int count;
-#ifdef S_IFLNK
           symlink_target = Ffile_symlink_p (file);
           if (! NILP (symlink_target))
             Fmake_symbolic_link (symlink_target, newname,
                                  NILP (ok_if_already_exists) ? Qnil : Qt);
           symlink_target = Ffile_symlink_p (file);
           if (! NILP (symlink_target))
             Fmake_symbolic_link (symlink_target, newname,
                                  NILP (ok_if_already_exists) ? Qnil : Qt);
-          else
-#endif
-         if (!NILP (Ffile_directory_p (file)))
+         else if (!NILP (Ffile_directory_p (file)))
            call4 (Qcopy_directory, file, newname, Qt, Qnil);
          else
            /* We have already prompted if it was an integer, so don't
            call4 (Qcopy_directory, file, newname, Qt, Qnil);
          else
            /* We have already prompted if it was an integer, so don't
@@ -2296,11 +2197,7 @@ This is what happens in interactive use with M-x.  */)
          count = SPECPDL_INDEX ();
          specbind (Qdelete_by_moving_to_trash, Qnil);
 
          count = SPECPDL_INDEX ();
          specbind (Qdelete_by_moving_to_trash, Qnil);
 
-         if (!NILP (Ffile_directory_p (file))
-#ifdef S_IFLNK
-             && NILP (symlink_target)
-#endif
-             )
+         if (!NILP (Ffile_directory_p (file)) && NILP (symlink_target))
            call2 (Qdelete_directory, file, Qt);
          else
            Fdelete_file (file, Qnil);
            call2 (Qdelete_directory, file, Qt);
          else
            Fdelete_file (file, Qnil);
@@ -2359,8 +2256,8 @@ This is what happens in interactive use with M-x.  */)
     barf_or_query_if_file_exists (newname, "make it a new name",
                                  INTEGERP (ok_if_already_exists), 0, 0);
 
     barf_or_query_if_file_exists (newname, "make it a new name",
                                  INTEGERP (ok_if_already_exists), 0, 0);
 
-  unlink (SDATA (newname));
-  if (0 > link (SDATA (encoded_file), SDATA (encoded_newname)))
+  unlink (SSDATA (newname));
+  if (0 > link (SSDATA (encoded_file), SSDATA (encoded_newname)))
     report_file_error ("Adding new name", list2 (file, newname));
 
   UNGCPRO;
     report_file_error ("Adding new name", list2 (file, newname));
 
   UNGCPRO;
@@ -2410,7 +2307,6 @@ This happens for interactive use with M-x.  */)
     RETURN_UNGCPRO (call4 (handler, Qmake_symbolic_link, filename,
                           linkname, ok_if_already_exists));
 
     RETURN_UNGCPRO (call4 (handler, Qmake_symbolic_link, filename,
                           linkname, ok_if_already_exists));
 
-#ifdef S_IFLNK
   encoded_filename = ENCODE_FILE (filename);
   encoded_linkname = ENCODE_FILE (linkname);
 
   encoded_filename = ENCODE_FILE (filename);
   encoded_linkname = ENCODE_FILE (linkname);
 
@@ -2418,31 +2314,31 @@ This happens for interactive use with M-x.  */)
       || INTEGERP (ok_if_already_exists))
     barf_or_query_if_file_exists (linkname, "make it a link",
                                  INTEGERP (ok_if_already_exists), 0, 0);
       || INTEGERP (ok_if_already_exists))
     barf_or_query_if_file_exists (linkname, "make it a link",
                                  INTEGERP (ok_if_already_exists), 0, 0);
-  if (0 > symlink (SDATA (encoded_filename),
-                  SDATA (encoded_linkname)))
+  if (0 > symlink (SSDATA (encoded_filename),
+                  SSDATA (encoded_linkname)))
     {
       /* If we didn't complain already, silently delete existing file.  */
       if (errno == EEXIST)
        {
     {
       /* If we didn't complain already, silently delete existing file.  */
       if (errno == EEXIST)
        {
-         unlink (SDATA (encoded_linkname));
-         if (0 <= symlink (SDATA (encoded_filename),
-                           SDATA (encoded_linkname)))
+         unlink (SSDATA (encoded_linkname));
+         if (0 <= symlink (SSDATA (encoded_filename),
+                           SSDATA (encoded_linkname)))
            {
              UNGCPRO;
              return Qnil;
            }
        }
            {
              UNGCPRO;
              return Qnil;
            }
        }
+      if (errno == ENOSYS)
+       {
+         UNGCPRO;
+         xsignal1 (Qfile_error,
+                   build_string ("Symbolic links are not supported"));
+       }
 
       report_file_error ("Making symbolic link", list2 (filename, linkname));
     }
   UNGCPRO;
   return Qnil;
 
       report_file_error ("Making symbolic link", list2 (filename, linkname));
     }
   UNGCPRO;
   return Qnil;
-
-#else
-  UNGCPRO;
-  xsignal1 (Qfile_error, build_string ("Symbolic links are not supported"));
-
-#endif /* S_IFLNK */
 }
 
 \f
 }
 
 \f
@@ -2453,7 +2349,7 @@ On Unix, this is a name starting with a `/' or a `~'.  */)
   (Lisp_Object filename)
 {
   CHECK_STRING (filename);
   (Lisp_Object filename)
 {
   CHECK_STRING (filename);
-  return file_name_absolute_p (SDATA (filename)) ? Qt : Qnil;
+  return file_name_absolute_p (SSDATA (filename)) ? Qt : Qnil;
 }
 \f
 /* Return nonzero if file FILENAME exists and can be executed.  */
 }
 \f
 /* Return nonzero if file FILENAME exists and can be executed.  */
@@ -2483,13 +2379,13 @@ check_executable (char *filename)
 /* Return nonzero if file FILENAME exists and can be written.  */
 
 static int
 /* Return nonzero if file FILENAME exists and can be written.  */
 
 static int
-check_writable (char *filename)
+check_writable (const char *filename)
 {
 #ifdef MSDOS
   struct stat st;
   if (stat (filename, &st) < 0)
     return 0;
 {
 #ifdef MSDOS
   struct stat st;
   if (stat (filename, &st) < 0)
     return 0;
-  return (st.st_mode & S_IWRITE || (st.st_mode & S_IFMT) == S_IFDIR);
+  return (st.st_mode & S_IWRITE || S_ISDIR (st.st_mode));
 #else /* not MSDOS */
 #ifdef HAVE_EUIDACCESS
   return (euidaccess (filename, 2) >= 0);
 #else /* not MSDOS */
 #ifdef HAVE_EUIDACCESS
   return (euidaccess (filename, 2) >= 0);
@@ -2526,7 +2422,7 @@ Use `file-symlink-p' to test for such links.  */)
 
   absname = ENCODE_FILE (absname);
 
 
   absname = ENCODE_FILE (absname);
 
-  return (stat (SDATA (absname), &statbuf) >= 0) ? Qt : Qnil;
+  return (stat (SSDATA (absname), &statbuf) >= 0) ? Qt : Qnil;
 }
 
 DEFUN ("file-executable-p", Ffile_executable_p, Sfile_executable_p, 1, 1, 0,
 }
 
 DEFUN ("file-executable-p", Ffile_executable_p, Sfile_executable_p, 1, 1, 0,
@@ -2548,7 +2444,7 @@ For a directory, this means you can access files in that directory.  */)
 
   absname = ENCODE_FILE (absname);
 
 
   absname = ENCODE_FILE (absname);
 
-  return (check_executable (SDATA (absname)) ? Qt : Qnil);
+  return (check_executable (SSDATA (absname)) ? Qt : Qnil);
 }
 
 DEFUN ("file-readable-p", Ffile_readable_p, Sfile_readable_p, 1, 1, 0,
 }
 
 DEFUN ("file-readable-p", Ffile_readable_p, Sfile_readable_p, 1, 1, 0,
@@ -2581,17 +2477,17 @@ See also `file-exists-p' and `file-attributes'.  */)
   return Qnil;
 #else /* not DOS_NT and not macintosh */
   flags = O_RDONLY;
   return Qnil;
 #else /* not DOS_NT and not macintosh */
   flags = O_RDONLY;
-#if defined (S_ISFIFO) && defined (O_NONBLOCK)
+#ifdef O_NONBLOCK
   /* Opening a fifo without O_NONBLOCK can wait.
      We don't want to wait.  But we don't want to mess wth O_NONBLOCK
      except in the case of a fifo, on a system which handles it.  */
   /* Opening a fifo without O_NONBLOCK can wait.
      We don't want to wait.  But we don't want to mess wth O_NONBLOCK
      except in the case of a fifo, on a system which handles it.  */
-  desc = stat (SDATA (absname), &statbuf);
+  desc = stat (SSDATA (absname), &statbuf);
   if (desc < 0)
     return Qnil;
   if (S_ISFIFO (statbuf.st_mode))
     flags |= O_NONBLOCK;
 #endif
   if (desc < 0)
     return Qnil;
   if (S_ISFIFO (statbuf.st_mode))
     flags |= O_NONBLOCK;
 #endif
-  desc = emacs_open (SDATA (absname), flags, 0);
+  desc = emacs_open (SSDATA (absname), flags, 0);
   if (desc < 0)
     return Qnil;
   emacs_close (desc);
   if (desc < 0)
     return Qnil;
   emacs_close (desc);
@@ -2619,8 +2515,8 @@ DEFUN ("file-writable-p", Ffile_writable_p, Sfile_writable_p, 1, 1, 0,
     return call2 (handler, Qfile_writable_p, absname);
 
   encoded = ENCODE_FILE (absname);
     return call2 (handler, Qfile_writable_p, absname);
 
   encoded = ENCODE_FILE (absname);
-  if (stat (SDATA (encoded), &statbuf) >= 0)
-    return (check_writable (SDATA (encoded))
+  if (stat (SSDATA (encoded), &statbuf) >= 0)
+    return (check_writable (SSDATA (encoded))
            ? Qt : Qnil);
 
   dir = Ffile_name_directory (absname);
            ? Qt : Qnil);
 
   dir = Ffile_name_directory (absname);
@@ -2636,9 +2532,9 @@ DEFUN ("file-writable-p", Ffile_writable_p, Sfile_writable_p, 1, 1, 0,
      should check ACLs though, which do affect this.  */
   if (stat (SDATA (dir), &statbuf) < 0)
     return Qnil;
      should check ACLs though, which do affect this.  */
   if (stat (SDATA (dir), &statbuf) < 0)
     return Qnil;
-  return (statbuf.st_mode & S_IFMT) == S_IFDIR ? Qt : Qnil;
+  return S_ISDIR (statbuf.st_mode) ? Qt : Qnil;
 #else
 #else
-  return (check_writable (!NILP (dir) ? (char *) SDATA (dir) : "")
+  return (check_writable (!NILP (dir) ? SSDATA (dir) : "")
          ? Qt : Qnil);
 #endif
 }
          ? Qt : Qnil);
 #endif
 }
@@ -2665,9 +2561,9 @@ If there is no error, returns nil.  */)
 
   encoded_filename = ENCODE_FILE (absname);
 
 
   encoded_filename = ENCODE_FILE (absname);
 
-  fd = emacs_open (SDATA (encoded_filename), O_RDONLY, 0);
+  fd = emacs_open (SSDATA (encoded_filename), O_RDONLY, 0);
   if (fd < 0)
   if (fd < 0)
-    report_file_error (SDATA (string), Fcons (filename, Qnil));
+    report_file_error (SSDATA (string), Fcons (filename, Qnil));
   emacs_close (fd);
 
   return Qnil;
   emacs_close (fd);
 
   return Qnil;
@@ -2683,6 +2579,10 @@ points to a nonexistent file.  */)
   (Lisp_Object filename)
 {
   Lisp_Object handler;
   (Lisp_Object filename)
 {
   Lisp_Object handler;
+  char *buf;
+  int bufsize;
+  int valsize;
+  Lisp_Object val;
 
   CHECK_STRING (filename);
   filename = Fexpand_file_name (filename, Qnil);
 
   CHECK_STRING (filename);
   filename = Fexpand_file_name (filename, Qnil);
@@ -2693,13 +2593,6 @@ points to a nonexistent file.  */)
   if (!NILP (handler))
     return call2 (handler, Qfile_symlink_p, filename);
 
   if (!NILP (handler))
     return call2 (handler, Qfile_symlink_p, filename);
 
-#ifdef S_IFLNK
-  {
-  char *buf;
-  int bufsize;
-  int valsize;
-  Lisp_Object val;
-
   filename = ENCODE_FILE (filename);
 
   bufsize = 50;
   filename = ENCODE_FILE (filename);
 
   bufsize = 50;
@@ -2711,7 +2604,7 @@ points to a nonexistent file.  */)
       memset (buf, 0, bufsize);
 
       errno = 0;
       memset (buf, 0, bufsize);
 
       errno = 0;
-      valsize = readlink (SDATA (filename), buf, bufsize);
+      valsize = readlink (SSDATA (filename), buf, bufsize);
       if (valsize == -1)
        {
 #ifdef ERANGE
       if (valsize == -1)
        {
 #ifdef ERANGE
@@ -2729,15 +2622,11 @@ points to a nonexistent file.  */)
   while (valsize >= bufsize);
 
   val = make_string (buf, valsize);
   while (valsize >= bufsize);
 
   val = make_string (buf, valsize);
-  if (buf[0] == '/' && index (buf, ':'))
+  if (buf[0] == '/' && strchr (buf, ':'))
     val = concat2 (build_string ("/:"), val);
   xfree (buf);
   val = DECODE_FILE (val);
   return val;
     val = concat2 (build_string ("/:"), val);
   xfree (buf);
   val = DECODE_FILE (val);
   return val;
-  }
-#else /* not S_IFLNK */
-  return Qnil;
-#endif /* not S_IFLNK */
 }
 
 DEFUN ("file-directory-p", Ffile_directory_p, Sfile_directory_p, 1, 1, 0,
 }
 
 DEFUN ("file-directory-p", Ffile_directory_p, Sfile_directory_p, 1, 1, 0,
@@ -2750,7 +2639,7 @@ See `file-symlink-p' to distinguish symlinks.  */)
   struct stat st;
   Lisp_Object handler;
 
   struct stat st;
   Lisp_Object handler;
 
-  absname = expand_and_dir_to_file (filename, current_buffer->directory);
+  absname = expand_and_dir_to_file (filename, BVAR (current_buffer, directory));
 
   /* If the file name has special constructs in it,
      call the corresponding file handler.  */
 
   /* If the file name has special constructs in it,
      call the corresponding file handler.  */
@@ -2760,9 +2649,9 @@ See `file-symlink-p' to distinguish symlinks.  */)
 
   absname = ENCODE_FILE (absname);
 
 
   absname = ENCODE_FILE (absname);
 
-  if (stat (SDATA (absname), &st) < 0)
+  if (stat (SSDATA (absname), &st) < 0)
     return Qnil;
     return Qnil;
-  return (st.st_mode & S_IFMT) == S_IFDIR ? Qt : Qnil;
+  return S_ISDIR (st.st_mode) ? Qt : Qnil;
 }
 
 DEFUN ("file-accessible-directory-p", Ffile_accessible_directory_p, Sfile_accessible_directory_p, 1, 1, 0,
 }
 
 DEFUN ("file-accessible-directory-p", Ffile_accessible_directory_p, Sfile_accessible_directory_p, 1, 1, 0,
@@ -2803,7 +2692,7 @@ See `file-symlink-p' to distinguish symlinks.  */)
   struct stat st;
   Lisp_Object handler;
 
   struct stat st;
   Lisp_Object handler;
 
-  absname = expand_and_dir_to_file (filename, current_buffer->directory);
+  absname = expand_and_dir_to_file (filename, BVAR (current_buffer, directory));
 
   /* If the file name has special constructs in it,
      call the corresponding file handler.  */
 
   /* If the file name has special constructs in it,
      call the corresponding file handler.  */
@@ -2825,12 +2714,12 @@ See `file-symlink-p' to distinguish symlinks.  */)
 
     if (result < 0)
       return Qnil;
 
     if (result < 0)
       return Qnil;
-    return (st.st_mode & S_IFMT) == S_IFREG ? Qt : Qnil;
+    return S_ISREG (st.st_mode) ? Qt : Qnil;
   }
 #else
   }
 #else
-  if (stat (SDATA (absname), &st) < 0)
+  if (stat (SSDATA (absname), &st) < 0)
     return Qnil;
     return Qnil;
-  return (st.st_mode & S_IFMT) == S_IFREG ? Qt : Qnil;
+  return S_ISREG (st.st_mode) ? Qt : Qnil;
 #endif
 }
 \f
 #endif
 }
 \f
@@ -2850,7 +2739,7 @@ if file does not exist, is not accessible, or SELinux is disabled */)
   context_t context;
 #endif
 
   context_t context;
 #endif
 
-  absname = expand_and_dir_to_file (filename, current_buffer->directory);
+  absname = expand_and_dir_to_file (filename, BVAR (current_buffer, directory));
 
   /* If the file name has special constructs in it,
      call the corresponding file handler.  */
 
   /* If the file name has special constructs in it,
      call the corresponding file handler.  */
@@ -2867,7 +2756,7 @@ if file does not exist, is not accessible, or SELinux is disabled */)
 #if HAVE_LIBSELINUX
   if (is_selinux_enabled ())
     {
 #if HAVE_LIBSELINUX
   if (is_selinux_enabled ())
     {
-      conlength = lgetfilecon (SDATA (absname), &con);
+      conlength = lgetfilecon (SSDATA (absname), &con);
       if (conlength > 0)
        {
          context = context_new (con);
       if (conlength > 0)
        {
          context = context_new (con);
@@ -2908,7 +2797,7 @@ is disabled. */)
   context_t parsed_con;
 #endif
 
   context_t parsed_con;
 #endif
 
-  absname = Fexpand_file_name (filename, current_buffer->directory);
+  absname = Fexpand_file_name (filename, BVAR (current_buffer, directory));
 
   /* If the file name has special constructs in it,
      call the corresponding file handler.  */
 
   /* If the file name has special constructs in it,
      call the corresponding file handler.  */
@@ -2922,34 +2811,35 @@ is disabled. */)
   if (is_selinux_enabled ())
     {
       /* Get current file context. */
   if (is_selinux_enabled ())
     {
       /* Get current file context. */
-      conlength = lgetfilecon (SDATA (encoded_absname), &con);
+      conlength = lgetfilecon (SSDATA (encoded_absname), &con);
       if (conlength > 0)
        {
          parsed_con = context_new (con);
          /* Change the parts defined in the parameter.*/
          if (STRINGP (user))
            {
       if (conlength > 0)
        {
          parsed_con = context_new (con);
          /* Change the parts defined in the parameter.*/
          if (STRINGP (user))
            {
-             if (context_user_set (parsed_con, SDATA (user)))
+             if (context_user_set (parsed_con, SSDATA (user)))
                error ("Doing context_user_set");
            }
          if (STRINGP (role))
            {
                error ("Doing context_user_set");
            }
          if (STRINGP (role))
            {
-             if (context_role_set (parsed_con, SDATA (role)))
+             if (context_role_set (parsed_con, SSDATA (role)))
                error ("Doing context_role_set");
            }
          if (STRINGP (type))
            {
                error ("Doing context_role_set");
            }
          if (STRINGP (type))
            {
-             if (context_type_set (parsed_con, SDATA (type)))
+             if (context_type_set (parsed_con, SSDATA (type)))
                error ("Doing context_type_set");
            }
          if (STRINGP (range))
            {
                error ("Doing context_type_set");
            }
          if (STRINGP (range))
            {
-             if (context_range_set (parsed_con, SDATA (range)))
+             if (context_range_set (parsed_con, SSDATA (range)))
                error ("Doing context_range_set");
            }
 
          /* Set the modified context back to the file. */
                error ("Doing context_range_set");
            }
 
          /* Set the modified context back to the file. */
-         fail = lsetfilecon (SDATA (encoded_absname), context_str (parsed_con));
+         fail = lsetfilecon (SSDATA (encoded_absname),
+                             context_str (parsed_con));
          if (fail)
            report_file_error ("Doing lsetfilecon", Fcons (absname, Qnil));
 
          if (fail)
            report_file_error ("Doing lsetfilecon", Fcons (absname, Qnil));
 
@@ -2975,7 +2865,7 @@ Return nil, if file does not exist or is not accessible.  */)
   struct stat st;
   Lisp_Object handler;
 
   struct stat st;
   Lisp_Object handler;
 
-  absname = expand_and_dir_to_file (filename, current_buffer->directory);
+  absname = expand_and_dir_to_file (filename, BVAR (current_buffer, directory));
 
   /* If the file name has special constructs in it,
      call the corresponding file handler.  */
 
   /* If the file name has special constructs in it,
      call the corresponding file handler.  */
@@ -2985,7 +2875,7 @@ Return nil, if file does not exist or is not accessible.  */)
 
   absname = ENCODE_FILE (absname);
 
 
   absname = ENCODE_FILE (absname);
 
-  if (stat (SDATA (absname), &st) < 0)
+  if (stat (SSDATA (absname), &st) < 0)
     return Qnil;
 
   return make_number (st.st_mode & 07777);
     return Qnil;
 
   return make_number (st.st_mode & 07777);
@@ -3004,7 +2894,7 @@ symbolic notation, like the `chmod' command from GNU Coreutils.  */)
   Lisp_Object absname, encoded_absname;
   Lisp_Object handler;
 
   Lisp_Object absname, encoded_absname;
   Lisp_Object handler;
 
-  absname = Fexpand_file_name (filename, current_buffer->directory);
+  absname = Fexpand_file_name (filename, BVAR (current_buffer, directory));
   CHECK_NUMBER (mode);
 
   /* If the file name has special constructs in it,
   CHECK_NUMBER (mode);
 
   /* If the file name has special constructs in it,
@@ -3015,7 +2905,7 @@ symbolic notation, like the `chmod' command from GNU Coreutils.  */)
 
   encoded_absname = ENCODE_FILE (absname);
 
 
   encoded_absname = ENCODE_FILE (absname);
 
-  if (chmod (SDATA (encoded_absname), XINT (mode)) < 0)
+  if (chmod (SSDATA (encoded_absname), XINT (mode)) < 0)
     report_file_error ("Doing chmod", Fcons (absname, Qnil));
 
   return Qnil;
     report_file_error ("Doing chmod", Fcons (absname, Qnil));
 
   return Qnil;
@@ -3049,31 +2939,30 @@ The value is an integer.  */)
   return value;
 }
 \f
   return value;
 }
 \f
-extern int lisp_time_argument (Lisp_Object, time_t *, int *);
 
 DEFUN ("set-file-times", Fset_file_times, Sset_file_times, 1, 2, 0,
 
 DEFUN ("set-file-times", Fset_file_times, Sset_file_times, 1, 2, 0,
-       doc: /* Set times of file FILENAME to TIME.
+       doc: /* Set times of file FILENAME to TIMESTAMP.
 Set both access and modification times.
 Return t on success, else nil.
 Set both access and modification times.
 Return t on success, else nil.
-Use the current time if TIME is nil.  TIME is in the format of
+Use the current time if TIMESTAMP is nil.  TIMESTAMP is in the format of
 `current-time'. */)
 `current-time'. */)
-  (Lisp_Object filename, Lisp_Object time)
+  (Lisp_Object filename, Lisp_Object timestamp)
 {
   Lisp_Object absname, encoded_absname;
   Lisp_Object handler;
   time_t sec;
   int usec;
 
 {
   Lisp_Object absname, encoded_absname;
   Lisp_Object handler;
   time_t sec;
   int usec;
 
-  if (! lisp_time_argument (time, &sec, &usec))
+  if (! lisp_time_argument (timestamp, &sec, &usec))
     error ("Invalid time specification");
 
     error ("Invalid time specification");
 
-  absname = Fexpand_file_name (filename, current_buffer->directory);
+  absname = Fexpand_file_name (filename, BVAR (current_buffer, directory));
 
   /* If the file name has special constructs in it,
      call the corresponding file handler.  */
   handler = Ffind_file_name_handler (absname, Qset_file_times);
   if (!NILP (handler))
 
   /* If the file name has special constructs in it,
      call the corresponding file handler.  */
   handler = Ffind_file_name_handler (absname, Qset_file_times);
   if (!NILP (handler))
-    return call3 (handler, Qset_file_times, absname, time);
+    return call3 (handler, Qset_file_times, absname, timestamp);
 
   encoded_absname = ENCODE_FILE (absname);
 
 
   encoded_absname = ENCODE_FILE (absname);
 
@@ -3083,14 +2972,13 @@ Use the current time if TIME is nil.  TIME is in the format of
     EMACS_SET_SECS (t, sec);
     EMACS_SET_USECS (t, usec);
 
     EMACS_SET_SECS (t, sec);
     EMACS_SET_USECS (t, usec);
 
-    if (set_file_times (SDATA (encoded_absname), t, t))
+    if (set_file_times (SSDATA (encoded_absname), t, t))
       {
 #ifdef DOS_NT
         struct stat st;
 
         /* Setting times on a directory always fails.  */
       {
 #ifdef DOS_NT
         struct stat st;
 
         /* Setting times on a directory always fails.  */
-        if (stat (SDATA (encoded_absname), &st) == 0
-            && (st.st_mode & S_IFMT) == S_IFDIR)
+        if (stat (SSDATA (encoded_absname), &st) == 0 && S_ISDIR (st.st_mode))
           return Qnil;
 #endif
         report_file_error ("Setting file times", Fcons (absname, Qnil));
           return Qnil;
 #endif
         report_file_error ("Setting file times", Fcons (absname, Qnil));
@@ -3129,8 +3017,8 @@ otherwise, if FILE2 does not exist, the answer is t.  */)
 
   absname1 = Qnil;
   GCPRO2 (absname1, file2);
 
   absname1 = Qnil;
   GCPRO2 (absname1, file2);
-  absname1 = expand_and_dir_to_file (file1, current_buffer->directory);
-  absname2 = expand_and_dir_to_file (file2, current_buffer->directory);
+  absname1 = expand_and_dir_to_file (file1, BVAR (current_buffer, directory));
+  absname2 = expand_and_dir_to_file (file2, BVAR (current_buffer, directory));
   UNGCPRO;
 
   /* If the file name has special constructs in it,
   UNGCPRO;
 
   /* If the file name has special constructs in it,
@@ -3146,21 +3034,17 @@ otherwise, if FILE2 does not exist, the answer is t.  */)
   absname2 = ENCODE_FILE (absname2);
   UNGCPRO;
 
   absname2 = ENCODE_FILE (absname2);
   UNGCPRO;
 
-  if (stat (SDATA (absname1), &st) < 0)
+  if (stat (SSDATA (absname1), &st) < 0)
     return Qnil;
 
   mtime1 = st.st_mtime;
 
     return Qnil;
 
   mtime1 = st.st_mtime;
 
-  if (stat (SDATA (absname2), &st) < 0)
+  if (stat (SSDATA (absname2), &st) < 0)
     return Qt;
 
   return (mtime1 > st.st_mtime) ? Qt : Qnil;
 }
 \f
     return Qt;
 
   return (mtime1 > st.st_mtime) ? Qt : Qnil;
 }
 \f
-#ifdef DOS_NT
-Lisp_Object Qfind_buffer_file_type;
-#endif /* DOS_NT */
-
 #ifndef READ_BUF_SIZE
 #define READ_BUF_SIZE (64 << 10)
 #endif
 #ifndef READ_BUF_SIZE
 #define READ_BUF_SIZE (64 << 10)
 #endif
@@ -3198,8 +3082,8 @@ decide_coding_unwind (Lisp_Object unwind_data)
   TEMP_SET_PT_BOTH (BEG, BEG_BYTE);
 
   /* Now we are safe to change the buffer's multibyteness directly.  */
   TEMP_SET_PT_BOTH (BEG, BEG_BYTE);
 
   /* Now we are safe to change the buffer's multibyteness directly.  */
-  current_buffer->enable_multibyte_characters = multibyte;
-  current_buffer->undo_list = undo_list;
+  BVAR (current_buffer, enable_multibyte_characters) = multibyte;
+  BVAR (current_buffer, undo_list) = undo_list;
 
   return Qnil;
 }
 
   return Qnil;
 }
@@ -3225,7 +3109,8 @@ read_non_regular (Lisp_Object ignore)
   immediate_quit = 1;
   QUIT;
   nbytes = emacs_read (non_regular_fd,
   immediate_quit = 1;
   QUIT;
   nbytes = emacs_read (non_regular_fd,
-                      BEG_ADDR + PT_BYTE - BEG_BYTE + non_regular_inserted,
+                      ((char *) BEG_ADDR + PT_BYTE - BEG_BYTE
+                       + non_regular_inserted),
                       non_regular_nbytes);
   immediate_quit = 0;
   return make_number (nbytes);
                       non_regular_nbytes);
   immediate_quit = 0;
   return make_number (nbytes);
@@ -3279,9 +3164,9 @@ variable `last-coding-system-used' to the coding system actually used.  */)
   Lisp_Object p;
   EMACS_INT total = 0;
   int not_regular = 0;
   Lisp_Object p;
   EMACS_INT total = 0;
   int not_regular = 0;
-  unsigned char read_buf[READ_BUF_SIZE];
+  char read_buf[READ_BUF_SIZE];
   struct coding_system coding;
   struct coding_system coding;
-  unsigned char buffer[1 << 14];
+  char buffer[1 << 14];
   int replace_handled = 0;
   int set_coding_system = 0;
   Lisp_Object coding_system;
   int replace_handled = 0;
   int set_coding_system = 0;
   Lisp_Object coding_system;
@@ -3293,7 +3178,7 @@ variable `last-coding-system-used' to the coding system actually used.  */)
   if (current_buffer->base_buffer && ! NILP (visit))
     error ("Cannot do file visiting in an indirect buffer");
 
   if (current_buffer->base_buffer && ! NILP (visit))
     error ("Cannot do file visiting in an indirect buffer");
 
-  if (!NILP (current_buffer->read_only))
+  if (!NILP (BVAR (current_buffer, read_only)))
     Fbarf_if_buffer_read_only ();
 
   val = Qnil;
     Fbarf_if_buffer_read_only ();
 
   val = Qnil;
@@ -3333,12 +3218,12 @@ variable `last-coding-system-used' to the coding system actually used.  */)
 
     /* Tell stat to use expensive method to get accurate info.  */
     Vw32_get_true_file_attributes = Qt;
 
     /* Tell stat to use expensive method to get accurate info.  */
     Vw32_get_true_file_attributes = Qt;
-    total = stat (SDATA (filename), &st);
+    total = stat (SSDATA (filename), &st);
     Vw32_get_true_file_attributes = tem;
   }
   if (total < 0)
 #else
     Vw32_get_true_file_attributes = tem;
   }
   if (total < 0)
 #else
-  if (stat (SDATA (filename), &st) < 0)
+  if (stat (SSDATA (filename), &st) < 0)
 #endif /* WINDOWSNT */
     {
       if (fd >= 0) emacs_close (fd);
 #endif /* WINDOWSNT */
     {
       if (fd >= 0) emacs_close (fd);
@@ -3352,7 +3237,6 @@ variable `last-coding-system-used' to the coding system actually used.  */)
       goto notfound;
     }
 
       goto notfound;
     }
 
-#ifdef S_IFREG
   /* This code will need to be changed in order to work on named
      pipes, and it's probably just not worth it.  So we should at
      least signal an error.  */
   /* This code will need to be changed in order to work on named
      pipes, and it's probably just not worth it.  So we should at
      least signal an error.  */
@@ -3367,10 +3251,9 @@ variable `last-coding-system-used' to the coding system actually used.  */)
        xsignal2 (Qfile_error,
                  build_string ("not a regular file"), orig_filename);
     }
        xsignal2 (Qfile_error,
                  build_string ("not a regular file"), orig_filename);
     }
-#endif
 
   if (fd < 0)
 
   if (fd < 0)
-    if ((fd = emacs_open (SDATA (filename), O_RDONLY, 0)) < 0)
+    if ((fd = emacs_open (SSDATA (filename), O_RDONLY, 0)) < 0)
       goto badopen;
 
   /* Replacement should preserve point as it preserves markers.  */
       goto badopen;
 
   /* Replacement should preserve point as it preserves markers.  */
@@ -3475,27 +3358,27 @@ variable `last-coding-system-used' to the coding system actually used.  */)
              else if (nread > 0)
                {
                  struct buffer *prev = current_buffer;
              else if (nread > 0)
                {
                  struct buffer *prev = current_buffer;
-                 Lisp_Object buffer;
+                 Lisp_Object workbuf;
                  struct buffer *buf;
 
                  record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
 
                  struct buffer *buf;
 
                  record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
 
-                 buffer = Fget_buffer_create (build_string (" *code-converting-work*"));
-                 buf = XBUFFER (buffer);
+                 workbuf = Fget_buffer_create (build_string (" *code-converting-work*"));
+                 buf = XBUFFER (workbuf);
 
                  delete_all_overlays (buf);
 
                  delete_all_overlays (buf);
-                 buf->directory = current_buffer->directory;
-                 buf->read_only = Qnil;
-                 buf->filename = Qnil;
-                 buf->undo_list = Qt;
+                 BVAR (buf, directory) = BVAR (current_buffer, directory);
+                 BVAR (buf, read_only) = Qnil;
+                 BVAR (buf, filename) = Qnil;
+                 BVAR (buf, undo_list) = Qt;
                  eassert (buf->overlays_before == NULL);
                  eassert (buf->overlays_after == NULL);
 
                  set_buffer_internal (buf);
                  Ferase_buffer ();
                  eassert (buf->overlays_before == NULL);
                  eassert (buf->overlays_after == NULL);
 
                  set_buffer_internal (buf);
                  Ferase_buffer ();
-                 buf->enable_multibyte_characters = Qnil;
+                 BVAR (buf, enable_multibyte_characters) = Qnil;
 
 
-                 insert_1_both (read_buf, nread, nread, 0, 0, 0);
+                 insert_1_both ((char *) read_buf, nread, nread, 0, 0, 0);
                  TEMP_SET_PT_BOTH (BEG, BEG_BYTE);
                  coding_system = call2 (Vset_auto_coding_function,
                                         filename, make_number (nread));
                  TEMP_SET_PT_BOTH (BEG, BEG_BYTE);
                  coding_system = call2 (Vset_auto_coding_function,
                                         filename, make_number (nread));
@@ -3531,7 +3414,7 @@ variable `last-coding-system-used' to the coding system actually used.  */)
       else
        CHECK_CODING_SYSTEM (coding_system);
 
       else
        CHECK_CODING_SYSTEM (coding_system);
 
-      if (NILP (current_buffer->enable_multibyte_characters))
+      if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
        /* We must suppress all character code conversion except for
           end-of-line conversion.  */
        coding_system = raw_text_coding_system (coding_system);
        /* We must suppress all character code conversion except for
           end-of-line conversion.  */
        coding_system = raw_text_coding_system (coding_system);
@@ -3589,13 +3472,14 @@ variable `last-coding-system-used' to the coding system actually used.  */)
          nread = emacs_read (fd, buffer, sizeof buffer);
          if (nread < 0)
            error ("IO error reading %s: %s",
          nread = emacs_read (fd, buffer, sizeof buffer);
          if (nread < 0)
            error ("IO error reading %s: %s",
-                  SDATA (orig_filename), emacs_strerror (errno));
+                  SSDATA (orig_filename), emacs_strerror (errno));
          else if (nread == 0)
            break;
 
          if (CODING_REQUIRE_DETECTION (&coding))
            {
          else if (nread == 0)
            break;
 
          if (CODING_REQUIRE_DETECTION (&coding))
            {
-             coding_system = detect_coding_system (buffer, nread, nread, 1, 0,
+             coding_system = detect_coding_system ((unsigned char *) buffer,
+                                                   nread, nread, 1, 0,
                                                    coding_system);
              setup_coding_system (coding_system, &coding);
            }
                                                    coding_system);
              setup_coding_system (coding_system, &coding);
            }
@@ -3678,7 +3562,7 @@ variable `last-coding-system-used' to the coding system actually used.  */)
                 we cannot use this method; giveup and try the other.  */
              if (same_at_end > same_at_start
                  && FETCH_BYTE (same_at_end - 1) >= 0200
                 we cannot use this method; giveup and try the other.  */
              if (same_at_end > same_at_start
                  && FETCH_BYTE (same_at_end - 1) >= 0200
-                 && ! NILP (current_buffer->enable_multibyte_characters)
+                 && ! NILP (BVAR (current_buffer, enable_multibyte_characters))
                  && (CODING_MAY_REQUIRE_DECODING (&coding)))
                giveup_match_end = 1;
              break;
                  && (CODING_MAY_REQUIRE_DECODING (&coding)))
                giveup_match_end = 1;
              break;
@@ -3697,14 +3581,14 @@ variable `last-coding-system-used' to the coding system actually used.  */)
 
          /* Extend the start of non-matching text area to multibyte
              character boundary.  */
 
          /* Extend the start of non-matching text area to multibyte
              character boundary.  */
-         if (! NILP (current_buffer->enable_multibyte_characters))
+         if (! NILP (BVAR (current_buffer, enable_multibyte_characters)))
            while (same_at_start > BEGV_BYTE
                   && ! CHAR_HEAD_P (FETCH_BYTE (same_at_start)))
              same_at_start--;
 
          /* Extend the end of non-matching text area to multibyte
              character boundary.  */
            while (same_at_start > BEGV_BYTE
                   && ! CHAR_HEAD_P (FETCH_BYTE (same_at_start)))
              same_at_start--;
 
          /* Extend the end of non-matching text area to multibyte
              character boundary.  */
-         if (! NILP (current_buffer->enable_multibyte_characters))
+         if (! NILP (BVAR (current_buffer, enable_multibyte_characters)))
            while (same_at_end < ZV_BYTE
                   && ! CHAR_HEAD_P (FETCH_BYTE (same_at_end)))
              same_at_end++;
            while (same_at_end < ZV_BYTE
                   && ! CHAR_HEAD_P (FETCH_BYTE (same_at_end)))
              same_at_end++;
@@ -3753,7 +3637,7 @@ variable `last-coding-system-used' to the coding system actually used.  */)
       unsigned char *decoded;
       EMACS_INT temp;
       int this_count = SPECPDL_INDEX ();
       unsigned char *decoded;
       EMACS_INT temp;
       int this_count = SPECPDL_INDEX ();
-      int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
+      int multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters));
       Lisp_Object conversion_buffer;
 
       conversion_buffer = code_conversion_save (1, multibyte);
       Lisp_Object conversion_buffer;
 
       conversion_buffer = code_conversion_save (1, multibyte);
@@ -3797,8 +3681,8 @@ variable `last-coding-system-used' to the coding system actually used.  */)
 
          BUF_TEMP_SET_PT (XBUFFER (conversion_buffer),
                           BUF_Z (XBUFFER (conversion_buffer)));
 
          BUF_TEMP_SET_PT (XBUFFER (conversion_buffer),
                           BUF_Z (XBUFFER (conversion_buffer)));
-         decode_coding_c_string (&coding, read_buf, unprocessed + this,
-                                 conversion_buffer);
+         decode_coding_c_string (&coding, (unsigned char *) read_buf,
+                                 unprocessed + this, conversion_buffer);
          unprocessed = coding.carryover_bytes;
          if (coding.carryover_bytes > 0)
            memcpy (read_buf, coding.carryover, unprocessed);
          unprocessed = coding.carryover_bytes;
          if (coding.carryover_bytes > 0)
            memcpy (read_buf, coding.carryover, unprocessed);
@@ -3821,8 +3705,8 @@ variable `last-coding-system-used' to the coding system actually used.  */)
       if (unprocessed > 0)
        {
          coding.mode |= CODING_MODE_LAST_BLOCK;
       if (unprocessed > 0)
        {
          coding.mode |= CODING_MODE_LAST_BLOCK;
-         decode_coding_c_string (&coding, read_buf, unprocessed,
-                                 conversion_buffer);
+         decode_coding_c_string (&coding, (unsigned char *) read_buf,
+                                 unprocessed, conversion_buffer);
          coding.mode &= ~CODING_MODE_LAST_BLOCK;
        }
 
          coding.mode &= ~CODING_MODE_LAST_BLOCK;
        }
 
@@ -3858,7 +3742,7 @@ variable `last-coding-system-used' to the coding system actually used.  */)
 
       /* Extend the start of non-matching text area to the previous
         multibyte character boundary.  */
 
       /* Extend the start of non-matching text area to the previous
         multibyte character boundary.  */
-      if (! NILP (current_buffer->enable_multibyte_characters))
+      if (! NILP (BVAR (current_buffer, enable_multibyte_characters)))
        while (same_at_start > BEGV_BYTE
               && ! CHAR_HEAD_P (FETCH_BYTE (same_at_start)))
          same_at_start--;
        while (same_at_start > BEGV_BYTE
               && ! CHAR_HEAD_P (FETCH_BYTE (same_at_start)))
          same_at_start--;
@@ -3875,7 +3759,7 @@ variable `last-coding-system-used' to the coding system actually used.  */)
 
       /* Extend the end of non-matching text area to the next
         multibyte character boundary.  */
 
       /* Extend the end of non-matching text area to the next
         multibyte character boundary.  */
-      if (! NILP (current_buffer->enable_multibyte_characters))
+      if (! NILP (BVAR (current_buffer, enable_multibyte_characters)))
        while (same_at_end < ZV_BYTE
               && ! CHAR_HEAD_P (FETCH_BYTE (same_at_end)))
          same_at_end++;
        while (same_at_end < ZV_BYTE
               && ! CHAR_HEAD_P (FETCH_BYTE (same_at_end)))
          same_at_end++;
@@ -3950,9 +3834,9 @@ variable `last-coding-system-used' to the coding system actually used.  */)
   if (NILP (visit) && inserted > 0)
     {
 #ifdef CLASH_DETECTION
   if (NILP (visit) && inserted > 0)
     {
 #ifdef CLASH_DETECTION
-      if (!NILP (current_buffer->file_truename)
+      if (!NILP (BVAR (current_buffer, file_truename))
          /* Make binding buffer-file-name to nil effective.  */
          /* Make binding buffer-file-name to nil effective.  */
-         && !NILP (current_buffer->filename)
+         && !NILP (BVAR (current_buffer, filename))
          && SAVE_MODIFF >= MODIFF)
        we_locked_file = 1;
 #endif /* CLASH_DETECTION */
          && SAVE_MODIFF >= MODIFF)
        we_locked_file = 1;
 #endif /* CLASH_DETECTION */
@@ -3992,7 +3876,7 @@ variable `last-coding-system-used' to the coding system actually used.  */)
 
        if (not_regular)
          {
 
        if (not_regular)
          {
-           Lisp_Object val;
+           Lisp_Object nbytes;
 
            /* Maybe make more room.  */
            if (gap_size < trytry)
 
            /* Maybe make more room.  */
            if (gap_size < trytry)
@@ -4007,15 +3891,16 @@ variable `last-coding-system-used' to the coding system actually used.  */)
            non_regular_fd = fd;
            non_regular_inserted = inserted;
            non_regular_nbytes = trytry;
            non_regular_fd = fd;
            non_regular_inserted = inserted;
            non_regular_nbytes = trytry;
-           val = internal_condition_case_1 (read_non_regular, Qnil, Qerror,
-                                            read_non_regular_quit);
-           if (NILP (val))
+           nbytes = internal_condition_case_1 (read_non_regular,
+                                               Qnil, Qerror,
+                                               read_non_regular_quit);
+           if (NILP (nbytes))
              {
                read_quit = 1;
                break;
              }
 
              {
                read_quit = 1;
                break;
              }
 
-           this = XINT (val);
+           this = XINT (nbytes);
          }
        else
          {
          }
        else
          {
@@ -4024,7 +3909,10 @@ variable `last-coding-system-used' to the coding system actually used.  */)
               here doesn't do any harm.  */
            immediate_quit = 1;
            QUIT;
               here doesn't do any harm.  */
            immediate_quit = 1;
            QUIT;
-           this = emacs_read (fd, BEG_ADDR + PT_BYTE - BEG_BYTE + inserted, trytry);
+           this = emacs_read (fd,
+                              ((char *) BEG_ADDR + PT_BYTE - BEG_BYTE
+                               + inserted),
+                              trytry);
            immediate_quit = 0;
          }
 
            immediate_quit = 0;
          }
 
@@ -4054,7 +3942,7 @@ variable `last-coding-system-used' to the coding system actually used.  */)
     {
 #ifdef CLASH_DETECTION
       if (we_locked_file)
     {
 #ifdef CLASH_DETECTION
       if (we_locked_file)
-       unlock_file (current_buffer->file_truename);
+       unlock_file (BVAR (current_buffer, file_truename));
 #endif
       Vdeactivate_mark = old_Vdeactivate_mark;
     }
 #endif
       Vdeactivate_mark = old_Vdeactivate_mark;
     }
@@ -4103,13 +3991,13 @@ variable `last-coding-system-used' to the coding system actually used.  */)
             care of marker adjustment.  By this way, we can run Lisp
             program safely before decoding the inserted text.  */
          Lisp_Object unwind_data;
             care of marker adjustment.  By this way, we can run Lisp
             program safely before decoding the inserted text.  */
          Lisp_Object unwind_data;
-         int count = SPECPDL_INDEX ();
+         int count1 = SPECPDL_INDEX ();
 
 
-         unwind_data = Fcons (current_buffer->enable_multibyte_characters,
-                              Fcons (current_buffer->undo_list,
+         unwind_data = Fcons (BVAR (current_buffer, enable_multibyte_characters),
+                              Fcons (BVAR (current_buffer, undo_list),
                                      Fcurrent_buffer ()));
                                      Fcurrent_buffer ()));
-         current_buffer->enable_multibyte_characters = Qnil;
-         current_buffer->undo_list = Qt;
+         BVAR (current_buffer, enable_multibyte_characters) = Qnil;
+         BVAR (current_buffer, undo_list) = Qt;
          record_unwind_protect (decide_coding_unwind, unwind_data);
 
          if (inserted > 0 && ! NILP (Vset_auto_coding_function))
          record_unwind_protect (decide_coding_unwind, unwind_data);
 
          if (inserted > 0 && ! NILP (Vset_auto_coding_function))
@@ -4130,7 +4018,7 @@ variable `last-coding-system-used' to the coding system actually used.  */)
              if (CONSP (coding_system))
                coding_system = XCAR (coding_system);
            }
              if (CONSP (coding_system))
                coding_system = XCAR (coding_system);
            }
-         unbind_to (count, Qnil);
+         unbind_to (count1, Qnil);
          inserted = Z_BYTE - BEG_BYTE;
        }
 
          inserted = Z_BYTE - BEG_BYTE;
        }
 
@@ -4139,7 +4027,7 @@ variable `last-coding-system-used' to the coding system actually used.  */)
       else
        CHECK_CODING_SYSTEM (coding_system);
 
       else
        CHECK_CODING_SYSTEM (coding_system);
 
-      if (NILP (current_buffer->enable_multibyte_characters))
+      if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
        /* We must suppress all character code conversion except for
           end-of-line conversion.  */
        coding_system = raw_text_coding_system (coding_system);
        /* We must suppress all character code conversion except for
           end-of-line conversion.  */
        coding_system = raw_text_coding_system (coding_system);
@@ -4157,10 +4045,10 @@ variable `last-coding-system-used' to the coding system actually used.  */)
          && NILP (replace))
        /* Visiting a file with these coding system makes the buffer
           unibyte. */
          && NILP (replace))
        /* Visiting a file with these coding system makes the buffer
           unibyte. */
-       current_buffer->enable_multibyte_characters = Qnil;
+       BVAR (current_buffer, enable_multibyte_characters) = Qnil;
     }
 
     }
 
-  coding.dst_multibyte = ! NILP (current_buffer->enable_multibyte_characters);
+  coding.dst_multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters));
   if (CODING_MAY_REQUIRE_DECODING (&coding)
       && (inserted > 0 || CODING_REQUIRE_FLUSHING (&coding)))
     {
   if (CODING_MAY_REQUIRE_DECODING (&coding)
       && (inserted > 0 || CODING_REQUIRE_FLUSHING (&coding)))
     {
@@ -4180,18 +4068,6 @@ variable `last-coding-system-used' to the coding system actually used.  */)
 
   /* Now INSERTED is measured in characters.  */
 
 
   /* Now INSERTED is measured in characters.  */
 
-#ifdef DOS_NT
-  /* Use the conversion type to determine buffer-file-type
-     (find-buffer-file-type is now used to help determine the
-     conversion).  */
-  if ((VECTORP (CODING_ID_EOL_TYPE (coding.id))
-       || EQ (CODING_ID_EOL_TYPE (coding.id), Qunix))
-      && ! CODING_REQUIRE_DECODING (&coding))
-    current_buffer->buffer_file_type = Qt;
-  else
-    current_buffer->buffer_file_type = Qnil;
-#endif
-
  handled:
 
   if (deferred_remove_unwind_protect)
  handled:
 
   if (deferred_remove_unwind_protect)
@@ -4201,24 +4077,24 @@ variable `last-coding-system-used' to the coding system actually used.  */)
 
   if (!NILP (visit))
     {
 
   if (!NILP (visit))
     {
-      if (!EQ (current_buffer->undo_list, Qt) && !nochange)
-       current_buffer->undo_list = Qnil;
+      if (!EQ (BVAR (current_buffer, undo_list), Qt) && !nochange)
+       BVAR (current_buffer, undo_list) = Qnil;
 
       if (NILP (handler))
        {
          current_buffer->modtime = st.st_mtime;
          current_buffer->modtime_size = st.st_size;
 
       if (NILP (handler))
        {
          current_buffer->modtime = st.st_mtime;
          current_buffer->modtime_size = st.st_size;
-         current_buffer->filename = orig_filename;
+         BVAR (current_buffer, filename) = orig_filename;
        }
 
       SAVE_MODIFF = MODIFF;
       BUF_AUTOSAVE_MODIFF (current_buffer) = MODIFF;
        }
 
       SAVE_MODIFF = MODIFF;
       BUF_AUTOSAVE_MODIFF (current_buffer) = MODIFF;
-      XSETFASTINT (current_buffer->save_length, Z - BEG);
+      XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG);
 #ifdef CLASH_DETECTION
       if (NILP (handler))
        {
 #ifdef CLASH_DETECTION
       if (NILP (handler))
        {
-         if (!NILP (current_buffer->file_truename))
-           unlock_file (current_buffer->file_truename);
+         if (!NILP (BVAR (current_buffer, file_truename)))
+           unlock_file (BVAR (current_buffer, file_truename));
          unlock_file (filename);
        }
 #endif /* CLASH_DETECTION */
          unlock_file (filename);
        }
 #endif /* CLASH_DETECTION */
@@ -4245,14 +4121,14 @@ variable `last-coding-system-used' to the coding system actually used.  */)
   if (inserted > 0)
     {
       /* Don't run point motion or modification hooks when decoding.  */
   if (inserted > 0)
     {
       /* Don't run point motion or modification hooks when decoding.  */
-      int count = SPECPDL_INDEX ();
+      int count1 = SPECPDL_INDEX ();
       EMACS_INT old_inserted = inserted;
       specbind (Qinhibit_point_motion_hooks, Qt);
       specbind (Qinhibit_modification_hooks, Qt);
 
       /* Save old undo list and don't record undo for decoding.  */
       EMACS_INT old_inserted = inserted;
       specbind (Qinhibit_point_motion_hooks, Qt);
       specbind (Qinhibit_modification_hooks, Qt);
 
       /* Save old undo list and don't record undo for decoding.  */
-      old_undo = current_buffer->undo_list;
-      current_buffer->undo_list = Qt;
+      old_undo = BVAR (current_buffer, undo_list);
+      BVAR (current_buffer, undo_list) = Qt;
 
       if (NILP (replace))
        {
 
       if (NILP (replace))
        {
@@ -4340,7 +4216,7 @@ variable `last-coding-system-used' to the coding system actually used.  */)
 
       if (NILP (visit))
        {
 
       if (NILP (visit))
        {
-         current_buffer->undo_list = old_undo;
+         BVAR (current_buffer, undo_list) = old_undo;
          if (CONSP (old_undo) && inserted != old_inserted)
            {
              /* Adjust the last undo record for the size change during
          if (CONSP (old_undo) && inserted != old_inserted)
            {
              /* Adjust the last undo record for the size change during
@@ -4355,9 +4231,9 @@ variable `last-coding-system-used' to the coding system actually used.  */)
       else
        /* If undo_list was Qt before, keep it that way.
           Otherwise start with an empty undo_list.  */
       else
        /* If undo_list was Qt before, keep it that way.
           Otherwise start with an empty undo_list.  */
-       current_buffer->undo_list = EQ (old_undo, Qt) ? Qt : Qnil;
+       BVAR (current_buffer, undo_list) = EQ (old_undo, Qt) ? Qt : Qnil;
 
 
-      unbind_to (count, Qnil);
+      unbind_to (count1, Qnil);
     }
 
   /* Call after-change hooks for the inserted text, aside from the case
     }
 
   /* Call after-change hooks for the inserted text, aside from the case
@@ -4409,8 +4285,8 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
   Lisp_Object eol_parent = Qnil;
 
   if (auto_saving
   Lisp_Object eol_parent = Qnil;
 
   if (auto_saving
-      && NILP (Fstring_equal (current_buffer->filename,
-                             current_buffer->auto_save_file_name)))
+      && NILP (Fstring_equal (BVAR (current_buffer, filename),
+                             BVAR (current_buffer, auto_save_file_name))))
     {
       val = Qutf_8_emacs;
       eol_parent = Qunix;
     {
       val = Qutf_8_emacs;
       eol_parent = Qunix;
@@ -4439,12 +4315,12 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
       int using_default_coding = 0;
       int force_raw_text = 0;
 
       int using_default_coding = 0;
       int force_raw_text = 0;
 
-      val = current_buffer->buffer_file_coding_system;
+      val = BVAR (current_buffer, buffer_file_coding_system);
       if (NILP (val)
          || NILP (Flocal_variable_p (Qbuffer_file_coding_system, Qnil)))
        {
          val = Qnil;
       if (NILP (val)
          || NILP (Flocal_variable_p (Qbuffer_file_coding_system, Qnil)))
        {
          val = Qnil;
-         if (NILP (current_buffer->enable_multibyte_characters))
+         if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
            force_raw_text = 1;
        }
 
            force_raw_text = 1;
        }
 
@@ -4465,7 +4341,7 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
        {
          /* If we still have not decided a coding system, use the
             default value of buffer-file-coding-system.  */
        {
          /* If we still have not decided a coding system, use the
             default value of buffer-file-coding-system.  */
-         val = current_buffer->buffer_file_coding_system;
+         val = BVAR (current_buffer, buffer_file_coding_system);
          using_default_coding = 1;
        }
 
          using_default_coding = 1;
        }
 
@@ -4489,9 +4365,9 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
         format, we use that of
         `default-buffer-file-coding-system'.  */
       if (! using_default_coding
         format, we use that of
         `default-buffer-file-coding-system'.  */
       if (! using_default_coding
-         && ! NILP (buffer_defaults.buffer_file_coding_system))
+         && ! NILP (BVAR (&buffer_defaults, buffer_file_coding_system)))
        val = (coding_inherit_eol_type
        val = (coding_inherit_eol_type
-              (val, buffer_defaults.buffer_file_coding_system));
+              (val, BVAR (&buffer_defaults, buffer_file_coding_system)));
 
       /* If we decide not to encode text, use `raw-text' or one of its
         subsidiaries.  */
 
       /* If we decide not to encode text, use `raw-text' or one of its
         subsidiaries.  */
@@ -4502,7 +4378,7 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
   val = coding_inherit_eol_type (val, eol_parent);
   setup_coding_system (val, coding);
 
   val = coding_inherit_eol_type (val, eol_parent);
   setup_coding_system (val, coding);
 
-  if (!STRINGP (start) && !NILP (current_buffer->selective_display))
+  if (!STRINGP (start) && !NILP (BVAR (current_buffer, selective_display)))
     coding->mode |= CODING_MODE_SELECTIVE_DISPLAY;
   return val;
 }
     coding->mode |= CODING_MODE_SELECTIVE_DISPLAY;
   return val;
 }
@@ -4549,7 +4425,7 @@ This calls `write-region-annotate-functions' at the start, and
   register int desc;
   int failure;
   int save_errno = 0;
   register int desc;
   int failure;
   int save_errno = 0;
-  const unsigned char *fn;
+  const char *fn;
   struct stat st;
   int count = SPECPDL_INDEX ();
   int count1;
   struct stat st;
   int count = SPECPDL_INDEX ();
   int count1;
@@ -4561,9 +4437,6 @@ This calls `write-region-annotate-functions' at the start, and
   int quietly = !NILP (visit);
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
   struct buffer *given_buffer;
   int quietly = !NILP (visit);
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
   struct buffer *given_buffer;
-#ifdef DOS_NT
-  int buffer_file_type = O_BINARY;
-#endif /* DOS_NT */
   struct coding_system coding;
 
   if (current_buffer->base_buffer && visiting)
   struct coding_system coding;
 
   if (current_buffer->base_buffer && visiting)
@@ -4606,8 +4479,8 @@ This calls `write-region-annotate-functions' at the start, and
       if (visiting)
        {
          SAVE_MODIFF = MODIFF;
       if (visiting)
        {
          SAVE_MODIFF = MODIFF;
-         XSETFASTINT (current_buffer->save_length, Z - BEG);
-         current_buffer->filename = visit_file;
+         XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG);
+         BVAR (current_buffer, filename) = visit_file;
        }
       UNGCPRO;
       return val;
        }
       UNGCPRO;
       return val;
@@ -4669,11 +4542,11 @@ This calls `write-region-annotate-functions' at the start, and
 
   encoded_filename = ENCODE_FILE (filename);
 
 
   encoded_filename = ENCODE_FILE (filename);
 
-  fn = SDATA (encoded_filename);
+  fn = SSDATA (encoded_filename);
   desc = -1;
   if (!NILP (append))
 #ifdef DOS_NT
   desc = -1;
   if (!NILP (append))
 #ifdef DOS_NT
-    desc = emacs_open (fn, O_WRONLY | buffer_file_type, 0);
+    desc = emacs_open (fn, O_WRONLY | O_BINARY, 0);
 #else  /* not DOS_NT */
     desc = emacs_open (fn, O_WRONLY, 0);
 #endif /* not DOS_NT */
 #else  /* not DOS_NT */
     desc = emacs_open (fn, O_WRONLY, 0);
 #endif /* not DOS_NT */
@@ -4681,7 +4554,7 @@ This calls `write-region-annotate-functions' at the start, and
   if (desc < 0 && (NILP (append) || errno == ENOENT))
 #ifdef DOS_NT
   desc = emacs_open (fn,
   if (desc < 0 && (NILP (append) || errno == ENOENT))
 #ifdef DOS_NT
   desc = emacs_open (fn,
-                    O_WRONLY | O_CREAT | buffer_file_type
+                    O_WRONLY | O_CREAT | O_BINARY
                     | (EQ (mustbenew, Qexcl) ? O_EXCL : O_TRUNC),
                     S_IREAD | S_IWRITE);
 #else  /* not DOS_NT */
                     | (EQ (mustbenew, Qexcl) ? O_EXCL : O_TRUNC),
                     S_IREAD | S_IWRITE);
 #else  /* not DOS_NT */
@@ -4820,15 +4693,15 @@ This calls `write-region-annotate-functions' at the start, and
   if (visiting)
     {
       SAVE_MODIFF = MODIFF;
   if (visiting)
     {
       SAVE_MODIFF = MODIFF;
-      XSETFASTINT (current_buffer->save_length, Z - BEG);
-      current_buffer->filename = visit_file;
+      XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG);
+      BVAR (current_buffer, filename) = visit_file;
       update_mode_lines++;
     }
   else if (quietly)
     {
       if (auto_saving
       update_mode_lines++;
     }
   else if (quietly)
     {
       if (auto_saving
-         && ! NILP (Fstring_equal (current_buffer->filename,
-                                   current_buffer->auto_save_file_name)))
+         && ! NILP (Fstring_equal (BVAR (current_buffer, filename),
+                                   BVAR (current_buffer, auto_save_file_name))))
        SAVE_MODIFF = MODIFF;
 
       return Qnil;
        SAVE_MODIFF = MODIFF;
 
       return Qnil;
@@ -4910,10 +4783,10 @@ build_annotations (Lisp_Object start, Lisp_Object end)
     }
 
   /* Now do the same for annotation functions implied by the file-format */
     }
 
   /* Now do the same for annotation functions implied by the file-format */
-  if (auto_saving && (!EQ (current_buffer->auto_save_file_format, Qt)))
-    p = current_buffer->auto_save_file_format;
+  if (auto_saving && (!EQ (BVAR (current_buffer, auto_save_file_format), Qt)))
+    p = BVAR (current_buffer, auto_save_file_format);
   else
   else
-    p = current_buffer->file_format;
+    p = BVAR (current_buffer, file_format);
   for (i = 0; CONSP (p); p = XCDR (p), ++i)
     {
       struct buffer *given_buffer = current_buffer;
   for (i = 0; CONSP (p); p = XCDR (p), ++i)
     {
       struct buffer *given_buffer = current_buffer;
@@ -5058,8 +4931,8 @@ e_write (int desc, Lisp_Object string, int start, int end, struct coding_system
          coding->produced -=
            emacs_write (desc,
                         STRINGP (coding->dst_object)
          coding->produced -=
            emacs_write (desc,
                         STRINGP (coding->dst_object)
-                        ? SDATA (coding->dst_object)
-                        : BYTE_POS_ADDR (coding->dst_pos_byte),
+                        ? SSDATA (coding->dst_object)
+                        : (char *) BYTE_POS_ADDR (coding->dst_pos_byte),
                         coding->produced);
 
          if (coding->produced)
                         coding->produced);
 
          if (coding->produced)
@@ -5072,9 +4945,10 @@ e_write (int desc, Lisp_Object string, int start, int end, struct coding_system
 }
 \f
 DEFUN ("verify-visited-file-modtime", Fverify_visited_file_modtime,
 }
 \f
 DEFUN ("verify-visited-file-modtime", Fverify_visited_file_modtime,
-       Sverify_visited_file_modtime, 1, 1, 0,
+       Sverify_visited_file_modtime, 0, 1, 0,
        doc: /* Return t if last mod time of BUF's visited file matches what BUF records.
 This means that the file has not been changed since it was visited or saved.
        doc: /* Return t if last mod time of BUF's visited file matches what BUF records.
 This means that the file has not been changed since it was visited or saved.
+If BUF is omitted or nil, it defaults to the current buffer.
 See Info node `(elisp)Modification Time' for more details.  */)
   (Lisp_Object buf)
 {
 See Info node `(elisp)Modification Time' for more details.  */)
   (Lisp_Object buf)
 {
@@ -5083,22 +4957,27 @@ See Info node `(elisp)Modification Time' for more details.  */)
   Lisp_Object handler;
   Lisp_Object filename;
 
   Lisp_Object handler;
   Lisp_Object filename;
 
-  CHECK_BUFFER (buf);
-  b = XBUFFER (buf);
+  if (NILP (buf))
+    b = current_buffer;
+  else
+    {
+      CHECK_BUFFER (buf);
+      b = XBUFFER (buf);
+    }
 
 
-  if (!STRINGP (b->filename)) return Qt;
+  if (!STRINGP (BVAR (b, filename))) return Qt;
   if (b->modtime == 0) return Qt;
 
   /* If the file name has special constructs in it,
      call the corresponding file handler.  */
   if (b->modtime == 0) return Qt;
 
   /* If the file name has special constructs in it,
      call the corresponding file handler.  */
-  handler = Ffind_file_name_handler (b->filename,
+  handler = Ffind_file_name_handler (BVAR (b, filename),
                                     Qverify_visited_file_modtime);
   if (!NILP (handler))
     return call2 (handler, Qverify_visited_file_modtime, buf);
 
                                     Qverify_visited_file_modtime);
   if (!NILP (handler))
     return call2 (handler, Qverify_visited_file_modtime, buf);
 
-  filename = ENCODE_FILE (b->filename);
+  filename = ENCODE_FILE (BVAR (b, filename));
 
 
-  if (stat (SDATA (filename), &st) < 0)
+  if (stat (SSDATA (filename), &st) < 0)
     {
       /* If the file doesn't exist now and didn't exist before,
         we say that it isn't modified, provided the error is a tame one.  */
     {
       /* If the file doesn't exist now and didn't exist before,
         we say that it isn't modified, provided the error is a tame one.  */
@@ -5164,7 +5043,7 @@ An argument specifies the modification time value to use
       struct stat st;
       Lisp_Object handler;
 
       struct stat st;
       Lisp_Object handler;
 
-      filename = Fexpand_file_name (current_buffer->filename, Qnil);
+      filename = Fexpand_file_name (BVAR (current_buffer, filename), Qnil);
 
       /* If the file name has special constructs in it,
         call the corresponding file handler.  */
 
       /* If the file name has special constructs in it,
         call the corresponding file handler.  */
@@ -5175,7 +5054,7 @@ An argument specifies the modification time value to use
 
       filename = ENCODE_FILE (filename);
 
 
       filename = ENCODE_FILE (filename);
 
-      if (stat (SDATA (filename), &st) >= 0)
+      if (stat (SSDATA (filename), &st) >= 0)
         {
          current_buffer->modtime = st.st_mtime;
           current_buffer->modtime_size = st.st_size;
         {
          current_buffer->modtime = st.st_mtime;
           current_buffer->modtime_size = st.st_size;
@@ -5185,8 +5064,8 @@ An argument specifies the modification time value to use
   return Qnil;
 }
 \f
   return Qnil;
 }
 \f
-Lisp_Object
-auto_save_error (Lisp_Object error)
+static Lisp_Object
+auto_save_error (Lisp_Object error_val)
 {
   Lisp_Object args[3], msg;
   int i, nbytes;
 {
   Lisp_Object args[3], msg;
   int i, nbytes;
@@ -5199,8 +5078,8 @@ auto_save_error (Lisp_Object error)
   ring_bell (XFRAME (selected_frame));
 
   args[0] = build_string ("Auto-saving %s: %s");
   ring_bell (XFRAME (selected_frame));
 
   args[0] = build_string ("Auto-saving %s: %s");
-  args[1] = current_buffer->name;
-  args[2] = Ferror_message_string (error);
+  args[1] = BVAR (current_buffer, name);
+  args[2] = Ferror_message_string (error_val);
   msg = Fformat (3, args);
   GCPRO1 (msg);
   nbytes = SBYTES (msg);
   msg = Fformat (3, args);
   GCPRO1 (msg);
   nbytes = SBYTES (msg);
@@ -5221,7 +5100,7 @@ auto_save_error (Lisp_Object error)
   return Qnil;
 }
 
   return Qnil;
 }
 
-Lisp_Object
+static Lisp_Object
 auto_save_1 (void)
 {
   struct stat st;
 auto_save_1 (void)
 {
   struct stat st;
@@ -5230,26 +5109,26 @@ auto_save_1 (void)
   auto_save_mode_bits = 0666;
 
   /* Get visited file's mode to become the auto save file's mode.  */
   auto_save_mode_bits = 0666;
 
   /* Get visited file's mode to become the auto save file's mode.  */
-  if (! NILP (current_buffer->filename))
+  if (! NILP (BVAR (current_buffer, filename)))
     {
     {
-      if (stat (SDATA (current_buffer->filename), &st) >= 0)
+      if (stat (SSDATA (BVAR (current_buffer, filename)), &st) >= 0)
        /* But make sure we can overwrite it later!  */
        auto_save_mode_bits = st.st_mode | 0600;
        /* But make sure we can overwrite it later!  */
        auto_save_mode_bits = st.st_mode | 0600;
-      else if ((modes = Ffile_modes (current_buffer->filename),
+      else if ((modes = Ffile_modes (BVAR (current_buffer, filename)),
                INTEGERP (modes)))
        /* Remote files don't cooperate with stat.  */
        auto_save_mode_bits = XINT (modes) | 0600;
     }
 
   return
                INTEGERP (modes)))
        /* Remote files don't cooperate with stat.  */
        auto_save_mode_bits = XINT (modes) | 0600;
     }
 
   return
-    Fwrite_region (Qnil, Qnil, current_buffer->auto_save_file_name, Qnil,
+    Fwrite_region (Qnil, Qnil, BVAR (current_buffer, auto_save_file_name), Qnil,
                   NILP (Vauto_save_visited_file_name) ? Qlambda : Qt,
                   Qnil, Qnil);
 }
 
 static Lisp_Object
 do_auto_save_unwind (Lisp_Object arg)  /* used as unwind-protect function */
                   NILP (Vauto_save_visited_file_name) ? Qlambda : Qt,
                   Qnil, Qnil);
 }
 
 static Lisp_Object
 do_auto_save_unwind (Lisp_Object arg)  /* used as unwind-protect function */
-                     
+
 {
   FILE *stream = (FILE *) XSAVE_VALUE (arg)->pointer;
   auto_saving = 0;
 {
   FILE *stream = (FILE *) XSAVE_VALUE (arg)->pointer;
   auto_saving = 0;
@@ -5264,7 +5143,7 @@ do_auto_save_unwind (Lisp_Object arg)  /* used as unwind-protect function */
 
 static Lisp_Object
 do_auto_save_unwind_1 (Lisp_Object value)  /* used as unwind-protect function */
 
 static Lisp_Object
 do_auto_save_unwind_1 (Lisp_Object value)  /* used as unwind-protect function */
-                       
+
 {
   minibuffer_auto_raise = XINT (value);
   return Qnil;
 {
   minibuffer_auto_raise = XINT (value);
   return Qnil;
@@ -5355,7 +5234,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer.  */)
          UNGCPRO;
        }
 
          UNGCPRO;
        }
 
-      stream = fopen (SDATA (listfile), "w");
+      stream = fopen (SSDATA (listfile), "w");
     }
 
   record_unwind_protect (do_auto_save_unwind,
     }
 
   record_unwind_protect (do_auto_save_unwind,
@@ -5383,18 +5262,18 @@ A non-nil CURRENT-ONLY argument means save only current buffer.  */)
        /* Record all the buffers that have auto save mode
           in the special file that lists them.  For each of these buffers,
           Record visited name (if any) and auto save name.  */
        /* Record all the buffers that have auto save mode
           in the special file that lists them.  For each of these buffers,
           Record visited name (if any) and auto save name.  */
-       if (STRINGP (b->auto_save_file_name)
+       if (STRINGP (BVAR (b, auto_save_file_name))
            && stream != NULL && do_handled_files == 0)
          {
            BLOCK_INPUT;
            && stream != NULL && do_handled_files == 0)
          {
            BLOCK_INPUT;
-           if (!NILP (b->filename))
+           if (!NILP (BVAR (b, filename)))
              {
              {
-               fwrite (SDATA (b->filename), 1,
-                       SBYTES (b->filename), stream);
+               fwrite (SDATA (BVAR (b, filename)), 1,
+                       SBYTES (BVAR (b, filename)), stream);
              }
            putc ('\n', stream);
              }
            putc ('\n', stream);
-           fwrite (SDATA (b->auto_save_file_name), 1,
-                   SBYTES (b->auto_save_file_name), stream);
+           fwrite (SDATA (BVAR (b, auto_save_file_name)), 1,
+                   SBYTES (BVAR (b, auto_save_file_name)), stream);
            putc ('\n', stream);
            UNBLOCK_INPUT;
          }
            putc ('\n', stream);
            UNBLOCK_INPUT;
          }
@@ -5411,13 +5290,13 @@ A non-nil CURRENT-ONLY argument means save only current buffer.  */)
        /* Check for auto save enabled
           and file changed since last auto save
           and file changed since last real save.  */
        /* Check for auto save enabled
           and file changed since last auto save
           and file changed since last real save.  */
-       if (STRINGP (b->auto_save_file_name)
+       if (STRINGP (BVAR (b, auto_save_file_name))
            && BUF_SAVE_MODIFF (b) < BUF_MODIFF (b)
            && BUF_AUTOSAVE_MODIFF (b) < BUF_MODIFF (b)
            /* -1 means we've turned off autosaving for a while--see below.  */
            && BUF_SAVE_MODIFF (b) < BUF_MODIFF (b)
            && BUF_AUTOSAVE_MODIFF (b) < BUF_MODIFF (b)
            /* -1 means we've turned off autosaving for a while--see below.  */
-           && XINT (b->save_length) >= 0
+           && XINT (BVAR (b, save_length)) >= 0
            && (do_handled_files
            && (do_handled_files
-               || NILP (Ffind_file_name_handler (b->auto_save_file_name,
+               || NILP (Ffind_file_name_handler (BVAR (b, auto_save_file_name),
                                                  Qwrite_region))))
          {
            EMACS_TIME before_time, after_time;
                                                  Qwrite_region))))
          {
            EMACS_TIME before_time, after_time;
@@ -5431,23 +5310,23 @@ A non-nil CURRENT-ONLY argument means save only current buffer.  */)
 
            set_buffer_internal (b);
            if (NILP (Vauto_save_include_big_deletions)
 
            set_buffer_internal (b);
            if (NILP (Vauto_save_include_big_deletions)
-               && (XFASTINT (b->save_length) * 10
+               && (XFASTINT (BVAR (b, save_length)) * 10
                    > (BUF_Z (b) - BUF_BEG (b)) * 13)
                /* A short file is likely to change a large fraction;
                   spare the user annoying messages.  */
                    > (BUF_Z (b) - BUF_BEG (b)) * 13)
                /* A short file is likely to change a large fraction;
                   spare the user annoying messages.  */
-               && XFASTINT (b->save_length) > 5000
+               && XFASTINT (BVAR (b, save_length)) > 5000
                /* These messages are frequent and annoying for `*mail*'.  */
                /* These messages are frequent and annoying for `*mail*'.  */
-               && !EQ (b->filename, Qnil)
+               && !EQ (BVAR (b, filename), Qnil)
                && NILP (no_message))
              {
                /* It has shrunk too much; turn off auto-saving here.  */
                minibuffer_auto_raise = orig_minibuffer_auto_raise;
                message_with_string ("Buffer %s has shrunk a lot; auto save disabled in that buffer until next real save",
                && NILP (no_message))
              {
                /* It has shrunk too much; turn off auto-saving here.  */
                minibuffer_auto_raise = orig_minibuffer_auto_raise;
                message_with_string ("Buffer %s has shrunk a lot; auto save disabled in that buffer until next real save",
-                                    b->name, 1);
+                                    BVAR (b, name), 1);
                minibuffer_auto_raise = 0;
                /* Turn off auto-saving until there's a real save,
                   and prevent any more warnings.  */
                minibuffer_auto_raise = 0;
                /* Turn off auto-saving until there's a real save,
                   and prevent any more warnings.  */
-               XSETINT (b->save_length, -1);
+               XSETINT (BVAR (b, save_length), -1);
                Fsleep_for (make_number (1), Qnil);
                continue;
              }
                Fsleep_for (make_number (1), Qnil);
                continue;
              }
@@ -5456,7 +5335,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer.  */)
            internal_condition_case (auto_save_1, Qt, auto_save_error);
            auto_saved++;
            BUF_AUTOSAVE_MODIFF (b) = BUF_MODIFF (b);
            internal_condition_case (auto_save_1, Qt, auto_save_error);
            auto_saved++;
            BUF_AUTOSAVE_MODIFF (b) = BUF_MODIFF (b);
-           XSETFASTINT (current_buffer->save_length, Z - BEG);
+           XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG);
            set_buffer_internal (old);
 
            EMACS_GET_TIME (after_time);
            set_buffer_internal (old);
 
            EMACS_GET_TIME (after_time);
@@ -5503,7 +5382,7 @@ No auto-save file will be written until the buffer changes again.  */)
   /* FIXME: This should not be called in indirect buffers, since
      they're not autosaved.  */
   BUF_AUTOSAVE_MODIFF (current_buffer) = MODIFF;
   /* FIXME: This should not be called in indirect buffers, since
      they're not autosaved.  */
   BUF_AUTOSAVE_MODIFF (current_buffer) = MODIFF;
-  XSETFASTINT (current_buffer->save_length, Z - BEG);
+  XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG);
   current_buffer->auto_save_failure_time = -1;
   return Qnil;
 }
   current_buffer->auto_save_failure_time = -1;
   return Qnil;
 }
@@ -5552,7 +5431,7 @@ before any other event (mouse or keypress) is handled.  */)
 Lisp_Object
 Fread_file_name (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object initial, Lisp_Object predicate)
 {
 Lisp_Object
 Fread_file_name (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object initial, Lisp_Object predicate)
 {
-  struct gcpro gcpro1, gcpro2;
+  struct gcpro gcpro1;
   Lisp_Object args[7];
 
   GCPRO1 (default_filename);
   Lisp_Object args[7];
 
   GCPRO1 (default_filename);
@@ -5657,18 +5536,13 @@ syms_of_fileio (void)
   Qexcl = intern_c_string ("excl");
   staticpro (&Qexcl);
 
   Qexcl = intern_c_string ("excl");
   staticpro (&Qexcl);
 
-#ifdef DOS_NT
-  Qfind_buffer_file_type = intern_c_string ("find-buffer-file-type");
-  staticpro (&Qfind_buffer_file_type);
-#endif /* DOS_NT */
-
-  DEFVAR_LISP ("file-name-coding-system", &Vfile_name_coding_system,
+  DEFVAR_LISP ("file-name-coding-system", Vfile_name_coding_system,
               doc: /* *Coding system for encoding file names.
 If it is nil, `default-file-name-coding-system' (which see) is used.  */);
   Vfile_name_coding_system = Qnil;
 
   DEFVAR_LISP ("default-file-name-coding-system",
               doc: /* *Coding system for encoding file names.
 If it is nil, `default-file-name-coding-system' (which see) is used.  */);
   Vfile_name_coding_system = Qnil;
 
   DEFVAR_LISP ("default-file-name-coding-system",
-              &Vdefault_file_name_coding_system,
+              Vdefault_file_name_coding_system,
               doc: /* Default coding system for encoding file names.
 This variable is used only when `file-name-coding-system' is nil.
 
               doc: /* Default coding system for encoding file names.
 This variable is used only when `file-name-coding-system' is nil.
 
@@ -5703,7 +5577,7 @@ of file names regardless of the current language environment.  */);
   Fput (Qfile_date_error, Qerror_message,
        make_pure_c_string ("Cannot set file date"));
 
   Fput (Qfile_date_error, Qerror_message,
        make_pure_c_string ("Cannot set file date"));
 
-  DEFVAR_LISP ("file-name-handler-alist", &Vfile_name_handler_alist,
+  DEFVAR_LISP ("file-name-handler-alist", Vfile_name_handler_alist,
               doc: /* *Alist of elements (REGEXP . HANDLER) for file names handled specially.
 If a file name matches REGEXP, then all I/O on that file is done by calling
 HANDLER.
               doc: /* *Alist of elements (REGEXP . HANDLER) for file names handled specially.
 If a file name matches REGEXP, then all I/O on that file is done by calling
 HANDLER.
@@ -5719,7 +5593,7 @@ for its argument.  */);
   Vfile_name_handler_alist = Qnil;
 
   DEFVAR_LISP ("set-auto-coding-function",
   Vfile_name_handler_alist = Qnil;
 
   DEFVAR_LISP ("set-auto-coding-function",
-              &Vset_auto_coding_function,
+              Vset_auto_coding_function,
               doc: /* If non-nil, a function to call to decide a coding system of file.
 Two arguments are passed to this function: the file name
 and the length of a file contents following the point.
               doc: /* If non-nil, a function to call to decide a coding system of file.
 Two arguments are passed to this function: the file name
 and the length of a file contents following the point.
@@ -5731,7 +5605,7 @@ specified in the heading lines with the format:
 or local variable spec of the tailing lines with `coding:' tag.  */);
   Vset_auto_coding_function = Qnil;
 
 or local variable spec of the tailing lines with `coding:' tag.  */);
   Vset_auto_coding_function = Qnil;
 
-  DEFVAR_LISP ("after-insert-file-functions", &Vafter_insert_file_functions,
+  DEFVAR_LISP ("after-insert-file-functions", Vafter_insert_file_functions,
               doc: /* A list of functions to be called at the end of `insert-file-contents'.
 Each is passed one argument, the number of characters inserted,
 with point at the start of the inserted text.  Each function
               doc: /* A list of functions to be called at the end of `insert-file-contents'.
 Each is passed one argument, the number of characters inserted,
 with point at the start of the inserted text.  Each function
@@ -5741,7 +5615,7 @@ If `insert-file-contents' is intercepted by a handler from
 functions in `after-insert-file-functions' if appropriate.  */);
   Vafter_insert_file_functions = Qnil;
 
 functions in `after-insert-file-functions' if appropriate.  */);
   Vafter_insert_file_functions = Qnil;
 
-  DEFVAR_LISP ("write-region-annotate-functions", &Vwrite_region_annotate_functions,
+  DEFVAR_LISP ("write-region-annotate-functions", Vwrite_region_annotate_functions,
               doc: /* A list of functions to be called at the start of `write-region'.
 Each is passed two arguments, START and END as for `write-region'.
 These are usually two numbers but not always; see the documentation
               doc: /* A list of functions to be called at the start of `write-region'.
 Each is passed two arguments, START and END as for `write-region'.
 These are usually two numbers but not always; see the documentation
@@ -5770,7 +5644,7 @@ buffer current.  */);
     = intern_c_string ("write-region-annotate-functions");
 
   DEFVAR_LISP ("write-region-post-annotation-function",
     = intern_c_string ("write-region-annotate-functions");
 
   DEFVAR_LISP ("write-region-post-annotation-function",
-              &Vwrite_region_post_annotation_function,
+              Vwrite_region_post_annotation_function,
               doc: /* Function to call after `write-region' completes.
 The function is called with no arguments.  If one or more of the
 annotation functions in `write-region-annotate-functions' changed the
               doc: /* Function to call after `write-region' completes.
 The function is called with no arguments.  If one or more of the
 annotation functions in `write-region-annotate-functions' changed the
@@ -5781,34 +5655,34 @@ buffer.  The relevant buffer is current during each function call.  */);
   staticpro (&Vwrite_region_annotation_buffers);
 
   DEFVAR_LISP ("write-region-annotations-so-far",
   staticpro (&Vwrite_region_annotation_buffers);
 
   DEFVAR_LISP ("write-region-annotations-so-far",
-              &Vwrite_region_annotations_so_far,
+              Vwrite_region_annotations_so_far,
               doc: /* When an annotation function is called, this holds the previous annotations.
 These are the annotations made by other annotation functions
 that were already called.  See also `write-region-annotate-functions'.  */);
   Vwrite_region_annotations_so_far = Qnil;
 
               doc: /* When an annotation function is called, this holds the previous annotations.
 These are the annotations made by other annotation functions
 that were already called.  See also `write-region-annotate-functions'.  */);
   Vwrite_region_annotations_so_far = Qnil;
 
-  DEFVAR_LISP ("inhibit-file-name-handlers", &Vinhibit_file_name_handlers,
+  DEFVAR_LISP ("inhibit-file-name-handlers", Vinhibit_file_name_handlers,
               doc: /* A list of file name handlers that temporarily should not be used.
 This applies only to the operation `inhibit-file-name-operation'.  */);
   Vinhibit_file_name_handlers = Qnil;
 
               doc: /* A list of file name handlers that temporarily should not be used.
 This applies only to the operation `inhibit-file-name-operation'.  */);
   Vinhibit_file_name_handlers = Qnil;
 
-  DEFVAR_LISP ("inhibit-file-name-operation", &Vinhibit_file_name_operation,
+  DEFVAR_LISP ("inhibit-file-name-operation", Vinhibit_file_name_operation,
               doc: /* The operation for which `inhibit-file-name-handlers' is applicable.  */);
   Vinhibit_file_name_operation = Qnil;
 
               doc: /* The operation for which `inhibit-file-name-handlers' is applicable.  */);
   Vinhibit_file_name_operation = Qnil;
 
-  DEFVAR_LISP ("auto-save-list-file-name", &Vauto_save_list_file_name,
+  DEFVAR_LISP ("auto-save-list-file-name", Vauto_save_list_file_name,
               doc: /* File name in which we write a list of all auto save file names.
 This variable is initialized automatically from `auto-save-list-file-prefix'
 shortly after Emacs reads your `.emacs' file, if you have not yet given it
 a non-nil value.  */);
   Vauto_save_list_file_name = Qnil;
 
               doc: /* File name in which we write a list of all auto save file names.
 This variable is initialized automatically from `auto-save-list-file-prefix'
 shortly after Emacs reads your `.emacs' file, if you have not yet given it
 a non-nil value.  */);
   Vauto_save_list_file_name = Qnil;
 
-  DEFVAR_LISP ("auto-save-visited-file-name", &Vauto_save_visited_file_name,
+  DEFVAR_LISP ("auto-save-visited-file-name", Vauto_save_visited_file_name,
               doc: /* Non-nil says auto-save a buffer in the file it is visiting, when practical.
 Normally auto-save files are written under other names.  */);
   Vauto_save_visited_file_name = Qnil;
 
               doc: /* Non-nil says auto-save a buffer in the file it is visiting, when practical.
 Normally auto-save files are written under other names.  */);
   Vauto_save_visited_file_name = Qnil;
 
-  DEFVAR_LISP ("auto-save-include-big-deletions", &Vauto_save_include_big_deletions,
+  DEFVAR_LISP ("auto-save-include-big-deletions", Vauto_save_include_big_deletions,
               doc: /* If non-nil, auto-save even if a large part of the text is deleted.
 If nil, deleting a substantial portion of the text disables auto-save
 in the buffer; this is the default behavior, because the auto-save
               doc: /* If non-nil, auto-save even if a large part of the text is deleted.
 If nil, deleting a substantial portion of the text disables auto-save
 in the buffer; this is the default behavior, because the auto-save
@@ -5816,14 +5690,14 @@ file is usually more useful if it contains the deleted text.  */);
   Vauto_save_include_big_deletions = Qnil;
 
 #ifdef HAVE_FSYNC
   Vauto_save_include_big_deletions = Qnil;
 
 #ifdef HAVE_FSYNC
-  DEFVAR_BOOL ("write-region-inhibit-fsync", &write_region_inhibit_fsync,
+  DEFVAR_BOOL ("write-region-inhibit-fsync", write_region_inhibit_fsync,
               doc: /* *Non-nil means don't call fsync in `write-region'.
 This variable affects calls to `write-region' as well as save commands.
 A non-nil value may result in data loss!  */);
   write_region_inhibit_fsync = 0;
 #endif
 
               doc: /* *Non-nil means don't call fsync in `write-region'.
 This variable affects calls to `write-region' as well as save commands.
 A non-nil value may result in data loss!  */);
   write_region_inhibit_fsync = 0;
 #endif
 
-  DEFVAR_BOOL ("delete-by-moving-to-trash", &delete_by_moving_to_trash,
+  DEFVAR_BOOL ("delete-by-moving-to-trash", delete_by_moving_to_trash,
                doc: /* Specifies whether to use the system's trash can.
 When non-nil, certain file deletion commands use the function
 `move-file-to-trash' instead of deleting files outright.
                doc: /* Specifies whether to use the system's trash can.
 When non-nil, certain file deletion commands use the function
 `move-file-to-trash' instead of deleting files outright.
@@ -5890,6 +5764,3 @@ This includes interactive calls to `delete-file' and
   defsubr (&Sunix_sync);
 #endif
 }
   defsubr (&Sunix_sync);
 #endif
 }
-
-/* arch-tag: 64ba3fd7-f844-4fb2-ba4b-427eb928786c
-   (do not change this comment) */