-Lisp_Object
-get_char_id_table (Emchar ch, Lisp_Object table)
-{
- unsigned int code = ch;
-
- return
- get_byte_table
- (get_byte_table
- (get_byte_table
- (get_byte_table
- (XCHAR_ID_TABLE (table)->table,
- (unsigned char)(code >> 24)),
- (unsigned char) (code >> 16)),
- (unsigned char) (code >> 8)),
- (unsigned char) code);
-}
-
-void
-put_char_id_table (Emchar ch, Lisp_Object value, Lisp_Object table)
-{
- unsigned int code = ch;
- Lisp_Object table1, table2, table3, table4;
-
- table1 = XCHAR_ID_TABLE (table)->table;
- table2 = get_byte_table (table1, (unsigned char)(code >> 24));
- table3 = get_byte_table (table2, (unsigned char)(code >> 16));
- table4 = get_byte_table (table3, (unsigned char)(code >> 8));
-
- table4 = put_byte_table (table4, (unsigned char)code, value);
- table3 = put_byte_table (table3, (unsigned char)(code >> 8), table4);
- table2 = put_byte_table (table2, (unsigned char)(code >> 16), table3);
- XCHAR_ID_TABLE (table)->table
- = put_byte_table (table1, (unsigned char)(code >> 24), table2);
-}
-
-/* Map FN (with client data ARG) in char table CT.
- Mapping stops the first time FN returns non-zero, and that value
- becomes the return value of map_char_id_table(). */
-int
-map_char_id_table (Lisp_Char_ID_Table *ct,
- struct chartab_range *range,
- int (*fn) (struct chartab_range *range,
- Lisp_Object val, void *arg),
- void *arg);
-int
-map_char_id_table (Lisp_Char_ID_Table *ct,
- struct chartab_range *range,
- int (*fn) (struct chartab_range *range,
- Lisp_Object val, void *arg),
- void *arg)
-{
- Lisp_Object v = ct->table;
-
- switch (range->type)
- {
- case CHARTAB_RANGE_ALL:
- if (UINT8_BYTE_TABLE_P (v))
- return map_over_uint8_byte_table (XUINT8_BYTE_TABLE(v), 0, 3,
- Qnil, fn, arg);
- else if (UINT16_BYTE_TABLE_P (v))
- return map_over_uint16_byte_table (XUINT16_BYTE_TABLE(v), 0, 3,
- Qnil, fn, arg);
- else if (BYTE_TABLE_P (v))
- return map_over_byte_table (XBYTE_TABLE(v), 0, 3, Qnil, fn, arg);
- else if (!UNBOUNDP (v))
- {
- struct chartab_range rainj;
- int unit = 1 << 24;
- Emchar c = 0;
- Emchar c1 = c + unit;
- int retval;
-
- rainj.type = CHARTAB_RANGE_CHAR;
-
- for (retval = 0; c < c1 && retval == 0; c++)
- {
- rainj.ch = c;
- retval = (fn) (&rainj, v, arg);
- }
- }
- return 0;
- case CHARTAB_RANGE_CHARSET:
- if (UINT8_BYTE_TABLE_P (v))
- return map_over_uint8_byte_table (XUINT8_BYTE_TABLE(v), 0, 3,
- range->charset, fn, arg);
- else if (UINT16_BYTE_TABLE_P (v))
- return map_over_uint16_byte_table (XUINT16_BYTE_TABLE(v), 0, 3,
- range->charset, fn, arg);
- else if (BYTE_TABLE_P (v))
- return map_over_byte_table (XBYTE_TABLE(v), 0, 3,
- range->charset, fn, arg);
- else if (!UNBOUNDP (v))
- {
- struct chartab_range rainj;
- int unit = 1 << 24;
- Emchar c = 0;
- Emchar c1 = c + unit;
- int retval;
-
- rainj.type = CHARTAB_RANGE_CHAR;
-
- for (retval = 0; c < c1 && retval == 0; c++)
- {
- if ( charset_code_point (range->charset, c) >= 0 )
- {
- rainj.ch = c;
- retval = (fn) (&rainj, v, arg);
- }
- }
- }
- return 0;
- case CHARTAB_RANGE_ROW:
- {
- int cell_min, cell_max, i;
- int retval;
- struct chartab_range rainj;
-
- if (XCHARSET_DIMENSION (range->charset) < 2)
- signal_simple_error ("Charset in row vector must be multi-byte",
- range->charset);
- else
- {
- switch (XCHARSET_CHARS (range->charset))
- {
- case 94:
- cell_min = 33; cell_max = 126;
- break;
- case 96:
- cell_min = 32; cell_max = 127;
- break;
- case 128:
- cell_min = 0; cell_max = 127;
- break;
- case 256:
- cell_min = 0; cell_max = 255;
- break;
- default:
- abort ();
- }
- }
- if (XCHARSET_DIMENSION (range->charset) == 2)
- check_int_range (range->row, cell_min, cell_max);
- else if (XCHARSET_DIMENSION (range->charset) == 3)
- {
- check_int_range (range->row >> 8 , cell_min, cell_max);
- check_int_range (range->row & 0xFF, cell_min, cell_max);
- }
- else if (XCHARSET_DIMENSION (range->charset) == 4)
- {
- check_int_range ( range->row >> 16 , cell_min, cell_max);
- check_int_range ((range->row >> 8) & 0xFF, cell_min, cell_max);
- check_int_range ( range->row & 0xFF, cell_min, cell_max);
- }
- else
- abort ();
-
- rainj.type = CHARTAB_RANGE_CHAR;
- for (retval =0, i = cell_min; i <= cell_max && retval == 0; i++)
- {
- Emchar ch = DECODE_CHAR (range->charset, (range->row << 8) | i);
- Lisp_Object val
- = get_byte_table (get_byte_table
- (get_byte_table
- (get_byte_table
- (v,
- (unsigned char)(ch >> 24)),
- (unsigned char) (ch >> 16)),
- (unsigned char) (ch >> 8)),
- (unsigned char) ch);
-
- if (!UNBOUNDP (val))
- {
- rainj.ch = ch;
- retval = (fn) (&rainj, val, arg);
- }
- }
- return retval;
- }
- case CHARTAB_RANGE_CHAR:
- {
- Emchar ch = range->ch;
- Lisp_Object val
- = get_byte_table (get_byte_table
- (get_byte_table
- (get_byte_table
- (v,
- (unsigned char)(ch >> 24)),
- (unsigned char) (ch >> 16)),
- (unsigned char) (ch >> 8)),
- (unsigned char) ch);
- struct chartab_range rainj;
-
- if (!UNBOUNDP (val))
- {
- rainj.type = CHARTAB_RANGE_CHAR;
- rainj.ch = ch;
- return (fn) (&rainj, val, arg);
- }
- else
- return 0;
- }
- default:
- abort ();
- }
- return 0;
-}
-
-