* process.c (allocate_pty): Let PTY_ITERATION declare iteration vars.
[bpt/emacs.git] / src / fileio.c
index 4a4935b..5d33fb9 100644 (file)
@@ -26,18 +26,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <setjmp.h>
 #include <unistd.h>
 
-#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>
 #endif
@@ -95,10 +83,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "commands.h"
 
-#ifndef S_ISLNK
-#  define lstat stat
-#endif
-
 #ifndef FILE_SYSTEM_CASE
 #define FILE_SYSTEM_CASE(filename)  (filename)
 #endif
@@ -194,7 +178,7 @@ report_file_error (const char *string, Lisp_Object data)
 
            str = SSDATA (errstring);
            c = STRING_CHAR ((unsigned char *) str);
-           Faset (errstring, make_number (0), make_number (DOWNCASE (c)));
+           Faset (errstring, make_number (0), make_number (downcase (c)));
          }
 
        xsignal (Qfile_error,
@@ -449,8 +433,8 @@ get a current directory to run processes in.  */)
 }
 
 \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;
 
@@ -512,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.
  */
 
-int
+static int
 directory_file_name (char *src, char *dst)
 {
   long slen;
@@ -744,7 +728,8 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
 {
   /* These point to SDATA and need to be careful with string-relocation
      during GC (via DECODE_FILE).  */
-  char *nm, *newdir;
+  char *nm;
+  const char *newdir;
   /* This should only point to alloca'd data.  */
   char *target;
 
@@ -770,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))
-    default_directory = B_ (current_buffer, directory);
+    default_directory = BVAR (current_buffer, directory);
   if (! STRINGP (default_directory))
     {
 #ifdef DOS_NT
@@ -1029,21 +1014,23 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
   if (!newdir && drive)
     {
       /* Get default directory if needed to make nm absolute. */
+      char *adir = NULL;
       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. */
-         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 */
 
@@ -1090,7 +1077,7 @@ 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. */
-
+         char *adir;
          if (IS_DRIVE (newdir[0]) && IS_DEVICE_SEP (newdir[1]))
            {
              drive = (unsigned char) newdir[0];
@@ -1103,14 +1090,15 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
              strcat (tmp, nm);
              nm = tmp;
            }
-         newdir = alloca (MAXPATHLEN + 1);
+         adir = alloca (MAXPATHLEN + 1);
          if (drive)
            {
-             if (!getdefdir (toupper (drive) - 'A' + 1, newdir))
+             if (!getdefdir (toupper (drive) - 'A' + 1, adir))
                newdir = "/";
            }
          else
-           getwd (newdir);
+           getwd (adir);
+         newdir = adir;
        }
 
       /* Strip off drive name from prefix, if present. */
@@ -1127,13 +1115,13 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
 #ifdef WINDOWSNT
          if (IS_DIRECTORY_SEP (newdir[0]) && IS_DIRECTORY_SEP (newdir[1]))
            {
-             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;
+             newdir = adir;
            }
          else
 #endif
@@ -1750,7 +1738,7 @@ 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.  */
 
-void
+static void
 barf_or_query_if_file_exists (Lisp_Object absname, const char *querystring,
                              int interactive, struct stat *statptr, int quick)
 {
@@ -1922,7 +1910,6 @@ on the system, we copy the SELinux context of FILE to NEWNAME.  */)
                         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)))
@@ -1934,7 +1921,6 @@ on the system, we copy the SELinux context of FILE to NEWNAME.  */)
          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.  */
@@ -2059,7 +2045,6 @@ DEFUN ("delete-directory-internal", Fdelete_directory_internal,
   (Lisp_Object directory)
 {
   const char *dir;
-  Lisp_Object handler;
   Lisp_Object encoded_dir;
 
   CHECK_STRING (directory);
@@ -2196,14 +2181,11 @@ This is what happens in interactive use with M-x.  */)
       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);
-          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
@@ -2215,11 +2197,7 @@ This is what happens in interactive use with M-x.  */)
          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);
