Mercurial > emacs
annotate src/chartab.c @ 88869:b26b42483aeb
*** empty log message ***
author | Dave Love <fx@gnu.org> |
---|---|
date | Thu, 18 Jul 2002 11:09:38 +0000 |
parents | 889b48cce7a1 |
children | d6c50ac00394 |
rev | line source |
---|---|
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
1 /* chartab.c -- char-table support |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
2 Copyright (C) 2001, 2002 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
3 National Institute of Advanced Industrial Science and Technology (AIST) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
4 Registration Number H13PRO009 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
5 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
6 This file is part of GNU Emacs. |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
7 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
8 GNU Emacs is free software; you can redistribute it and/or modify |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
9 it under the terms of the GNU General Public License as published by |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
10 the Free Software Foundation; either version 2, or (at your option) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
11 any later version. |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
12 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
13 GNU Emacs is distributed in the hope that it will be useful, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
14 but WITHOUT ANY WARRANTY; without even the implied warranty of |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
16 GNU General Public License for more details. |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
17 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
18 You should have received a copy of the GNU General Public License |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
19 along with GNU Emacs; see the file COPYING. If not, write to |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
21 Boston, MA 02111-1307, USA. */ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
22 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
23 #include <config.h> |
88858
889b48cce7a1
Include "...h", not <...h> in some cases.
Dave Love <fx@gnu.org>
parents:
88822
diff
changeset
|
24 #include "lisp.h" |
889b48cce7a1
Include "...h", not <...h> in some cases.
Dave Love <fx@gnu.org>
parents:
88822
diff
changeset
|
25 #include "character.h" |
889b48cce7a1
Include "...h", not <...h> in some cases.
Dave Love <fx@gnu.org>
parents:
88822
diff
changeset
|
26 #include "charset.h" |
889b48cce7a1
Include "...h", not <...h> in some cases.
Dave Love <fx@gnu.org>
parents:
88822
diff
changeset
|
27 #include "ccl.h" |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
28 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
29 /* 64/16/32/128 */ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
30 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
31 /* Number of elements in Nth level char-table. */ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
32 const int chartab_size[4] = |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
33 { (1 << CHARTAB_SIZE_BITS_0), |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
34 (1 << CHARTAB_SIZE_BITS_1), |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
35 (1 << CHARTAB_SIZE_BITS_2), |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
36 (1 << CHARTAB_SIZE_BITS_3) }; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
37 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
38 /* Number of characters each element of Nth level char-table |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
39 covers. */ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
40 const int chartab_chars[4] = |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
41 { (1 << (CHARTAB_SIZE_BITS_1 + CHARTAB_SIZE_BITS_2 + CHARTAB_SIZE_BITS_3)), |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
42 (1 << (CHARTAB_SIZE_BITS_2 + CHARTAB_SIZE_BITS_3)), |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
43 (1 << CHARTAB_SIZE_BITS_3), |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
44 1 }; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
45 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
46 /* Number of characters (in bits) each element of Nth level char-table |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
47 covers. */ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
48 const int chartab_bits[4] = |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
49 { (CHARTAB_SIZE_BITS_1 + CHARTAB_SIZE_BITS_2 + CHARTAB_SIZE_BITS_3), |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
50 (CHARTAB_SIZE_BITS_2 + CHARTAB_SIZE_BITS_3), |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
51 CHARTAB_SIZE_BITS_3, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
52 0 }; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
53 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
54 #define CHARTAB_IDX(c, depth, min_char) \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
55 (((c) - (min_char)) >> chartab_bits[(depth)]) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
56 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
57 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
58 DEFUN ("make-char-table", Fmake_char_table, Smake_char_table, 1, 2, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
59 doc: /* Return a newly created char-table. |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
60 Each element is initialized to INIT, which defaults to nil. |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
61 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
62 Optional second argument PURPOSE, if non-nil, should be a symbol |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
63 which has a `char-table-extra-slots' property. |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
64 The property's value should be an integer between 0 and 10 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
65 that specify how many extra slots the char-table has. |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
66 By default, the char-table has no extra slot. */) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
67 (purpose, init) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
68 register Lisp_Object purpose, init; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
69 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
70 Lisp_Object vector; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
71 Lisp_Object n; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
72 int n_extras = 0; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
73 int size; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
74 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
75 CHECK_SYMBOL (purpose); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
76 if (! NILP (purpose)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
77 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
78 n = Fget (purpose, Qchar_table_extra_slots); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
79 if (INTEGERP (n)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
80 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
81 if (XINT (n) < 0 || XINT (n) > 10) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
82 args_out_of_range (n, Qnil); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
83 n_extras = XINT (n); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
84 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
85 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
86 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
87 size = VECSIZE (struct Lisp_Char_Table) - 1 + n_extras; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
88 vector = Fmake_vector (make_number (size), init); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
89 XCHAR_TABLE (vector)->parent = Qnil; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
90 XCHAR_TABLE (vector)->purpose = purpose; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
91 XSETCHAR_TABLE (vector, XCHAR_TABLE (vector)); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
92 return vector; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
93 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
94 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
95 static Lisp_Object |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
96 make_sub_char_table (depth, min_char, defalt) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
97 int depth, min_char; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
98 Lisp_Object defalt; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
99 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
100 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
101 int size = VECSIZE (struct Lisp_Sub_Char_Table) - 1 + chartab_size[depth]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
102 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
103 table = Fmake_vector (make_number (size), defalt); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
104 XSUB_CHAR_TABLE (table)->depth = make_number (depth); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
105 XSUB_CHAR_TABLE (table)->min_char = make_number (min_char); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
106 XSETSUB_CHAR_TABLE (table, XSUB_CHAR_TABLE (table)); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
107 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
108 return table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
109 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
110 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
111 static Lisp_Object |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
112 char_table_ascii (table) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
113 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
114 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
115 Lisp_Object sub; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
116 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
117 sub = XCHAR_TABLE (table)->contents[0]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
118 sub = XSUB_CHAR_TABLE (sub)->contents[0]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
119 return XSUB_CHAR_TABLE (sub)->contents[0]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
120 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
121 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
122 Lisp_Object |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
123 copy_sub_char_table (table) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
124 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
125 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
126 Lisp_Object copy; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
127 int depth = XINT (XSUB_CHAR_TABLE (table)->depth); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
128 int min_char = XINT (XSUB_CHAR_TABLE (table)->min_char); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
129 Lisp_Object val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
130 int i; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
131 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
132 copy = make_sub_char_table (depth, min_char, Qnil); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
133 /* Recursively copy any sub char-tables. */ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
134 for (i = 0; i < chartab_size[depth]; i++) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
135 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
136 val = XSUB_CHAR_TABLE (table)->contents[i]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
137 if (SUB_CHAR_TABLE_P (val)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
138 XSUB_CHAR_TABLE (copy)->contents[i] = copy_sub_char_table (val); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
139 else |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
140 XSUB_CHAR_TABLE (copy)->contents[i] = val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
141 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
142 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
143 return copy; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
144 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
145 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
146 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
147 Lisp_Object |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
148 copy_char_table (table) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
149 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
150 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
151 Lisp_Object copy; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
152 int size = XCHAR_TABLE (table)->size & PSEUDOVECTOR_SIZE_MASK; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
153 int i; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
154 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
155 copy = Fmake_vector (make_number (size), Qnil); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
156 XCHAR_TABLE (copy)->defalt = XCHAR_TABLE (table)->defalt; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
157 XCHAR_TABLE (copy)->parent = XCHAR_TABLE (table)->parent; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
158 XCHAR_TABLE (copy)->purpose = XCHAR_TABLE (table)->purpose; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
159 XCHAR_TABLE (copy)->ascii = XCHAR_TABLE (table)->ascii; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
160 for (i = 0; i < chartab_size[0]; i++) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
161 XCHAR_TABLE (copy)->contents[i] |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
162 = (SUB_CHAR_TABLE_P (XCHAR_TABLE (table)->contents[i]) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
163 ? copy_sub_char_table (XCHAR_TABLE (table)->contents[i]) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
164 : XCHAR_TABLE (table)->contents[i]); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
165 if (SUB_CHAR_TABLE_P (XCHAR_TABLE (copy)->ascii)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
166 XCHAR_TABLE (copy)->ascii = char_table_ascii (copy); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
167 size -= VECSIZE (struct Lisp_Char_Table) - 1; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
168 for (i = 0; i < size; i++) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
169 XCHAR_TABLE (copy)->extras[i] = XCHAR_TABLE (table)->extras[i]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
170 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
171 XSETCHAR_TABLE (copy, XCHAR_TABLE (copy)); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
172 return copy; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
173 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
174 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
175 Lisp_Object |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
176 sub_char_table_ref (table, c) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
177 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
178 int c; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
179 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
180 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
181 int depth = XINT (tbl->depth); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
182 int min_char = XINT (tbl->min_char); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
183 Lisp_Object val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
184 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
185 val = tbl->contents[CHARTAB_IDX (c, depth, min_char)]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
186 if (SUB_CHAR_TABLE_P (val)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
187 val = sub_char_table_ref (val, c); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
188 return val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
189 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
190 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
191 Lisp_Object |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
192 char_table_ref (table, c) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
193 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
194 int c; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
195 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
196 struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
197 Lisp_Object val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
198 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
199 if (ASCII_CHAR_P (c)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
200 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
201 val = tbl->ascii; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
202 if (SUB_CHAR_TABLE_P (val)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
203 val = XSUB_CHAR_TABLE (val)->contents[c]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
204 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
205 else |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
206 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
207 val = tbl->contents[CHARTAB_IDX (c, 0, 0)]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
208 if (SUB_CHAR_TABLE_P (val)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
209 val = sub_char_table_ref (val, c); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
210 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
211 if (NILP (val)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
212 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
213 val = tbl->defalt; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
214 if (NILP (val) && CHAR_TABLE_P (tbl->parent)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
215 val = char_table_ref (tbl->parent, c); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
216 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
217 return val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
218 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
219 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
220 static Lisp_Object |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
221 sub_char_table_ref_and_range (table, c, from, to, defalt) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
222 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
223 int c; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
224 int *from, *to; |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
225 Lisp_Object defalt; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
226 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
227 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
228 int depth = XINT (tbl->depth); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
229 int min_char = XINT (tbl->min_char); |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
230 int max_char = min_char + chartab_chars[depth - 1] - 1; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
231 int index = CHARTAB_IDX (c, depth, min_char); |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
232 Lisp_Object val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
233 |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
234 val = tbl->contents[index]; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
235 *from = min_char + index * chartab_chars[depth]; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
236 *to = *from + chartab_chars[depth] - 1; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
237 if (SUB_CHAR_TABLE_P (val)) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
238 val = sub_char_table_ref_and_range (val, c, from, to, defalt); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
239 else if (NILP (val)) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
240 val = defalt; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
241 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
242 while (*from > min_char |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
243 && *from == min_char + index * chartab_chars[depth]) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
244 { |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
245 Lisp_Object this_val; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
246 int this_from = *from - chartab_chars[depth]; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
247 int this_to = *from - 1; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
248 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
249 index--; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
250 this_val = tbl->contents[index]; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
251 if (SUB_CHAR_TABLE_P (this_val)) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
252 this_val = sub_char_table_ref_and_range (this_val, this_to, |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
253 &this_from, &this_to, |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
254 defalt); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
255 else if (NILP (this_val)) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
256 this_val = defalt; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
257 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
258 if (! EQ (this_val, val)) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
259 break; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
260 *from = this_from; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
261 } |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
262 index = CHARTAB_IDX (c, depth, min_char); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
263 while (*to < max_char |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
264 && *to == min_char + (index + 1) * chartab_chars[depth] - 1) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
265 { |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
266 Lisp_Object this_val; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
267 int this_from = *to + 1; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
268 int this_to = this_from + chartab_chars[depth] - 1; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
269 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
270 index++; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
271 this_val = tbl->contents[index]; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
272 if (SUB_CHAR_TABLE_P (this_val)) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
273 this_val = sub_char_table_ref_and_range (this_val, this_from, |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
274 &this_from, &this_to, |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
275 defalt); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
276 else if (NILP (this_val)) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
277 this_val = defalt; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
278 if (! EQ (this_val, val)) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
279 break; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
280 *to = this_to; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
281 } |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
282 |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
283 return val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
284 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
285 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
286 |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
287 /* Return the value for C in char-table TABLE. Set *FROM and *TO to |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
288 the range of characters (containing C) that have the same value as |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
289 C. It is not assured that the value of (*FROM - 1) and (*TO + 1) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
290 is different from that of C. */ |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
291 |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
292 Lisp_Object |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
293 char_table_ref_and_range (table, c, from, to) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
294 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
295 int c; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
296 int *from, *to; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
297 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
298 struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
299 int index = CHARTAB_IDX (c, 0, 0); |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
300 Lisp_Object val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
301 |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
302 val = tbl->contents[index]; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
303 *from = index * chartab_chars[0]; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
304 *to = *from + chartab_chars[0] - 1; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
305 if (SUB_CHAR_TABLE_P (val)) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
306 val = sub_char_table_ref_and_range (val, c, from, to, tbl->defalt); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
307 else if (NILP (val)) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
308 val = tbl->defalt; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
309 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
310 while (*from > 0 && *from == index * chartab_chars[0]) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
311 { |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
312 Lisp_Object this_val; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
313 int this_from = *from - chartab_chars[0]; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
314 int this_to = *from - 1; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
315 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
316 index--; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
317 this_val = tbl->contents[index]; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
318 if (SUB_CHAR_TABLE_P (this_val)) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
319 this_val = sub_char_table_ref_and_range (this_val, this_to, |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
320 &this_from, &this_to, |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
321 tbl->defalt); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
322 else if (NILP (this_val)) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
323 this_val = tbl->defalt; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
324 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
325 if (! EQ (this_val, val)) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
326 break; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
327 *from = this_from; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
328 } |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
329 while (*to < MAX_CHAR && *to == (index + 1) * chartab_chars[0] - 1) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
330 { |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
331 Lisp_Object this_val; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
332 int this_from = *to + 1; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
333 int this_to = this_from + chartab_chars[0] - 1; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
334 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
335 index++; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
336 this_val = tbl->contents[index]; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
337 if (SUB_CHAR_TABLE_P (this_val)) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
338 this_val = sub_char_table_ref_and_range (this_val, this_from, |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
339 &this_from, &this_to, |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
340 tbl->defalt); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
341 else if (NILP (this_val)) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
342 this_val = tbl->defalt; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
343 if (! EQ (this_val, val)) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
344 break; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
345 *to = this_to; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
346 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
347 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
348 return val; |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
349 } |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
350 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
351 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
352 #define ASET_RANGE(ARRAY, FROM, TO, LIMIT, VAL) \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
353 do { \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
354 int limit = (TO) < (LIMIT) ? (TO) : (LIMIT); \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
355 for (; (FROM) < limit; (FROM)++) (ARRAY)->contents[(FROM)] = (VAL); \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
356 } while (0) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
357 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
358 #define GET_SUB_CHAR_TABLE(TABLE, SUBTABLE, IDX, DEPTH, MIN_CHAR) \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
359 do { \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
360 (SUBTABLE) = (TABLE)->contents[(IDX)]; \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
361 if (!SUB_CHAR_TABLE_P (SUBTABLE)) \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
362 (SUBTABLE) = make_sub_char_table ((DEPTH), (MIN_CHAR), (SUBTABLE)); \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
363 } while (0) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
364 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
365 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
366 static void |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
367 sub_char_table_set (table, c, val) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
368 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
369 int c; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
370 Lisp_Object val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
371 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
372 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
373 int depth = XINT ((tbl)->depth); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
374 int min_char = XINT ((tbl)->min_char); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
375 int i = CHARTAB_IDX (c, depth, min_char); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
376 Lisp_Object sub; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
377 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
378 if (depth == 3) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
379 tbl->contents[i] = val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
380 else |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
381 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
382 sub = tbl->contents[i]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
383 if (! SUB_CHAR_TABLE_P (sub)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
384 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
385 sub = make_sub_char_table (depth + 1, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
386 min_char + i * chartab_chars[depth], sub); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
387 tbl->contents[i] = sub; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
388 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
389 sub_char_table_set (sub, c, val); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
390 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
391 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
392 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
393 Lisp_Object |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
394 char_table_set (table, c, val) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
395 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
396 int c; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
397 Lisp_Object val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
398 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
399 struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
400 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
401 if (ASCII_CHAR_P (c) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
402 && SUB_CHAR_TABLE_P (tbl->ascii)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
403 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
404 XSUB_CHAR_TABLE (tbl->ascii)->contents[c] = val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
405 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
406 else |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
407 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
408 int i = CHARTAB_IDX (c, 0, 0); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
409 Lisp_Object sub; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
410 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
411 sub = tbl->contents[i]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
412 if (! SUB_CHAR_TABLE_P (sub)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
413 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
414 sub = make_sub_char_table (1, i * chartab_chars[0], sub); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
415 tbl->contents[i] = sub; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
416 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
417 sub_char_table_set (sub, c, val); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
418 if (ASCII_CHAR_P (c)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
419 tbl->ascii = char_table_ascii (tbl); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
420 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
421 return val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
422 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
423 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
424 static void |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
425 sub_char_table_set_range (table, depth, min_char, from, to, val) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
426 Lisp_Object *table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
427 int depth; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
428 int min_char; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
429 int from, to; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
430 Lisp_Object val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
431 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
432 int max_char = min_char + chartab_chars[depth] - 1; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
433 |
88429
89eaf88b37b4
(sub_char_table_set_range): Optimized for the case
Kenichi Handa <handa@m17n.org>
parents:
88358
diff
changeset
|
434 if (depth == 3 || from <= min_char && to >= max_char) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
435 *table = val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
436 else |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
437 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
438 int i, j; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
439 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
440 depth++; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
441 if (! SUB_CHAR_TABLE_P (*table)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
442 *table = make_sub_char_table (depth, min_char, *table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
443 if (from < min_char) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
444 from = min_char; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
445 if (to > max_char) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
446 to = max_char; |
88429
89eaf88b37b4
(sub_char_table_set_range): Optimized for the case
Kenichi Handa <handa@m17n.org>
parents:
88358
diff
changeset
|
447 i = CHARTAB_IDX (from, depth, min_char); |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
448 j = CHARTAB_IDX (to, depth, min_char); |
88429
89eaf88b37b4
(sub_char_table_set_range): Optimized for the case
Kenichi Handa <handa@m17n.org>
parents:
88358
diff
changeset
|
449 min_char += chartab_chars[depth] * i; |
89eaf88b37b4
(sub_char_table_set_range): Optimized for the case
Kenichi Handa <handa@m17n.org>
parents:
88358
diff
changeset
|
450 for (; i <= j; i++, min_char += chartab_chars[depth]) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
451 sub_char_table_set_range (XSUB_CHAR_TABLE (*table)->contents + i, |
88429
89eaf88b37b4
(sub_char_table_set_range): Optimized for the case
Kenichi Handa <handa@m17n.org>
parents:
88358
diff
changeset
|
452 depth, min_char, from, to, val); |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
453 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
454 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
455 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
456 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
457 Lisp_Object |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
458 char_table_set_range (table, from, to, val) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
459 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
460 int from, to; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
461 Lisp_Object val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
462 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
463 struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
464 Lisp_Object *contents = tbl->contents; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
465 int i, min_char; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
466 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
467 if (from == to) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
468 char_table_set (table, from, val); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
469 else |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
470 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
471 for (i = CHARTAB_IDX (from, 0, 0), min_char = i * chartab_chars[0]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
472 min_char <= to; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
473 i++, min_char += chartab_chars[0]) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
474 sub_char_table_set_range (contents + i, 0, min_char, from, to, val); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
475 if (ASCII_CHAR_P (from)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
476 tbl->ascii = char_table_ascii (tbl); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
477 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
478 return val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
479 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
480 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
481 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
482 DEFUN ("char-table-subtype", Fchar_table_subtype, Schar_table_subtype, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
483 1, 1, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
484 doc: /* |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
485 Return the subtype of char-table CHAR-TABLE. The value is a symbol. */) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
486 (char_table) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
487 Lisp_Object char_table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
488 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
489 CHECK_CHAR_TABLE (char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
490 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
491 return XCHAR_TABLE (char_table)->purpose; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
492 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
493 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
494 DEFUN ("char-table-parent", Fchar_table_parent, Schar_table_parent, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
495 1, 1, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
496 doc: /* Return the parent char-table of CHAR-TABLE. |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
497 The value is either nil or another char-table. |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
498 If CHAR-TABLE holds nil for a given character, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
499 then the actual applicable value is inherited from the parent char-table |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
500 \(or from its parents, if necessary). */) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
501 (char_table) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
502 Lisp_Object char_table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
503 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
504 CHECK_CHAR_TABLE (char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
505 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
506 return XCHAR_TABLE (char_table)->parent; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
507 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
508 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
509 DEFUN ("set-char-table-parent", Fset_char_table_parent, Sset_char_table_parent, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
510 2, 2, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
511 doc: /* Set the parent char-table of CHAR-TABLE to PARENT. |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
512 PARENT must be either nil or another char-table. */) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
513 (char_table, parent) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
514 Lisp_Object char_table, parent; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
515 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
516 Lisp_Object temp; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
517 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
518 CHECK_CHAR_TABLE (char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
519 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
520 if (!NILP (parent)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
521 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
522 CHECK_CHAR_TABLE (parent); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
523 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
524 for (temp = parent; !NILP (temp); temp = XCHAR_TABLE (temp)->parent) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
525 if (EQ (temp, char_table)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
526 error ("Attempt to make a chartable be its own parent"); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
527 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
528 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
529 XCHAR_TABLE (char_table)->parent = parent; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
530 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
531 return parent; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
532 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
533 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
534 DEFUN ("char-table-extra-slot", Fchar_table_extra_slot, Schar_table_extra_slot, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
535 2, 2, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
536 doc: /* Return the value of CHAR-TABLE's extra-slot number N. */) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
537 (char_table, n) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
538 Lisp_Object char_table, n; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
539 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
540 CHECK_CHAR_TABLE (char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
541 CHECK_NUMBER (n); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
542 if (XINT (n) < 0 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
543 || XINT (n) >= CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (char_table))) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
544 args_out_of_range (char_table, n); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
545 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
546 return XCHAR_TABLE (char_table)->extras[XINT (n)]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
547 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
548 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
549 DEFUN ("set-char-table-extra-slot", Fset_char_table_extra_slot, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
550 Sset_char_table_extra_slot, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
551 3, 3, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
552 doc: /* Set CHAR-TABLE's extra-slot number N to VALUE. */) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
553 (char_table, n, value) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
554 Lisp_Object char_table, n, value; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
555 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
556 CHECK_CHAR_TABLE (char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
557 CHECK_NUMBER (n); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
558 if (XINT (n) < 0 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
559 || XINT (n) >= CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (char_table))) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
560 args_out_of_range (char_table, n); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
561 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
562 return XCHAR_TABLE (char_table)->extras[XINT (n)] = value; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
563 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
564 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
565 DEFUN ("char-table-range", Fchar_table_range, Schar_table_range, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
566 2, 2, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
567 doc: /* Return the value in CHAR-TABLE for a range of characters RANGE. |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
568 RANGE should be nil (for the default value), |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
569 a cons of character codes (for characters in the range), or a character code. */) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
570 (char_table, range) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
571 Lisp_Object char_table, range; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
572 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
573 Lisp_Object val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
574 CHECK_CHAR_TABLE (char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
575 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
576 if (EQ (range, Qnil)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
577 val = XCHAR_TABLE (char_table)->defalt; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
578 else if (INTEGERP (range)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
579 val = CHAR_TABLE_REF (char_table, XINT (range)); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
580 else if (CONSP (range)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
581 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
582 int from, to; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
583 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
584 CHECK_CHARACTER (XCAR (range)); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
585 CHECK_CHARACTER (XCDR (range)); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
586 val = char_table_ref_and_range (char_table, XINT (XCAR (range)), |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
587 &from, &to); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
588 /* Not yet implemented. */ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
589 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
590 else |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
591 error ("Invalid RANGE argument to `char-table-range'"); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
592 return val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
593 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
594 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
595 DEFUN ("set-char-table-range", Fset_char_table_range, Sset_char_table_range, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
596 3, 3, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
597 doc: /* |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
598 Set the value in CHAR-TABLE for characters specified by RANGE to VALUE. |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
599 RANGE should be t (for all characters), nil (for the default value), |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
600 a cons of character codes (for characters in the range), or a character code. */) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
601 (char_table, range, value) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
602 Lisp_Object char_table, range, value; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
603 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
604 CHECK_CHAR_TABLE (char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
605 if (EQ (range, Qt)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
606 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
607 int i; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
608 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
609 XCHAR_TABLE (char_table)->ascii = Qnil; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
610 for (i = 0; i < chartab_size[0]; i++) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
611 XCHAR_TABLE (char_table)->contents[i] = Qnil; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
612 XCHAR_TABLE (char_table)->defalt = value; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
613 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
614 else if (EQ (range, Qnil)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
615 XCHAR_TABLE (char_table)->defalt = value; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
616 else if (INTEGERP (range)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
617 char_table_set (char_table, XINT (range), value); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
618 else if (CONSP (range)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
619 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
620 CHECK_CHARACTER (XCAR (range)); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
621 CHECK_CHARACTER (XCDR (range)); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
622 char_table_set_range (char_table, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
623 XINT (XCAR (range)), XINT (XCDR (range)), value); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
624 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
625 else |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
626 error ("Invalid RANGE argument to `set-char-table-range'"); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
627 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
628 return value; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
629 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
630 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
631 DEFUN ("set-char-table-default", Fset_char_table_default, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
632 Sset_char_table_default, 3, 3, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
633 doc: /* |
88822
9c92853c0d10
(make_sub_char_table): Remove unused var.
Dave Love <fx@gnu.org>
parents:
88746
diff
changeset
|
634 This function is obsolete and has no effect. */) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
635 (char_table, ch, value) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
636 Lisp_Object char_table, ch, value; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
637 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
638 return Qnil; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
639 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
640 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
641 /* Look up the element in TABLE at index CH, and return it as an |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
642 integer. If the element is nil, return CH itself. (Actually we do |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
643 that for any non-integer.) */ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
644 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
645 int |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
646 char_table_translate (table, ch) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
647 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
648 int ch; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
649 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
650 Lisp_Object value; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
651 value = Faref (table, make_number (ch)); |
88822
9c92853c0d10
(make_sub_char_table): Remove unused var.
Dave Love <fx@gnu.org>
parents:
88746
diff
changeset
|
652 if (! INTEGERP (value)) /* fixme: use CHARACTERP? */ |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
653 return ch; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
654 return XINT (value); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
655 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
656 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
657 static Lisp_Object |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
658 optimize_sub_char_table (table) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
659 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
660 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
661 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
662 int depth = XINT (tbl->depth); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
663 Lisp_Object elt, this; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
664 int i; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
665 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
666 elt = XSUB_CHAR_TABLE (table)->contents[0]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
667 if (SUB_CHAR_TABLE_P (elt)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
668 elt = XSUB_CHAR_TABLE (table)->contents[0] = optimize_sub_char_table (elt); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
669 if (SUB_CHAR_TABLE_P (elt)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
670 return table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
671 for (i = 1; i < chartab_size[depth]; i++) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
672 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
673 this = XSUB_CHAR_TABLE (table)->contents[i]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
674 if (SUB_CHAR_TABLE_P (this)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
675 this = XSUB_CHAR_TABLE (table)->contents[i] |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
676 = optimize_sub_char_table (this); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
677 if (SUB_CHAR_TABLE_P (this) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
678 || NILP (Fequal (this, elt))) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
679 break; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
680 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
681 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
682 return (i < chartab_size[depth] ? table : elt); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
683 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
684 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
685 DEFUN ("optimize-char-table", Foptimize_char_table, Soptimize_char_table, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
686 1, 1, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
687 doc: /* Optimize CHAR-TABLE. */) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
688 (char_table) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
689 Lisp_Object char_table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
690 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
691 Lisp_Object elt; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
692 int i; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
693 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
694 CHECK_CHAR_TABLE (char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
695 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
696 for (i = 0; i < chartab_size[0]; i++) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
697 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
698 elt = XCHAR_TABLE (char_table)->contents[i]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
699 if (SUB_CHAR_TABLE_P (elt)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
700 XCHAR_TABLE (char_table)->contents[i] = optimize_sub_char_table (elt); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
701 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
702 return Qnil; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
703 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
704 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
705 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
706 static Lisp_Object |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
707 map_sub_char_table (c_function, function, table, arg, val, range) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
708 void (*c_function) P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
709 Lisp_Object function, table, arg, val, range; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
710 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
711 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
712 int depth = XINT (tbl->depth); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
713 int i, c; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
714 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
715 for (i = 0, c = XINT (tbl->min_char); i < chartab_size[depth]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
716 i++, c += chartab_chars[depth]) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
717 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
718 Lisp_Object this; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
719 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
720 this = tbl->contents[i]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
721 if (SUB_CHAR_TABLE_P (this)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
722 val = map_sub_char_table (c_function, function, this, arg, val, range); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
723 else if (NILP (Fequal (val, this))) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
724 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
725 if (! NILP (val)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
726 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
727 XCDR (range) = make_number (c - 1); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
728 if (depth == 3 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
729 && EQ (XCAR (range), XCDR (range))) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
730 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
731 if (c_function) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
732 (*c_function) (arg, XCAR (range), val); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
733 else |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
734 call2 (function, XCAR (range), val); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
735 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
736 else |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
737 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
738 if (c_function) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
739 (*c_function) (arg, range, val); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
740 else |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
741 call2 (function, range, val); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
742 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
743 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
744 val = this; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
745 XCAR (range) = make_number (c); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
746 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
747 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
748 return val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
749 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
750 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
751 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
752 /* Map C_FUNCTION or FUNCTION over TABLE, calling it for each |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
753 character or group of characters that share a value. |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
754 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
755 ARG is passed to C_FUNCTION when that is called. |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
756 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
757 DEPTH and INDICES are ignored. They are removed in the new |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
758 feature. */ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
759 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
760 void |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
761 map_char_table (c_function, function, table, arg, depth, indices) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
762 void (*c_function) P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
763 Lisp_Object function, table, arg, *indices; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
764 int depth; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
765 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
766 Lisp_Object range, val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
767 int c, i; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
768 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
769 range = Fcons (make_number (0), Qnil); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
770 val = char_table_ref (table, 0); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
771 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
772 for (i = 0, c = 0; i < chartab_size[0]; i++, c += chartab_chars[0]) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
773 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
774 Lisp_Object this; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
775 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
776 this = XCHAR_TABLE (table)->contents[i]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
777 if (SUB_CHAR_TABLE_P (this)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
778 val = map_sub_char_table (c_function, function, this, arg, val, range); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
779 else if (NILP (Fequal (val, this))) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
780 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
781 if (! NILP (val)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
782 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
783 XCDR (range) = make_number (c - 1); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
784 if (c_function) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
785 (*c_function) (arg, range, val); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
786 else |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
787 call2 (function, range, val); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
788 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
789 val = this; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
790 XCAR (range) = make_number (c); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
791 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
792 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
793 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
794 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
795 DEFUN ("map-char-table", Fmap_char_table, Smap_char_table, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
796 2, 2, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
797 doc: /* |
88822
9c92853c0d10
(make_sub_char_table): Remove unused var.
Dave Love <fx@gnu.org>
parents:
88746
diff
changeset
|
798 Call FUNCTION for each character in CHAR-TABLE. |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
799 FUNCTION is called with two arguments--a key and a value. |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
800 The key is always a possible IDX argument to `aref'. */) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
801 (function, char_table) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
802 Lisp_Object function, char_table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
803 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
804 CHECK_CHAR_TABLE (char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
805 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
806 map_char_table (NULL, function, char_table, char_table, 0, NULL); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
807 return Qnil; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
808 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
809 |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
810 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
811 static void |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
812 map_sub_char_table_for_charset (c_function, function, table, arg, range, |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
813 charset, from, to) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
814 void (*c_function) P_ ((Lisp_Object, Lisp_Object)); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
815 Lisp_Object function, table, arg, range; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
816 struct charset *charset; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
817 unsigned from, to; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
818 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
819 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
820 int depth = XINT (tbl->depth); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
821 int c, i; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
822 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
823 if (depth < 3) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
824 for (i = 0, c = XINT (tbl->min_char); i < chartab_size[depth]; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
825 i++, c += chartab_chars[depth]) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
826 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
827 Lisp_Object this; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
828 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
829 this = tbl->contents[i]; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
830 if (SUB_CHAR_TABLE_P (this)) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
831 map_sub_char_table_for_charset (c_function, function, this, arg, |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
832 range, charset, from, to); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
833 else |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
834 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
835 if (! NILP (XCAR (range))) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
836 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
837 XSETCDR (range, make_number (c - 1)); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
838 if (c_function) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
839 (*c_function) (arg, range); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
840 else |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
841 call2 (function, range, arg); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
842 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
843 XSETCAR (range, Qnil); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
844 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
845 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
846 else |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
847 for (i = 0, c = XINT (tbl->min_char); i < chartab_size[depth]; i++, c ++) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
848 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
849 Lisp_Object this; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
850 unsigned code; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
851 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
852 this = tbl->contents[i]; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
853 if (NILP (this) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
854 || (charset |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
855 && (code = ENCODE_CHAR (charset, c), |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
856 (code < from || code > to)))) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
857 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
858 if (! NILP (XCAR (range))) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
859 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
860 XSETCDR (range, make_number (c - 1)); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
861 if (c_function) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
862 (*c_function) (range, arg); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
863 else |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
864 call2 (function, range, arg); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
865 XSETCAR (range, Qnil); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
866 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
867 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
868 else |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
869 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
870 if (NILP (XCAR (range))) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
871 XSETCAR (range, make_number (c)); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
872 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
873 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
874 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
875 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
876 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
877 void |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
878 map_char_table_for_charset (c_function, function, table, arg, |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
879 charset, from, to) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
880 void (*c_function) P_ ((Lisp_Object, Lisp_Object)); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
881 Lisp_Object function, table, arg; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
882 struct charset *charset; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
883 unsigned from, to; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
884 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
885 Lisp_Object range; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
886 int c, i; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
887 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
888 if (NILP (char_table_ref (table, 0))) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
889 range = Fcons (Qnil, Qnil); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
890 else |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
891 range = Fcons (make_number (0), make_number (0)); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
892 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
893 for (i = 0, c = 0; i < chartab_size[0]; i++, c += chartab_chars[0]) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
894 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
895 Lisp_Object this; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
896 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
897 this = XCHAR_TABLE (table)->contents[i]; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
898 if (SUB_CHAR_TABLE_P (this)) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
899 map_sub_char_table_for_charset (c_function, function, this, arg, |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
900 range, charset, from, to); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
901 else |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
902 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
903 if (! NILP (XCAR (range))) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
904 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
905 XSETCDR (range, make_number (c - 1)); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
906 if (c_function) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
907 (*c_function) (arg, range); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
908 else |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
909 call2 (function, range, arg); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
910 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
911 XSETCAR (range, Qnil); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
912 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
913 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
914 if (! NILP (XCAR (range))) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
915 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
916 XSETCDR (range, make_number (c - 1)); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
917 if (c_function) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
918 (*c_function) (arg, range); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
919 else |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
920 call2 (function, range, arg); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
921 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
922 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
923 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
924 |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
925 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
926 #if 0 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
927 Lisp_Object |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
928 make_class_table (purpose) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
929 Lisp_Object purpose; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
930 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
931 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
932 Lisp_Object args[4]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
933 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
934 args[0] = purpose; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
935 args[1] = Qnil; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
936 args[2] = QCextra_slots; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
937 args[3] = Fmake_vector (make_number (2), Qnil); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
938 ASET (args[3], 0, Fmakehash (Qequal)); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
939 table = Fmake_char_table (4, args); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
940 return table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
941 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
942 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
943 Lisp_Object |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
944 modify_class_entry (c, val, table, set) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
945 int c; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
946 Lisp_Object val, table, set; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
947 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
948 Lisp_Object classes, hash, canon; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
949 int i, ival; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
950 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
951 hash = XCHAR_TABLE (table)->extras[0]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
952 classes = CHAR_TABLE_REF (table, c); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
953 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
954 if (! BOOL_VECTOR_P (classes)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
955 classes = (NILP (set) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
956 ? Qnil |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
957 : Fmake_bool_vector (make_number ((ival / 8) * 8 + 8), Qnil)); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
958 else if (ival < XBOOL_VECTOR (classes)->size) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
959 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
960 Lisp_Object old; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
961 old = classes; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
962 classes = Fmake_bool_vector (make_number ((ival / 8) * 8 + 8), Qnil); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
963 for (i = 0; i < XBOOL_VECTOR (classes)->size; i++) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
964 Faset (classes, make_number (i), Faref (old, make_number (i))); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
965 Faset (classes, val, set); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
966 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
967 else if (NILP (Faref (classes, val)) != NILP (set)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
968 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
969 classes = Fcopy_sequence (classes); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
970 Faset (classes, val, set); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
971 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
972 else |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
973 classes = Qnil; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
974 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
975 if (!NILP (classes)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
976 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
977 canon = Fgethash (classes, hash, Qnil); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
978 if (NILP (canon)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
979 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
980 canon = classes; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
981 Fputhash (canon, canon, hash); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
982 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
983 char_table_set (table, c, canon); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
984 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
985 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
986 return val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
987 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
988 #endif |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
989 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
990 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
991 void |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
992 syms_of_chartab () |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
993 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
994 defsubr (&Smake_char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
995 defsubr (&Schar_table_parent); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
996 defsubr (&Schar_table_subtype); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
997 defsubr (&Sset_char_table_parent); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
998 defsubr (&Schar_table_extra_slot); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
999 defsubr (&Sset_char_table_extra_slot); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
1000 defsubr (&Schar_table_range); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
1001 defsubr (&Sset_char_table_range); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
1002 defsubr (&Sset_char_table_default); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
1003 defsubr (&Soptimize_char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
1004 defsubr (&Smap_char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
1005 } |