comparison src/fns.c @ 17182:47bfc66eb7f1

(map_char_table): Handle multibyte characters.
author Kenichi Handa <handa@m17n.org>
date Tue, 18 Mar 1997 23:31:34 +0000
parents 647b28ba4d1b
children b66473f0d0fe
comparison
equal deleted inserted replaced
17181:156896ccc86e 17182:47bfc66eb7f1
26 #undef vector 26 #undef vector
27 #define vector ***** 27 #define vector *****
28 28
29 #include "lisp.h" 29 #include "lisp.h"
30 #include "commands.h" 30 #include "commands.h"
31 #include "charset.h"
31 32
32 #include "buffer.h" 33 #include "buffer.h"
33 #include "keyboard.h" 34 #include "keyboard.h"
34 #include "intervals.h" 35 #include "intervals.h"
35 #include "frame.h" 36 #include "frame.h"
1365 map_char_table (c_function, function, chartable, depth, indices) 1366 map_char_table (c_function, function, chartable, depth, indices)
1366 Lisp_Object (*c_function) (), function, chartable, *indices; 1367 Lisp_Object (*c_function) (), function, chartable, *indices;
1367 int depth; 1368 int depth;
1368 { 1369 {
1369 int i; 1370 int i;
1370 int size = CHAR_TABLE_ORDINARY_SLOTS; 1371 int from, to;
1371 1372
1373 if (depth == 0)
1374 from = 0, to = CHAR_TABLE_ORDINARY_SLOTS;
1375 else
1376 from = 32, to = 128;
1372 /* Make INDICES longer if we are about to fill it up. */ 1377 /* Make INDICES longer if we are about to fill it up. */
1373 if ((depth % 10) == 9) 1378 if ((depth % 10) == 9)
1374 { 1379 {
1375 Lisp_Object *new_indices 1380 Lisp_Object *new_indices
1376 = (Lisp_Object *) alloca ((depth += 10) * sizeof (Lisp_Object)); 1381 = (Lisp_Object *) alloca ((depth += 10) * sizeof (Lisp_Object));
1377 bcopy (indices, new_indices, depth * sizeof (Lisp_Object)); 1382 bcopy (indices, new_indices, depth * sizeof (Lisp_Object));
1378 indices = new_indices; 1383 indices = new_indices;
1379 } 1384 }
1380 1385
1381 for (i = 0; i < size; i++) 1386 for (i = from; i < to; i++)
1382 { 1387 {
1383 Lisp_Object elt; 1388 Lisp_Object elt;
1384 indices[depth] = i; 1389 indices[depth] = i;
1385 elt = XCHAR_TABLE (chartable)->contents[i]; 1390 elt = XCHAR_TABLE (chartable)->contents[i];
1386 if (CHAR_TABLE_P (elt)) 1391 if (CHAR_TABLE_P (elt))
1387 map_char_table (c_function, function, chartable, depth + 1, indices); 1392 map_char_table (c_function, function, elt, depth + 1, indices);
1388 else if (c_function) 1393 else if (c_function)
1389 (*c_function) (depth + 1, indices, elt); 1394 (*c_function) (depth + 1, indices, elt);
1390 /* Here we should handle all cases where the range is a single character 1395 else if (depth == 0 && i < 256)
1391 by passing that character as a number. Currently, that is 1396 /* This is an ASCII or 8-bit European character. */
1392 all the time, but with the MULE code this will have to be changed. */
1393 else if (depth == 0)
1394 call2 (function, make_number (i), elt); 1397 call2 (function, make_number (i), elt);
1395 else 1398 else
1396 call2 (function, Fvector (depth + 1, indices), elt); 1399 {
1400 /* This is an entry for multibyte characters. */
1401 unsigned int charset = XFASTINT (indices[0]) - 128, c1, c2, c;
1402 if (CHARSET_DEFINED_P (charset))
1403 {
1404 c1 = depth < 1 ? 0 : XFASTINT (indices[1]);
1405 c2 = depth < 2 ? 0 : XFASTINT (indices[2]);
1406 c = MAKE_NON_ASCII_CHAR (charset, c1, c2);
1407 call2 (function, make_number (c), elt);
1408 }
1409 }
1397 } 1410 }
1398 } 1411 }
1399 1412
1400 DEFUN ("map-char-table", Fmap_char_table, Smap_char_table, 1413 DEFUN ("map-char-table", Fmap_char_table, Smap_char_table,
1401 2, 2, 0, 1414 2, 2, 0,