summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1995-10-11 17:11:32 +0000
committerRichard M. Stallman <rms@gnu.org>1995-10-11 17:11:32 +0000
commit0c52d1b44c3028b56de303b1fc446edba826bea2 (patch)
treefbf0379b31dc97d91aba1588de51c000588f6cd6
parentc36cfa654acbb47873b0ea161786c76d44c6d1b3 (diff)
downloademacs-0c52d1b44c3028b56de303b1fc446edba826bea2.tar.gz
(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.
-rw-r--r--src/fns.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/fns.c b/src/fns.c
index efa8e23f453..1f14e0ef4b8 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -301,7 +301,7 @@ with the original.")
/* 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 @@ PARENT must be either nil or another char-table.")
Lisp_Object temp;
CHECK_CHAR_TABLE (chartable, 0);
- 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");
+ 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");
+ }
XCHAR_TABLE (chartable)->parent = parent;
@@ -1279,9 +1283,15 @@ or a character code.")
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 @@ map_char_table (function, chartable, depth, indices)
Lisp_Object elt;
indices[depth] = i;
elt = XCHAR_TABLE (chartable)->contents[i];
- if (!CHAR_TABLE_P (elt))
- call2 (function, Fvector (depth + 1, indices), 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
- map_char_table (chartable, function, depth + 1, indices);
+ call2 (function, Fvector (depth + 1, indices), elt);
}
}
@@ -1318,7 +1330,7 @@ The key is always a possible RANGE argument to `set-char-table-range'.")
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;
}