aboutsummaryrefslogtreecommitdiffstats
path: root/src/comp.c
diff options
context:
space:
mode:
authorAndrea Corallo2020-09-10 07:35:29 +0200
committerAndrea Corallo2020-09-10 08:36:51 +0200
commit107514a6e21f2c434cdae0eca76fe0a60e287ac8 (patch)
tree19ac408e9fc9da958ce501cf6b93403158128f03 /src/comp.c
parentc2724c3ebb7228ecd8607c3017334e0efb57e069 (diff)
downloademacs-107514a6e21f2c434cdae0eca76fe0a60e287ac8.tar.gz
emacs-107514a6e21f2c434cdae0eca76fe0a60e287ac8.zip
* Fix rename file error when reloading the same file from an sys eln dir.
* src/comp.c (Fnative_elisp_load): Don't rename files we don't have the permission for.
Diffstat (limited to 'src/comp.c')
-rw-r--r--src/comp.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/comp.c b/src/comp.c
index 5880224ac77..4550833a6a2 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -4924,17 +4924,24 @@ DEFUN ("native-elisp-load", Fnative_elisp_load, Snative_elisp_load, 1, 2, 0,
4924 xsignal2 (Qnative_lisp_load_failed, build_string ("file does not exists"), 4924 xsignal2 (Qnative_lisp_load_failed, build_string ("file does not exists"),
4925 filename); 4925 filename);
4926 struct Lisp_Native_Comp_Unit *comp_u = allocate_native_comp_unit (); 4926 struct Lisp_Native_Comp_Unit *comp_u = allocate_native_comp_unit ();
4927 if (!NILP (Fgethash (filename, all_loaded_comp_units_h, Qnil))) 4927
4928 if (!NILP (Fgethash (filename, all_loaded_comp_units_h, Qnil))
4929 && !NILP (Ffile_writable_p (filename)))
4928 { 4930 {
4929 /* If in this session there was ever a file loaded with this 4931 /* If in this session there was ever a file loaded with this
4930 name rename before loading it to make sure we always get a 4932 name rename before loading it to make sure we always get a
4931 new handle! */ 4933 new handle! */
4932 Lisp_Object tmp_filename = 4934 Lisp_Object tmp_filename =
4933 Fmake_temp_file_internal (filename, make_fixnum (0), 4935 Fmake_temp_file_internal (filename, Qnil, build_string (".eln.tmp"),
4934 build_string (".eln"), Qnil); 4936 Qnil);
4935 Frename_file (filename, tmp_filename, Qnil); 4937 if (NILP (Ffile_writable_p (tmp_filename)))
4936 comp_u->handle = dynlib_open (SSDATA (tmp_filename)); 4938 comp_u->handle = dynlib_open (SSDATA (filename));
4937 Frename_file (tmp_filename, filename, Qnil); 4939 else
4940 {
4941 Frename_file (filename, tmp_filename, Qt);
4942 comp_u->handle = dynlib_open (SSDATA (tmp_filename));
4943 Frename_file (tmp_filename, filename, Qnil);
4944 }
4938 } 4945 }
4939 else 4946 else
4940 comp_u->handle = dynlib_open (SSDATA (filename)); 4947 comp_u->handle = dynlib_open (SSDATA (filename));