Mercurial > emacs
annotate src/chartab.c @ 110028:2547676f6961
smiley-regexp-alist: Don't delete the semicolon before the blinking smiley by Miles Bader <miles@gnu.org>; Disallow ;;) from being treated as a blink smiley by Simon Josefsson <simon@josefsson.org>.
2009-03-24 Miles Bader <miles@gnu.org>
* smiley.el (smiley-regexp-alist): Don't delete the semicolon before
the blinking smiley.
2009-03-24 Simon Josefsson <simon@josefsson.org>
* smiley.el (smiley-regexp-alist): Disallow ;;) from being treated as a
blink smiley.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Mon, 30 Aug 2010 06:28:53 +0000 |
parents | 8cfee7d2955f |
children | ac49e05bfcf2 |
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 |
106815 | 2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 |
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 |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94589
diff
changeset
|
8 GNU Emacs is free software: you can redistribute it and/or modify |
88358
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 |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94589
diff
changeset
|
10 the Free Software Foundation, either version 3 of the License, or |
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94589
diff
changeset
|
11 (at your option) any later version. |
88358
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 |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94589
diff
changeset
|
19 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
20 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
21 #include <config.h> |
105669
68dd71358159
* alloc.c: Do not define struct catchtag.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103877
diff
changeset
|
22 #include <setjmp.h> |
88858
889b48cce7a1
Include "...h", not <...h> in some cases.
Dave Love <fx@gnu.org>
parents:
88822
diff
changeset
|
23 #include "lisp.h" |
889b48cce7a1
Include "...h", not <...h> in some cases.
Dave Love <fx@gnu.org>
parents:
88822
diff
changeset
|
24 #include "character.h" |
889b48cce7a1
Include "...h", not <...h> in some cases.
Dave Love <fx@gnu.org>
parents:
88822
diff
changeset
|
25 #include "charset.h" |
889b48cce7a1
Include "...h", not <...h> in some cases.
Dave Love <fx@gnu.org>
parents:
88822
diff
changeset
|
26 #include "ccl.h" |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
27 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
28 /* 64/16/32/128 */ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
29 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
30 /* Number of elements in Nth level char-table. */ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
31 const int chartab_size[4] = |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
32 { (1 << CHARTAB_SIZE_BITS_0), |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
33 (1 << CHARTAB_SIZE_BITS_1), |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
34 (1 << CHARTAB_SIZE_BITS_2), |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
35 (1 << CHARTAB_SIZE_BITS_3) }; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
36 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
37 /* 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
|
38 covers. */ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
39 const int chartab_chars[4] = |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
40 { (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
|
41 (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_3), |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
43 1 }; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
44 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
45 /* 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
|
46 covers. */ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
47 const int chartab_bits[4] = |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
48 { (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
|
49 (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_3, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
51 0 }; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
52 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
53 #define CHARTAB_IDX(c, depth, min_char) \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
54 (((c) - (min_char)) >> chartab_bits[(depth)]) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
55 |
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 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
|
58 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
|
59 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
|
60 |
88900
d6c50ac00394
(Fmake_char_table): Doc fixed. If PURPOSE doesn't
Kenichi Handa <handa@m17n.org>
parents:
88858
diff
changeset
|
61 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
|
62 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
|
63 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
|
64 the char-table has no extra slot. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109139
diff
changeset
|
65 (register Lisp_Object purpose, Lisp_Object init) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
66 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
67 Lisp_Object vector; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
68 Lisp_Object n; |
88900
d6c50ac00394
(Fmake_char_table): Doc fixed. If PURPOSE doesn't
Kenichi Handa <handa@m17n.org>
parents:
88858
diff
changeset
|
69 int n_extras; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
70 int size; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
71 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
72 CHECK_SYMBOL (purpose); |
88900
d6c50ac00394
(Fmake_char_table): Doc fixed. If PURPOSE doesn't
Kenichi Handa <handa@m17n.org>
parents:
88858
diff
changeset
|
73 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
|
74 if (NILP (n)) |
d6c50ac00394
(Fmake_char_table): Doc fixed. If PURPOSE doesn't
Kenichi Handa <handa@m17n.org>
parents:
88858
diff
changeset
|
75 n_extras = 0; |
d6c50ac00394
(Fmake_char_table): Doc fixed. If PURPOSE doesn't
Kenichi Handa <handa@m17n.org>
parents:
88858
diff
changeset
|
76 else |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
77 { |
88900
d6c50ac00394
(Fmake_char_table): Doc fixed. If PURPOSE doesn't
Kenichi Handa <handa@m17n.org>
parents:
88858
diff
changeset
|
78 CHECK_NATNUM (n); |
d6c50ac00394
(Fmake_char_table): Doc fixed. If PURPOSE doesn't
Kenichi Handa <handa@m17n.org>
parents:
88858
diff
changeset
|
79 n_extras = XINT (n); |
d6c50ac00394
(Fmake_char_table): Doc fixed. If PURPOSE doesn't
Kenichi Handa <handa@m17n.org>
parents:
88858
diff
changeset
|
80 if (n_extras > 10) |
d6c50ac00394
(Fmake_char_table): Doc fixed. If PURPOSE doesn't
Kenichi Handa <handa@m17n.org>
parents:
88858
diff
changeset
|
81 args_out_of_range (n, Qnil); |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
82 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
83 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
84 size = VECSIZE (struct Lisp_Char_Table) - 1 + n_extras; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
85 vector = Fmake_vector (make_number (size), init); |
91046 | 86 XSETPVECTYPE (XVECTOR (vector), PVEC_CHAR_TABLE); |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
87 XCHAR_TABLE (vector)->parent = Qnil; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
88 XCHAR_TABLE (vector)->purpose = purpose; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
89 XSETCHAR_TABLE (vector, XCHAR_TABLE (vector)); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
90 return vector; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
91 } |
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 static Lisp_Object |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
94 make_sub_char_table (int depth, int min_char, Lisp_Object defalt) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
95 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
96 Lisp_Object table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
97 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
|
98 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
99 table = Fmake_vector (make_number (size), defalt); |
91046 | 100 XSETPVECTYPE (XVECTOR (table), PVEC_SUB_CHAR_TABLE); |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
101 XSUB_CHAR_TABLE (table)->depth = make_number (depth); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
102 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
|
103 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
104 return table; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
105 } |
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 static Lisp_Object |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
108 char_table_ascii (Lisp_Object table) |
88358
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 Lisp_Object sub; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
111 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
112 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
|
113 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
|
114 return sub; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
115 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
|
116 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
|
117 return sub; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
118 return XSUB_CHAR_TABLE (sub)->contents[0]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
119 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
120 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
121 Lisp_Object |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
122 copy_sub_char_table (Lisp_Object table) |
88358
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 Lisp_Object copy; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
125 int depth = XINT (XSUB_CHAR_TABLE (table)->depth); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
126 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
|
127 Lisp_Object val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
128 int i; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
129 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
130 copy = make_sub_char_table (depth, min_char, Qnil); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
131 /* Recursively copy any sub char-tables. */ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
132 for (i = 0; i < chartab_size[depth]; i++) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
133 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
134 val = XSUB_CHAR_TABLE (table)->contents[i]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
135 if (SUB_CHAR_TABLE_P (val)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
136 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
|
137 else |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
138 XSUB_CHAR_TABLE (copy)->contents[i] = val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
139 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
140 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
141 return copy; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
142 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
143 |
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 Lisp_Object |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
146 copy_char_table (Lisp_Object table) |
88358
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 Lisp_Object copy; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
149 int size = XCHAR_TABLE (table)->size & PSEUDOVECTOR_SIZE_MASK; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
150 int i; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
151 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
152 copy = Fmake_vector (make_number (size), Qnil); |
91046 | 153 XSETPVECTYPE (XVECTOR (copy), PVEC_CHAR_TABLE); |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
154 XCHAR_TABLE (copy)->defalt = XCHAR_TABLE (table)->defalt; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
155 XCHAR_TABLE (copy)->parent = XCHAR_TABLE (table)->parent; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
156 XCHAR_TABLE (copy)->purpose = XCHAR_TABLE (table)->purpose; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
157 for (i = 0; i < chartab_size[0]; i++) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
158 XCHAR_TABLE (copy)->contents[i] |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
159 = (SUB_CHAR_TABLE_P (XCHAR_TABLE (table)->contents[i]) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
160 ? copy_sub_char_table (XCHAR_TABLE (table)->contents[i]) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
161 : XCHAR_TABLE (table)->contents[i]); |
95430
04a952ac356f
* chartab.c (Foptimize_char_table, optimize_sub_char_table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94963
diff
changeset
|
162 XCHAR_TABLE (copy)->ascii = char_table_ascii (copy); |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
163 size -= VECSIZE (struct Lisp_Char_Table) - 1; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
164 for (i = 0; i < size; i++) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
165 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
|
166 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
167 XSETCHAR_TABLE (copy, XCHAR_TABLE (copy)); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
168 return copy; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
169 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
170 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
171 Lisp_Object |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
172 sub_char_table_ref (Lisp_Object table, int c) |
88358
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 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
|
175 int depth = XINT (tbl->depth); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
176 int min_char = XINT (tbl->min_char); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
177 Lisp_Object val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
178 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
179 val = tbl->contents[CHARTAB_IDX (c, depth, min_char)]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
180 if (SUB_CHAR_TABLE_P (val)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
181 val = sub_char_table_ref (val, c); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
182 return val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
183 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
184 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
185 Lisp_Object |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
186 char_table_ref (Lisp_Object table, int c) |
88358
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 struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
189 Lisp_Object val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
190 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
191 if (ASCII_CHAR_P (c)) |
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 val = tbl->ascii; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
194 if (SUB_CHAR_TABLE_P (val)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
195 val = XSUB_CHAR_TABLE (val)->contents[c]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
196 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
197 else |
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 val = tbl->contents[CHARTAB_IDX (c, 0, 0)]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
200 if (SUB_CHAR_TABLE_P (val)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
201 val = sub_char_table_ref (val, c); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
202 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
203 if (NILP (val)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
204 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
205 val = tbl->defalt; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
206 if (NILP (val) && CHAR_TABLE_P (tbl->parent)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
207 val = char_table_ref (tbl->parent, c); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
208 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
209 return val; |
89483 | 210 } |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
211 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
212 static Lisp_Object |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
213 sub_char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to, Lisp_Object defalt) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
214 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
215 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
|
216 int depth = XINT (tbl->depth); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
217 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
|
218 int max_char = min_char + chartab_chars[depth - 1] - 1; |
99979
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
219 int index = CHARTAB_IDX (c, depth, min_char), idx; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
220 Lisp_Object val; |
89483 | 221 |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
222 val = tbl->contents[index]; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
223 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
|
224 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
|
225 else if (NILP (val)) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
226 val = defalt; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
227 |
99979
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
228 idx = index; |
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
229 while (idx > 0 && *from < min_char + idx * chartab_chars[depth]) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
230 { |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
231 Lisp_Object this_val; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
232 |
99979
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
233 c = min_char + idx * chartab_chars[depth] - 1; |
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
234 idx--; |
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
235 this_val = tbl->contents[idx]; |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
236 if (SUB_CHAR_TABLE_P (this_val)) |
99979
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
237 this_val = sub_char_table_ref_and_range (this_val, c, from, to, defalt); |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
238 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
|
239 this_val = defalt; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
240 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
241 if (! EQ (this_val, val)) |
99979
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
242 { |
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
243 *from = c + 1; |
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
244 break; |
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
245 } |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
246 } |
103877
65728b0073ee
(sub_char_table_ref_and_range): Fix the range check against max_char.
Kenichi Handa <handa@m17n.org>
parents:
100951
diff
changeset
|
247 while ((c = min_char + (index + 1) * chartab_chars[depth]) <= max_char |
99979
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
248 && *to >= c) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
249 { |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
250 Lisp_Object this_val; |
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)) |
99979
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
255 this_val = sub_char_table_ref_and_range (this_val, c, from, to, defalt); |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
256 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
|
257 this_val = defalt; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
258 if (! EQ (this_val, val)) |
99979
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
259 { |
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
260 *to = c - 1; |
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
261 break; |
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
262 } |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
263 } |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
264 |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
265 return val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
266 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
267 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
268 |
99979
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
269 /* Return the value for C in char-table TABLE. Shrink the range *FROM |
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
270 and *TO to cover characters (containing C) that have the same value |
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
271 as C. It is not assured that the values of (*FROM - 1) and (*TO + |
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
272 1) are different from that of C. */ |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
273 |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
274 Lisp_Object |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
275 char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
276 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
277 struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); |
99979
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
278 int index = CHARTAB_IDX (c, 0, 0), idx; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
279 Lisp_Object val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
280 |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
281 val = tbl->contents[index]; |
99979
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
282 if (*from < 0) |
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
283 *from = 0; |
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
284 if (*to < 0) |
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
285 *to = MAX_CHAR; |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
286 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
|
287 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
|
288 else if (NILP (val)) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
289 val = tbl->defalt; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
290 |
99979
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
291 idx = index; |
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
292 while (*from < idx * chartab_chars[0]) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
293 { |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
294 Lisp_Object this_val; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
295 |
99979
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
296 c = idx * chartab_chars[0] - 1; |
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
297 idx--; |
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
298 this_val = tbl->contents[idx]; |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
299 if (SUB_CHAR_TABLE_P (this_val)) |
99979
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
300 this_val = sub_char_table_ref_and_range (this_val, c, from, to, |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
301 tbl->defalt); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
302 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
|
303 this_val = tbl->defalt; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
304 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
305 if (! EQ (this_val, val)) |
99979
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
306 { |
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
307 *from = c + 1; |
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
308 break; |
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
309 } |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
310 } |
99979
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
311 while (*to >= (index + 1) * chartab_chars[0]) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
312 { |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
313 Lisp_Object this_val; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
314 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
315 index++; |
99979
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
316 c = index * chartab_chars[0]; |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
317 this_val = tbl->contents[index]; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
318 if (SUB_CHAR_TABLE_P (this_val)) |
99979
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
319 this_val = sub_char_table_ref_and_range (this_val, c, from, to, |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
320 tbl->defalt); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
321 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
|
322 this_val = tbl->defalt; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
323 if (! EQ (this_val, val)) |
99979
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
324 { |
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
325 *to = c - 1; |
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
326 break; |
a33d93f0c185
(sub_char_table_ref_and_range): Adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
99485
diff
changeset
|
327 } |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
328 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
329 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
330 return val; |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
331 } |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
332 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
333 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
334 #define ASET_RANGE(ARRAY, FROM, TO, LIMIT, VAL) \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
335 do { \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
336 int limit = (TO) < (LIMIT) ? (TO) : (LIMIT); \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
337 for (; (FROM) < limit; (FROM)++) (ARRAY)->contents[(FROM)] = (VAL); \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
338 } while (0) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
339 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
340 #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
|
341 do { \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
342 (SUBTABLE) = (TABLE)->contents[(IDX)]; \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
343 if (!SUB_CHAR_TABLE_P (SUBTABLE)) \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
344 (SUBTABLE) = make_sub_char_table ((DEPTH), (MIN_CHAR), (SUBTABLE)); \ |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
345 } while (0) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
346 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
347 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
348 static void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
349 sub_char_table_set (Lisp_Object table, int c, Lisp_Object val) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
350 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
351 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
|
352 int depth = XINT ((tbl)->depth); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
353 int min_char = XINT ((tbl)->min_char); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
354 int i = CHARTAB_IDX (c, depth, min_char); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
355 Lisp_Object sub; |
89483 | 356 |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
357 if (depth == 3) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
358 tbl->contents[i] = val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
359 else |
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 sub = tbl->contents[i]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
362 if (! SUB_CHAR_TABLE_P (sub)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
363 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
364 sub = make_sub_char_table (depth + 1, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
365 min_char + i * chartab_chars[depth], sub); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
366 tbl->contents[i] = sub; |
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 sub_char_table_set (sub, c, val); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
369 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
370 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
371 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
372 Lisp_Object |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
373 char_table_set (Lisp_Object table, int c, Lisp_Object val) |
88358
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_Char_Table *tbl = XCHAR_TABLE (table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
376 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
377 if (ASCII_CHAR_P (c) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
378 && SUB_CHAR_TABLE_P (tbl->ascii)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
379 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
380 XSUB_CHAR_TABLE (tbl->ascii)->contents[c] = val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
381 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
382 else |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
383 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
384 int i = CHARTAB_IDX (c, 0, 0); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
385 Lisp_Object sub; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
386 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
387 sub = tbl->contents[i]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
388 if (! SUB_CHAR_TABLE_P (sub)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
389 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
390 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
|
391 tbl->contents[i] = sub; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
392 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
393 sub_char_table_set (sub, c, val); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
394 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
|
395 tbl->ascii = char_table_ascii (table); |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
396 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
397 return val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
398 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
399 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
400 static void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
401 sub_char_table_set_range (Lisp_Object *table, int depth, int min_char, int from, int to, Lisp_Object val) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
402 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
403 int max_char = min_char + chartab_chars[depth] - 1; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
404 |
88988 | 405 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
|
406 *table = val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
407 else |
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 int i, j; |
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 depth++; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
412 if (! SUB_CHAR_TABLE_P (*table)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
413 *table = make_sub_char_table (depth, min_char, *table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
414 if (from < min_char) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
415 from = min_char; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
416 if (to > max_char) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
417 to = max_char; |
88429
89eaf88b37b4
(sub_char_table_set_range): Optimized for the case
Kenichi Handa <handa@m17n.org>
parents:
88358
diff
changeset
|
418 i = CHARTAB_IDX (from, depth, min_char); |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
419 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
|
420 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
|
421 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
|
422 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
|
423 depth, min_char, from, to, val); |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
424 } |
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 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
428 Lisp_Object |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
429 char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
430 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
431 struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
432 Lisp_Object *contents = tbl->contents; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
433 int i, min_char; |
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 if (from == to) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
436 char_table_set (table, from, val); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
437 else |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
438 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
439 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
|
440 min_char <= to; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
441 i++, min_char += chartab_chars[0]) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
442 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
|
443 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
|
444 tbl->ascii = char_table_ascii (table); |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
445 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
446 return val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
447 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
448 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
449 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
450 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
|
451 1, 1, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
452 doc: /* |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
453 Return the subtype of char-table CHAR-TABLE. The value is a symbol. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109139
diff
changeset
|
454 (Lisp_Object char_table) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
455 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
456 CHECK_CHAR_TABLE (char_table); |
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 return XCHAR_TABLE (char_table)->purpose; |
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 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
461 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
|
462 1, 1, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
463 doc: /* Return the parent char-table of CHAR-TABLE. |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
464 The value is either nil or another char-table. |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
465 If CHAR-TABLE holds nil for a given character, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
466 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
|
467 \(or from its parents, if necessary). */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109139
diff
changeset
|
468 (Lisp_Object char_table) |
88358
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 CHECK_CHAR_TABLE (char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
471 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
472 return XCHAR_TABLE (char_table)->parent; |
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 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
475 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
|
476 2, 2, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
477 doc: /* Set the parent char-table of CHAR-TABLE to PARENT. |
89909 | 478 Return PARENT. PARENT must be either nil or another char-table. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109139
diff
changeset
|
479 (Lisp_Object char_table, Lisp_Object parent) |
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 Lisp_Object temp; |
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 CHECK_CHAR_TABLE (char_table); |
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 if (!NILP (parent)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
486 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
487 CHECK_CHAR_TABLE (parent); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
488 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
489 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
|
490 if (EQ (temp, char_table)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
491 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
|
492 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
493 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
494 XCHAR_TABLE (char_table)->parent = parent; |
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 return parent; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
497 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
498 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
499 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
|
500 2, 2, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
501 doc: /* Return the value of CHAR-TABLE's extra-slot number N. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109139
diff
changeset
|
502 (Lisp_Object char_table, Lisp_Object n) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
503 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
504 CHECK_CHAR_TABLE (char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
505 CHECK_NUMBER (n); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
506 if (XINT (n) < 0 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
507 || 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
|
508 args_out_of_range (char_table, n); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
509 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
510 return XCHAR_TABLE (char_table)->extras[XINT (n)]; |
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 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
513 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
|
514 Sset_char_table_extra_slot, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
515 3, 3, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
516 doc: /* Set CHAR-TABLE's extra-slot number N to VALUE. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109139
diff
changeset
|
517 (Lisp_Object char_table, Lisp_Object n, Lisp_Object value) |
88358
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 CHECK_CHAR_TABLE (char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
520 CHECK_NUMBER (n); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
521 if (XINT (n) < 0 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
522 || 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
|
523 args_out_of_range (char_table, n); |
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 return XCHAR_TABLE (char_table)->extras[XINT (n)] = value; |
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 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
528 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
|
529 2, 2, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
530 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
|
531 RANGE should be nil (for the default value), |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
532 a cons of character codes (for characters in the range), or a character code. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109139
diff
changeset
|
533 (Lisp_Object char_table, Lisp_Object range) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
534 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
535 Lisp_Object val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
536 CHECK_CHAR_TABLE (char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
537 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
538 if (EQ (range, Qnil)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
539 val = XCHAR_TABLE (char_table)->defalt; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
540 else if (INTEGERP (range)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
541 val = CHAR_TABLE_REF (char_table, XINT (range)); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
542 else if (CONSP (range)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
543 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
544 int from, to; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
545 |
89483 | 546 CHECK_CHARACTER_CAR (range); |
547 CHECK_CHARACTER_CDR (range); | |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
548 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
|
549 &from, &to); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
550 /* Not yet implemented. */ |
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 else |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
553 error ("Invalid RANGE argument to `char-table-range'"); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
554 return val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
555 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
556 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
557 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
|
558 3, 3, 0, |
89909 | 559 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
|
560 RANGE should be t (for all characters), nil (for the default value), |
89909 | 561 a cons of character codes (for characters in the range), |
562 or a character code. Return VALUE. */) | |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109139
diff
changeset
|
563 (Lisp_Object char_table, Lisp_Object range, Lisp_Object value) |
88358
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 CHECK_CHAR_TABLE (char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
566 if (EQ (range, Qt)) |
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 int i; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
569 |
94589
d97320b13374
(Fset_char_table_range): If range is t, really set all chars to that value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91547
diff
changeset
|
570 XCHAR_TABLE (char_table)->ascii = value; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
571 for (i = 0; i < chartab_size[0]; i++) |
94589
d97320b13374
(Fset_char_table_range): If range is t, really set all chars to that value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91547
diff
changeset
|
572 XCHAR_TABLE (char_table)->contents[i] = value; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
573 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
574 else if (EQ (range, Qnil)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
575 XCHAR_TABLE (char_table)->defalt = value; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
576 else if (INTEGERP (range)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
577 char_table_set (char_table, XINT (range), value); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
578 else if (CONSP (range)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
579 { |
89483 | 580 CHECK_CHARACTER_CAR (range); |
581 CHECK_CHARACTER_CDR (range); | |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
582 char_table_set_range (char_table, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
583 XINT (XCAR (range)), XINT (XCDR (range)), value); |
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 else |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
586 error ("Invalid RANGE argument to `set-char-table-range'"); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
587 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
588 return value; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
589 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
590 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
591 DEFUN ("set-char-table-default", Fset_char_table_default, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
592 Sset_char_table_default, 3, 3, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
593 doc: /* |
88822
9c92853c0d10
(make_sub_char_table): Remove unused var.
Dave Love <fx@gnu.org>
parents:
88746
diff
changeset
|
594 This function is obsolete and has no effect. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109139
diff
changeset
|
595 (Lisp_Object char_table, Lisp_Object ch, Lisp_Object value) |
88358
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 return Qnil; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
598 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
599 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
600 /* 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
|
601 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
|
602 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
603 int |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
604 char_table_translate (Lisp_Object table, int ch) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
605 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
606 Lisp_Object value; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
607 value = Faref (table, make_number (ch)); |
89570
c92884b9ca4a
(char_table_translate): Use CHARACTERP, not INETEGERP.
Kenichi Handa <handa@m17n.org>
parents:
89484
diff
changeset
|
608 if (! CHARACTERP (value)) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
609 return ch; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
610 return XINT (value); |
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 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
613 static Lisp_Object |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
614 optimize_sub_char_table (Lisp_Object table, Lisp_Object test) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
615 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
616 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
|
617 int depth = XINT (tbl->depth); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
618 Lisp_Object elt, this; |
97818
a4677d55715f
(optimize_sub_char_table): Perform more greedy optimization.
Kenichi Handa <handa@m17n.org>
parents:
95430
diff
changeset
|
619 int i, optimizable; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
620 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
621 elt = XSUB_CHAR_TABLE (table)->contents[0]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
622 if (SUB_CHAR_TABLE_P (elt)) |
95430
04a952ac356f
* chartab.c (Foptimize_char_table, optimize_sub_char_table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94963
diff
changeset
|
623 elt = XSUB_CHAR_TABLE (table)->contents[0] |
04a952ac356f
* chartab.c (Foptimize_char_table, optimize_sub_char_table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94963
diff
changeset
|
624 = optimize_sub_char_table (elt, test); |
97818
a4677d55715f
(optimize_sub_char_table): Perform more greedy optimization.
Kenichi Handa <handa@m17n.org>
parents:
95430
diff
changeset
|
625 optimizable = SUB_CHAR_TABLE_P (elt) ? 0 : 1; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
626 for (i = 1; i < chartab_size[depth]; i++) |
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 this = XSUB_CHAR_TABLE (table)->contents[i]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
629 if (SUB_CHAR_TABLE_P (this)) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
630 this = XSUB_CHAR_TABLE (table)->contents[i] |
95430
04a952ac356f
* chartab.c (Foptimize_char_table, optimize_sub_char_table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94963
diff
changeset
|
631 = optimize_sub_char_table (this, test); |
97818
a4677d55715f
(optimize_sub_char_table): Perform more greedy optimization.
Kenichi Handa <handa@m17n.org>
parents:
95430
diff
changeset
|
632 if (optimizable |
a4677d55715f
(optimize_sub_char_table): Perform more greedy optimization.
Kenichi Handa <handa@m17n.org>
parents:
95430
diff
changeset
|
633 && (NILP (test) ? NILP (Fequal (this, elt)) /* defaults to `equal'. */ |
95430
04a952ac356f
* chartab.c (Foptimize_char_table, optimize_sub_char_table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94963
diff
changeset
|
634 : EQ (test, Qeq) ? !EQ (this, elt) /* Optimize `eq' case. */ |
04a952ac356f
* chartab.c (Foptimize_char_table, optimize_sub_char_table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94963
diff
changeset
|
635 : NILP (call2 (test, this, elt)))) |
97818
a4677d55715f
(optimize_sub_char_table): Perform more greedy optimization.
Kenichi Handa <handa@m17n.org>
parents:
95430
diff
changeset
|
636 optimizable = 0; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
637 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
638 |
97818
a4677d55715f
(optimize_sub_char_table): Perform more greedy optimization.
Kenichi Handa <handa@m17n.org>
parents:
95430
diff
changeset
|
639 return (optimizable ? elt : table); |
88358
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 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
642 DEFUN ("optimize-char-table", Foptimize_char_table, Soptimize_char_table, |
95430
04a952ac356f
* chartab.c (Foptimize_char_table, optimize_sub_char_table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94963
diff
changeset
|
643 1, 2, 0, |
04a952ac356f
* chartab.c (Foptimize_char_table, optimize_sub_char_table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94963
diff
changeset
|
644 doc: /* Optimize CHAR-TABLE. |
04a952ac356f
* chartab.c (Foptimize_char_table, optimize_sub_char_table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94963
diff
changeset
|
645 TEST is the comparison function used to decide whether two entries are |
04a952ac356f
* chartab.c (Foptimize_char_table, optimize_sub_char_table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94963
diff
changeset
|
646 equivalent and can be merged. It defaults to `equal'. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109139
diff
changeset
|
647 (Lisp_Object char_table, Lisp_Object test) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
648 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
649 Lisp_Object elt; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
650 int i; |
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 CHECK_CHAR_TABLE (char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
653 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
654 for (i = 0; i < chartab_size[0]; i++) |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
655 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
656 elt = XCHAR_TABLE (char_table)->contents[i]; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
657 if (SUB_CHAR_TABLE_P (elt)) |
95430
04a952ac356f
* chartab.c (Foptimize_char_table, optimize_sub_char_table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94963
diff
changeset
|
658 XCHAR_TABLE (char_table)->contents[i] |
04a952ac356f
* chartab.c (Foptimize_char_table, optimize_sub_char_table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94963
diff
changeset
|
659 = optimize_sub_char_table (elt, test); |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
660 } |
99143
f0ad9e3cb1a4
(Foptimize_char_table): Make sure `ascii' doesn't point to
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97818
diff
changeset
|
661 /* Reset the `ascii' cache, in case it got optimized away. */ |
f0ad9e3cb1a4
(Foptimize_char_table): Make sure `ascii' doesn't point to
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97818
diff
changeset
|
662 XCHAR_TABLE (char_table)->ascii = char_table_ascii (char_table); |
f0ad9e3cb1a4
(Foptimize_char_table): Make sure `ascii' doesn't point to
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97818
diff
changeset
|
663 |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
664 return Qnil; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
665 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
666 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
667 |
90966
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
668 /* Map C_FUNCTION or FUNCTION over TABLE (top or sub char-table), |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
669 calling it for each character or group of characters that share a |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
670 value. RANGE is a cons (FROM . TO) specifying the range of target |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
671 characters, VAL is a value of FROM in TABLE, DEFAULT_VAL is the |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
672 default value of the char-table, PARENT is the parent of the |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
673 char-table. |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
674 |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
675 ARG is passed to C_FUNCTION when that is called. |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
676 |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
677 It returns the value of last character covered by TABLE (not the |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
678 value inheritted from the parent), and by side-effect, the car part |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
679 of RANGE is updated to the minimum character C where C and all the |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
680 following characters in TABLE have the same value. */ |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
681 |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
682 static Lisp_Object |
109139
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
683 map_sub_char_table (void (*c_function) (Lisp_Object, Lisp_Object, Lisp_Object), |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
684 Lisp_Object function, Lisp_Object table, Lisp_Object arg, Lisp_Object val, |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
685 Lisp_Object range, Lisp_Object default_val, Lisp_Object parent) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
686 { |
90966
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
687 /* Pointer to the elements of TABLE. */ |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
688 Lisp_Object *contents; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
689 /* Depth of TABLE. */ |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
690 int depth; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
691 /* Minimum and maxinum characters covered by TABLE. */ |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
692 int min_char, max_char; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
693 /* Number of characters covered by one element of TABLE. */ |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
694 int chars_in_block; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
695 int from = XINT (XCAR (range)), to = XINT (XCDR (range)); |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
696 int i, c; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
697 |
90966
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
698 if (SUB_CHAR_TABLE_P (table)) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
699 { |
90966
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
700 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
701 |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
702 depth = XINT (tbl->depth); |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
703 contents = tbl->contents; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
704 min_char = XINT (tbl->min_char); |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
705 max_char = min_char + chartab_chars[depth - 1] - 1; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
706 } |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
707 else |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
708 { |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
709 depth = 0; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
710 contents = XCHAR_TABLE (table)->contents; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
711 min_char = 0; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
712 max_char = MAX_CHAR; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
713 } |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
714 chars_in_block = chartab_chars[depth]; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
715 |
90966
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
716 if (to < max_char) |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
717 max_char = to; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
718 /* Set I to the index of the first element to check. */ |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
719 if (from <= min_char) |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
720 i = 0; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
721 else |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
722 i = (from - min_char) / chars_in_block; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
723 for (c = min_char + chars_in_block * i; c <= max_char; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
724 i++, c += chars_in_block) |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
725 { |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
726 Lisp_Object this = contents[i]; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
727 int nextc = c + chars_in_block; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
728 |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
729 if (SUB_CHAR_TABLE_P (this)) |
90966
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
730 { |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
731 if (to >= nextc) |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
732 XSETCDR (range, make_number (nextc - 1)); |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
733 val = map_sub_char_table (c_function, function, this, arg, |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
734 val, range, default_val, parent); |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
735 } |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
736 else |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
737 { |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
738 if (NILP (this)) |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
739 this = default_val; |
95430
04a952ac356f
* chartab.c (Foptimize_char_table, optimize_sub_char_table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94963
diff
changeset
|
740 if (!EQ (val, this)) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
741 { |
90966
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
742 int different_value = 1; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
743 |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
744 if (NILP (val)) |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
745 { |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
746 if (! NILP (parent)) |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
747 { |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
748 Lisp_Object temp = XCHAR_TABLE (parent)->parent; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
749 |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
750 /* This is to get a value of FROM in PARENT |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
751 without checking the parent of PARENT. */ |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
752 XCHAR_TABLE (parent)->parent = Qnil; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
753 val = CHAR_TABLE_REF (parent, from); |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
754 XCHAR_TABLE (parent)->parent = temp; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
755 XSETCDR (range, make_number (c - 1)); |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
756 val = map_sub_char_table (c_function, function, |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
757 parent, arg, val, range, |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
758 XCHAR_TABLE (parent)->defalt, |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
759 XCHAR_TABLE (parent)->parent); |
95430
04a952ac356f
* chartab.c (Foptimize_char_table, optimize_sub_char_table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94963
diff
changeset
|
760 if (EQ (val, this)) |
90966
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
761 different_value = 0; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
762 } |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
763 } |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
764 if (! NILP (val) && different_value) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
765 { |
89483 | 766 XSETCDR (range, make_number (c - 1)); |
91036
f5e7e4e0fa66
(map_sub_char_table): If the range contains just one
Kenichi Handa <handa@m17n.org>
parents:
90966
diff
changeset
|
767 if (EQ (XCAR (range), XCDR (range))) |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
768 { |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
769 if (c_function) |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
770 (*c_function) (arg, XCAR (range), val); |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
771 else |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
772 call2 (function, XCAR (range), val); |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
773 } |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
774 else |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
775 { |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
776 if (c_function) |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
777 (*c_function) (arg, range, val); |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
778 else |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
779 call2 (function, range, val); |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
780 } |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
781 } |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
782 val = this; |
90966
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
783 from = c; |
89483 | 784 XSETCAR (range, make_number (c)); |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
785 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
786 } |
90966
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
787 XSETCDR (range, make_number (to)); |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
788 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
789 return val; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
790 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
791 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
792 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
793 /* 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
|
794 character or group of characters that share a value. |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
795 |
89483 | 796 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
|
797 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
798 void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
799 map_char_table (void (*c_function) (Lisp_Object, Lisp_Object, Lisp_Object), Lisp_Object function, Lisp_Object table, Lisp_Object arg) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
800 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
801 Lisp_Object range, val; |
90047
20480108ff4e
(map_char_table): GCPRO table and arg.
Andreas Schwab <schwab@suse.de>
parents:
89911
diff
changeset
|
802 struct gcpro gcpro1, gcpro2, gcpro3; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
803 |
90966
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
804 range = Fcons (make_number (0), make_number (MAX_CHAR)); |
90047
20480108ff4e
(map_char_table): GCPRO table and arg.
Andreas Schwab <schwab@suse.de>
parents:
89911
diff
changeset
|
805 GCPRO3 (table, arg, range); |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
806 val = XCHAR_TABLE (table)->ascii; |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
807 if (SUB_CHAR_TABLE_P (val)) |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
808 val = XSUB_CHAR_TABLE (val)->contents[0]; |
90966
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
809 val = map_sub_char_table (c_function, function, table, arg, val, range, |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
810 XCHAR_TABLE (table)->defalt, |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
811 XCHAR_TABLE (table)->parent); |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
812 /* If VAL is nil and TABLE has a parent, we must consult the parent |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
813 recursively. */ |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
814 while (NILP (val) && ! NILP (XCHAR_TABLE (table)->parent)) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
815 { |
90966
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
816 Lisp_Object parent = XCHAR_TABLE (table)->parent; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
817 Lisp_Object temp = XCHAR_TABLE (parent)->parent; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
818 int from = XINT (XCAR (range)); |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
819 |
90966
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
820 /* This is to get a value of FROM in PARENT without checking the |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
821 parent of PARENT. */ |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
822 XCHAR_TABLE (parent)->parent = Qnil; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
823 val = CHAR_TABLE_REF (parent, from); |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
824 XCHAR_TABLE (parent)->parent = temp; |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
825 val = map_sub_char_table (c_function, function, parent, arg, val, range, |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
826 XCHAR_TABLE (parent)->defalt, |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
827 XCHAR_TABLE (parent)->parent); |
d563fa5ce200
(map_sub_char_table): Make it work for the top-level
Kenichi Handa <handa@m17n.org>
parents:
90047
diff
changeset
|
828 table = parent; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
829 } |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
830 |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
831 if (! NILP (val)) |
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
832 { |
91036
f5e7e4e0fa66
(map_sub_char_table): If the range contains just one
Kenichi Handa <handa@m17n.org>
parents:
90966
diff
changeset
|
833 if (EQ (XCAR (range), XCDR (range))) |
f5e7e4e0fa66
(map_sub_char_table): If the range contains just one
Kenichi Handa <handa@m17n.org>
parents:
90966
diff
changeset
|
834 { |
f5e7e4e0fa66
(map_sub_char_table): If the range contains just one
Kenichi Handa <handa@m17n.org>
parents:
90966
diff
changeset
|
835 if (c_function) |
f5e7e4e0fa66
(map_sub_char_table): If the range contains just one
Kenichi Handa <handa@m17n.org>
parents:
90966
diff
changeset
|
836 (*c_function) (arg, XCAR (range), val); |
f5e7e4e0fa66
(map_sub_char_table): If the range contains just one
Kenichi Handa <handa@m17n.org>
parents:
90966
diff
changeset
|
837 else |
f5e7e4e0fa66
(map_sub_char_table): If the range contains just one
Kenichi Handa <handa@m17n.org>
parents:
90966
diff
changeset
|
838 call2 (function, XCAR (range), val); |
f5e7e4e0fa66
(map_sub_char_table): If the range contains just one
Kenichi Handa <handa@m17n.org>
parents:
90966
diff
changeset
|
839 } |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
840 else |
91036
f5e7e4e0fa66
(map_sub_char_table): If the range contains just one
Kenichi Handa <handa@m17n.org>
parents:
90966
diff
changeset
|
841 { |
f5e7e4e0fa66
(map_sub_char_table): If the range contains just one
Kenichi Handa <handa@m17n.org>
parents:
90966
diff
changeset
|
842 if (c_function) |
f5e7e4e0fa66
(map_sub_char_table): If the range contains just one
Kenichi Handa <handa@m17n.org>
parents:
90966
diff
changeset
|
843 (*c_function) (arg, range, val); |
f5e7e4e0fa66
(map_sub_char_table): If the range contains just one
Kenichi Handa <handa@m17n.org>
parents:
90966
diff
changeset
|
844 else |
f5e7e4e0fa66
(map_sub_char_table): If the range contains just one
Kenichi Handa <handa@m17n.org>
parents:
90966
diff
changeset
|
845 call2 (function, range, val); |
f5e7e4e0fa66
(map_sub_char_table): If the range contains just one
Kenichi Handa <handa@m17n.org>
parents:
90966
diff
changeset
|
846 } |
89424
7020f4f73751
(map_sub_char_table): New argument DEFAULT_VAL.
Kenichi Handa <handa@m17n.org>
parents:
89334
diff
changeset
|
847 } |
89484
5c41371d228b
(map_char_table): Protect `range' from GC.
Andreas Schwab <schwab@suse.de>
parents:
89483
diff
changeset
|
848 |
5c41371d228b
(map_char_table): Protect `range' from GC.
Andreas Schwab <schwab@suse.de>
parents:
89483
diff
changeset
|
849 UNGCPRO; |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
850 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
851 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
852 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
|
853 2, 2, 0, |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
854 doc: /* |
89425 | 855 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
|
856 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
|
857 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
|
858 range of characters that have the same value. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109139
diff
changeset
|
859 (Lisp_Object function, Lisp_Object char_table) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
860 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
861 CHECK_CHAR_TABLE (char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
862 |
89483 | 863 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
|
864 return Qnil; |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
865 } |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
866 |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
867 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
868 static void |
109139
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
869 map_sub_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Object), |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
870 Lisp_Object function, Lisp_Object table, Lisp_Object arg, |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
871 Lisp_Object range, struct charset *charset, |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
872 unsigned from, unsigned to) |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
873 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
874 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
|
875 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
|
876 int c, i; |
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 if (depth < 3) |
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]; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
880 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
|
881 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
882 Lisp_Object this; |
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 (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
|
886 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
|
887 range, charset, from, to); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
888 else |
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) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
894 (*c_function) (arg, range); |
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 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
898 XSETCAR (range, Qnil); |
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 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
901 else |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
902 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
|
903 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
904 Lisp_Object this; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
905 unsigned code; |
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 this = tbl->contents[i]; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
908 if (NILP (this) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
909 || (charset |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
910 && (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
|
911 (code < from || code > to)))) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
912 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
913 if (! NILP (XCAR (range))) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
914 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
915 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
|
916 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
|
917 (*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
|
918 else |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
919 call2 (function, range, arg); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
920 XSETCAR (range, Qnil); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
921 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
922 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
923 else |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
924 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
925 if (NILP (XCAR (range))) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
926 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
|
927 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
928 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
929 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
930 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
931 |
99483
203b7f0b2698
(map_char_table_for_charset): Add comment.
Kenichi Handa <handa@m17n.org>
parents:
99143
diff
changeset
|
932 /* Support function for `map-charset-chars'. Map C_FUNCTION or |
99485 | 933 FUNCTION over TABLE, calling it for each character or a group of |
99483
203b7f0b2698
(map_char_table_for_charset): Add comment.
Kenichi Handa <handa@m17n.org>
parents:
99143
diff
changeset
|
934 succeeding characters that have non-nil value in TABLE. TABLE is a |
203b7f0b2698
(map_char_table_for_charset): Add comment.
Kenichi Handa <handa@m17n.org>
parents:
99143
diff
changeset
|
935 "mapping table" or a "deunifier table" of a certain charset. |
203b7f0b2698
(map_char_table_for_charset): Add comment.
Kenichi Handa <handa@m17n.org>
parents:
99143
diff
changeset
|
936 |
203b7f0b2698
(map_char_table_for_charset): Add comment.
Kenichi Handa <handa@m17n.org>
parents:
99143
diff
changeset
|
937 If CHARSET is not NULL (this is the case that `map-charset-chars' |
203b7f0b2698
(map_char_table_for_charset): Add comment.
Kenichi Handa <handa@m17n.org>
parents:
99143
diff
changeset
|
938 is called with non-nil FROM-CODE and TO-CODE), it is a charset who |
203b7f0b2698
(map_char_table_for_charset): Add comment.
Kenichi Handa <handa@m17n.org>
parents:
99143
diff
changeset
|
939 owns TABLE, and the function is called only on a character in the |
203b7f0b2698
(map_char_table_for_charset): Add comment.
Kenichi Handa <handa@m17n.org>
parents:
99143
diff
changeset
|
940 range FROM and TO. FROM and TO are not character codes, but code |
203b7f0b2698
(map_char_table_for_charset): Add comment.
Kenichi Handa <handa@m17n.org>
parents:
99143
diff
changeset
|
941 points of a character in CHARSET. |
203b7f0b2698
(map_char_table_for_charset): Add comment.
Kenichi Handa <handa@m17n.org>
parents:
99143
diff
changeset
|
942 |
203b7f0b2698
(map_char_table_for_charset): Add comment.
Kenichi Handa <handa@m17n.org>
parents:
99143
diff
changeset
|
943 This function is called in these two cases: |
203b7f0b2698
(map_char_table_for_charset): Add comment.
Kenichi Handa <handa@m17n.org>
parents:
99143
diff
changeset
|
944 |
203b7f0b2698
(map_char_table_for_charset): Add comment.
Kenichi Handa <handa@m17n.org>
parents:
99143
diff
changeset
|
945 (1) A charset has a mapping file name in :map property. |
203b7f0b2698
(map_char_table_for_charset): Add comment.
Kenichi Handa <handa@m17n.org>
parents:
99143
diff
changeset
|
946 |
203b7f0b2698
(map_char_table_for_charset): Add comment.
Kenichi Handa <handa@m17n.org>
parents:
99143
diff
changeset
|
947 (2) A charset has an upper code space in :offset property and a |
203b7f0b2698
(map_char_table_for_charset): Add comment.
Kenichi Handa <handa@m17n.org>
parents:
99143
diff
changeset
|
948 mapping file name in :unify-map property. In this case, this |
203b7f0b2698
(map_char_table_for_charset): Add comment.
Kenichi Handa <handa@m17n.org>
parents:
99143
diff
changeset
|
949 function is called only for characters in the Unicode code space. |
203b7f0b2698
(map_char_table_for_charset): Add comment.
Kenichi Handa <handa@m17n.org>
parents:
99143
diff
changeset
|
950 Characters in upper code space are handled directly in |
203b7f0b2698
(map_char_table_for_charset): Add comment.
Kenichi Handa <handa@m17n.org>
parents:
99143
diff
changeset
|
951 map_charset_chars. */ |
203b7f0b2698
(map_char_table_for_charset): Add comment.
Kenichi Handa <handa@m17n.org>
parents:
99143
diff
changeset
|
952 |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
953 void |
109139
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
954 map_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Object), |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
955 Lisp_Object function, Lisp_Object table, Lisp_Object arg, |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
956 struct charset *charset, |
c25c24812fb1
Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109126
diff
changeset
|
957 unsigned from, unsigned to) |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
958 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
959 Lisp_Object range; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
960 int c, i; |
89484
5c41371d228b
(map_char_table): Protect `range' from GC.
Andreas Schwab <schwab@suse.de>
parents:
89483
diff
changeset
|
961 struct gcpro gcpro1; |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
962 |
89483 | 963 range = Fcons (Qnil, Qnil); |
89484
5c41371d228b
(map_char_table): Protect `range' from GC.
Andreas Schwab <schwab@suse.de>
parents:
89483
diff
changeset
|
964 GCPRO1 (range); |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
965 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
966 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
|
967 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
968 Lisp_Object this; |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
969 |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
970 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
|
971 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
|
972 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
|
973 range, charset, from, to); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
974 else |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
975 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
976 if (! NILP (XCAR (range))) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
977 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
978 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
|
979 if (c_function) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
980 (*c_function) (arg, range); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
981 else |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
982 call2 (function, range, arg); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
983 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
984 XSETCAR (range, Qnil); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
985 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
986 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
987 if (! NILP (XCAR (range))) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
988 { |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
989 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
|
990 if (c_function) |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
991 (*c_function) (arg, range); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
992 else |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
993 call2 (function, range, arg); |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
994 } |
89484
5c41371d228b
(map_char_table): Protect `range' from GC.
Andreas Schwab <schwab@suse.de>
parents:
89483
diff
changeset
|
995 |
5c41371d228b
(map_char_table): Protect `range' from GC.
Andreas Schwab <schwab@suse.de>
parents:
89483
diff
changeset
|
996 UNGCPRO; |
88746
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
997 } |
388c82972bb9
(sub_char_table_ref_and_range): New arg defalt. Fix
Kenichi Handa <handa@m17n.org>
parents:
88429
diff
changeset
|
998 |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
999 |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
1000 void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
1001 syms_of_chartab (void) |
88358
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
1002 { |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
1003 defsubr (&Smake_char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
1004 defsubr (&Schar_table_parent); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
1005 defsubr (&Schar_table_subtype); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
1006 defsubr (&Sset_char_table_parent); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
1007 defsubr (&Schar_table_extra_slot); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
1008 defsubr (&Sset_char_table_extra_slot); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
1009 defsubr (&Schar_table_range); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
1010 defsubr (&Sset_char_table_range); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
1011 defsubr (&Sset_char_table_default); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
1012 defsubr (&Soptimize_char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
1013 defsubr (&Smap_char_table); |
5f98d0806407
New file that implements char table.
Kenichi Handa <handa@m17n.org>
parents:
diff
changeset
|
1014 } |
89911 | 1015 |
1016 /* arch-tag: 18b5b560-7ab5-4108-b09e-d5dd65dc6fda | |
1017 (do not change this comment) */ |