@@ -2329,7 +2307,6 @@ This happens for interactive use with M-x.  */)
     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);
 
@@ -2351,17 +2328,17 @@ This happens for interactive use with M-x.  */)
              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;
-
-#else
-  UNGCPRO;
-  xsignal1 (Qfile_error, build_string ("Symbolic links are not supported"));
-
-#endif /* S_IFLNK */
 }
 
 \f
@@ -2408,7 +2385,7 @@ check_writable (const char *filename)
   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);
@@ -2500,7 +2477,7 @@ See also `file-exists-p' and `file-attributes'.  */)
   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.  */
@@ -2555,7 +2532,7 @@ 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;
-  return (statbuf.st_mode & S_IFMT) == S_IFDIR ? Qt : Qnil;
+  return S_ISDIR (statbuf.st_mode) ? Qt : Qnil;
 #else
   return (check_writable (!NILP (dir) ? SSDATA (dir) : "")
          ? Qt : Qnil);
@@ -2602,6 +2579,10 @@ points to a nonexistent file.  */)
   (Lisp_Object filename)
 {
   Lisp_Object handler;
+  char *buf;
+  int bufsize;
+  int valsize;
+  Lisp_Object val;
 
   CHECK_STRING (filename);
   filename = Fexpand_file_name (filename, Qnil);
@@ -2612,13 +2593,6 @@ points to a nonexistent file.  */)
   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;
@@ -2653,10 +2627,6 @@ points to a nonexistent file.  */)
   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,
@@ -2669,7 +2639,7 @@ See `file-symlink-p' to distinguish symlinks.  */)
   struct stat st;
   Lisp_Object handler;
 
-  absname = expand_and_dir_to_file (filename, B_ (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.  */
@@ -2681,7 +2651,7 @@ See `file-symlink-p' to distinguish symlinks.  */)
 
   if (stat (SSDATA (absname), &st) < 0)
     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,
@@ -2722,7 +2692,7 @@ See `file-symlink-p' to distinguish symlinks.  */)
   struct stat st;
   Lisp_Object handler;
 
-  absname = expand_and_dir_to_file (filename, B_ (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.  */
@@ -2744,12 +2714,12 @@ See `file-symlink-p' to distinguish symlinks.  */)
 
     if (result < 0)
       return Qnil;
-    return (st.st_mode & S_IFMT) == S_IFREG ? Qt : Qnil;
+    return S_ISREG (st.st_mode) ? Qt : Qnil;
   }
 #else
   if (stat (SSDATA (absname), &st) < 0)
     return Qnil;
-  return (st.st_mode & S_IFMT) == S_IFREG ? Qt : Qnil;
+  return S_ISREG (st.st_mode) ? Qt : Qnil;
 #endif
 }
 \f
@@ -2769,7 +2739,7 @@ if file does not exist, is not accessible, or SELinux is disabled */)
   context_t context;
 #endif
 
-  absname = expand_and_dir_to_file (filename, B_ (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.  */
@@ -2786,7 +2756,7 @@ if file does not exist, is not accessible, or SELinux is disabled */)
 #if HAVE_LIBSELINUX
   if (is_selinux_enabled ())
     {
-      conlength = lgetfilecon (SDATA (absname), &con);
+      conlength = lgetfilecon (SSDATA (absname), &con);
       if (conlength > 0)
        {
          context = context_new (con);
@@ -2827,7 +2797,7 @@ is disabled. */)
   context_t parsed_con;
 #endif
 
-  absname = Fexpand_file_name (filename, B_ (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.  */
@@ -2841,34 +2811,35 @@ is disabled. */)
   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 (context_user_set (parsed_con, SDATA (user)))
+             if (context_user_set (parsed_con, SSDATA (user)))
                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))
            {
-             if (context_type_set (parsed_con, SDATA (type)))
+             if (context_type_set (parsed_con, SSDATA (type)))
                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. */
-         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));
 
@@ -2894,7 +2865,7 @@ Return nil, if file does not exist or is not accessible.  */)
   struct stat st;
   Lisp_Object handler;
 
