(Fset_keymap_parent): Check for cycles in keymap
authorGerd Moellmann <gerd@gnu.org>
Fri, 8 Sep 2000 13:30:21 +0000 (13:30 +0000)
committerGerd Moellmann <gerd@gnu.org>
Fri, 8 Sep 2000 13:30:21 +0000 (13:30 +0000)
inheritance.

src/ChangeLog
src/keymap.c

index 2ed9135..64cd6de 100644 (file)
@@ -1,5 +1,8 @@
 2000-09-08  Gerd Moellmann  <gerd@gnu.org>
 
+       * keymap.c (Fset_keymap_parent): Check for cycles in keymap
+       inheritance.
+
        * xdisp.c (try_window_id): When trying to locate cursor in
        unchanged rows at the top, handle the case that we can't find it.
 
index 410d38e..2665941 100644 (file)
@@ -307,6 +307,7 @@ DEFUN ("keymap-parent", Fkeymap_parent, Skeymap_parent, 1, 1, 0,
   return Qnil;
 }
 
+
 /* Set the parent keymap of MAP to PARENT.  */
 
 DEFUN ("set-keymap-parent", Fset_keymap_parent, Sset_keymap_parent, 2, 2, 0,
@@ -323,7 +324,18 @@ PARENT should be nil or another keymap.")
   GCPRO1 (keymap);
   
   if (!NILP (parent))
-    parent = get_keymap_1 (parent, 1, 1);
+    {
+      Lisp_Object k;
+      
+      parent = get_keymap_1 (parent, 1, 1);
+
+      /* Check for cycles.  */
+      k = parent;
+      while (KEYMAPP (k) && !EQ (keymap, k))
+       k = Fkeymap_parent (k);
+      if (EQ (keymap, k))
+       error ("Cyclic keymap inheritance");
+    }
 
   /* Skip past the initial element `keymap'.  */
   prev = keymap;