changeset 30134:784ef95b020b

(get_keymap_1): Add comment that this function can GC. (where_is_internal_2, where_is_internal_1): Add GCPROs, add comment that functions can GC. (Fset_keymap_parent): GCPRO arg KEYMAP.
author Gerd Moellmann <gerd@gnu.org>
date Mon, 10 Jul 2000 14:10:51 +0000
parents 8db9c1163258
children b935180b3893
files src/keymap.c
diffstat 1 files changed, 31 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/keymap.c	Mon Jul 10 13:46:32 2000 +0000
+++ b/src/keymap.c	Mon Jul 10 14:10:51 2000 +0000
@@ -212,7 +212,10 @@
    Functions like Faccessible_keymaps which scan entire keymap trees
    shouldn't load every autoloaded keymap.  I'm not sure about this,
    but it seems to me that only read_key_sequence, Flookup_key, and
-   Fdefine_key should cause keymaps to be autoloaded.  */
+   Fdefine_key should cause keymaps to be autoloaded.
+
+   This function can GC when AUTOLOAD is non-zero, because it calls
+   do_autoload which can GC.  */
 
 Lisp_Object
 get_keymap_1 (object, error, autoload)
@@ -305,9 +308,12 @@
      Lisp_Object keymap, parent;
 {
   Lisp_Object list, prev;
+  struct gcpro gcpro1;
   int i;
 
   keymap = get_keymap_1 (keymap, 1, 1);
+  GCPRO1 (keymap);
+  
   if (!NILP (parent))
     parent = get_keymap_1 (parent, 1, 1);
 
@@ -323,7 +329,7 @@
 	  /* If we already have the right parent, return now
 	     so that we avoid the loops below.  */
 	  if (EQ (XCDR (prev), parent))
-	    return parent;
+	    RETURN_UNGCPRO (parent);
 
 	  XCDR (prev) = parent;
 	  break;
@@ -360,7 +366,7 @@
 	}
     }
 
-  return parent;
+  RETURN_UNGCPRO (parent);
 }
 
 /* EVENT is defined in MAP as a prefix, and SUBMAP is its definition.
@@ -635,7 +641,8 @@
       /* If the contents are (KEYMAP . ELEMENT), go indirect.  */
       else
 	{
-	  register Lisp_Object map;
+	  Lisp_Object map;
+	  
 	  map = get_keymap_1 (Fcar_safe (object), 0, autoload);
 	  if (NILP (map))
 	    /* Invalid keymap */
@@ -2203,7 +2210,6 @@
 			    Fcons (Fcons (this, last),
 				   Fcons (make_number (nomenus),
 					  make_number (last_is_meta))));
-
 	      map_char_table (where_is_internal_2, Qnil, elt, args,
 			      0, indices);
 	      sequences = XCDR (XCDR (XCAR (args)));
@@ -2265,7 +2271,10 @@
     .
     ((THIS . LAST) . (NOMENUS . LAST_IS_META)))
    Since map_char_table doesn't really use the return value from this function,
-   we the result append to RESULT, the slot in ARGS.  */
+   we the result append to RESULT, the slot in ARGS.
+
+   This function can GC because it calls where_is_internal_1 which can
+   GC.  */
 
 static void
 where_is_internal_2 (args, key, binding)
@@ -2274,7 +2283,9 @@
   Lisp_Object definition, noindirect, keymap, this, last;
   Lisp_Object result, sequence;
   int nomenus, last_is_meta;
-
+  struct gcpro gcpro1, gcpro2, gcpro3;
+
+  GCPRO3 (args, key, binding);
   result = XCDR (XCDR (XCAR (args)));
   definition = XCAR (XCAR (XCAR (args)));
   noindirect = XCDR (XCAR (XCAR (args)));
@@ -2288,10 +2299,15 @@
 				  this, last, nomenus, last_is_meta);
 
   if (!NILP (sequence))
-    XCDR (XCDR (XCAR (args)))
-      = Fcons (sequence, result);
+    XCDR (XCDR (XCAR (args))) = Fcons (sequence, result);
+
+  UNGCPRO;
 }
 
+
+/* This function can GC.because Flookup_key calls get_keymap_1 with
+   non-zero argument AUTOLOAD.  */
+
 static Lisp_Object
 where_is_internal_1 (binding, key, definition, noindirect, keymap, this, last,
 		     nomenus, last_is_meta)
@@ -2300,6 +2316,7 @@
 {
   Lisp_Object sequence;
   int keymap_specified = !NILP (keymap);
+  struct gcpro gcpro1, gcpro2;
 
   /* Search through indirections unless that's not wanted.  */
   if (NILP (noindirect))
@@ -2360,6 +2377,7 @@
 
      Either nil or number as value from Flookup_key
      means undefined.  */
+  GCPRO2 (sequence, binding);
   if (keymap_specified)
     {
       binding = Flookup_key (keymap, sequence, Qnil);
@@ -2370,21 +2388,21 @@
 	      Lisp_Object tem;
 	      tem = Fequal (binding, definition);
 	      if (NILP (tem))
-		return Qnil;
+		RETURN_UNGCPRO (Qnil);
 	    }
 	  else
 	    if (!EQ (binding, definition))
-	      return Qnil;
+	      RETURN_UNGCPRO (Qnil);
 	}
     }
   else
     {
       binding = Fkey_binding (sequence, Qnil);
       if (!EQ (binding, definition))
-	return Qnil;
+	RETURN_UNGCPRO (Qnil);
     }
 
-  return sequence;
+  RETURN_UNGCPRO (sequence);
 }
 
 /* describe-bindings - summarizing all the bindings in a set of keymaps.  */