changeset 13184:04170e19b3d4

(Fcopy_sequence): Call Fmake_char_table the new way. (map_char_table): No longer static. New arg C_FUNCTION. (Fmap_char_table): Call to map_char_table changed. (Fset_char_table_parent): Allow nil s new parent. Fix the code that checks for a loop in parents.
author Richard M. Stallman <rms@gnu.org>
date Wed, 11 Oct 1995 17:11:32 +0000
parents 6b79b1d9cddd
children 5b1671bd3cc1
files src/fns.c
diffstat 1 files changed, 24 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/fns.c	Wed Oct 11 17:07:03 1995 +0000
+++ b/src/fns.c	Wed Oct 11 17:11:32 1995 +0000
@@ -301,7 +301,7 @@
 
       /* Calculate the number of extra slots.  */
       size = CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (arg));
-      copy = Fmake_char_table (make_number (size), Qnil);
+      copy = Fmake_char_table (XCHAR_TABLE (arg)->purpose, Qnil);
       /* Copy all the slots, including the extra ones.  */
       bcopy (XCHAR_TABLE (arg)->contents, XCHAR_TABLE (copy)->contents,
 	     (XCHAR_TABLE (arg)->size & PSEUDOVECTOR_SIZE_MASK) * sizeof (Lisp_Object));
@@ -1201,11 +1201,15 @@
   Lisp_Object temp;
 
   CHECK_CHAR_TABLE (chartable, 0);  
-  CHECK_CHAR_TABLE (parent, 0);  
+
+  if (!NILP (parent))
+    {
+      CHECK_CHAR_TABLE (parent, 0);  
 
-  for (temp = parent; !NILP (temp); temp = XCHAR_TABLE (temp)->parent)
-    if (EQ (temp, chartable))
-      error ("Attempt to make a chartable be its own parent");
+      for (temp = parent; !NILP (temp); temp = XCHAR_TABLE (temp)->parent)
+	if (EQ (temp, chartable))
+	  error ("Attempt to make a chartable be its own parent");
+    }
 
   XCHAR_TABLE (chartable)->parent = parent;
 
@@ -1279,9 +1283,15 @@
   return value;
 }
 
-static void
-map_char_table (function, chartable, depth, indices)
-     Lisp_Object function, chartable, depth, *indices;
+/* Map C_FUNCTION or FUNCTION over CHARTABLE, calling it for each
+   character or group of characters that share a value.
+   DEPTH is the current depth in the originally specified
+   chartable, and INDICES contains the vector indices
+   for the levels our callers have descended.  */
+
+void
+map_char_table (c_function, function, chartable, depth, indices)
+     Lisp_Object (*c_function) (), function, chartable, depth, *indices;
 {
   int i;
   int size = XCHAR_TABLE (chartable)->size;
@@ -1300,10 +1310,12 @@
       Lisp_Object elt;
       indices[depth] = i;
       elt = XCHAR_TABLE (chartable)->contents[i];
-      if (!CHAR_TABLE_P (elt))
+      if (CHAR_TABLE_P (elt))
+	map_char_table (chartable, c_function, function, depth + 1, indices);
+      else if (c_function)
+	(*c_function) (depth + 1, indices, elt);
+      else
 	call2 (function, Fvector (depth + 1, indices), elt);
-      else
-	map_char_table (chartable, function, depth + 1, indices);
     }
 }
 
@@ -1318,7 +1330,7 @@
   Lisp_Object keyvec;
   Lisp_Object *indices = (Lisp_Object *) alloca (10 * sizeof (Lisp_Object));
 
-  map_char_table (function, chartable, 0, indices);
+  map_char_table (function, NULL, chartable, 0, indices);
   return Qnil;
 }