aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-10-11 17:11:32 +0000
committerRichard M. Stallman1995-10-11 17:11:32 +0000
commitc8640abf7e12893dd3879eeac754e06b05d8a859 (patch)
tree1cd089bf077a8e1580bd2d758bbf5b445948cb1e
parent80af4e50533ee43bd2d7e22adb10d6175f6c8561 (diff)
downloademacs-c8640abf7e12893dd3879eeac754e06b05d8a859.tar.gz
emacs-c8640abf7e12893dd3879eeac754e06b05d8a859.zip
(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.")
301 301
302 /* Calculate the number of extra slots. */ 302 /* Calculate the number of extra slots. */
303 size = CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (arg)); 303 size = CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (arg));
304 copy = Fmake_char_table (make_number (size), Qnil); 304 copy = Fmake_char_table (XCHAR_TABLE (arg)->purpose, Qnil);
305 /* Copy all the slots, including the extra ones. */ 305 /* Copy all the slots, including the extra ones. */
306 bcopy (XCHAR_TABLE (arg)->contents, XCHAR_TABLE (copy)->contents, 306 bcopy (XCHAR_TABLE (arg)->contents, XCHAR_TABLE (copy)->contents,
307 (XCHAR_TABLE (arg)->size & PSEUDOVECTOR_SIZE_MASK) * sizeof (Lisp_Object)); 307 (XCHAR_TABLE (arg)->size & PSEUDOVECTOR_SIZE_MASK) * sizeof (Lisp_Object));
@@ -1201,11 +1201,15 @@ PARENT must be either nil or another char-table.")
1201 Lisp_Object temp; 1201 Lisp_Object temp;
1202 1202
1203 CHECK_CHAR_TABLE (chartable, 0); 1203 CHECK_CHAR_TABLE (chartable, 0);
1204 CHECK_CHAR_TABLE (parent, 0);
1205 1204
1206 for (temp = parent; !NILP (temp); temp = XCHAR_TABLE (temp)->parent) 1205 if (!NILP (parent))
1207 if (EQ (temp, chartable)) 1206 {
1208 error ("Attempt to make a chartable be its own parent"); 1207 CHECK_CHAR_TABLE (parent, 0);
1208
1209 for (temp = parent; !NILP (temp); temp = XCHAR_TABLE (temp)->parent)
1210 if (EQ (temp, chartable))
1211 error ("Attempt to make a chartable be its own parent");
1212 }
1209 1213
1210 XCHAR_TABLE (chartable)->parent = parent; 1214 XCHAR_TABLE (chartable)->parent = parent;
1211 1215
@@ -1279,9 +1283,15 @@ or a character code.")
1279 return value; 1283 return value;
1280} 1284}
1281 1285
1282static void 1286/* Map C_FUNCTION or FUNCTION over CHARTABLE, calling it for each
1283map_char_table (function, chartable, depth, indices) 1287 character or group of characters that share a value.
1284 Lisp_Object function, chartable, depth, *indices; 1288 DEPTH is the current depth in the originally specified
1289 chartable, and INDICES contains the vector indices
1290 for the levels our callers have descended. */
1291
1292void
1293map_char_table (c_function, function, chartable, depth, indices)
1294 Lisp_Object (*c_function) (), function, chartable, depth, *indices;
1285{ 1295{
1286 int i; 1296 int i;
1287 int size = XCHAR_TABLE (chartable)->size; 1297 int size = XCHAR_TABLE (chartable)->size;
@@ -1300,10 +1310,12 @@ map_char_table (function, chartable, depth, indices)
1300 Lisp_Object elt; 1310 Lisp_Object elt;
1301 indices[depth] = i; 1311 indices[depth] = i;
1302 elt = XCHAR_TABLE (chartable)->contents[i]; 1312 elt = XCHAR_TABLE (chartable)->contents[i];
1303 if (!CHAR_TABLE_P (elt)) 1313 if (CHAR_TABLE_P (elt))
1304 call2 (function, Fvector (depth + 1, indices), elt); 1314 map_char_table (chartable, c_function, function, depth + 1, indices);
1315 else if (c_function)
1316 (*c_function) (depth + 1, indices, elt);
1305 else 1317 else
1306 map_char_table (chartable, function, depth + 1, indices); 1318 call2 (function, Fvector (depth + 1, indices), elt);
1307 } 1319 }
1308} 1320}
1309 1321
@@ -1318,7 +1330,7 @@ The key is always a possible RANGE argument to `set-char-table-range'.")
1318 Lisp_Object keyvec; 1330 Lisp_Object keyvec;
1319 Lisp_Object *indices = (Lisp_Object *) alloca (10 * sizeof (Lisp_Object)); 1331 Lisp_Object *indices = (Lisp_Object *) alloca (10 * sizeof (Lisp_Object));
1320 1332
1321 map_char_table (function, chartable, 0, indices); 1333 map_char_table (function, NULL, chartable, 0, indices);
1322 return Qnil; 1334 return Qnil;
1323} 1335}
1324 1336