Mercurial > emacs
annotate src/chartab.c @ 90357:ee03316bed9d
*** empty log message ***
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 08 Mar 2006 11:56:59 +0000 |
parents | 20480108ff4e |
children | d563fa5ce200 |
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 |
89483 | 2 Copyright (C) 2003 |
88358
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, |
88900
d6c50ac00394
(Fmake_char_table): Doc fixed. If PURPOSE doesn't
Kenichi Handa <handa@m17n.org>
parents:
88858
diff
changeset
|
59 doc: /* Return a newly created char-table, with purpose PURPOSE. |
88358
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 |
88900
d6c50ac00394
(Fmake_char_table): Doc fixed. If PURPOSE doesn't
Kenichi Handa <handa@m17n.org>
parents:
88858
diff
changeset
|
62 PURPOSE should be a symbol. If it has a `char-table-extra-slots' |
d6c50ac00394
(Fmake_char_table): Doc fixed. If PURPOSE doesn't
Kenichi Handa <handa@m17n.org>
parents:
88858
diff
changeset
|
63 property, the property's value should be an integer between 0 and 10 |
d6c50ac00394
(Fmake_char_table): Doc fixed. If PURPOSE doesn't
Kenichi Handa <handa@m17n.org>
parents:
88858
diff
changeset
|
64 that specifies how many extra slots the char-table has. Otherwise, |
d6c50ac00394
(Fmake_char_table): Doc fixed. If PURPOSE doesn't
Kenichi Handa <handa@m17n.org>
parents:
88858
diff
changeset
|
65 the char-table has no extra slot. */) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
66 (purpose, init) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
67 register Lisp_Object purpose, init; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
68 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
69 Lisp_Object vector; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
70 Lisp_Object n; |
88900
d6c50ac00394
(Fmake_char_table): Doc fixed. If PURPOSE doesn't
Kenichi Handa <handa@m17n.org>
parents:
88858
diff
changeset
|
71 int n_extras; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
72 int size; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
73 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
74 CHECK_SYMBOL (purpose); |
88900
d6c50ac00394
(Fmake_char_table): Doc fixed. If PURPOSE doesn't
Kenichi Handa <handa@m17n.org>
parents:
88858
diff
changeset
|
75 n = Fget (purpose, Qchar_table_extra_slots); |
d6c50ac00394
(Fmake_char_table): Doc fixed. If PURPOSE doesn't
Kenichi Handa <handa@m17n.org>
parents:
88858
diff
changeset
|
76 if (NILP (n)) |
d6c50ac00394
(Fmake_char_table): Doc fixed. If PURPOSE doesn't
Kenichi Handa <handa@m17n.org>
parents:
88858
diff
changeset
|
77 n_extras = 0; |
d6c50ac00394
(Fmake_char_table): Doc fixed. If PURPOSE doesn't
Kenichi Handa <handa@m17n.org>
parents:
88858
diff
changeset
|
78 else |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
79 { |
88900
d6c50ac00394
(Fmake_char_table): Doc fixed. If PURPOSE doesn't
Kenichi Handa <handa@m17n.org>
parents:
88858
diff
changeset
|
80 CHECK_NATNUM (n); |
d6c50ac00394
(Fmake_char_table): Doc fixed. If PURPOSE doesn't
Kenichi Handa <handa@m17n.org>
parents:
88858
diff
changeset
|
81 n_extras = XINT (n); |
d6c50ac00394
(Fmake_char_table): Doc fixed. If PURPOSE doesn't
Kenichi Handa <handa@m17n.org>
parents:
88858
diff
changeset
|
82 if (n_extras > 10) |
d6c50ac00394
(Fmake_char_table): Doc fixed. If PURPOSE doesn't
Kenichi Handa <handa@m17n.org>
parents:
88858
diff
changeset
|
83 args_out_of_range (n, Qnil); |
88358
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 size = VECSIZE (struct Lisp_Char_Table) - 1 + n_extras; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
87 vector = Fmake_vector (make_number (size), init); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
88 XCHAR_TABLE (vector)->parent = Qnil; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
89 XCHAR_TABLE (vector)->purpose = purpose; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
90 XSETCHAR_TABLE (vector, XCHAR_TABLE (vector)); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
91 return vector; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
92 } |
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 static Lisp_Object |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
95 make_sub_char_table (depth, min_char, defalt) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
96 int depth, min_char; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
97 Lisp_Object defalt; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
98 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
99 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
100 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
|
101 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
102 table = Fmake_vector (make_number (size), defalt); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
103 XSUB_CHAR_TABLE (table)->depth = make_number (depth); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
104 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
|
105 XSETSUB_CHAR_TABLE (table, XSUB_CHAR_TABLE (table)); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
106 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
107 return table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
108 } |
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 static Lisp_Object |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
111 char_table_ascii (table) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
112 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
113 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
114 Lisp_Object sub; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
115 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
116 sub = XCHAR_TABLE (table)->contents[0]; |
89334
0b3ed65e4e97
(char_table_ascii): Check if the char table contents
Kenichi Handa <handa@m17n.org>
parents:
88988
diff
changeset
|
117 if (! SUB_CHAR_TABLE_P (sub)) |
0b3ed65e4e97
(char_table_ascii): Check if the char table contents
Kenichi Handa <handa@m17n.org>
parents:
88988
diff
changeset
|
118 return sub; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
119 sub = XSUB_CHAR_TABLE (sub)->contents[0]; |
89334
0b3ed65e4e97
(char_table_ascii): Check if the char table contents
Kenichi Handa <handa@m17n.org>
parents:
88988
diff
changeset
|
120 if (! SUB_CHAR_TABLE_P (sub)) |
0b3ed65e4e97
(char_table_ascii): Check if the char table contents
Kenichi Handa <handa@m17n.org>
parents:
88988
diff
changeset
|
121 return sub; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
122 return XSUB_CHAR_TABLE (sub)->contents[0]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
123 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
124 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
125 Lisp_Object |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
126 copy_sub_char_table (table) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
127 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
128 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
129 Lisp_Object copy; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
130 int depth = XINT (XSUB_CHAR_TABLE (table)->depth); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
131 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
|
132 Lisp_Object val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
133 int i; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
134 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
135 copy = make_sub_char_table (depth, min_char, Qnil); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
136 /* Recursively copy any sub char-tables. */ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
137 for (i = 0; i < chartab_size[depth]; i++) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
138 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
139 val = XSUB_CHAR_TABLE (table)->contents[i]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
140 if (SUB_CHAR_TABLE_P (val)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
141 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
|
142 else |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
143 XSUB_CHAR_TABLE (copy)->contents[i] = val; |
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 return copy; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
147 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
148 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
149 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
150 Lisp_Object |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
151 copy_char_table (table) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
152 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
153 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
154 Lisp_Object copy; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
155 int size = XCHAR_TABLE (table)->size & PSEUDOVECTOR_SIZE_MASK; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
156 int i; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
157 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
158 copy = Fmake_vector (make_number (size), Qnil); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
159 XCHAR_TABLE (copy)->defalt = XCHAR_TABLE (table)->defalt; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
160 XCHAR_TABLE (copy)->parent = XCHAR_TABLE (table)->parent; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
161 XCHAR_TABLE (copy)->purpose = XCHAR_TABLE (table)->purpose; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
162 XCHAR_TABLE (copy)->ascii = XCHAR_TABLE (table)->ascii; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
163 for (i = 0; i < chartab_size[0]; i++) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
164 XCHAR_TABLE (copy)->contents[i] |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
165 = (SUB_CHAR_TABLE_P (XCHAR_TABLE (table)->contents[i]) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
166 ? copy_sub_char_table (XCHAR_TABLE (table)->contents[i]) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
167 : XCHAR_TABLE (table)->contents[i]); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
168 if (SUB_CHAR_TABLE_P (XCHAR_TABLE (copy)->ascii)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
169 XCHAR_TABLE (copy)->ascii = char_table_ascii (copy); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
170 size -= VECSIZE (struct Lisp_Char_Table) - 1; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
171 for (i = 0; i < size; i++) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
172 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
|
173 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
174 XSETCHAR_TABLE (copy, XCHAR_TABLE (copy)); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
175 return copy; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
176 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
177 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
178 Lisp_Object |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
179 sub_char_table_ref (table, c) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
180 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
181 int c; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
182 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
183 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
|
184 int depth = XINT (tbl->depth); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
185 int min_char = XINT (tbl->min_char); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
186 Lisp_Object val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
187 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
188 val = tbl->contents[CHARTAB_IDX (c, depth, min_char)]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
189 if (SUB_CHAR_TABLE_P (val)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
190 val = sub_char_table_ref (val, c); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
191 return val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
192 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
193 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
194 Lisp_Object |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
195 char_table_ref (table, c) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
196 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
197 int c; |
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 struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
200 Lisp_Object val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
201 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
202 if (ASCII_CHAR_P (c)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
203 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
204 val = tbl->ascii; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
205 if (SUB_CHAR_TABLE_P (val)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
206 val = XSUB_CHAR_TABLE (val)->contents[c]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
207 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
208 else |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
209 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
210 val = tbl->contents[CHARTAB_IDX (c, 0, 0)]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
211 if (SUB_CHAR_TABLE_P (val)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
212 val = sub_char_table_ref (val, c); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
213 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
214 if (NILP (val)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
215 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
216 val = tbl->defalt; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
217 if (NILP (val) && CHAR_TABLE_P (tbl->parent)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
218 val = char_table_ref (tbl->parent, c); |
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 return val; |
89483 | 221 } |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
222 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
223 static Lisp_Object |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
224 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
|
225 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
226 int c; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
227 int *from, *to; |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
228 Lisp_Object defalt; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
229 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
230 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
|
231 int depth = XINT (tbl->depth); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
232 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
|
233 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
|
234 int index = CHARTAB_IDX (c, depth, min_char); |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
235 Lisp_Object val; |
89483 | 236 |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
237 val = tbl->contents[index]; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
238 *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
|
239 *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
|
240 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
|
241 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
|
242 else if (NILP (val)) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
243 val = defalt; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
244 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
245 while (*from > min_char |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
246 && *from == min_char + index * chartab_chars[depth]) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
247 { |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
248 Lisp_Object this_val; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
249 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
|
250 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
|
251 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
252 index--; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
253 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
|
254 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
|
255 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
|
256 &this_from, &this_to, |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
257 defalt); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
258 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
|
259 this_val = defalt; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
260 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
261 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
|
262 break; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
263 *from = this_from; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
264 } |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
265 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
|
266 while (*to < max_char |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
267 && *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
|
268 { |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
269 Lisp_Object this_val; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
270 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
|
271 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
|
272 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
273 index++; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
274 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
|
275 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
|
276 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
|
277 &this_from, &this_to, |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
278 defalt); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
279 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
|
280 this_val = defalt; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
281 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
|
282 break; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
283 *to = this_to; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
284 } |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
285 |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
286 return val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
287 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
288 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
289 |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
290 /* 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
|
291 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
|
292 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
|
293 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
|
294 |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
295 Lisp_Object |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
296 char_table_ref_and_range (table, c, from, to) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
297 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
298 int c; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
299 int *from, *to; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
300 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
301 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
|
302 int index = CHARTAB_IDX (c, 0, 0); |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
303 Lisp_Object val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
304 |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
305 val = tbl->contents[index]; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
306 *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
|
307 *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
|
308 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
|
309 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
|
310 else if (NILP (val)) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
311 val = tbl->defalt; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
312 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
313 while (*from > 0 && *from == index * chartab_chars[0]) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
314 { |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
315 Lisp_Object this_val; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
316 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
|
317 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
|
318 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
319 index--; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
320 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
|
321 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
|
322 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
|
323 &this_from, &this_to, |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
324 tbl->defalt); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
325 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
|
326 this_val = tbl->defalt; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
327 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
328 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
|
329 break; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
330 *from = this_from; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
331 } |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
332 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
|
333 { |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
334 Lisp_Object this_val; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
335 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
|
336 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
|
337 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
338 index++; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
339 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
|
340 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
|
341 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
|
342 &this_from, &this_to, |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
343 tbl->defalt); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
344 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
|
345 this_val = tbl->defalt; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
346 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
|
347 break; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
348 *to = this_to; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
349 } |
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 return val; |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
352 } |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
353 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
354 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
355 #define ASET_RANGE(ARRAY, FROM, TO, LIMIT, VAL) \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
356 do { \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
357 int limit = (TO) < (LIMIT) ? (TO) : (LIMIT); \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
358 for (; (FROM) < limit; (FROM)++) (ARRAY)->contents[(FROM)] = (VAL); \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
359 } while (0) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
360 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
361 #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
|
362 do { \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
363 (SUBTABLE) = (TABLE)->contents[(IDX)]; \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
364 if (!SUB_CHAR_TABLE_P (SUBTABLE)) \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
365 (SUBTABLE) = make_sub_char_table ((DEPTH), (MIN_CHAR), (SUBTABLE)); \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
366 } while (0) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
367 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
368 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
369 static void |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
370 sub_char_table_set (table, c, val) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
371 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
372 int c; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
373 Lisp_Object val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
374 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
375 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
|
376 int depth = XINT ((tbl)->depth); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
377 int min_char = XINT ((tbl)->min_char); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
378 int i = CHARTAB_IDX (c, depth, min_char); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
379 Lisp_Object sub; |
89483 | 380 |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
381 if (depth == 3) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
382 tbl->contents[i] = val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
383 else |
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 = tbl->contents[i]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
386 if (! SUB_CHAR_TABLE_P (sub)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
387 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
388 sub = make_sub_char_table (depth + 1, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
389 min_char + i * chartab_chars[depth], sub); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
390 tbl->contents[i] = sub; |
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 sub_char_table_set (sub, c, val); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
393 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
394 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
395 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
396 Lisp_Object |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
397 char_table_set (table, c, val) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
398 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
399 int c; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
400 Lisp_Object val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
401 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
402 struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); |
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 if (ASCII_CHAR_P (c) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
405 && SUB_CHAR_TABLE_P (tbl->ascii)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
406 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
407 XSUB_CHAR_TABLE (tbl->ascii)->contents[c] = val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
408 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
409 else |
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 int i = CHARTAB_IDX (c, 0, 0); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
412 Lisp_Object 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 = tbl->contents[i]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
415 if (! SUB_CHAR_TABLE_P (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 = 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
|
418 tbl->contents[i] = sub; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
419 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
420 sub_char_table_set (sub, c, val); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
421 if (ASCII_CHAR_P (c)) |
89334
0b3ed65e4e97
(char_table_ascii): Check if the char table contents
Kenichi Handa <handa@m17n.org>
parents:
88988
diff
changeset
|
422 tbl->ascii = char_table_ascii (table); |
88358
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 return val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
425 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
426 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
427 static void |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
428 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
|
429 Lisp_Object *table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
430 int depth; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
431 int min_char; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
432 int from, to; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
433 Lisp_Object val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
434 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
435 int max_char = min_char + chartab_chars[depth] - 1; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
436 |
88988 | 437 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
|
438 *table = val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
439 else |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
440 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
441 int i, j; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
442 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
443 depth++; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
444 if (! SUB_CHAR_TABLE_P (*table)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
445 *table = make_sub_char_table (depth, min_char, *table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
446 if (from < min_char) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
447 from = min_char; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
448 if (to > max_char) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
449 to = max_char; |
88429
89eaf88b37b4
(sub_char_table_set_range): Optimized for the case
Kenichi Handa <handa@m17n.org>
parents:
88358
diff
changeset
|
450 i = CHARTAB_IDX (from, depth, min_char); |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
451 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
|
452 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
|
453 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
|
454 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
|
455 depth, min_char, from, to, val); |
88358
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 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
458 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
459 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
460 Lisp_Object |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
461 char_table_set_range (table, from, to, val) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
462 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
463 int from, to; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
464 Lisp_Object val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
465 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
466 struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
467 Lisp_Object *contents = tbl->contents; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
468 int i, min_char; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
469 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
470 if (from == to) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
471 char_table_set (table, from, val); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
472 else |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
473 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
474 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
|
475 min_char <= to; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
476 i++, min_char += chartab_chars[0]) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
477 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
|
478 if (ASCII_CHAR_P (from)) |
89334
0b3ed65e4e97
(char_table_ascii): Check if the char table contents
Kenichi Handa <handa@m17n.org>
parents:
88988
diff
changeset
|
479 tbl->ascii = char_table_ascii (table); |
88358
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 return val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
482 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
483 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
484 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
485 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
|
486 1, 1, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
487 doc: /* |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
488 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
|
489 (char_table) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
490 Lisp_Object char_table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
491 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
492 CHECK_CHAR_TABLE (char_table); |
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 return XCHAR_TABLE (char_table)->purpose; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
495 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
496 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
497 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
|
498 1, 1, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
499 doc: /* Return the parent char-table of CHAR-TABLE. |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
500 The value is either nil or another char-table. |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
501 If CHAR-TABLE holds nil for a given character, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
502 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
|
503 \(or from its parents, if necessary). */) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
504 (char_table) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
505 Lisp_Object char_table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
506 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
507 CHECK_CHAR_TABLE (char_table); |
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 return XCHAR_TABLE (char_table)->parent; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
510 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
511 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
512 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
|
513 2, 2, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
514 doc: /* Set the parent char-table of CHAR-TABLE to PARENT. |
89909 | 515 Return PARENT. PARENT must be either nil or another char-table. */) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
516 (char_table, parent) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
517 Lisp_Object char_table, parent; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
518 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
519 Lisp_Object temp; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
520 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
521 CHECK_CHAR_TABLE (char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
522 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
523 if (!NILP (parent)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
524 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
525 CHECK_CHAR_TABLE (parent); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
526 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
527 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
|
528 if (EQ (temp, char_table)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
529 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
|
530 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
531 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
532 XCHAR_TABLE (char_table)->parent = parent; |
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 return parent; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
535 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
536 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
537 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
|
538 2, 2, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
539 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
|
540 (char_table, n) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
541 Lisp_Object char_table, n; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
542 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
543 CHECK_CHAR_TABLE (char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
544 CHECK_NUMBER (n); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
545 if (XINT (n) < 0 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
546 || 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
|
547 args_out_of_range (char_table, n); |
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 return XCHAR_TABLE (char_table)->extras[XINT (n)]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
550 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
551 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
552 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
|
553 Sset_char_table_extra_slot, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
554 3, 3, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
555 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
|
556 (char_table, n, value) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
557 Lisp_Object char_table, n, value; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
558 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
559 CHECK_CHAR_TABLE (char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
560 CHECK_NUMBER (n); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
561 if (XINT (n) < 0 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
562 || 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
|
563 args_out_of_range (char_table, n); |
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 return XCHAR_TABLE (char_table)->extras[XINT (n)] = value; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
566 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
567 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
568 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
|
569 2, 2, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
570 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
|
571 RANGE should be nil (for the default value), |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
572 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
|
573 (char_table, range) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
574 Lisp_Object char_table, range; |
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 Lisp_Object val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
577 CHECK_CHAR_TABLE (char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
578 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
579 if (EQ (range, Qnil)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
580 val = XCHAR_TABLE (char_table)->defalt; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
581 else if (INTEGERP (range)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
582 val = CHAR_TABLE_REF (char_table, XINT (range)); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
583 else if (CONSP (range)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
584 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
585 int from, to; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
586 |
89483 | 587 CHECK_CHARACTER_CAR (range); |
588 CHECK_CHARACTER_CDR (range); | |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
589 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
|
590 &from, &to); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
591 /* Not yet implemented. */ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
592 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
593 else |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
594 error ("Invalid RANGE argument to `char-table-range'"); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
595 return val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
596 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
597 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
598 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
|
599 3, 3, 0, |
89909 | 600 doc: /* Set the value in CHAR-TABLE for a range of characters RANGE to VALUE. |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
601 RANGE should be t (for all characters), nil (for the default value), |
89909 | 602 a cons of character codes (for characters in the range), |
603 or a character code. Return VALUE. */) | |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
604 (char_table, range, value) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
605 Lisp_Object char_table, range, value; |
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 CHECK_CHAR_TABLE (char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
608 if (EQ (range, Qt)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
609 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
610 int i; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
611 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
612 XCHAR_TABLE (char_table)->ascii = Qnil; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
613 for (i = 0; i < chartab_size[0]; i++) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
614 XCHAR_TABLE (char_table)->contents[i] = 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 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
617 else if (EQ (range, Qnil)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
618 XCHAR_TABLE (char_table)->defalt = value; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
619 else if (INTEGERP (range)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
620 char_table_set (char_table, XINT (range), value); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
621 else if (CONSP (range)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
622 { |
89483 | 623 CHECK_CHARACTER_CAR (range); |
624 CHECK_CHARACTER_CDR (range); | |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
625 char_table_set_range (char_table, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
626 XINT (XCAR (range)), XINT (XCDR (range)), value); |
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 else |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
629 error ("Invalid RANGE argument to `set-char-table-range'"); |
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 return value; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
632 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
633 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
634 DEFUN ("set-char-table-default", Fset_char_table_default, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
635 Sset_char_table_default, 3, 3, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
636 doc: /* |
88822
9c92853c0d10
(make_sub_char_table): Remove unused var.
Dave Love <fx@gnu.org>
parents:
88746
diff
changeset
|
637 This function is obsolete and has no effect. */) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
638 (char_table, ch, value) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
639 Lisp_Object char_table, ch, value; |
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 return Qnil; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
642 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
643 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
644 /* Look up the element in TABLE at index CH, and return it as an |
89570
c92884b9ca4a
(char_table_translate): Use CHARACTERP, not INETEGERP.
Kenichi Handa <handa@m17n.org>
parents:
89484
diff
changeset
|
645 integer. If the element is not a character, return CH itself. */ |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
646 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
647 int |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
648 char_table_translate (table, ch) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
649 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
650 int ch; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
651 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
652 Lisp_Object value; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
653 value = Faref (table, make_number (ch)); |
89570
c92884b9ca4a
(char_table_translate): Use CHARACTERP, not INETEGERP.
Kenichi Handa <handa@m17n.org>
parents:
89484
diff
changeset
|
654 if (! CHARACTERP (value)) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
655 return ch; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
656 return XINT (value); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
657 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
658 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
659 static Lisp_Object |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
660 optimize_sub_char_table (table) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
661 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
662 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
663 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
|
664 int depth = XINT (tbl->depth); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
665 Lisp_Object elt, this; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
666 int i; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
667 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
668 elt = XSUB_CHAR_TABLE (table)->contents[0]; |
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 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
|
671 if (SUB_CHAR_TABLE_P (elt)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
672 return table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
673 for (i = 1; i < chartab_size[depth]; i++) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
674 { |
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 if (SUB_CHAR_TABLE_P (this)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
677 this = XSUB_CHAR_TABLE (table)->contents[i] |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
678 = optimize_sub_char_table (this); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
679 if (SUB_CHAR_TABLE_P (this) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
680 || NILP (Fequal (this, elt))) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
681 break; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
682 } |
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 return (i < chartab_size[depth] ? table : elt); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
685 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
686 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
687 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
|
688 1, 1, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
689 doc: /* Optimize CHAR-TABLE. */) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
690 (char_table) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
691 Lisp_Object char_table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
692 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
693 Lisp_Object elt; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
694 int i; |
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 CHECK_CHAR_TABLE (char_table); |
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 for (i = 0; i < chartab_size[0]; i++) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
699 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
700 elt = XCHAR_TABLE (char_table)->contents[i]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
701 if (SUB_CHAR_TABLE_P (elt)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
702 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
|
703 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
704 return Qnil; |
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 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
707 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
708 static Lisp_Object |
89483 | 709 map_sub_char_table (c_function, function, table, arg, val, range, |
710 default_val, parent) | |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
711 void (*c_function) P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); |
89483 | 712 Lisp_Object function, table, arg, val, range, default_val, parent; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
713 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
714 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
|
715 int depth = XINT (tbl->depth); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
716 int i, c; |
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 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
|
719 i++, c += chartab_chars[depth]) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
720 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
721 Lisp_Object this; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
722 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
723 this = tbl->contents[i]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
724 if (SUB_CHAR_TABLE_P (this)) |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
725 val = map_sub_char_table (c_function, function, this, arg, val, range, |
89483 | 726 default_val, parent); |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
727 else |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
728 { |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
729 if (NILP (this)) |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
730 this = default_val; |
89483 | 731 if (NILP (this) && ! NILP (parent)) |
732 this = CHAR_TABLE_REF (parent, c); | |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
733 if (NILP (Fequal (val, this))) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
734 { |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
735 if (! NILP (val)) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
736 { |
89483 | 737 XSETCDR (range, make_number (c - 1)); |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
738 if (depth == 3 |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
739 && EQ (XCAR (range), XCDR (range))) |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
740 { |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
741 if (c_function) |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
742 (*c_function) (arg, XCAR (range), val); |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
743 else |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
744 call2 (function, XCAR (range), val); |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
745 } |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
746 else |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
747 { |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
748 if (c_function) |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
749 (*c_function) (arg, range, val); |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
750 else |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
751 call2 (function, range, val); |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
752 } |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
753 } |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
754 val = this; |
89483 | 755 XSETCAR (range, make_number (c)); |
88358
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 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
758 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
759 return val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
760 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
761 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
762 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
763 /* 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
|
764 character or group of characters that share a value. |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
765 |
89483 | 766 ARG is passed to C_FUNCTION when that is called. */ |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
767 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
768 void |
89483 | 769 map_char_table (c_function, function, table, arg) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
770 void (*c_function) P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); |
89483 | 771 Lisp_Object function, table, arg; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
772 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
773 Lisp_Object range, val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
774 int c, i; |
90047
20480108ff4e
(map_char_table): GCPRO table and arg.
Andreas Schwab <schwab@suse.de>
parents:
89911
diff
changeset
|
775 struct gcpro gcpro1, gcpro2, gcpro3; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
776 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
777 range = Fcons (make_number (0), Qnil); |
90047
20480108ff4e
(map_char_table): GCPRO table and arg.
Andreas Schwab <schwab@suse.de>
parents:
89911
diff
changeset
|
778 GCPRO3 (table, arg, range); |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
779 val = XCHAR_TABLE (table)->ascii; |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
780 if (SUB_CHAR_TABLE_P (val)) |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
781 val = XSUB_CHAR_TABLE (val)->contents[0]; |
88358
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 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
|
784 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
785 Lisp_Object this; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
786 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
787 this = XCHAR_TABLE (table)->contents[i]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
788 if (SUB_CHAR_TABLE_P (this)) |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
789 val = map_sub_char_table (c_function, function, this, arg, val, range, |
89483 | 790 XCHAR_TABLE (table)->defalt, |
791 XCHAR_TABLE (table)->parent); | |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
792 else |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
793 { |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
794 if (NILP (this)) |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
795 this = XCHAR_TABLE (table)->defalt; |
89483 | 796 if (NILP (this) && ! NILP (XCHAR_TABLE (table)->parent)) |
797 this = CHAR_TABLE_REF (XCHAR_TABLE (table)->parent, c); | |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
798 if (NILP (Fequal (val, this))) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
799 { |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
800 if (! NILP (val)) |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
801 { |
89483 | 802 XSETCDR (range, make_number (c - 1)); |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
803 if (c_function) |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
804 (*c_function) (arg, range, val); |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
805 else |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
806 call2 (function, range, val); |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
807 } |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
808 val = this; |
89483 | 809 XSETCAR (range, make_number (c)); |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
810 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
811 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
812 } |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
813 |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
814 if (! NILP (val)) |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
815 { |
89483 | 816 XSETCDR (range, make_number (c - 1)); |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
817 if (c_function) |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
818 (*c_function) (arg, range, val); |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
819 else |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
820 call2 (function, range, val); |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
821 } |
89484
5c41371d228b
(map_char_table): Protect `range' from GC.
Andreas Schwab <schwab@suse.de>
parents:
89483
diff
changeset
|
822 |
5c41371d228b
(map_char_table): Protect `range' from GC.
Andreas Schwab <schwab@suse.de>
parents:
89483
diff
changeset
|
823 UNGCPRO; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
824 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
825 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
826 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
|
827 2, 2, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
828 doc: /* |
89425 | 829 Call FUNCTION for each character in CHAR-TABLE that has non-nil value. |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
830 FUNCTION is called with two arguments--a key and a value. |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
831 The key is a character code or a cons of character codes specifying a |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
832 range of characters that have the same value. */) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
833 (function, char_table) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
834 Lisp_Object function, char_table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
835 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
836 CHECK_CHAR_TABLE (char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
837 |
89483 | 838 map_char_table (NULL, function, char_table, char_table); |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
839 return Qnil; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
840 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
841 |
88746
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 static void |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
844 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
|
845 charset, from, to) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
846 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
|
847 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
|
848 struct charset *charset; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
849 unsigned from, to; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
850 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
851 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
|
852 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
|
853 int c, i; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
854 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
855 if (depth < 3) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
856 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
|
857 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
|
858 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
859 Lisp_Object this; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
860 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
861 this = tbl->contents[i]; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
862 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
|
863 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
|
864 range, charset, from, to); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
865 else |
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 if (! NILP (XCAR (range))) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
868 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
869 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
|
870 if (c_function) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
871 (*c_function) (arg, range); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
872 else |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
873 call2 (function, range, arg); |
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 XSETCAR (range, Qnil); |
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 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
878 else |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
879 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
|
880 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
881 Lisp_Object this; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
882 unsigned code; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
883 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
884 this = tbl->contents[i]; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
885 if (NILP (this) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
886 || (charset |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
887 && (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
|
888 (code < from || code > to)))) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
889 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
890 if (! NILP (XCAR (range))) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
891 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
892 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
|
893 if (c_function) |
89684
d81f2ea4fc8d
(map_sub_char_table_for_charset): Fix args to c_function with.
Kenichi Handa <handa@m17n.org>
parents:
89570
diff
changeset
|
894 (*c_function) (arg, range); |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
895 else |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
896 call2 (function, range, arg); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
897 XSETCAR (range, Qnil); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
898 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
899 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
900 else |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
901 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
902 if (NILP (XCAR (range))) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
903 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
|
904 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
905 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
906 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
907 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
908 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
909 void |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
910 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
|
911 charset, from, to) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
912 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
|
913 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
|
914 struct charset *charset; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
915 unsigned from, to; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
916 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
917 Lisp_Object range; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
918 int c, i; |
89484
5c41371d228b
(map_char_table): Protect `range' from GC.
Andreas Schwab <schwab@suse.de>
parents:
89483
diff
changeset
|
919 struct gcpro gcpro1; |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
920 |
89483 | 921 range = Fcons (Qnil, Qnil); |
89484
5c41371d228b
(map_char_table): Protect `range' from GC.
Andreas Schwab <schwab@suse.de>
parents:
89483
diff
changeset
|
922 GCPRO1 (range); |
88746
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 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
|
925 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
926 Lisp_Object this; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
927 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
928 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
|
929 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
|
930 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
|
931 range, charset, from, to); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
932 else |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
933 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
934 if (! NILP (XCAR (range))) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
935 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
936 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
|
937 if (c_function) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
938 (*c_function) (arg, range); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
939 else |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
940 call2 (function, range, arg); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
941 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
942 XSETCAR (range, Qnil); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
943 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
944 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
945 if (! NILP (XCAR (range))) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
946 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
947 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
|
948 if (c_function) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
949 (*c_function) (arg, range); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
950 else |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
951 call2 (function, range, arg); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
952 } |
89484
5c41371d228b
(map_char_table): Protect `range' from GC.
Andreas Schwab <schwab@suse.de>
parents:
89483
diff
changeset
|
953 |
5c41371d228b
(map_char_table): Protect `range' from GC.
Andreas Schwab <schwab@suse.de>
parents:
89483
diff
changeset
|
954 UNGCPRO; |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
955 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
956 |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
957 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
958 void |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
959 syms_of_chartab () |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
960 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
961 defsubr (&Smake_char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
962 defsubr (&Schar_table_parent); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
963 defsubr (&Schar_table_subtype); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
964 defsubr (&Sset_char_table_parent); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
965 defsubr (&Schar_table_extra_slot); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
966 defsubr (&Sset_char_table_extra_slot); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
967 defsubr (&Schar_table_range); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
968 defsubr (&Sset_char_table_range); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
969 defsubr (&Sset_char_table_default); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
970 defsubr (&Soptimize_char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
971 defsubr (&Smap_char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
972 } |
89911 | 973 |
974 /* arch-tag: 18b5b560-7ab5-4108-b09e-d5dd65dc6fda | |
975 (do not change this comment) */ |