summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1997-08-29 19:53:25 +0000
committerRichard M. Stallman <rms@gnu.org>1997-08-29 19:53:25 +0000
commitbdabf13c91d4b1df1ce18232c12c47b260d5d6bc (patch)
tree54f0d97a1bb11976cd7860a4bce3207d4776ae58 /src
parentd4335ff9aedf20c15d2d7d8f5a78c04b2c729f06 (diff)
downloademacs-bdabf13c91d4b1df1ce18232c12c47b260d5d6bc.tar.gz
(Fload): If FILE arg ends in .el or .elc, don't insist on adding a suffix.
Diffstat (limited to 'src')
-rw-r--r--src/lread.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/lread.c b/src/lread.c
index 8718a05c9d4..c065db926fe 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -395,8 +395,9 @@ Print messages at start and end of loading unless\n\
optional third arg NOMESSAGE is non-nil.\n\
If optional fourth arg NOSUFFIX is non-nil, don't try adding\n\
suffixes `.elc' or `.el' to the specified name FILE.\n\
-If optional fifth arg MUST-SUFFIX is non-nil, insist on adding\n\
- the suffixe `.elc' or `.el'; don't accept just FILE.\n\
+If optional fifth arg MUST-SUFFIX is non-nil, insist on\n\
+ the suffix `.elc' or `.el'; don't accept just FILE unless
+ it ends in one of those suffixes or includes a directory name.\n\
Return t if file exists.")
(file, noerror, nomessage, nosuffix, must_suffix)
Lisp_Object file, noerror, nomessage, nosuffix, must_suffix;
@@ -433,7 +434,25 @@ Return t if file exists.")
since it would try to load a directory as a Lisp file */
if (XSTRING (file)->size > 0)
{
+ int size = XSTRING (file)->size;
+
GCPRO1 (file);
+
+ if (! NILP (must_suffix))
+ {
+ /* Don't insist on adding a suffix if FILE already ends with one. */
+ if (size > 3
+ && !strcmp (XSTRING (file)->data + size - 3, ".el"))
+ must_suffix = Qnil;
+ else if (size > 4
+ && !strcmp (XSTRING (file)->data + size - 4, ".elc"))
+ must_suffix = Qnil;
+ /* Don't insist on adding a suffix
+ if the argument includes a directory name. */
+ else if (! NILP (Ffile_name_directory (file)))
+ must_suffix = Qnil;
+ }
+
fd = openp (Vload_path, file,
(!NILP (nosuffix) ? ""
: ! NILP (must_suffix) ? ".elc:.el"