emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r105479: Fix bug #9311 with loading o


From: Eli Zaretskii
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r105479: Fix bug #9311 with loading on MS-Windows .elc files in root directories.
Date: Wed, 17 Aug 2011 11:50:08 +0300
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 105479
fixes bug(s): http://debbugs.gnu.org/9311
committer: Eli Zaretskii <address@hidden>
branch nick: trunk
timestamp: Wed 2011-08-17 11:50:08 +0300
message:
  Fix bug #9311 with loading on MS-Windows .elc files in root directories.
  
   src/lread.c (Fload) [DOS_NT]: If `openp' returns -2, but the file
   has no `load' handler, try opening the file locally.
modified:
  src/ChangeLog
  src/lread.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2011-08-16 20:31:32 +0000
+++ b/src/ChangeLog     2011-08-17 08:50:08 +0000
@@ -1,3 +1,8 @@
+2011-08-17  Eli Zaretskii  <address@hidden>
+
+       * lread.c (Fload) [DOS_NT]: If `openp' returns -2, but the file
+       has no `load' handler, try opening the file locally.  (Bug#9311)
+
 2011-08-16  Ken Brown  <address@hidden>
 
        * gmalloc.c: Expand comment.

=== modified file 'src/lread.c'
--- a/src/lread.c       2011-07-28 20:23:19 +0000
+++ b/src/lread.c       2011-08-17 08:50:08 +0000
@@ -1124,6 +1124,22 @@
        handler = Ffind_file_name_handler (found, Qload);
       if (! NILP (handler))
        return call5 (handler, Qload, found, noerror, nomessage, Qt);
+#ifdef DOS_NT
+      /* Tramp has to deal with semi-broken packages that prepend
+        drive letters to remote files.  For that reason, Tramp
+        catches file operations that test for file existence, which
+        makes openp think X:/foo.elc files are remote.  However,
+        Tramp does not catch `load' operations for such files, so we
+        end up with a nil as the `load' handler above.  If we would
+        continue with fd = -2, we will behave wrongly, and in
+        particular try reading a .elc file in the "rt" mode instead
+        of "rb".  See bug #9311 for the results.  To work around
+        this, we try to open the file locally, and go with that if it
+        succeeds.  */
+      fd = emacs_open (SSDATA (ENCODE_FILE (found)), O_RDONLY, 0);
+      if (fd == -1)
+       fd = -2;
+#endif
     }
 
   /* Check if we're stuck in a recursive load cycle.
@@ -1247,9 +1263,17 @@
   GCPRO3 (file, found, hist_file_name);
 
 #ifdef WINDOWSNT
-  emacs_close (fd);
   efound = ENCODE_FILE (found);
-  stream = fopen (SSDATA (efound), fmode);
+  /* If we somehow got here with fd == -2, meaning the file is deemed
+     to be remote, don't even try to reopen the file locally; just
+     force a failure instead.  */
+  if (fd >= 0)
+    {
+      emacs_close (fd);
+      stream = fopen (SSDATA (efound), fmode);
+    }
+  else
+    stream = NULL;
 #else  /* not WINDOWSNT */
   stream = fdopen (fd, fmode);
 #endif /* not WINDOWSNT */


reply via email to

[Prev in Thread] Current Thread [Next in Thread]