-  absname = expand_and_dir_to_file (filename, B_ (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.  */
@@ -2923,7 +2894,7 @@ symbolic notation, like the `chmod' command from GNU Coreutils.  */)
   Lisp_Object absname, encoded_absname;
   Lisp_Object handler;
 
-  absname = Fexpand_file_name (filename, B_ (current_buffer, directory));
+  absname = Fexpand_file_name (filename, BVAR (current_buffer, directory));
   CHECK_NUMBER (mode);
 
   /* If the file name has special constructs in it,
@@ -2970,28 +2941,28 @@ The value is an integer.  */)
 \f
 
 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.
-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'. */)
-  (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;
 
-  if (! lisp_time_argument (time, &sec, &usec))
+  if (! lisp_time_argument (timestamp, &sec, &usec))
     error ("Invalid time specification");
 
-  absname = Fexpand_file_name (filename, B_ (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))
-    return call3 (handler, Qset_file_times, absname, time);
+    return call3 (handler, Qset_file_times, absname, timestamp);
 
   encoded_absname = ENCODE_FILE (absname);
 
@@ -3007,8 +2978,7 @@ Use the current time if TIME is nil.  TIME is in the format of
         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));
@@ -3047,8 +3017,8 @@ otherwise, if FILE2 does not exist, the answer is t.  */)
 
   absname1 = Qnil;
   GCPRO2 (absname1, file2);
-  absname1 = expand_and_dir_to_file (file1, B_ (current_buffer, directory));
-  absname2 = expand_and_dir_to_file (file2, B_ (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,
@@ -3075,10 +3045,6 @@ otherwise, if FILE2 does not exist, the answer is t.  */)
   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
@@ -3116,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.  */
-  B_ (current_buffer, enable_multibyte_characters) = multibyte;
-  B_ (current_buffer, undo_list) = undo_list;
+  BVAR (current_buffer, enable_multibyte_characters) = multibyte;
+  BVAR (current_buffer, undo_list) = undo_list;
 
   return Qnil;
 }
@@ -3212,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 (!NILP (B_ (current_buffer, read_only)))
+  if (!NILP (BVAR (current_buffer, read_only)))
     Fbarf_if_buffer_read_only ();
 
   val = Qnil;
@@ -3271,7 +3237,6 @@ variable `last-coding-system-used' to the coding system actually used.  */)
       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.  */
@@ -3286,7 +3251,6 @@ variable `last-coding-system-used' to the coding system actually used.  */)
        xsignal2 (Qfile_error,
                  build_string ("not a regular file"), orig_filename);
     }
-#endif
 
   if (fd < 0)
     if ((fd = emacs_open (SSDATA (filename), O_RDONLY, 0)) < 0)
@@ -3394,25 +3358,25 @@ variable `last-coding-system-used' to the coding system actually used.  */)
              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 ());
 
-                 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);
-                 B_ (buf, directory) = B_ (current_buffer, directory);
-                 B_ (buf, read_only) = Qnil;
-                 B_ (buf, filename) = Qnil;
-                 B_ (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 ();
-                 B_ (buf, enable_multibyte_characters) = Qnil;
+                 BVAR (buf, enable_multibyte_characters) = Qnil;
 
                  insert_1_both ((char *) read_buf, nread, nread, 0, 0, 0);
                  TEMP_SET_PT_BOTH (BEG, BEG_BYTE);
@@ -3450,7 +3414,7 @@ variable `last-coding-system-used' to the coding system actually used.  */)
       else
        CHECK_CODING_SYSTEM (coding_system);
 
-      if (NILP (B_ (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);
@@ -3598,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
-                 && ! NILP (B_ (current_buffer, enable_multibyte_characters))
+                 && ! NILP (BVAR (current_buffer, enable_multibyte_characters))
                  && (CODING_MAY_REQUIRE_DECODING (&coding)))
                giveup_match_end = 1;
              break;
@@ -3617,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.  */
-         if (! NILP (B_ (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.  */
-         if (! NILP (B_ (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++;
@@ -3673,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 ();
-      int multibyte = ! NILP (B_ (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);
@@ -3778,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.  */
-      if (! NILP (B_ (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--;
@@ -3795,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.  */
-      if (! NILP (B_ (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++;
@@ -3870,9 +3834,9 @@ variable `last-coding-system-used' to the coding system actually used.  */)
   if (NILP (visit) && inserted > 0)
     {
 #ifdef CLASH_DETECTION
-      if (!NILP (B_ (current_buffer, file_truename))
+      if (!NILP (BVAR (current_buffer, file_truename))
          /* Make binding buffer-file-name to nil effective.  */
-         && !NILP (B_ (current_buffer, filename))
+         && !NILP (BVAR (current_buffer, filename))
          && SAVE_MODIFF >= MODIFF)
        we_locked_file = 1;
 #endif /* CLASH_DETECTION */
@@ -3912,7 +3876,7 @@ variable `last-coding-system-used' to the coding system actually used.  */)
 
        if (not_regular)
          {
-           Lisp_Object val;
+           Lisp_Object nbytes;
 
            /* Maybe make more room.  */
            if (gap_size < trytry)
@@ -3927,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;
-           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;
              }
 
-           this = XINT (val);
+           this = XINT (nbytes);
          }
        else
          {
@@ -3977,7 +3942,7 @@ variable `last-coding-system-used' to the coding system actually used.  */)
     {
 #ifdef CLASH_DETECTION
       if (we_locked_file)
-       unlock_file (B_ (current_buffer, file_truename));
+       unlock_file (BVAR (current_buffer, file_truename));
 #endif
       Vdeactivate_mark = old_Vdeactivate_mark;
     }
@@ -4026,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;
-         int count = SPECPDL_INDEX ();
+         int count1 = SPECPDL_INDEX ();
 
-         unwind_data = Fcons (B_ (current_buffer, enable_multibyte_characters),
-                              Fcons (B_ (current_buffer, undo_list),
+         unwind_data = Fcons (BVAR (current_buffer, enable_multibyte_characters),
+                              Fcons (BVAR (current_buffer, undo_list),
                                      Fcurrent_buffer ()));
-         B_ (current_buffer, enable_multibyte_characters) = Qnil;
-         B_ (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))
@@ -4053,7 +4018,7 @@ variable `last-coding-system-used' to the coding system actually used.  */)
              if (CONSP (coding_system))
                coding_system = XCAR (coding_system);
            }
-         unbind_to (count, Qnil);
+         unbind_to (count1, Qnil);
          inserted = Z_BYTE - BEG_BYTE;
        }
 
@@ -4062,7 +4027,7 @@ variable `last-coding-system-used' to the coding system actually used.  */)
       else
        CHECK_CODING_SYSTEM (coding_system);
 
-      if (NILP (B_ (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);
@@ -4080,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. */
-       B_ (current_buffer, enable_multibyte_characters) = Qnil;
+       BVAR (current_buffer, enable_multibyte_characters) = Qnil;
     }
 
-  coding.dst_multibyte = ! NILP (B_ (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)))
     {
@@ -4103,18 +4068,6 @@ variable `last-coding-system-used' to the coding system actually used.  */)
 
   /* 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))
-    B_ (current_buffer, buffer_file_type) = Qt;
-  else
-    B_ (current_buffer, buffer_file_type) = Qnil;
-#endif
-
  handled:
 
   if (deferred_remove_unwind_protect)
@@ -4124,24 +4077,24 @@ variable `last-coding-system-used' to the coding system actually used.  */)
 
   if (!NILP (visit))
     {
-      if (!EQ (B_ (current_buffer, undo_list), Qt) && !nochange)
-       B_ (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;
-         B_ (current_buffer, filename) = orig_filename;
+         BVAR (current_buffer, filename) = orig_filename;
        }
 
       SAVE_MODIFF = MODIFF;
       BUF_AUTOSAVE_MODIFF (current_buffer) = MODIFF;
-      XSETFASTINT (B_ (current_buffer, save_length), Z - BEG);
+      XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG);
 #ifdef CLASH_DETECTION
       if (NILP (handler))
        {
-         if (!NILP (B_ (current_buffer, file_truename)))
-           unlock_file (B_ (current_buffer, file_truename));
+         if (!NILP (BVAR (current_buffer, file_truename)))
+           unlock_file (BVAR (current_buffer, file_truename));
          unlock_file (filename);
        }
 #endif /* CLASH_DETECTION */
@@ -4168,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.  */
-      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.  */
-      old_undo = B_ (current_buffer, undo_list);
-      B_ (current_buffer, undo_list) = Qt;
+      old_undo = BVAR (current_buffer, undo_list);
+      BVAR (current_buffer, undo_list) = Qt;
 
       if (NILP (replace))
        {
@@ -4263,7 +4216,7 @@ variable `last-coding-system-used' to the coding system actually used.  */)
 
       if (NILP (visit))
        {
-         B_ (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
@@ -4278,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.  */
-       B_ (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
@@ -4332,8 +4285,8 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
   Lisp_Object eol_parent = Qnil;
 
   if (auto_saving
-      && NILP (Fstring_equal (B_ (current_buffer, filename),
-                             B_ (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;
@@ -4362,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;
 
-      val = B_ (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 (B_ (current_buffer, enable_multibyte_characters)))
+         if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
            force_raw_text = 1;
        }
 
@@ -4388,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.  */
-         val = B_ (current_buffer, buffer_file_coding_system);
+         val = BVAR (current_buffer, buffer_file_coding_system);
          using_default_coding = 1;
        }
 
@@ -4412,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
-         && ! NILP (B_ (&buffer_defaults, buffer_file_coding_system)))
+         && ! NILP (BVAR (&buffer_defaults, buffer_file_coding_system)))
        val = (coding_inherit_eol_type
-              (val, B_ (&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.  */
@@ -4425,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);
 
-  if (!STRINGP (start) && !NILP (B_ (current_buffer, selective_display)))
+  if (!STRINGP (start) && !NILP (BVAR (current_buffer, selective_display)))
     coding->mode |= CODING_MODE_SELECTIVE_DISPLAY;
   return val;
 }
@@ -4484,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;
-#ifdef DOS_NT
-  int buffer_file_type = O_BINARY;
-#endif /* DOS_NT */
   struct coding_system coding;
 
   if (current_buffer->base_buffer && visiting)
@@ -4529,8 +4479,8 @@ This calls `write-region-annotate-functions' at the start, and
       if (visiting)
        {
          SAVE_MODIFF = MODIFF;
-         XSETFASTINT (B_ (current_buffer, save_length), Z - BEG);
-         B_ (current_buffer, filename) = visit_file;
+         XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG);
+         BVAR (current_buffer, filename) = visit_file;
        }
       UNGCPRO;
       return val;
@@ -4596,7 +4546,7 @@ This calls `write-region-annotate-functions' at the start, and
   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 */
@@ -4604,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,
-                    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 */
@@ -4743,15 +4693,15 @@ This calls `write-region-annotate-functions' at the start, and
   if (visiting)
     {
       SAVE_MODIFF = MODIFF;
-      XSETFASTINT (B_ (current_buffer, save_length), Z - BEG);
-      B_ (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
-         && ! NILP (Fstring_equal (B_ (current_buffer, filename),
-                                   B_ (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;
@@ -4833,10 +4783,10 @@ build_annotations (Lisp_Object start, Lisp_Object end)
     }
 
   /* Now do the same for annotation functions implied by the file-format */
-  if (auto_saving && (!EQ (B_ (current_buffer, auto_save_file_format), Qt)))
-    p = B_ (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
-    p = B_ (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;
@@ -5015,17 +4965,17 @@ See Info node `(elisp)Modification Time' for more details.  */)
       b = XBUFFER (buf);
     }
 
-  if (!STRINGP (B_ (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.  */
-  handler = Ffind_file_name_handler (B_ (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);
 
-  filename = ENCODE_FILE (B_ (b, filename));
+  filename = ENCODE_FILE (BVAR (b, filename));
 
   if (stat (SSDATA (filename), &st) < 0)
     {
@@ -5093,7 +5043,7 @@ An argument specifies the modification time value to use
       struct stat st;
       Lisp_Object handler;
 
-      filename = Fexpand_file_name (B_ (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.  */
@@ -5114,8 +5064,8 @@ An argument specifies the modification time value to use
   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;
@@ -5128,8 +5078,8 @@ auto_save_error (Lisp_Object error)
   ring_bell (XFRAME (selected_frame));
 
   args[0] = build_string ("Auto-saving %s: %s");
-  args[1] = B_ (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);
@@ -5150,7 +5100,7 @@ auto_save_error (Lisp_Object error)
   return Qnil;
 }
 
-Lisp_Object
+static Lisp_Object
 auto_save_1 (void)
 {
   struct stat st;
@@ -5159,19 +5109,19 @@ auto_save_1 (void)
   auto_save_mode_bits = 0666;
 
   /* Get visited file's mode to become the auto save file's mode.  */
-  if (! NILP (B_ (current_buffer, filename)))
+  if (! NILP (BVAR (current_buffer, filename)))
     {
-      if (stat (SSDATA (B_ (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;
-      else if ((modes = Ffile_modes (B_ (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
-    Fwrite_region (Qnil, Qnil, B_ (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);
 }
@@ -5312,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.  */
-       if (STRINGP (B_ (b, auto_save_file_name))
+       if (STRINGP (BVAR (b, auto_save_file_name))
            && stream != NULL && do_handled_files == 0)
          {
            BLOCK_INPUT;
-           if (!NILP (B_ (b, filename)))
+           if (!NILP (BVAR (b, filename)))
              {
-               fwrite (SDATA (B_ (b, filename)), 1,
-                       SBYTES (B_ (b, filename)), stream);
+               fwrite (SDATA (BVAR (b, filename)), 1,
+                       SBYTES (BVAR (b, filename)), stream);
              }
            putc ('\n', stream);
-           fwrite (SDATA (B_ (b, auto_save_file_name)), 1,
-                   SBYTES (B_ (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;
          }
@@ -5340,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.  */
-       if (STRINGP (B_ (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.  */
-           && XINT (B_ (b, save_length)) >= 0
+           && XINT (BVAR (b, save_length)) >= 0
            && (do_handled_files
-               || NILP (Ffind_file_name_handler (B_ (b, auto_save_file_name),
+               || NILP (Ffind_file_name_handler (BVAR (b, auto_save_file_name),
                                                  Qwrite_region))))
          {
            EMACS_TIME before_time, after_time;
@@ -5360,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)
-               && (XFASTINT (B_ (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.  */
-               && XFASTINT (B_ (b, save_length)) > 5000
+               && XFASTINT (BVAR (b, save_length)) > 5000
                /* These messages are frequent and annoying for `*mail*'.  */
-               && !EQ (B_ (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",
-                                    B_ (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.  */
-               XSETINT (B_ (b, save_length), -1);
+               XSETINT (BVAR (b, save_length), -1);
                Fsleep_for (make_number (1), Qnil);
                continue;
              }
@@ -5385,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);
-           XSETFASTINT (B_ (current_buffer, save_length), Z - BEG);
+           XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG);
            set_buffer_internal (old);
 
            EMACS_GET_TIME (after_time);
@@ -5432,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;
-  XSETFASTINT (B_ (current_buffer, save_length), Z - BEG);
+  XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG);
   current_buffer->auto_save_failure_time = -1;
   return Qnil;
 }
@@ -5481,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)
 {
-  struct gcpro gcpro1, gcpro2;
+  struct gcpro gcpro1;
   Lisp_Object args[7];
 
   GCPRO1 (default_filename);
@@ -5586,11 +5536,6 @@ syms_of_fileio (void)
   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,
               doc: /* *Coding system for encoding file names.
 If it is nil, `default-file-name-coding-system' (which see) is used.  */);