aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAurélien Aptel2015-11-16 00:53:15 +0100
committerTed Zlatanov2015-11-18 14:24:28 -0500
commit218caccd968d16a1a8d1f336e72f211c3e169142 (patch)
treecddfb2f8c614b7d390c84b49d5415e8a62aee2c5 /src
parent307e76c79979736c109cfa6de07b1567700231f3 (diff)
downloademacs-218caccd968d16a1a8d1f336e72f211c3e169142.tar.gz
emacs-218caccd968d16a1a8d1f336e72f211c3e169142.zip
Make 'Fload' look for modules
'Fload' can now load dynamic modules. This also makes 'require' work. * src/lread.c: (suffix_p): New function. (Fload): Use 'suffix_p'. Call 'Fmodule_load' when we try to load a file with a module suffix. (syms_of_lread): Append module suffix to 'Vload_suffixes'.
Diffstat (limited to 'src')
-rw-r--r--src/lread.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/lread.c b/src/lread.c
index c4456f37f6d..4a89d7d8133 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -975,6 +975,16 @@ This uses the variables `load-suffixes' and `load-file-rep-suffixes'. */)
975 return Fnreverse (lst); 975 return Fnreverse (lst);
976} 976}
977 977
978/* Returns true if STRING ends with SUFFIX */
979static bool
980suffix_p (Lisp_Object string, const char *suffix)
981{
982 const size_t suffix_len = strlen (suffix);
983 const size_t string_len = SBYTES (string);
984
985 return string_len >= suffix_len && !strcmp (SSDATA (string) + string_len - suffix_len, suffix);
986}
987
978DEFUN ("load", Fload, Sload, 1, 5, 0, 988DEFUN ("load", Fload, Sload, 1, 5, 0,
979 doc: /* Execute a file of Lisp code named FILE. 989 doc: /* Execute a file of Lisp code named FILE.
980First try FILE with `.elc' appended, then try with `.el', 990First try FILE with `.elc' appended, then try with `.el',
@@ -1075,11 +1085,7 @@ Return t if the file exists and loads successfully. */)
1075 { 1085 {
1076 /* Don't insist on adding a suffix if FILE already ends with one. */ 1086 /* Don't insist on adding a suffix if FILE already ends with one. */
1077 ptrdiff_t size = SBYTES (file); 1087 ptrdiff_t size = SBYTES (file);
1078 if (size > 3 1088 if (suffix_p (file, ".el") || suffix_p (file, ".elc"))
1079 && !strcmp (SSDATA (file) + size - 3, ".el"))
1080 must_suffix = Qnil;
1081 else if (size > 4
1082 && !strcmp (SSDATA (file) + size - 4, ".elc"))
1083 must_suffix = Qnil; 1089 must_suffix = Qnil;
1084 /* Don't insist on adding a suffix 1090 /* Don't insist on adding a suffix
1085 if the argument includes a directory name. */ 1091 if the argument includes a directory name. */
@@ -1151,6 +1157,13 @@ Return t if the file exists and loads successfully. */)
1151 record_unwind_protect_int (close_file_unwind, fd); 1157 record_unwind_protect_int (close_file_unwind, fd);
1152 } 1158 }
1153 1159
1160#ifdef HAVE_MODULES
1161 if (suffix_p (found, MODULES_SUFFIX))
1162 {
1163 return Fmodule_load (found);
1164 }
1165#endif
1166
1154 /* Check if we're stuck in a recursive load cycle. 1167 /* Check if we're stuck in a recursive load cycle.
1155 1168
1156 2000-09-21: It's not possible to just check for the file loaded 1169 2000-09-21: It's not possible to just check for the file loaded
@@ -1189,8 +1202,7 @@ Return t if the file exists and loads successfully. */)
1189 specbind (Qold_style_backquotes, Qnil); 1202 specbind (Qold_style_backquotes, Qnil);
1190 record_unwind_protect (load_warn_old_style_backquotes, file); 1203 record_unwind_protect (load_warn_old_style_backquotes, file);
1191 1204
1192 if (!memcmp (SDATA (found) + SBYTES (found) - 4, ".elc", 4) 1205 if (suffix_p (found, ".elc") || (fd >= 0 && (version = safe_to_load_version (fd)) > 0))
1193 || (fd >= 0 && (version = safe_to_load_version (fd)) > 0))
1194 /* Load .elc files directly, but not when they are 1206 /* Load .elc files directly, but not when they are
1195 remote and have no handler! */ 1207 remote and have no handler! */
1196 { 1208 {
@@ -4491,8 +4503,14 @@ and without trailing slashes. */);
4491This list should not include the empty string. 4503This list should not include the empty string.
4492`load' and related functions try to append these suffixes, in order, 4504`load' and related functions try to append these suffixes, in order,
4493to the specified file name if a Lisp suffix is allowed or required. */); 4505to the specified file name if a Lisp suffix is allowed or required. */);
4506#ifdef HAVE_MODULES
4507 Vload_suffixes = list3 (build_pure_c_string (".elc"),
4508 build_pure_c_string (".el"),
4509 build_pure_c_string (MODULES_SUFFIX));
4510#else
4494 Vload_suffixes = list2 (build_pure_c_string (".elc"), 4511 Vload_suffixes = list2 (build_pure_c_string (".elc"),
4495 build_pure_c_string (".el")); 4512 build_pure_c_string (".el"));
4513#endif
4496 DEFVAR_LISP ("load-file-rep-suffixes", Vload_file_rep_suffixes, 4514 DEFVAR_LISP ("load-file-rep-suffixes", Vload_file_rep_suffixes,
4497 doc: /* List of suffixes that indicate representations of \ 4515 doc: /* List of suffixes that indicate representations of \
4498the same file. 4516the same file.