Subject: bug#37819: [PATCH] Make 'load-dangerous-libraries' obsolete

From: Stefan Kangas <[email-masked]>
Date: Thu, 23 Jan 2020 18:12:48 +0100

Lars Ingebrigtsen <[email-masked]> writes:

> Stefan Kangas <[email-masked]> writes:
>
>> Does anyone have any objections to installing this on master?
>
> Looks good to me.

I realized that we can also remove some now extraneous warnings that
will never happen with the patch (since Fload errors out before them).
Please find attached an updated patch.

Best regards,
Stefan Kangas

>From 46c857bdb2ee9234fe1a241b49168ee11a31315b Mon Sep 17 00:00:00 2001
From: Stefan Kangas <[email-masked]>
Date: Sat, 19 Oct 2019 02:05:50 +0200
Subject: [PATCH] Make 'load-dangerous-libraries' obsolete (Bug#37819)

* lisp/subr.el (load-dangerous-libraries): Declare obsolete.
* src/lread.c (Fload): Ignore its value.
(syms_of_lread): Update doc string of 'bytecomp-version-regexp' to not
refer to it.
* doc/emacs/building.texi (Lisp Libraries): Remove its documentation.
---
 doc/emacs/building.texi |  7 -------
 etc/NEWS                |  5 +++++
 lisp/subr.el            |  3 +++
 src/lread.c             | 23 +++++------------------
 4 files changed, 13 insertions(+), 25 deletions(-)

diff --git a/doc/emacs/building.texi b/doc/emacs/building.texi
index 02f18865f3..272b08d08e 100644
--- a/doc/emacs/building.texi
+++ b/doc/emacs/building.texi
@@ -1528,13 +1528,6 @@ Lisp Libraries
 prefix being completed.  To disable this feature, change the variable
 @code{help-enable-completion-autoload} to @code{nil}.
 
-@vindex load-dangerous-libraries
-@cindex Lisp files byte-compiled by XEmacs
-  By default, Emacs refuses to load compiled Lisp files which were
-compiled with XEmacs, a modified version of Emacs---they can cause
-Emacs to crash.  Set the variable @code{load-dangerous-libraries} to
-@code{t} if you want to try loading them.
-
 @node Lisp Eval
 @section Evaluating Emacs Lisp Expressions
 @cindex Emacs Lisp mode
diff --git a/etc/NEWS b/etc/NEWS
index f5740c8b3c..1c2c43e2a6 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -67,6 +67,11 @@ Formerly it made an exception for integer components of SOA records,
 because SOA serial numbers can exceed fixnum ranges on 32-bit platforms.
 Emacs now supports bignums so this old glitch is no longer needed.
 
+** The 'load-dangerous-libraries' variable is now obsolete.
+It was used to allow loading Lisp libraries compiled by XEmacs, a
+modified version of Emacs which is no longer actively maintained.
+This is no longer supported, and setting this variable has no effect.
+
 
 * Lisp Changes in Emacs 28.1
 
diff --git a/lisp/subr.el b/lisp/subr.el
index 0e09228f6f..8f73614d0a 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1621,6 +1621,9 @@ log10
 (defvaralias 'messages-buffer-max-lines 'message-log-max)
 (define-obsolete-variable-alias 'inhibit-null-byte-detection
   'inhibit-nul-byte-detection "27.1")
+(make-obsolete-variable 'load-dangerous-libraries
+                        "no longer used." "27.1")
+
 
 ;;;; Alternate names for functions - these are not being phased out.
 
diff --git a/src/lread.c b/src/lread.c
index 290b3d3d64..c7de4cc426 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -985,9 +985,7 @@ #define UPDATE_BEG_END_STATE(ch)				\
 
 /* Value is a version number of byte compiled code if the file
    associated with file descriptor FD is a compiled Lisp file that's
-   safe to load.  Only files compiled with Emacs are safe to load.
-   Files compiled with XEmacs can lead to a crash in Fbyte_code
-   because of an incompatible change in the byte compiler.  */
+   safe to load.  Only files compiled with Emacs are safe to load.  */
 
 static int
 safe_to_load_version (int fd)
@@ -1153,7 +1151,6 @@ DEFUN ("load", Fload, Sload, 1, 5, 0,
   /* True means we are loading a compiled file.  */
   bool compiled = 0;
   Lisp_Object handler;
-  bool safe_p = 1;
   const char *fmode = "r" FOPEN_TEXT;
   int version;
 
@@ -1336,11 +1333,7 @@ DEFUN ("load", Fload, Sload, 1, 5, 0,
 	  if (version < 0
 	      && ! (version = safe_to_load_version (fd)))
 	    {
-	      safe_p = 0;
-	      if (!load_dangerous_libraries)
-		error ("File `%s' was not compiled in Emacs", SDATA (found));
-	      else if (!NILP (nomessage) && !force_load_messages)
-		message_with_string ("File `%s' not compiled in Emacs", found, 1);
+	      error ("File `%s' was not compiled in Emacs", SDATA (found));
 	    }
 
 	  compiled = 1;
@@ -1447,10 +1440,7 @@ DEFUN ("load", Fload, Sload, 1, 5, 0,
 
   if (NILP (nomessage) || force_load_messages)
     {
-      if (!safe_p)
-	message_with_string ("Loading %s (compiled; note unsafe, not compiled in Emacs)...",
-		 file, 1);
-      else if (is_module)
+      if (is_module)
         message_with_string ("Loading %s (module)...", file, 1);
       else if (!compiled)
 	message_with_string ("Loading %s (source)...", file, 1);
@@ -1510,10 +1500,7 @@ DEFUN ("load", Fload, Sload, 1, 5, 0,
 
   if (!noninteractive && (NILP (nomessage) || force_load_messages))
     {
-      if (!safe_p)
-	message_with_string ("Loading %s (compiled; note unsafe, not compiled in Emacs)...done",
-		 file, 1);
-      else if (is_module)
+      if (is_module)
         message_with_string ("Loading %s (module)...done", file, 1);
       else if (!compiled)
 	message_with_string ("Loading %s (source)...done", file, 1);
@@ -5022,7 +5009,7 @@ syms_of_lread (void)
 When Emacs loads a compiled Lisp file, it reads the first 512 bytes
 from the file, and matches them against this regular expression.
 When the regular expression matches, the file is considered to be safe
-to load.  See also `load-dangerous-libraries'.  */);
+to load.  */);
   Vbytecomp_version_regexp
     = build_pure_c_string ("^;;;.\\(in Emacs version\\|bytecomp version FSF\\)");
 
-- 
2.20.1