diff src/symbols.c @ 930:eaedf30d9d76

[xemacs-hg @ 2002-07-23 08:34:59 by youngs] 2002-07-15 Jerry James <james@xemacs.org> * make-docfile.c: Change whitespace and organization to reduce the size of the diff against FSF Emacs sources and synch to Emacs 21.2. Remove unused DO_REALLOC. Mark XEmacs changes and additions more clearly. Reintroduce previously deleted Emacs code inside #if 0 ... #endif. * make-docfile.c (next_extra_elc): Replace goto with do-while. * make-docfile.c (main): Put XEmacs-only args in one place. * make-docfile.c (write_c_args): Change buff to buf to match Emacs. Replace pointer arithmetic with simpler array syntax. * make-docfile.c (scan_c_file): Note that DEFSIMPLE and DEFPRED no longer exist. Correct the "name too long" test (off by one). Die with message if a DEFUN has no docstring instead of hanging. * make-docfile.c (scan_lisp_file): Introduce while loops used in Emacs sources to skip consecutive blank lines. 2002-07-21 John Paul Wallington <jpw@xemacs.org> * process.el (substitute-env-vars): New function; sync with GNU Emacs 21.1.50. (setenv): Add optional arg SUBSTITUTE-ENV-VARS; sync with GNU Emacs 21.1.50. 2002-07-20 Mike Sperber <mike@xemacs.org> * eval.c (run_post_gc_hook): Use more correct flags when running post-gc-hook. 2002-07-20 Mike Sperber <mike@xemacs.org> * process-unix.c (child_setup): Don't try to close file descriptors for chid process once again---it's already being done in close_process_descs. (unix_create_process): Call begin_dont_check_for_quit to inhibit unwanted interaction (and thus breaking of X event synchronicity) in the child. 2002-07-15 Jerry James <james@xemacs.org> * lisp.h: Make Qdll_error visible globally. * symbols.c (check_sane_subr): Revert 2002-06-26 change. Check only if !initialized. * symbols.c (check_module_subr): Add parameter. Duplicate check_sane_subr checks, but signal an error instead of asserting. * symbols.c (defsubr): Use check_module_subr parameter. * symbols.c (defsubr_macro): Ditto.
author youngs
date Tue, 23 Jul 2002 08:35:11 +0000
parents 7f5ac0d2a71f
children c925bacdda60
line wrap: on
line diff
--- a/src/symbols.c	Sun Jul 21 04:51:07 2002 +0000
+++ b/src/symbols.c	Tue Jul 23 08:35:11 2002 +0000
@@ -3358,25 +3358,24 @@
 }
 
 #ifdef DEBUG_XEMACS
-/* Check that nobody spazzed writing a DEFUN. */
+/* Check that nobody spazzed writing a builtin (non-module) DEFUN. */
 static void
 check_sane_subr (Lisp_Subr *subr, Lisp_Object sym)
 {
-  Lisp_Object f;
-
-  assert (subr->min_args >= 0);
-  assert (subr->min_args <= SUBR_MAX_ARGS);
-
-  if (subr->max_args != MANY &&
-      subr->max_args != UNEVALLED)
-    {
-      /* Need to fix lisp.h and eval.c if SUBR_MAX_ARGS too small */
-      assert (subr->max_args <= SUBR_MAX_ARGS);
-      assert (subr->min_args <= subr->max_args);
-    }
-
-  f = XSYMBOL (sym)->function;
-  assert (UNBOUNDP (f) || (CONSP (f) && EQ (XCAR (f), Qautoload)));
+  if (!initialized) {
+    assert (subr->min_args >= 0);
+    assert (subr->min_args <= SUBR_MAX_ARGS);
+
+    if (subr->max_args != MANY &&
+	subr->max_args != UNEVALLED)
+      {
+	/* Need to fix lisp.h and eval.c if SUBR_MAX_ARGS too small */
+	assert (subr->max_args <= SUBR_MAX_ARGS);
+	assert (subr->min_args <= subr->max_args);
+      }
+
+    assert (UNBOUNDP (XSYMBOL (sym)->function));
+  }
 }
 #else
 #define check_sane_subr(subr, sym) /* nothing */
@@ -3407,17 +3406,43 @@
  * FIXME: Should newsubr be staticpro()'ed? I don't think so but I need
  * a guru to check.
  */
-#define check_module_subr()						\
-do {									\
-  if (initialized) {							\
-    Lisp_Subr *newsubr = (Lisp_Subr *) xmalloc (sizeof (Lisp_Subr));	\
-    memcpy (newsubr, subr, sizeof (Lisp_Subr));				\
-    subr->doc = (const char *)newsubr;					\
-    subr = newsubr;							\
-  }									\
+#define check_module_subr(subr)						      \
+do {									      \
+  if (initialized) {							      \
+    Lisp_Subr *newsubr;							      \
+    Lisp_Object f;							      \
+									      \
+    if (subr->min_args < 0)						      \
+      signal_ferror (Qdll_error, "%s min_args (%hd) too small",		      \
+		     subr_name (subr), subr->min_args);			      \
+    if (subr->min_args > SUBR_MAX_ARGS)					      \
+      signal_ferror (Qdll_error, "%s min_args (%hd) too big (max = %d)",      \
+		     subr_name (subr), subr->min_args, SUBR_MAX_ARGS);	      \
+									      \
+    if (subr->max_args != MANY &&					      \
+	subr->max_args != UNEVALLED)					      \
+      {									      \
+	/* Need to fix lisp.h and eval.c if SUBR_MAX_ARGS too small */	      \
+	if (subr->max_args > SUBR_MAX_ARGS)				      \
+	  signal_ferror (Qdll_error, "%s max_args (%hd) too big (max = %d)",  \
+			 subr_name (subr), subr->max_args, SUBR_MAX_ARGS);    \
+	if (subr->min_args > subr->max_args)				      \
+	  signal_ferror (Qdll_error, "%s min_args (%hd) > max_args (%hd)",    \
+			 subr_name (subr), subr->min_args, subr->max_args);   \
+      }									      \
+									      \
+    f = XSYMBOL (sym)->function;					      \
+    if (!UNBOUNDP (f) && (!CONSP (f) || !EQ (XCAR (f), Qautoload)))	      \
+      signal_ferror (Qdll_error, "Attempt to redefine %s", subr_name (subr)); \
+									      \
+    newsubr = (Lisp_Subr *) xmalloc (sizeof (Lisp_Subr));		      \
+    memcpy (newsubr, subr, sizeof (Lisp_Subr));				      \
+    subr->doc = (const char *)newsubr;					      \
+    subr = newsubr;							      \
+  }									      \
 } while (0)
 #else /* ! HAVE_SHLIB */
-#define check_module_subr()
+#define check_module_subr(subr)
 #endif
 
 void
@@ -3427,7 +3452,7 @@
   Lisp_Object fun;
 
   check_sane_subr (subr, sym);
-  check_module_subr ();
+  check_module_subr (subr);
 
   fun = wrap_subr (subr);
   XSYMBOL (sym)->function = fun;
@@ -3441,7 +3466,7 @@
   Lisp_Object fun;
 
   check_sane_subr (subr, sym);
-  check_module_subr();
+  check_module_subr (subr);
 
   fun = wrap_subr (subr);
   XSYMBOL (sym)->function = Fcons (Qmacro, fun);