aboutsummaryrefslogtreecommitdiffstats
path: root/src/lread.c
diff options
context:
space:
mode:
authorK. Handa2016-01-03 17:53:43 +0900
committerK. Handa2016-01-03 17:53:43 +0900
commitfb6d826c69939c2d016c1b824d4e9bcb53d9e643 (patch)
treeb9ce862d6cbe25e740203421984df21e4cbadbf4 /src/lread.c
parent536f48e9a2251b9e654ea974bd90ff2f40218753 (diff)
parent91917dd58ec5278e555b9c693a830749083e8f89 (diff)
downloademacs-fb6d826c69939c2d016c1b824d4e9bcb53d9e643.tar.gz
emacs-fb6d826c69939c2d016c1b824d4e9bcb53d9e643.zip
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Diffstat (limited to 'src/lread.c')
-rw-r--r--src/lread.c87
1 files changed, 60 insertions, 27 deletions
diff --git a/src/lread.c b/src/lread.c
index c4456f37f6d..74a5fdfe67b 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -975,9 +975,20 @@ 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 ptrdiff_t suffix_len = strlen (suffix);
983 ptrdiff_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', then try
991with a system-dependent suffix of dynamic modules (see `load-suffixes'),
981then try FILE unmodified (the exact suffixes in the exact order are 992then try FILE unmodified (the exact suffixes in the exact order are
982determined by `load-suffixes'). Environment variable references in 993determined by `load-suffixes'). Environment variable references in
983FILE are replaced with their values by calling `substitute-in-file-name'. 994FILE are replaced with their values by calling `substitute-in-file-name'.
@@ -989,10 +1000,10 @@ Print messages at start and end of loading unless
989optional third arg NOMESSAGE is non-nil (but `force-load-messages' 1000optional third arg NOMESSAGE is non-nil (but `force-load-messages'
990overrides that). 1001overrides that).
991If optional fourth arg NOSUFFIX is non-nil, don't try adding 1002If optional fourth arg NOSUFFIX is non-nil, don't try adding
992suffixes `.elc' or `.el' to the specified name FILE. 1003suffixes to the specified name FILE.
993If optional fifth arg MUST-SUFFIX is non-nil, insist on 1004If optional fifth arg MUST-SUFFIX is non-nil, insist on
994the suffix `.elc' or `.el'; don't accept just FILE unless 1005the suffix `.elc' or `.el' or the module suffix; don't accept just
995it ends in one of those suffixes or includes a directory name. 1006FILE unless it ends in one of those suffixes or includes a directory name.
996 1007
997If NOSUFFIX is nil, then if a file could not be found, try looking for 1008If NOSUFFIX is nil, then if a file could not be found, try looking for
998a different representation of the file by adding non-empty suffixes to 1009a different representation of the file by adding non-empty suffixes to
@@ -1074,12 +1085,12 @@ Return t if the file exists and loads successfully. */)
1074 if (! NILP (must_suffix)) 1085 if (! NILP (must_suffix))
1075 { 1086 {
1076 /* Don't insist on adding a suffix if FILE already ends with one. */ 1087 /* Don't insist on adding a suffix if FILE already ends with one. */
1077 ptrdiff_t size = SBYTES (file); 1088 if (suffix_p (file, ".el")
1078 if (size > 3 1089 || suffix_p (file, ".elc")
1079 && !strcmp (SSDATA (file) + size - 3, ".el")) 1090#ifdef HAVE_MODULES
1080 must_suffix = Qnil; 1091 || suffix_p (file, MODULES_SUFFIX)
1081 else if (size > 4 1092#endif
1082 && !strcmp (SSDATA (file) + size - 4, ".elc")) 1093 )
1083 must_suffix = Qnil; 1094 must_suffix = Qnil;
1084 /* Don't insist on adding a suffix 1095 /* Don't insist on adding a suffix
1085 if the argument includes a directory name. */ 1096 if the argument includes a directory name. */
@@ -1151,6 +1162,11 @@ Return t if the file exists and loads successfully. */)
1151 record_unwind_protect_int (close_file_unwind, fd); 1162 record_unwind_protect_int (close_file_unwind, fd);
1152 } 1163 }
1153 1164
1165#ifdef HAVE_MODULES
1166 if (suffix_p (found, MODULES_SUFFIX))
1167 return unbind_to (count, Fmodule_load (found));
1168#endif
1169
1154 /* Check if we're stuck in a recursive load cycle. 1170 /* Check if we're stuck in a recursive load cycle.
1155 1171
1156 2000-09-21: It's not possible to just check for the file loaded 1172 2000-09-21: It's not possible to just check for the file loaded
@@ -1189,8 +1205,7 @@ Return t if the file exists and loads successfully. */)
1189 specbind (Qold_style_backquotes, Qnil); 1205 specbind (Qold_style_backquotes, Qnil);
1190 record_unwind_protect (load_warn_old_style_backquotes, file); 1206 record_unwind_protect (load_warn_old_style_backquotes, file);
1191 1207
1192 if (!memcmp (SDATA (found) + SBYTES (found) - 4, ".elc", 4) 1208 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 1209 /* Load .elc files directly, but not when they are
1195 remote and have no handler! */ 1210 remote and have no handler! */
1196 { 1211 {
@@ -1926,17 +1941,22 @@ readevalloop (Lisp_Object readcharfun,
1926} 1941}
1927 1942
1928DEFUN ("eval-buffer", Feval_buffer, Seval_buffer, 0, 5, "", 1943DEFUN ("eval-buffer", Feval_buffer, Seval_buffer, 0, 5, "",
1929 doc: /* Execute the current buffer as Lisp code. 1944 doc: /* Execute the accessible portion of current buffer as Lisp code.
1945You can use \\[narrow-to-region] to limit the part of buffer to be evaluated.
1930When called from a Lisp program (i.e., not interactively), this 1946When called from a Lisp program (i.e., not interactively), this
1931function accepts up to five optional arguments: 1947function accepts up to five optional arguments:
1932BUFFER is the buffer to evaluate (nil means use current buffer). 1948BUFFER is the buffer to evaluate (nil means use current buffer),
1933PRINTFLAG controls printing of output: 1949 or a name of a buffer (a string).
1934 A value of nil means discard it; anything else is stream for print. 1950PRINTFLAG controls printing of output by any output functions in the
1951 evaluated code, such as `print', `princ', and `prin1':
1952 a value of nil means discard it; anything else is the stream to print to.
1953 See Info node `(elisp)Output Streams' for details on streams.
1935FILENAME specifies the file name to use for `load-history'. 1954FILENAME specifies the file name to use for `load-history'.
1936UNIBYTE, if non-nil, specifies `load-convert-to-unibyte' for this 1955UNIBYTE, if non-nil, specifies `load-convert-to-unibyte' for this
1937 invocation. 1956 invocation.
1938DO-ALLOW-PRINT, if non-nil, specifies that `print' and related 1957DO-ALLOW-PRINT, if non-nil, specifies that output functions in the
1939 functions should work normally even if PRINTFLAG is nil. 1958 evaluated code should work normally even if PRINTFLAG is nil, in
1959 which case the output is displayed in the echo area.
1940 1960
1941This function preserves the position of point. */) 1961This function preserves the position of point. */)
1942 (Lisp_Object buffer, Lisp_Object printflag, Lisp_Object filename, Lisp_Object unibyte, Lisp_Object do_allow_print) 1962 (Lisp_Object buffer, Lisp_Object printflag, Lisp_Object filename, Lisp_Object unibyte, Lisp_Object do_allow_print)
@@ -1977,7 +1997,8 @@ When called from programs, expects two arguments,
1977giving starting and ending indices in the current buffer 1997giving starting and ending indices in the current buffer
1978of the text to be executed. 1998of the text to be executed.
1979Programs can pass third argument PRINTFLAG which controls output: 1999Programs can pass third argument PRINTFLAG which controls output:
1980A value of nil means discard it; anything else is stream for printing it. 2000 a value of nil means discard it; anything else is stream for printing it.
2001 See Info node `(elisp)Output Streams' for details on streams.
1981Also the fourth argument READ-FUNCTION, if non-nil, is used 2002Also the fourth argument READ-FUNCTION, if non-nil, is used
1982instead of `read' to read each expression. It gets one argument 2003instead of `read' to read each expression. It gets one argument
1983which is the input stream for reading characters. 2004which is the input stream for reading characters.
@@ -3926,10 +3947,8 @@ oblookup (Lisp_Object obarray, register const char *ptr, ptrdiff_t size, ptrdiff
3926 Lisp_Object bucket, tem; 3947 Lisp_Object bucket, tem;
3927 3948
3928 obarray = check_obarray (obarray); 3949 obarray = check_obarray (obarray);
3929 obsize = ASIZE (obarray);
3930
3931 /* This is sometimes needed in the middle of GC. */ 3950 /* This is sometimes needed in the middle of GC. */
3932 obsize &= ~ARRAY_MARK_FLAG; 3951 obsize = gc_asize (obarray);
3933 hash = hash_string (ptr, size_byte) % obsize; 3952 hash = hash_string (ptr, size_byte) % obsize;
3934 bucket = AREF (obarray, hash); 3953 bucket = AREF (obarray, hash);
3935 oblookup_last_bucket_number = hash; 3954 oblookup_last_bucket_number = hash;
@@ -4334,7 +4353,7 @@ init_lread (void)
4334 load_path_check (default_lpath); 4353 load_path_check (default_lpath);
4335 4354
4336 /* Add the site-lisp directories to the front of the default. */ 4355 /* Add the site-lisp directories to the front of the default. */
4337 if (!no_site_lisp) 4356 if (!no_site_lisp && PATH_SITELOADSEARCH[0] != '\0')
4338 { 4357 {
4339 Lisp_Object sitelisp; 4358 Lisp_Object sitelisp;
4340 sitelisp = decode_env_path (0, PATH_SITELOADSEARCH, 0); 4359 sitelisp = decode_env_path (0, PATH_SITELOADSEARCH, 0);
@@ -4365,7 +4384,7 @@ init_lread (void)
4365 load_path_check (Vload_path); 4384 load_path_check (Vload_path);
4366 4385
4367 /* Add the site-lisp directories at the front. */ 4386 /* Add the site-lisp directories at the front. */
4368 if (initialized && !no_site_lisp) 4387 if (initialized && !no_site_lisp && PATH_SITELOADSEARCH[0] != '\0')
4369 { 4388 {
4370 Lisp_Object sitelisp; 4389 Lisp_Object sitelisp;
4371 sitelisp = decode_env_path (0, PATH_SITELOADSEARCH, 0); 4390 sitelisp = decode_env_path (0, PATH_SITELOADSEARCH, 0);
@@ -4436,7 +4455,7 @@ to find all the symbols in an obarray, use `mapatoms'. */);
4436 4455
4437 DEFVAR_LISP ("values", Vvalues, 4456 DEFVAR_LISP ("values", Vvalues,
4438 doc: /* List of values of all expressions which were read, evaluated and printed. 4457 doc: /* List of values of all expressions which were read, evaluated and printed.
4439 Order is reverse chronological. */); 4458Order is reverse chronological. */);
4440 XSYMBOL (intern ("values"))->declared_special = 0; 4459 XSYMBOL (intern ("values"))->declared_special = 0;
4441 4460
4442 DEFVAR_LISP ("standard-input", Vstandard_input, 4461 DEFVAR_LISP ("standard-input", Vstandard_input,
@@ -4487,12 +4506,26 @@ programs that process this list should tolerate directories both with
4487and without trailing slashes. */); 4506and without trailing slashes. */);
4488 4507
4489 DEFVAR_LISP ("load-suffixes", Vload_suffixes, 4508 DEFVAR_LISP ("load-suffixes", Vload_suffixes,
4490 doc: /* List of suffixes for (compiled or source) Emacs Lisp files. 4509 doc: /* List of suffixes for Emacs Lisp files and dynamic modules.
4510This list includes suffixes for both compiled and source Emacs Lisp files.
4491This list should not include the empty string. 4511This list should not include the empty string.
4492`load' and related functions try to append these suffixes, in order, 4512`load' and related functions try to append these suffixes, in order,
4493to the specified file name if a Lisp suffix is allowed or required. */); 4513to the specified file name if a suffix is allowed or required. */);
4514#ifdef HAVE_MODULES
4515 Vload_suffixes = list3 (build_pure_c_string (".elc"),
4516 build_pure_c_string (".el"),
4517 build_pure_c_string (MODULES_SUFFIX));
4518#else
4494 Vload_suffixes = list2 (build_pure_c_string (".elc"), 4519 Vload_suffixes = list2 (build_pure_c_string (".elc"),
4495 build_pure_c_string (".el")); 4520 build_pure_c_string (".el"));
4521#endif
4522 DEFVAR_LISP ("module-file-suffix", Vmodule_file_suffix,
4523 doc: /* Suffix of loadable module file, or nil of modules are not supported. */);
4524#ifdef HAVE_MODULES
4525 Vmodule_file_suffix = build_pure_c_string (MODULES_SUFFIX);
4526#else
4527 Vmodule_file_suffix = Qnil;
4528#endif
4496 DEFVAR_LISP ("load-file-rep-suffixes", Vload_file_rep_suffixes, 4529 DEFVAR_LISP ("load-file-rep-suffixes", Vload_file_rep_suffixes,
4497 doc: /* List of suffixes that indicate representations of \ 4530 doc: /* List of suffixes that indicate representations of \
4498the same file. 4531the same file.