Mercurial > emacs
comparison src/fns.c @ 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 | 99c5d39b9531 |
children | c9af99bb26d4 |
comparison
equal
deleted
inserted
replaced
13183:6b79b1d9cddd | 13184:04170e19b3d4 |
---|---|
299 int i, size; | 299 int i, size; |
300 Lisp_Object copy; | 300 Lisp_Object copy; |
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)); |
308 | 308 |
309 /* Recursively copy any char-tables in the ordinary slots. */ | 309 /* Recursively copy any char-tables in the ordinary slots. */ |
1199 Lisp_Object chartable, parent; | 1199 Lisp_Object chartable, parent; |
1200 { | 1200 { |
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); | 1204 |
1205 | 1205 if (!NILP (parent)) |
1206 for (temp = parent; !NILP (temp); temp = XCHAR_TABLE (temp)->parent) | 1206 { |
1207 if (EQ (temp, chartable)) | 1207 CHECK_CHAR_TABLE (parent, 0); |
1208 error ("Attempt to make a chartable be its own parent"); | 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 |
1212 return parent; | 1216 return parent; |
1213 } | 1217 } |
1277 error ("Invalid RANGE argument to `set-char-table-range'"); | 1281 error ("Invalid RANGE argument to `set-char-table-range'"); |
1278 | 1282 |
1279 return value; | 1283 return value; |
1280 } | 1284 } |
1281 | 1285 |
1282 static void | 1286 /* Map C_FUNCTION or FUNCTION over CHARTABLE, calling it for each |
1283 map_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 | |
1292 void | |
1293 map_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; |
1288 | 1298 |
1289 /* Make INDICES longer if we are about to fill it up. */ | 1299 /* Make INDICES longer if we are about to fill it up. */ |
1298 for (i = 0; i < size; i++) | 1308 for (i = 0; i < size; i++) |
1299 { | 1309 { |
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)) |
1314 map_char_table (chartable, c_function, function, depth + 1, indices); | |
1315 else if (c_function) | |
1316 (*c_function) (depth + 1, indices, elt); | |
1317 else | |
1304 call2 (function, Fvector (depth + 1, indices), elt); | 1318 call2 (function, Fvector (depth + 1, indices), elt); |
1305 else | |
1306 map_char_table (chartable, function, depth + 1, indices); | |
1307 } | 1319 } |
1308 } | 1320 } |
1309 | 1321 |
1310 DEFUN ("map-char-table", Fmap_char_table, Smap_char_table, | 1322 DEFUN ("map-char-table", Fmap_char_table, Smap_char_table, |
1311 2, 2, 0, | 1323 2, 2, 0, |
1316 Lisp_Object function, chartable; | 1328 Lisp_Object function, chartable; |
1317 { | 1329 { |
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 |
1325 /* ARGSUSED */ | 1337 /* ARGSUSED */ |
1326 Lisp_Object | 1338 Lisp_Object |