mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-30 19:53:09 +00:00
Do not load native code when `load' is explicitly called on a .elc file
* src/lread.c (Fload): Do not load native code when `load' is explicitly called on a .elc file. (Flocate_file_internal): Update 'openp' call sites. (maybe_swap_for_eln): Add new 'no_native' parameter. (openp): Likewise + update 'maybe_swap_for_eln' and 'openp' call sites. * src/lisp.h: Update 'openp' signature. * src/w32proc.c (sys_spawnve): Update 'openp' call sites. * src/w32.c (check_windows_init_file): Likewise. * src/sound.c (Fplay_sound_internal): Likewise. * src/process.c (Fmake_process): Likewise. * src/image.c (image_create_bitmap_from_file) (image_find_image_fd): Likewise. * src/emacs.c (set_invocation_vars): Likewise. * src/charset.c (load_charset_map_from_file): Likewise. * src/callproc.c (call_process): Likewise.
This commit is contained in:
parent
3e133cc050
commit
b3ad62f8a3
@ -457,7 +457,7 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
|
||||
int ok;
|
||||
|
||||
ok = openp (Vexec_path, args[0], Vexec_suffixes, &path,
|
||||
make_fixnum (X_OK), false);
|
||||
make_fixnum (X_OK), false, false);
|
||||
if (ok < 0)
|
||||
report_file_error ("Searching for program", args[0]);
|
||||
}
|
||||
|
@ -486,7 +486,7 @@ load_charset_map_from_file (struct charset *charset, Lisp_Object mapfile,
|
||||
ptrdiff_t count = SPECPDL_INDEX ();
|
||||
record_unwind_protect_nothing ();
|
||||
specbind (Qfile_name_handler_alist, Qnil);
|
||||
fd = openp (Vcharset_map_path, mapfile, suffixes, NULL, Qnil, false);
|
||||
fd = openp (Vcharset_map_path, mapfile, suffixes, NULL, Qnil, false, false);
|
||||
fp = fd < 0 ? 0 : fdopen (fd, "r");
|
||||
if (!fp)
|
||||
{
|
||||
|
@ -468,8 +468,9 @@ set_invocation_vars (char *argv0, char const *original_pwd)
|
||||
if (NILP (Vinvocation_directory))
|
||||
{
|
||||
Lisp_Object found;
|
||||
int yes = openp (Vexec_path, Vinvocation_name,
|
||||
Vexec_suffixes, &found, make_fixnum (X_OK), false);
|
||||
int yes =
|
||||
openp (Vexec_path, Vinvocation_name, Vexec_suffixes, &found,
|
||||
make_fixnum (X_OK), false, false);
|
||||
if (yes == 1)
|
||||
{
|
||||
/* Add /: to the front of the name
|
||||
|
@ -519,7 +519,7 @@ image_create_bitmap_from_file (struct frame *f, Lisp_Object file)
|
||||
|
||||
/* Search bitmap-file-path for the file, if appropriate. */
|
||||
if (openp (Vx_bitmap_file_path, file, Qnil, &found,
|
||||
make_fixnum (R_OK), false)
|
||||
make_fixnum (R_OK), false, false)
|
||||
< 0)
|
||||
return -1;
|
||||
|
||||
@ -3128,7 +3128,7 @@ image_find_image_fd (Lisp_Object file, int *pfd)
|
||||
|
||||
/* Try to find FILE in data-directory/images, then x-bitmap-file-path. */
|
||||
fd = openp (search_path, file, Qnil, &file_found,
|
||||
pfd ? Qt : make_fixnum (R_OK), false);
|
||||
pfd ? Qt : make_fixnum (R_OK), false, false);
|
||||
if (fd >= 0 || fd == -2)
|
||||
{
|
||||
file_found = ENCODE_FILE (file_found);
|
||||
|
@ -4087,7 +4087,7 @@ extern bool suffix_p (Lisp_Object, const char *);
|
||||
extern Lisp_Object save_match_data_load (Lisp_Object, Lisp_Object, Lisp_Object,
|
||||
Lisp_Object, Lisp_Object);
|
||||
extern int openp (Lisp_Object, Lisp_Object, Lisp_Object,
|
||||
Lisp_Object *, Lisp_Object, bool);
|
||||
Lisp_Object *, Lisp_Object, bool, bool);
|
||||
enum { S2N_IGNORE_TRAILING = 1 };
|
||||
extern Lisp_Object string_to_number (char const *, int, ptrdiff_t *);
|
||||
extern void map_obarray (Lisp_Object, void (*) (Lisp_Object, Lisp_Object),
|
||||
|
24
src/lread.c
24
src/lread.c
@ -1240,6 +1240,8 @@ Return t if the file exists and loads successfully. */)
|
||||
else
|
||||
file = Fsubstitute_in_file_name (file);
|
||||
|
||||
bool no_native = suffix_p (file, ".elc");
|
||||
|
||||
/* Avoid weird lossage with null string as arg,
|
||||
since it would try to load a directory as a Lisp file. */
|
||||
if (SCHARS (file) == 0)
|
||||
@ -1280,7 +1282,9 @@ Return t if the file exists and loads successfully. */)
|
||||
suffixes = CALLN (Fappend, suffixes, Vload_file_rep_suffixes);
|
||||
}
|
||||
|
||||
fd = openp (Vload_path, file, suffixes, &found, Qnil, load_prefer_newer);
|
||||
fd =
|
||||
openp (Vload_path, file, suffixes, &found, Qnil, load_prefer_newer,
|
||||
no_native);
|
||||
}
|
||||
|
||||
if (fd == -1)
|
||||
@ -1635,7 +1639,7 @@ directories, make sure the PREDICATE function returns `dir-ok' for them. */)
|
||||
(Lisp_Object filename, Lisp_Object path, Lisp_Object suffixes, Lisp_Object predicate)
|
||||
{
|
||||
Lisp_Object file;
|
||||
int fd = openp (path, filename, suffixes, &file, predicate, false);
|
||||
int fd = openp (path, filename, suffixes, &file, predicate, false, false);
|
||||
if (NILP (predicate) && fd >= 0)
|
||||
emacs_close (fd);
|
||||
return file;
|
||||
@ -1645,12 +1649,13 @@ directories, make sure the PREDICATE function returns `dir-ok' for them. */)
|
||||
If found replace the content of FILENAME and FD. */
|
||||
|
||||
static void
|
||||
maybe_swap_for_eln (Lisp_Object *filename, int *fd)
|
||||
maybe_swap_for_eln (bool no_native, Lisp_Object *filename, int *fd)
|
||||
{
|
||||
#ifdef HAVE_NATIVE_COMP
|
||||
struct stat eln_st;
|
||||
|
||||
if (load_no_native
|
||||
if (no_native
|
||||
|| load_no_native
|
||||
|| !suffix_p (*filename, ".elc"))
|
||||
return;
|
||||
|
||||
@ -1714,11 +1719,14 @@ maybe_swap_for_eln (Lisp_Object *filename, int *fd)
|
||||
|
||||
If NEWER is true, try all SUFFIXes and return the result for the
|
||||
newest file that exists. Does not apply to remote files,
|
||||
or if a non-nil and non-t PREDICATE is specified. */
|
||||
or if a non-nil and non-t PREDICATE is specified.
|
||||
|
||||
if NO_NATIVE is true do not try to load native code. */
|
||||
|
||||
int
|
||||
openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes,
|
||||
Lisp_Object *storeptr, Lisp_Object predicate, bool newer)
|
||||
Lisp_Object *storeptr, Lisp_Object predicate, bool newer,
|
||||
bool no_native)
|
||||
{
|
||||
ptrdiff_t fn_size = 100;
|
||||
char buf[100];
|
||||
@ -1928,7 +1936,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes,
|
||||
}
|
||||
else
|
||||
{
|
||||
maybe_swap_for_eln (&string, &fd);
|
||||
maybe_swap_for_eln (no_native, &string, &fd);
|
||||
/* We succeeded; return this descriptor and filename. */
|
||||
if (storeptr)
|
||||
*storeptr = string;
|
||||
@ -1940,7 +1948,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes,
|
||||
/* No more suffixes. Return the newest. */
|
||||
if (0 <= save_fd && ! CONSP (XCDR (tail)))
|
||||
{
|
||||
maybe_swap_for_eln (&save_string, &save_fd);
|
||||
maybe_swap_for_eln (no_native, &save_string, &save_fd);
|
||||
if (storeptr)
|
||||
*storeptr = save_string;
|
||||
SAFE_FREE ();
|
||||
|
@ -1936,7 +1936,7 @@ usage: (make-process &rest ARGS) */)
|
||||
{
|
||||
tem = Qnil;
|
||||
openp (Vexec_path, program, Vexec_suffixes, &tem,
|
||||
make_fixnum (X_OK), false);
|
||||
make_fixnum (X_OK), false, false);
|
||||
if (NILP (tem))
|
||||
report_file_error ("Searching for program", program);
|
||||
tem = Fexpand_file_name (tem, Qnil);
|
||||
|
@ -1370,8 +1370,9 @@ Internal use only, use `play-sound' instead. */)
|
||||
if (STRINGP (attrs[SOUND_FILE]))
|
||||
{
|
||||
/* Open the sound file. */
|
||||
current_sound->fd = openp (list1 (Vdata_directory),
|
||||
attrs[SOUND_FILE], Qnil, &file, Qnil, false);
|
||||
current_sound->fd =
|
||||
openp (list1 (Vdata_directory), attrs[SOUND_FILE], Qnil, &file, Qnil,
|
||||
false, false);
|
||||
if (current_sound->fd < 0)
|
||||
sound_perror ("Could not open sound file");
|
||||
|
||||
|
@ -10255,7 +10255,8 @@ check_windows_init_file (void)
|
||||
need to ENCODE_FILE here, but we do need to convert the file
|
||||
names from UTF-8 to ANSI. */
|
||||
init_file = build_string ("term/w32-win");
|
||||
fd = openp (Vload_path, init_file, Fget_load_suffixes (), NULL, Qnil, 0);
|
||||
fd =
|
||||
openp (Vload_path, init_file, Fget_load_suffixes (), NULL, Qnil, 0, 0);
|
||||
if (fd < 0)
|
||||
{
|
||||
Lisp_Object load_path_print = Fprin1_to_string (Vload_path, Qnil);
|
||||
|
@ -1918,7 +1918,8 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp)
|
||||
{
|
||||
program = build_string (cmdname);
|
||||
full = Qnil;
|
||||
openp (Vexec_path, program, Vexec_suffixes, &full, make_fixnum (X_OK), 0);
|
||||
openp (Vexec_path, program, Vexec_suffixes, &full, make_fixnum (X_OK),
|
||||
0, 0);
|
||||
if (NILP (full))
|
||||
{
|
||||
errno = EINVAL;
|
||||
|
Loading…
Reference in New Issue
Block a user