changeset 1067:a0a7ace216fe

[xemacs-hg @ 2002-10-24 13:55:42 by youngs] 2002-10-24 John Paul Wallington <jpw@shootybangbang.com> * fns.c (Frequire): Add optional `noerror' argument.
author youngs
date Thu, 24 Oct 2002 13:55:49 +0000
parents 5de13d96e131
children 9d75b4fe084c
files src/ChangeLog src/fns.c
diffstat 2 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Thu Oct 24 13:49:13 2002 +0000
+++ b/src/ChangeLog	Thu Oct 24 13:55:49 2002 +0000
@@ -1,3 +1,7 @@
+2002-10-24  John Paul Wallington  <jpw@shootybangbang.com>
+
+	* fns.c (Frequire): Add optional `noerror' argument.
+
 2002-10-24  Andy Piper  <andy@xemacs.org>
 
 	* glyphs-widget.c (layout_query_geometry): only resize dynamically
--- a/src/fns.c	Thu Oct 24 13:49:13 2002 +0000
+++ b/src/fns.c	Thu Oct 24 13:55:49 2002 +0000
@@ -3546,13 +3546,15 @@
   return feature;
 }
 
-DEFUN ("require", Frequire, 1, 2, 0, /*
+DEFUN ("require", Frequire, 1, 3, 0, /*
 If feature FEATURE is not loaded, load it from FILENAME.
 If FEATURE is not a member of the list `features', then the feature
 is not loaded; so load the file FILENAME.
 If FILENAME is omitted, the printname of FEATURE is used as the file name.
+If optional third argument NOERROR is non-nil, then return nil if the file
+is not found instead of signaling an error.
 */
-       (feature, filename))
+       (feature, filename, noerror))
 {
   Lisp_Object tem;
   CHECK_SYMBOL (feature);
@@ -3568,8 +3570,11 @@
       record_unwind_protect (un_autoload, Vautoload_queue);
       Vautoload_queue = Qt;
 
-      call4 (Qload, NILP (filename) ? Fsymbol_name (feature) : filename,
-	     Qnil, require_prints_loading_message ? Qrequire : Qt, Qnil);
+      tem = call4 (Qload, NILP (filename) ? Fsymbol_name (feature) : filename,
+		   noerror, require_prints_loading_message ? Qrequire : Qt, Qnil);
+      /* If load failed entirely, return nil.  */
+      if (NILP (tem))
+	return unbind_to_1 (speccount, Qnil);
 
       tem = Fmemq (feature, Vfeatures);
       if (NILP (tem))