annotate src/chartab.c @ 131:869e1851236b xemacs-20-1p4

Import from CVS: tag xemacs-20-1p4
author cvs
date Mon, 13 Aug 2007 09:29:07 +0200
parents fe104dbd9147
children bfd6434d15b3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1 /* XEmacs routines to deal with char tables.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
2 Copyright (C) 1992, 1995 Free Software Foundation, Inc.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
3 Copyright (C) 1995 Sun Microsystems, Inc.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
4 Copyright (C) 1995, 1996 Ben Wing.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
5
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
6 This file is part of XEmacs.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
7
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
8 XEmacs is free software; you can redistribute it and/or modify it
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
10 Free Software Foundation; either version 2, or (at your option) any
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
11 later version.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
12
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
16 for more details.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
17
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
19 along with XEmacs; see the file COPYING. If not, write to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
21 Boston, MA 02111-1307, USA. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
22
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
23 /* Synched up with: Mule 2.3. Not synched with FSF.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
24
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
25 This file was written independently of the FSF implementation,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
26 and is not compatible. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
27
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
28 /* Authorship:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
29
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
30 Ben Wing: wrote, for 19.13 (Mule). Some category table stuff
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
31 loosely based on the original Mule.
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
32 Jareth Hein: fixed a couple of bugs in the implementation, and
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
33 added regex support for categories with check_category_at
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
34 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
35
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
36 #include <config.h>
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
37 #include "lisp.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
38
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
39 #include "buffer.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
40 #include "chartab.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
41 #include "commands.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
42 #include "syntax.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
43
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
44 Lisp_Object Qchar_tablep, Qchar_table;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
45
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
46 Lisp_Object Vall_syntax_tables;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
47
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
48 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
49 Lisp_Object Qcategory_table_p;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
50 Lisp_Object Qcategory_designator_p;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
51 Lisp_Object Qcategory_table_value_p;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
52
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
53 Lisp_Object Vstandard_category_table;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
54 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
55
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
56
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
57 /* A char table maps from ranges of characters to values.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
58
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
59 Implementing a general data structure that maps from arbitrary
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
60 ranges of numbers to values is tricky to do efficiently. As it
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
61 happens, it should suffice fine (and is usually more convenient,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
62 anyway) when dealing with characters to restrict the sorts of
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
63 ranges that can be assigned values, as follows:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
64
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
65 1) All characters.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
66 2) All characters in a charset.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
67 3) All characters in a particular row of a charset, where a "row"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
68 means all characters with the same first byte.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
69 4) A particular character in a charset.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
71
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
72 We use char tables to generalize the 256-element vectors now
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
73 littering the Emacs code.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
74
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
75 Possible uses (all should be converted at some point):
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
76
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
77 1) category tables
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
78 2) syntax tables
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
79 3) display tables
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
80 4) case tables
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
81 5) keyboard-translate-table?
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
82
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
83 We do the very non-Stallman-esque thing of actually providing an
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
84 abstract type to generalize the Emacs vectors and Mule
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
85 vectors-of-vectors goo.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
86 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
87
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
88 /************************************************************************/
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
89 /* Char Table object */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
90 /************************************************************************/
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
91
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
92 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
93
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
94 static Lisp_Object mark_char_table_entry (Lisp_Object, void (*) (Lisp_Object));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
95 static int char_table_entry_equal (Lisp_Object, Lisp_Object, int depth);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
96 static unsigned long char_table_entry_hash (Lisp_Object obj, int depth);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
97 DEFINE_LRECORD_IMPLEMENTATION ("char-table-entry", char_table_entry,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
98 mark_char_table_entry, internal_object_printer,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
99 0, char_table_entry_equal,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
100 char_table_entry_hash,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
101 struct Lisp_Char_Table_Entry);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
102
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
103 static Lisp_Object
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
104 mark_char_table_entry (Lisp_Object obj, void (*markobj) (Lisp_Object))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
105 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
106 struct Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (obj);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
107 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
108
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
109 for (i = 0; i < 96; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
110 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
111 (markobj) (cte->level2[i]);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
112 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
113 return Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
114 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
115
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
116 static int
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
117 char_table_entry_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
118 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
119 struct Lisp_Char_Table_Entry *cte1 = XCHAR_TABLE_ENTRY (obj1);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
120 struct Lisp_Char_Table_Entry *cte2 = XCHAR_TABLE_ENTRY (obj2);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
121 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
122
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
123 for (i = 0; i < 96; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
124 if (!internal_equal (cte1->level2[i], cte2->level2[i], depth + 1))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
125 return 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
126
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
127 return 1;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
128 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
129
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
130 static unsigned long
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
131 char_table_entry_hash (Lisp_Object obj, int depth)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
132 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
133 struct Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (obj);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
134
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
135 return internal_array_hash (cte->level2, 96, depth);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
136 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
137
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
138 #endif /* MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
139
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
140 static Lisp_Object mark_char_table (Lisp_Object, void (*) (Lisp_Object));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
141 static void print_char_table (Lisp_Object, Lisp_Object, int);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
142 static int char_table_equal (Lisp_Object, Lisp_Object, int depth);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
143 static unsigned long char_table_hash (Lisp_Object obj, int depth);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
144 DEFINE_LRECORD_IMPLEMENTATION ("char-table", char_table,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
145 mark_char_table, print_char_table, 0,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
146 char_table_equal, char_table_hash,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
147 struct Lisp_Char_Table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
148
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
149 static Lisp_Object
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
150 mark_char_table (Lisp_Object obj, void (*markobj) (Lisp_Object))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
151 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
152 struct Lisp_Char_Table *ct = XCHAR_TABLE (obj);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
153 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
154
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
155 for (i = 0; i < NUM_ASCII_CHARS; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
156 (markobj) (ct->ascii[i]);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
157 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
158 for (i = 0; i < NUM_LEADING_BYTES; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
159 (markobj) (ct->level1[i]);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
160 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
161 return ct->mirror_table;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
162 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
163
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
164 /* WARNING: All functions of this nature need to be written extremely
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
165 carefully to avoid crashes during GC. Cf. prune_specifiers()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
166 and prune_weak_hashtables(). */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
167
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
168 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
169 prune_syntax_tables (int (*obj_marked_p) (Lisp_Object))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
170 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
171 Lisp_Object rest, prev = Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
172
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
173 for (rest = Vall_syntax_tables;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
174 !GC_NILP (rest);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
175 rest = XCHAR_TABLE (rest)->next_table)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
176 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
177 if (! ((*obj_marked_p) (rest)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
178 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
179 /* This table is garbage. Remove it from the list. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
180 if (GC_NILP (prev))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
181 Vall_syntax_tables = XCHAR_TABLE (rest)->next_table;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
182 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
183 XCHAR_TABLE (prev)->next_table =
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
184 XCHAR_TABLE (rest)->next_table;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
185 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
186 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
187 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
188
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
189 static Lisp_Object
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
190 char_table_type_to_symbol (enum char_table_type type)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
191 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
192 switch (type)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
193 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
194 case CHAR_TABLE_TYPE_GENERIC: return Qgeneric;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
195 case CHAR_TABLE_TYPE_SYNTAX: return Qsyntax;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
196 case CHAR_TABLE_TYPE_DISPLAY: return Qdisplay;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
197 case CHAR_TABLE_TYPE_CHAR: return Qchar;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
198 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
199 case CHAR_TABLE_TYPE_CATEGORY: return Qcategory;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
200 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
201 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
202
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
203 abort ();
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
204 return Qnil; /* not reached */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
205 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
206
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
207 static enum char_table_type
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
208 symbol_to_char_table_type (Lisp_Object symbol)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
209 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
210 CHECK_SYMBOL (symbol);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
211
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
212 if (EQ (symbol, Qgeneric)) return CHAR_TABLE_TYPE_GENERIC;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
213 if (EQ (symbol, Qsyntax)) return CHAR_TABLE_TYPE_SYNTAX;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
214 if (EQ (symbol, Qdisplay)) return CHAR_TABLE_TYPE_DISPLAY;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
215 if (EQ (symbol, Qchar)) return CHAR_TABLE_TYPE_CHAR;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
216 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
217 if (EQ (symbol, Qcategory)) return CHAR_TABLE_TYPE_CATEGORY;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
218 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
219
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
220 signal_simple_error ("Unrecognized char table type", symbol);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
221 return CHAR_TABLE_TYPE_GENERIC; /* not reached */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
222 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
223
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
224 static void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
225 print_chartab_range (Emchar first, Emchar last, Lisp_Object val,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
226 Lisp_Object printcharfun)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
227 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
228 if (first != last)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
229 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
230 write_c_string (" (", printcharfun);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
231 print_internal (make_char (first), printcharfun, 0);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
232 write_c_string (" ", printcharfun);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
233 print_internal (make_char (last), printcharfun, 0);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
234 write_c_string (") ", printcharfun);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
235 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
236 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
237 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
238 write_c_string (" ", printcharfun);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
239 print_internal (make_char (first), printcharfun, 0);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
240 write_c_string (" ", printcharfun);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
241 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
242 print_internal (val, printcharfun, 1);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
243 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
244
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
245 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
246
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
247 static void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
248 print_chartab_charset_row (Lisp_Object charset,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
249 int row,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
250 struct Lisp_Char_Table_Entry *cte,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
251 Lisp_Object printcharfun)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
252 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
253 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
254 Lisp_Object cat = Qunbound;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
255 int first = -1;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
256
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
257 for (i = 32; i < 128; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
258 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
259 Lisp_Object pam = cte->level2[i - 32];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
260
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
261 if (first == -1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
262 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
263 first = i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
264 cat = pam;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
265 continue;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
266 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
267
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
268 if (!EQ (cat, pam))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
269 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
270 if (row == -1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
271 print_chartab_range (MAKE_CHAR (charset, first, 0),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
272 MAKE_CHAR (charset, i - 1, 0),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
273 cat, printcharfun);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
274 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
275 print_chartab_range (MAKE_CHAR (charset, row, first),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
276 MAKE_CHAR (charset, row, i - 1),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
277 cat, printcharfun);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
278 first = -1;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
279 i--;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
280 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
281 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
282
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
283 if (first != -1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
284 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
285 if (row == -1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
286 print_chartab_range (MAKE_CHAR (charset, first, 0),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
287 MAKE_CHAR (charset, i - 1, 0),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
288 cat, printcharfun);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
289 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
290 print_chartab_range (MAKE_CHAR (charset, row, first),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
291 MAKE_CHAR (charset, row, i - 1),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
292 cat, printcharfun);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
293 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
294 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
295
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
296 static void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
297 print_chartab_two_byte_charset (Lisp_Object charset,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
298 struct Lisp_Char_Table_Entry *cte,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
299 Lisp_Object printcharfun)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
300 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
301 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
302
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
303 for (i = 32; i < 128; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
304 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
305 Lisp_Object jen = cte->level2[i - 32];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
306
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
307 if (!CHAR_TABLE_ENTRYP (jen))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
308 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
309 char buf[100];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
310
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
311 write_c_string (" [", printcharfun);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
312 print_internal (XCHARSET_NAME (charset), printcharfun, 0);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
313 sprintf (buf, " %d] ", i);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
314 write_c_string (buf, printcharfun);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
315 print_internal (jen, printcharfun, 0);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
316 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
317 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
318 print_chartab_charset_row (charset, i, XCHAR_TABLE_ENTRY (jen),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
319 printcharfun);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
320 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
321 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
322
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
323 #endif /* MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
324
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
325 static void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
326 print_char_table (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
327 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
328 struct Lisp_Char_Table *ct = XCHAR_TABLE (obj);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
329 char buf[200];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
330
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
331 sprintf (buf, "#s(char-table type %s data (",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
332 string_data (symbol_name (XSYMBOL
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
333 (char_table_type_to_symbol (ct->type)))));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
334 write_c_string (buf, printcharfun);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
335
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
336 /* Now write out the ASCII/Control-1 stuff. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
337 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
338 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
339 int first = -1;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
340 Lisp_Object val = Qunbound;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
341
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
342 for (i = 0; i < NUM_ASCII_CHARS; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
343 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
344 if (first == -1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
345 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
346 first = i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
347 val = ct->ascii[i];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
348 continue;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
349 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
350
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
351 if (!EQ (ct->ascii[i], val))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
352 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
353 print_chartab_range (first, i - 1, val, printcharfun);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
354 first = -1;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
355 i--;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
356 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
357 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
358
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
359 if (first != -1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
360 print_chartab_range (first, i - 1, val, printcharfun);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
361 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
362
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
363 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
364 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
365 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
366
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
367 for (i = MIN_LEADING_BYTE; i < MIN_LEADING_BYTE + NUM_LEADING_BYTES;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
368 i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
369 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
370 Lisp_Object ann = ct->level1[i - MIN_LEADING_BYTE];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
371 Lisp_Object charset = CHARSET_BY_LEADING_BYTE (i);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
372
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
373 if (!CHARSETP (charset) || i == LEADING_BYTE_ASCII
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
374 || i == LEADING_BYTE_CONTROL_1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
375 continue;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
376 if (!CHAR_TABLE_ENTRYP (ann))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
377 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
378 write_c_string (" ", printcharfun);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
379 print_internal (XCHARSET_NAME (charset),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
380 printcharfun, 0);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
381 write_c_string (" ", printcharfun);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
382 print_internal (ann, printcharfun, 0);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
383 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
384 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
385 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
386 struct Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (ann);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
387 if (XCHARSET_DIMENSION (charset) == 1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
388 print_chartab_charset_row (charset, -1, cte, printcharfun);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
389 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
390 print_chartab_two_byte_charset (charset, cte, printcharfun);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
391 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
392 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
393 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
394 #endif /* MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
395
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
396 write_c_string ("))", printcharfun);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
397 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
398
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
399 static int
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
400 char_table_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
401 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
402 struct Lisp_Char_Table *ct1 = XCHAR_TABLE (obj1);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
403 struct Lisp_Char_Table *ct2 = XCHAR_TABLE (obj2);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
404 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
405
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
406 if (CHAR_TABLE_TYPE (ct1) != CHAR_TABLE_TYPE (ct2))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
407 return 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
408
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
409 for (i = 0; i < NUM_ASCII_CHARS; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
410 if (!internal_equal (ct1->ascii[i], ct2->ascii[i], depth + 1))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
411 return 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
412
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
413 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
414 for (i = 0; i < NUM_LEADING_BYTES; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
415 if (!internal_equal (ct1->level1[i], ct2->level1[i], depth + 1))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
416 return 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
417 #endif /* MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
418
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
419 return 1;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
420 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
421
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
422 static unsigned long
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
423 char_table_hash (Lisp_Object obj, int depth)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
424 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
425 struct Lisp_Char_Table *ct = XCHAR_TABLE (obj);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
426 unsigned long hashval = internal_array_hash (ct->ascii, NUM_ASCII_CHARS,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
427 depth);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
428 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
429 hashval = HASH2 (hashval,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
430 internal_array_hash (ct->level1, NUM_LEADING_BYTES, depth));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
431 #endif /* MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
432 return hashval;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
433 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
434
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
435 DEFUN ("char-table-p", Fchar_table_p, 1, 1, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
436 Return non-nil if OBJECT is a char table.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
437
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
438 A char table is a table that maps characters (or ranges of characters)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
439 to values. Char tables are specialized for characters, only allowing
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
440 particular sorts of ranges to be assigned values. Although this
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
441 loses in generality, it makes for extremely fast (constant-time)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
442 lookups, and thus is feasible for applications that do an extremely
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
443 large number of lookups (e.g. scanning a buffer for a character in
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
444 a particular syntax, where a lookup in the syntax table must occur
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
445 once per character).
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
446
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
447 When Mule support exists, the types of ranges that can be assigned
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
448 values are
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
449
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
450 -- all characters
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
451 -- an entire charset
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
452 -- a single row in a two-octet charset
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
453 -- a single character
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
454
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
455 When Mule support is not present, the types of ranges that can be
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
456 assigned values are
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
457
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
458 -- all characters
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
459 -- a single character
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
460
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
461 To create a char table, use `make-char-table'. To modify a char
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
462 table, use `put-char-table' or `remove-char-table'. To retrieve the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
463 value for a particular character, use `get-char-table'. See also
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
464 `map-char-table', `clear-char-table', `copy-char-table',
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
465 `valid-char-table-type-p', `char-table-type-list', `valid-char-table-value-p',
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
466 and `check-char-table-value'.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
467 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
468 (object))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
469 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
470 return (CHAR_TABLEP (object) ? Qt : Qnil);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
471 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
472
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
473 DEFUN ("char-table-type-list", Fchar_table_type_list, 0, 0, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
474 Return a list of the recognized char table types.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
475 See `valid-char-table-type-p'.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
476 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
477 ())
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
478 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
479 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
480 return list5 (Qchar, Qcategory, Qdisplay, Qgeneric, Qsyntax);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
481 #else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
482 return list4 (Qchar, Qdisplay, Qgeneric, Qsyntax);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
483 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
484 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
485
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
486 DEFUN ("valid-char-table-type-p", Fvalid_char_table_type_p, 1, 1, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
487 Return t if TYPE if a recognized char table type.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
488
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
489 Each char table type is used for a different purpose and allows different
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
490 sorts of values. The different char table types are
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
491
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
492 `category'
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
493 Used for category tables, which specify the regexp categories
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
494 that a character is in. The valid values are nil or a
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
495 bit vector of 95 elements. Higher-level Lisp functions are
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
496 provided for working with category tables. Currently categories
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
497 and category tables only exist when Mule support is present.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
498 `char'
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
499 A generalized char table, for mapping from one character to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
500 another. Used for case tables, syntax matching tables,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
501 `keyboard-translate-table', etc. The valid values are characters.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
502 `generic'
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
503 An even more generalized char table, for mapping from a
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
504 character to anything.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
505 `display'
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
506 Used for display tables, which specify how a particular character
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
507 is to appear when displayed. #### Not yet implemented.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
508 `syntax'
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
509 Used for syntax tables, which specify the syntax of a particular
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
510 character. Higher-level Lisp functions are provided for
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
511 working with syntax tables. The valid values are integers.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
512
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
513 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
514 (type))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
515 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
516 if (EQ (type, Qchar)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
517 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
518 || EQ (type, Qcategory)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
519 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
520 || EQ (type, Qdisplay)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
521 || EQ (type, Qgeneric)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
522 || EQ (type, Qsyntax))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
523 return Qt;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
524
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
525 return Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
526 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
527
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
528 DEFUN ("char-table-type", Fchar_table_type, 1, 1, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
529 Return the type of char table TABLE.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
530 See `valid-char-table-type-p'.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
531 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
532 (table))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
533 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
534 CHECK_CHAR_TABLE (table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
535 return char_table_type_to_symbol (XCHAR_TABLE (table)->type);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
536 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
537
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
538 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
539 fill_char_table (struct Lisp_Char_Table *ct, Lisp_Object value)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
540 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
541 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
542
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
543 for (i = 0; i < NUM_ASCII_CHARS; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
544 ct->ascii[i] = value;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
545 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
546 for (i = 0; i < NUM_LEADING_BYTES; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
547 ct->level1[i] = value;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
548 #endif /* MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
549
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
550 if (ct->type == CHAR_TABLE_TYPE_SYNTAX)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
551 update_syntax_table (ct);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
552 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
553
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
554 DEFUN ("reset-char-table", Freset_char_table, 1, 1, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
555 Reset a char table to its default state.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
556 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
557 (table))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
558 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
559 struct Lisp_Char_Table *ct;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
560
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
561 CHECK_CHAR_TABLE (table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
562 ct = XCHAR_TABLE (table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
563
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
564 switch (ct->type)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
565 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
566 case CHAR_TABLE_TYPE_CHAR:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
567 case CHAR_TABLE_TYPE_DISPLAY:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
568 case CHAR_TABLE_TYPE_GENERIC:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
569 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
570 case CHAR_TABLE_TYPE_CATEGORY:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
571 fill_char_table (ct, Qnil);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
572 break;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
573 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
574
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
575 case CHAR_TABLE_TYPE_SYNTAX:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
576 fill_char_table (ct, make_int (Sinherit));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
577 break;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
578
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
579 default:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
580 abort ();
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
581 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
582
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
583 return Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
584 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
585
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
586 DEFUN ("make-char-table", Fmake_char_table, 1, 1, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
587 Make a new, empty char table of type TYPE.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
588 Currently recognized types are 'char, 'category, 'display, 'generic,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
589 and 'syntax. See `valid-char-table-type-p'.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
590 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
591 (type))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
592 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
593 struct Lisp_Char_Table *ct;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
594 Lisp_Object obj = Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
595 enum char_table_type ty = symbol_to_char_table_type (type);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
596
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
597 ct = (struct Lisp_Char_Table *)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
598 alloc_lcrecord (sizeof (struct Lisp_Char_Table), lrecord_char_table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
599 ct->type = ty;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
600 if (ty == CHAR_TABLE_TYPE_SYNTAX)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
601 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
602 ct->mirror_table = Fmake_char_table (Qgeneric);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
603 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
604 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
605 ct->mirror_table = Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
606 ct->next_table = Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
607 XSETCHAR_TABLE (obj, ct);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
608 if (ty == CHAR_TABLE_TYPE_SYNTAX)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
609 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
610 ct->next_table = Vall_syntax_tables;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
611 Vall_syntax_tables = obj;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
612 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
613 Freset_char_table (obj);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
614 return obj;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
615 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
616
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
617 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
618
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
619 static Lisp_Object
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
620 make_char_table_entry (Lisp_Object initval)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
621 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
622 struct Lisp_Char_Table_Entry *cte;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
623 Lisp_Object obj = Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
624 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
625
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
626 cte = (struct Lisp_Char_Table_Entry *)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
627 alloc_lcrecord (sizeof (struct Lisp_Char_Table_Entry),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
628 lrecord_char_table_entry);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
629 for (i = 0; i < 96; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
630 cte->level2[i] = initval;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
631 XSETCHAR_TABLE_ENTRY (obj, cte);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
632 return obj;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
633 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
634
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
635 static Lisp_Object
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
636 copy_char_table_entry (Lisp_Object entry)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
637 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
638 struct Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (entry);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
639 struct Lisp_Char_Table_Entry *ctenew;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
640 Lisp_Object obj = Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
641 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
642
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
643 ctenew = (struct Lisp_Char_Table_Entry *)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
644 alloc_lcrecord (sizeof (struct Lisp_Char_Table_Entry),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
645 lrecord_char_table_entry);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
646 for (i = 0; i < 96; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
647 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
648 Lisp_Object new = cte->level2[i];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
649 if (CHAR_TABLE_ENTRYP (new))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
650 ctenew->level2[i] = copy_char_table_entry (new);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
651 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
652 ctenew->level2[i] = new;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
653 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
654
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
655 XSETCHAR_TABLE_ENTRY (obj, cte);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
656 return obj;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
657 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
658
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
659 #endif /* MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
660
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
661 DEFUN ("copy-char-table", Fcopy_char_table, 1, 1, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
662 Make a new char table which is a copy of OLD-TABLE.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
663 It will contain the same values for the same characters and ranges
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
664 as OLD-TABLE. The values will not themselves be copied.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
665 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
666 (old_table))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
667 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
668 struct Lisp_Char_Table *ct, *ctnew;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
669 Lisp_Object obj = Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
670 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
671
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
672 CHECK_CHAR_TABLE (old_table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
673 ct = XCHAR_TABLE (old_table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
674 ctnew = (struct Lisp_Char_Table *)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
675 alloc_lcrecord (sizeof (struct Lisp_Char_Table), lrecord_char_table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
676 ctnew->type = ct->type;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
677
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
678 for (i = 0; i < NUM_ASCII_CHARS; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
679 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
680 Lisp_Object new = ct->ascii[i];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
681 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
682 assert (! (CHAR_TABLE_ENTRYP (new)));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
683 #endif /* MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
684 ctnew->ascii[i] = new;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
685 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
686
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
687 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
688
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
689 for (i = 0; i < NUM_LEADING_BYTES; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
690 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
691 Lisp_Object new = ct->level1[i];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
692 if (CHAR_TABLE_ENTRYP (new))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
693 ctnew->level1[i] = copy_char_table_entry (new);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
694 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
695 ctnew->level1[i] = new;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
696 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
697
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
698 #endif /* MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
699
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
700 if (CHAR_TABLEP (ct->mirror_table))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
701 ctnew->mirror_table = Fcopy_char_table (ct->mirror_table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
702 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
703 ctnew->mirror_table = ct->mirror_table;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
704 XSETCHAR_TABLE (obj, ctnew);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
705 return obj;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
706 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
707
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
708 static void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
709 decode_char_table_range (Lisp_Object range, struct chartab_range *outrange)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
710 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
711 if (EQ (range, Qt))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
712 outrange->type = CHARTAB_RANGE_ALL;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
713 else if (CHAR_OR_CHAR_INTP (range))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
714 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
715 outrange->type = CHARTAB_RANGE_CHAR;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
716 outrange->ch = XCHAR_OR_CHAR_INT (range);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
717 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
718 #ifndef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
719 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
720 signal_simple_error ("Range must be t or a character", range);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
721 #else /* MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
722 else if (VECTORP (range))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
723 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
724 struct Lisp_Vector *vec = XVECTOR (range);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
725 Lisp_Object *elts = vector_data (vec);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
726 if (vector_length (vec) != 2)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
727 signal_simple_error ("Length of charset row vector must be 2",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
728 range);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
729 outrange->type = CHARTAB_RANGE_ROW;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
730 outrange->charset = Fget_charset (elts[0]);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
731 CHECK_INT (elts[1]);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
732 outrange->row = XINT (elts[1]);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
733 switch (XCHARSET_TYPE (outrange->charset))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
734 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
735 case CHARSET_TYPE_94:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
736 case CHARSET_TYPE_96:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
737 signal_simple_error ("Charset in row vector must be multi-byte",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
738 outrange->charset);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
739 case CHARSET_TYPE_94X94:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
740 check_int_range (outrange->row, 33, 126);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
741 break;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
742 case CHARSET_TYPE_96X96:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
743 check_int_range (outrange->row, 32, 127);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
744 break;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
745 default:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
746 abort ();
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
747 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
748 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
749 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
750 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
751 if (!CHARSETP (range) && !SYMBOLP (range))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
752 signal_simple_error
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
753 ("Char table range must be t, charset, char, or vector", range);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
754 outrange->type = CHARTAB_RANGE_CHARSET;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
755 outrange->charset = Fget_charset (range);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
756 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
757 #endif /* MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
758 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
759
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
760 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
761
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
762 /* called from CHAR_TABLE_VALUE(). */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
763 Lisp_Object
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
764 get_non_ascii_char_table_value (struct Lisp_Char_Table *ct, int leading_byte,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
765 Emchar c)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
766 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
767 Lisp_Object val;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
768 Lisp_Object charset = CHARSET_BY_LEADING_BYTE (leading_byte);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
769 int byte1, byte2;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
770
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
771 BREAKUP_CHAR_1_UNSAFE (c, charset, byte1, byte2);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
772 val = ct->level1[leading_byte - MIN_LEADING_BYTE];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
773 if (CHAR_TABLE_ENTRYP (val))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
774 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
775 struct Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (val);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
776 val = cte->level2[byte1 - 32];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
777 if (CHAR_TABLE_ENTRYP (val))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
778 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
779 cte = XCHAR_TABLE_ENTRY (val);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
780 assert (byte2 >= 32);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
781 val = cte->level2[byte2 - 32];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
782 assert (!CHAR_TABLE_ENTRYP (val));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
783 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
784 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
785
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
786 return val;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
787 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
788
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
789 #endif /* MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
790
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
791 static Lisp_Object
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
792 get_char_table (Emchar ch, struct Lisp_Char_Table *ct)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
793 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
794 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
795 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
796 Lisp_Object charset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
797 int byte1, byte2;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
798 Lisp_Object val;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
799
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
800 BREAKUP_CHAR (ch, charset, byte1, byte2);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
801
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
802 if (EQ (charset, Vcharset_ascii))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
803 val = ct->ascii[byte1];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
804 else if (EQ (charset, Vcharset_control_1))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
805 val = ct->ascii[byte1 + 128];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
806 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
807 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
808 int lb = XCHARSET_LEADING_BYTE (charset) - MIN_LEADING_BYTE;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
809 val = ct->level1[lb];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
810 if (CHAR_TABLE_ENTRYP (val))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
811 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
812 struct Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (val);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
813 val = cte->level2[byte1 - 32];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
814 if (CHAR_TABLE_ENTRYP (val))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
815 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
816 cte = XCHAR_TABLE_ENTRY (val);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
817 assert (byte2 >= 32);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
818 val = cte->level2[byte2 - 32];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
819 assert (!CHAR_TABLE_ENTRYP (val));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
820 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
821 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
822 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
823
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
824 return val;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
825 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
826 #else /* not MULE */
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
827 return ct->ascii[(unsigned char)ch];
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
828 #endif /* not MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
829 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
830
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
831
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
832 DEFUN ("get-char-table", Fget_char_table, 2, 2, 0, /*
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
833 Find value for char CH in TABLE.
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
834 */
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
835 (ch, table))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
836 {
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
837 struct Lisp_Char_Table *ct;
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
838 Emchar chr;
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
839
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
840 CHECK_CHAR_TABLE (table);
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
841 ct = XCHAR_TABLE (table);
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
842 CHECK_CHAR_COERCE_INT (ch);
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
843 chr = XCHAR(ch);
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
844
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
845 return (get_char_table (chr, ct));
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
846 }
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
847
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
848 DEFUN ("get-range-char-table", Fget_range_char_table, 2, 3, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
849 Find value for a range in TABLE.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
850 If there is more than one value, return MULTI (defaults to nil).
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
851 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
852 (range, table, multi))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
853 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
854 struct Lisp_Char_Table *ct;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
855 struct chartab_range rainj;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
856
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
857 if (CHAR_OR_CHAR_INTP (range))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
858 return Fget_char_table (range, table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
859 CHECK_CHAR_TABLE (table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
860 ct = XCHAR_TABLE (table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
861
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
862 decode_char_table_range (range, &rainj);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
863 switch (rainj.type)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
864 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
865 case CHARTAB_RANGE_ALL:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
866 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
867 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
868 Lisp_Object first = ct->ascii[0];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
869
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
870 for (i = 1; i < NUM_ASCII_CHARS; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
871 if (!EQ (first, ct->ascii[i]))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
872 return multi;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
873
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
874 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
875 for (i = MIN_LEADING_BYTE; i < MIN_LEADING_BYTE + NUM_LEADING_BYTES;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
876 i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
877 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
878 if (!CHARSETP (CHARSET_BY_LEADING_BYTE (i))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
879 || i == LEADING_BYTE_ASCII
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
880 || i == LEADING_BYTE_CONTROL_1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
881 continue;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
882 if (!EQ (first, ct->level1[i - MIN_LEADING_BYTE]))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
883 return multi;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
884 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
885 #endif /* MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
886
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
887 return first;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
888 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
889
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
890 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
891 case CHARTAB_RANGE_CHARSET:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
892 if (EQ (rainj.charset, Vcharset_ascii))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
893 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
894 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
895 Lisp_Object first = ct->ascii[0];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
896
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
897 for (i = 1; i < 128; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
898 if (!EQ (first, ct->ascii[i]))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
899 return multi;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
900 return first;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
901 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
902
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
903 if (EQ (rainj.charset, Vcharset_control_1))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
904 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
905 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
906 Lisp_Object first = ct->ascii[128];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
907
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
908 for (i = 129; i < 160; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
909 if (!EQ (first, ct->ascii[i]))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
910 return multi;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
911 return first;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
912 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
913
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
914 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
915 Lisp_Object val = ct->level1[XCHARSET_LEADING_BYTE (rainj.charset) -
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
916 MIN_LEADING_BYTE];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
917 if (CHAR_TABLE_ENTRYP (val))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
918 return multi;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
919 return val;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
920 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
921
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
922 case CHARTAB_RANGE_ROW:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
923 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
924 Lisp_Object val = ct->level1[XCHARSET_LEADING_BYTE (rainj.charset) -
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
925 MIN_LEADING_BYTE];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
926 if (!CHAR_TABLE_ENTRYP (val))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
927 return val;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
928 val = XCHAR_TABLE_ENTRY (val)->level2[rainj.row - 32];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
929 if (CHAR_TABLE_ENTRYP (val))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
930 return multi;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
931 return val;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
932 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
933 #endif /* not MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
934
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
935 default:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
936 abort ();
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
937 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
938
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
939 return Qnil; /* not reached */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
940 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
941
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
942 static int
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
943 check_valid_char_table_value (Lisp_Object value, enum char_table_type type,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
944 Error_behavior errb)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
945 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
946 switch (type)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
947 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
948 case CHAR_TABLE_TYPE_SYNTAX:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
949 if (!ERRB_EQ (errb, ERROR_ME))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
950 return INTP (value) || (CONSP (value) && INTP (XCAR (value))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
951 && CHAR_OR_CHAR_INTP (XCDR (value)));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
952 if (CONSP (value))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
953 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
954 Lisp_Object cdr = XCDR (value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
955 CHECK_INT (XCAR (value));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
956 CHECK_CHAR_COERCE_INT (cdr);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
957 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
958 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
959 CHECK_INT (value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
960 break;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
961
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
962 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
963 case CHAR_TABLE_TYPE_CATEGORY:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
964 if (!ERRB_EQ (errb, ERROR_ME))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
965 return CATEGORY_TABLE_VALUEP (value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
966 CHECK_CATEGORY_TABLE_VALUE (value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
967 break;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
968 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
969
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
970 case CHAR_TABLE_TYPE_GENERIC:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
971 return 1;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
972
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
973 case CHAR_TABLE_TYPE_DISPLAY:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
974 /* #### fix this */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
975 maybe_signal_simple_error ("Display char tables not yet implemented",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
976 value, Qchar_table, errb);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
977 return 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
978
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
979 case CHAR_TABLE_TYPE_CHAR:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
980 if (!ERRB_EQ (errb, ERROR_ME))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
981 return CHAR_OR_CHAR_INTP (value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
982 CHECK_CHAR_COERCE_INT (value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
983 break;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
984
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
985 default:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
986 abort ();
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
987 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
988
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
989 return 0; /* not reached */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
990 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
991
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
992 static Lisp_Object
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
993 canonicalize_char_table_value (Lisp_Object value, enum char_table_type type)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
994 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
995 switch (type)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
996 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
997 case CHAR_TABLE_TYPE_SYNTAX:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
998 if (CONSP (value))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
999 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1000 Lisp_Object car = XCAR (value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1001 Lisp_Object cdr = XCDR (value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1002 CHECK_CHAR_COERCE_INT (cdr);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1003 return Fcons (car, cdr);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1004 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1005 default:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1006 break;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1007 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1008 return value;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1009 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1010
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1011 DEFUN ("valid-char-table-value-p", Fvalid_char_table_value_p, 2, 2, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1012 Return non-nil if VALUE is a valid value for CHAR-TABLE-TYPE.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1013 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1014 (value, char_table_type))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1015 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1016 enum char_table_type type = symbol_to_char_table_type (char_table_type);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1017
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1018 return check_valid_char_table_value (value, type, ERROR_ME_NOT) ? Qt : Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1019 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1020
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1021 DEFUN ("check-valid-char-table-value", Fcheck_valid_char_table_value, 2, 2, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1022 Signal an error if VALUE is not a valid value for CHAR-TABLE-TYPE.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1023 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1024 (value, char_table_type))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1025 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1026 enum char_table_type type = symbol_to_char_table_type (char_table_type);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1027
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1028 check_valid_char_table_value (value, type, ERROR_ME);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1029 return Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1030 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1031
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1032 /* Assign VAL to all characters in RANGE in char table CT. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1033
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1034 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1035 put_char_table (struct Lisp_Char_Table *ct, struct chartab_range *range,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1036 Lisp_Object val)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1037 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1038 switch (range->type)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1039 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1040 case CHARTAB_RANGE_ALL:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1041 fill_char_table (ct, val);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1042 return; /* avoid the duplicate call to update_syntax_table() below,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1043 since fill_char_table() also did that. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1044
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1045 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1046 case CHARTAB_RANGE_CHARSET:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1047 if (EQ (range->charset, Vcharset_ascii))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1048 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1049 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1050 for (i = 0; i < 128; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1051 ct->ascii[i] = val;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1052 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1053 else if (EQ (range->charset, Vcharset_control_1))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1054 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1055 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1056 for (i = 128; i < 160; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1057 ct->ascii[i] = val;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1058 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1059 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1060 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1061 int lb = XCHARSET_LEADING_BYTE (range->charset) - MIN_LEADING_BYTE;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1062 ct->level1[lb] = val;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1063 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1064 break;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1065
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1066 case CHARTAB_RANGE_ROW:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1067 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1068 struct Lisp_Char_Table_Entry *cte;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1069 int lb = XCHARSET_LEADING_BYTE (range->charset) - MIN_LEADING_BYTE;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1070 /* make sure that there is a separate entry for the row. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1071 if (!CHAR_TABLE_ENTRYP (ct->level1[lb]))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1072 ct->level1[lb] = make_char_table_entry (ct->level1[lb]);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1073 cte = XCHAR_TABLE_ENTRY (ct->level1[lb]);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1074 cte->level2[range->row - 32] = val;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1075 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1076 break;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1077 #endif /* MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1078
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1079 case CHARTAB_RANGE_CHAR:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1080 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1081 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1082 Lisp_Object charset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1083 int byte1, byte2;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1084
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1085 BREAKUP_CHAR (range->ch, charset, byte1, byte2);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1086 if (EQ (charset, Vcharset_ascii))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1087 ct->ascii[byte1] = val;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1088 else if (EQ (charset, Vcharset_control_1))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1089 ct->ascii[byte1 + 128] = val;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1090 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1091 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1092 struct Lisp_Char_Table_Entry *cte;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1093 int lb = XCHARSET_LEADING_BYTE (charset) - MIN_LEADING_BYTE;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1094 /* make sure that there is a separate entry for the row. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1095 if (!CHAR_TABLE_ENTRYP (ct->level1[lb]))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1096 ct->level1[lb] = make_char_table_entry (ct->level1[lb]);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1097 cte = XCHAR_TABLE_ENTRY (ct->level1[lb]);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1098 /* now CTE is a char table entry for the charset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1099 each entry is for a single row (or character of
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1100 a one-octet charset). */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1101 if (XCHARSET_DIMENSION (charset) == 1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1102 cte->level2[byte1 - 32] = val;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1103 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1104 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1105 /* assigning to one character in a two-octet charset. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1106 /* make sure that the charset row contains a separate
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1107 entry for each character. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1108 if (!CHAR_TABLE_ENTRYP (cte->level2[byte1 - 32]))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1109 cte->level2[byte1 - 32] =
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1110 make_char_table_entry (cte->level2[byte1 - 32]);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1111 cte = XCHAR_TABLE_ENTRY (cte->level2[byte1 - 32]);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1112 cte->level2[byte2 - 32] = val;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1113 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1114 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1115 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1116 #else /* not MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1117 ct->ascii[(unsigned char) (range->ch)] = val;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1118 break;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1119 #endif /* not MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1120 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1121
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1122 if (ct->type == CHAR_TABLE_TYPE_SYNTAX)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1123 update_syntax_table (ct);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1124 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1125
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1126 DEFUN ("put-char-table", Fput_char_table, 3, 3, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1127 Set the value for chars in RANGE to be VAL in TABLE.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1128
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1129 RANGE specifies one or more characters to be affected and should be
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1130 one of the following:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1131
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1132 -- t (all characters are affected)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1133 -- A charset (only allowed when Mule support is present)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1134 -- A vector of two elements: a two-octet charset and a row number
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1135 (only allowed when Mule support is present)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1136 -- A single character
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1137
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1138 VAL must be a value appropriate for the type of TABLE.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1139 See `valid-char-table-type-p'.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1140 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1141 (range, val, table))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1142 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1143 struct Lisp_Char_Table *ct;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1144 struct chartab_range rainj;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1145
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1146 CHECK_CHAR_TABLE (table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1147 ct = XCHAR_TABLE (table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1148 check_valid_char_table_value (val, ct->type, ERROR_ME);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1149 decode_char_table_range (range, &rainj);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1150 val = canonicalize_char_table_value (val, ct->type);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1151 put_char_table (ct, &rainj, val);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1152 return Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1153 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1154
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1155 /* Map FN over the ASCII chars in CT. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1156
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1157 static int
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1158 map_over_charset_ascii (struct Lisp_Char_Table *ct,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1159 int (*fn) (struct chartab_range *range,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1160 Lisp_Object val, void *arg),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1161 void *arg)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1162 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1163 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1164
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1165 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1166 for (i = 0; i < 128; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1167 #else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1168 for (i = 0; i < 256; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1169 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1170 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1171 Lisp_Object val = ct->ascii[i];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1172 struct chartab_range rainj;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1173 int retval;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1174
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1175 rainj.type = CHARTAB_RANGE_CHAR;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1176 rainj.ch = (Emchar) i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1177 retval = (fn) (&rainj, val, arg);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1178 if (retval)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1179 return retval;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1180 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1181
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1182 return 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1183 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1184
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1185 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1186
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1187 /* Map FN over the Control-1 chars in CT. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1188
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1189 static int
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1190 map_over_charset_control_1 (struct Lisp_Char_Table *ct,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1191 int (*fn) (struct chartab_range *range,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1192 Lisp_Object val, void *arg),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1193 void *arg)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1194 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1195 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1196
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1197 for (i = 0; i < 32; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1198 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1199 Lisp_Object val = ct->ascii[i + 128];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1200 struct chartab_range rainj;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1201 int retval;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1202
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1203 rainj.type = CHARTAB_RANGE_CHAR;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1204 rainj.ch = (Emchar) (i + 128);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1205 retval = (fn) (&rainj, val, arg);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1206 if (retval)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1207 return retval;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1208 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1209
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1210 return 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1211 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1212
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1213 /* Map FN over the row ROW of two-byte charset CHARSET.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1214 There must be a separate value for that row in the char table.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1215 CTE specifies the char table entry for CHARSET. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1216
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1217 static int
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1218 map_over_charset_row (struct Lisp_Char_Table_Entry *cte,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1219 Lisp_Object charset, int row,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1220 int (*fn) (struct chartab_range *range,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1221 Lisp_Object val, void *arg),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1222 void *arg)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1223 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1224 Lisp_Object val;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1225
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1226 val = cte->level2[row - 32];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1227 if (!CHAR_TABLE_ENTRYP (val))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1228 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1229 struct chartab_range rainj;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1230
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1231 rainj.type = CHARTAB_RANGE_ROW;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1232 rainj.charset = charset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1233 rainj.row = row;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1234 return (fn) (&rainj, val, arg);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1235 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1236 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1237 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1238 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1239 int start, stop;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1240
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1241 cte = XCHAR_TABLE_ENTRY (val);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1242 if (XCHARSET_CHARS (charset) == 94)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1243 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1244 start = 33;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1245 stop = 127;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1246 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1247 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1248 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1249 start = 32;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1250 stop = 128;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1251 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1252
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1253 for (i = start; i < stop; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1254 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1255 int retval;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1256 struct chartab_range rainj;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1257
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1258 rainj.type = CHARTAB_RANGE_CHAR;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1259 rainj.ch = MAKE_CHAR (charset, row, i);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1260
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1261 val = cte->level2[i - 32];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1262 retval = (fn) (&rainj, val, arg);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1263 if (retval)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1264 return retval;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1265 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1266 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1267
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1268 return 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1269 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1270
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1271 static int
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1272 map_over_other_charset (struct Lisp_Char_Table *ct, int lb,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1273 int (*fn) (struct chartab_range *range,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1274 Lisp_Object val, void *arg),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1275 void *arg)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1276 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1277 Lisp_Object charset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1278 Lisp_Object val;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1279
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1280 val = ct->level1[lb - MIN_LEADING_BYTE];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1281
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1282 charset = CHARSET_BY_LEADING_BYTE (lb);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1283 if (!CHARSETP (charset) || lb == LEADING_BYTE_ASCII
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1284 || lb == LEADING_BYTE_CONTROL_1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1285 return 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1286 if (!CHAR_TABLE_ENTRYP (val))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1287 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1288 struct chartab_range rainj;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1289
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1290 rainj.type = CHARTAB_RANGE_CHARSET;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1291 rainj.charset = charset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1292 return (fn) (&rainj, val, arg);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1293 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1294 else if (XCHARSET_DIMENSION (charset) == 1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1295 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1296 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1297 struct Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (val);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1298 int start, stop;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1299
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1300 if (XCHARSET_CHARS (charset) == 94)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1301 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1302 start = 33;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1303 stop = 127;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1304 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1305 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1306 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1307 start = 32;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1308 stop = 128;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1309 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1310
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1311 for (i = start; i < stop; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1312 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1313 int retval;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1314 struct chartab_range rainj;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1315
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1316 rainj.type = CHARTAB_RANGE_CHAR;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1317 rainj.ch = MAKE_CHAR (charset, i, 0);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1318 retval = (fn) (&rainj, cte->level2[i - 32], arg);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1319 if (retval)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1320 return retval;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1321 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1322 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1323 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1324 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1325 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1326 struct Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (val);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1327 int start, stop;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1328
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1329 if (XCHARSET_CHARS (charset) == 94)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1330 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1331 start = 33;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1332 stop = 127;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1333 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1334 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1335 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1336 start = 32;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1337 stop = 128;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1338 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1339
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1340 for (i = start; i < stop; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1341 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1342 int retval =
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1343 map_over_charset_row (cte, charset, i, fn, arg);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1344 if (retval)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1345 return retval;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1346 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1347 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1348
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1349 return 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1350 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1351
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1352 #endif /* MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1353
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1354 /* Map FN (with client data ARG) over range RANGE in char table CT.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1355 Mapping stops the first time FN returns non-zero, and that value
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1356 becomes the return value of map_char_table(). */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1357
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1358 int
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1359 map_char_table (struct Lisp_Char_Table *ct,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1360 struct chartab_range *range,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1361 int (*fn) (struct chartab_range *range,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1362 Lisp_Object val, void *arg),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1363 void *arg)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1364 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1365 switch (range->type)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1366 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1367 case CHARTAB_RANGE_ALL:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1368 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1369 int retval;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1370
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1371 retval = map_over_charset_ascii (ct, fn, arg);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1372 if (retval)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1373 return retval;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1374 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1375 retval = map_over_charset_control_1 (ct, fn, arg);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1376 if (retval)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1377 return retval;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1378 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1379 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1380 for (i = MIN_LEADING_BYTE; i < MIN_LEADING_BYTE + NUM_LEADING_BYTES;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1381 i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1382 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1383 retval = map_over_other_charset (ct, i, fn, arg);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1384 if (retval)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1385 return retval;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1386 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1387 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1388 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1389 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1390 break;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1391
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1392 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1393 case CHARTAB_RANGE_CHARSET:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1394 return map_over_other_charset (ct,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1395 XCHARSET_LEADING_BYTE (range->charset),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1396 fn, arg);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1397
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1398 case CHARTAB_RANGE_ROW:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1399 {
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1400 Lisp_Object val = ct->level1[XCHARSET_LEADING_BYTE (range->charset) - MIN_LEADING_BYTE];
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1401 if (!CHAR_TABLE_ENTRYP (val))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1402 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1403 struct chartab_range rainj;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1404
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1405 rainj.type = CHARTAB_RANGE_ROW;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1406 rainj.charset = range->charset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1407 rainj.row = range->row;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1408 return (fn) (&rainj, val, arg);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1409 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1410 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1411 return map_over_charset_row (XCHAR_TABLE_ENTRY (val),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1412 range->charset, range->row,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1413 fn, arg);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1414 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1415 #endif /* MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1416
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1417 case CHARTAB_RANGE_CHAR:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1418 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1419 Emchar ch = range->ch;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1420 Lisp_Object val = CHAR_TABLE_VALUE_UNSAFE (ct, ch);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1421 struct chartab_range rainj;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1422
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1423 rainj.type = CHARTAB_RANGE_CHAR;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1424 rainj.ch = ch;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1425 return (fn) (&rainj, val, arg);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1426 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1427
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1428 default:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1429 abort ();
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1430 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1431
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1432 return 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1433 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1434
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1435 struct slow_map_char_table_arg
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1436 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1437 Lisp_Object function;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1438 Lisp_Object retval;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1439 };
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1440
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1441 static int
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1442 slow_map_char_table_fun (struct chartab_range *range,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1443 Lisp_Object val, void *arg)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1444 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1445 Lisp_Object ranjarg = Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1446 struct slow_map_char_table_arg *closure =
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1447 (struct slow_map_char_table_arg *) arg;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1448
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1449 switch (range->type)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1450 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1451 case CHARTAB_RANGE_ALL:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1452 ranjarg = Qt;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1453 break;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1454
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1455 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1456 case CHARTAB_RANGE_CHARSET:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1457 ranjarg = XCHARSET_NAME (range->charset);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1458 break;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1459
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1460 case CHARTAB_RANGE_ROW:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1461 ranjarg = vector2 (XCHARSET_NAME (range->charset),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1462 make_int (range->row));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1463 break;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1464 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1465 case CHARTAB_RANGE_CHAR:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1466 ranjarg = make_char (range->ch);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1467 break;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1468 default:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1469 abort ();
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1470 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1471
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1472 closure->retval = call2 (closure->function, ranjarg, val);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1473 return (!NILP (closure->retval));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1474 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1475
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1476 DEFUN ("map-char-table", Fmap_char_table, 2, 3, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1477 Map FUNCTION over entries in TABLE, calling it with two args,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1478 each key and value in the table.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1479
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1480 RANGE specifies a subrange to map over and is in the same format as
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1481 the RANGE argument to `put-range-table'. If omitted or t, it defaults to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1482 the entire table.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1483 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1484 (function, table, range))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1485 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1486 struct Lisp_Char_Table *ct;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1487 struct slow_map_char_table_arg slarg;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1488 struct gcpro gcpro1, gcpro2;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1489 struct chartab_range rainj;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1490
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1491 CHECK_CHAR_TABLE (table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1492 ct = XCHAR_TABLE (table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1493 if (NILP (range))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1494 range = Qt;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1495 decode_char_table_range (range, &rainj);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1496 slarg.function = function;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1497 slarg.retval = Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1498 GCPRO2 (slarg.function, slarg.retval);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1499 map_char_table (ct, &rainj, slow_map_char_table_fun, &slarg);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1500 UNGCPRO;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1501
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1502 return slarg.retval;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1503 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1504
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1505
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1506
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1507 /************************************************************************/
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1508 /* Char table read syntax */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1509 /************************************************************************/
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1510
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1511 static int
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1512 chartab_type_validate (Lisp_Object keyword, Lisp_Object value,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1513 Error_behavior errb)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1514 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1515 /* #### should deal with ERRB */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1516 (void) symbol_to_char_table_type (value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1517 return 1;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1518 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1519
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1520 static int
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1521 chartab_data_validate (Lisp_Object keyword, Lisp_Object value,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1522 Error_behavior errb)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1523 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1524 Lisp_Object rest;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1525
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1526 /* #### should deal with ERRB */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1527 EXTERNAL_LIST_LOOP (rest, value)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1528 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1529 Lisp_Object range = XCAR (rest);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1530 struct chartab_range dummy;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1531
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1532 rest = XCDR (rest);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1533 if (!CONSP (rest))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1534 signal_simple_error ("Invalid list format", value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1535 if (CONSP (range))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1536 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1537 if (!CONSP (XCDR (range))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1538 || !NILP (XCDR (XCDR (range))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1539 signal_simple_error ("Invalid range format", range);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1540 decode_char_table_range (XCAR (range), &dummy);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1541 decode_char_table_range (XCAR (XCDR (range)), &dummy);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1542 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1543 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1544 decode_char_table_range (range, &dummy);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1545 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1546
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1547 return 1;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1548 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1549
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1550 static Lisp_Object
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1551 chartab_instantiate (Lisp_Object data)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1552 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1553 Lisp_Object chartab;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1554 Lisp_Object type = Qgeneric;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1555 Lisp_Object dataval = Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1556
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1557 while (!NILP (data))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1558 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1559 Lisp_Object keyw = Fcar (data);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1560 Lisp_Object valw;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1561
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1562 data = Fcdr (data);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1563 valw = Fcar (data);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1564 data = Fcdr (data);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1565 if (EQ (keyw, Qtype))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1566 type = valw;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1567 else if (EQ (keyw, Qdata))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1568 dataval = valw;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1569 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1570
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1571 chartab = Fmake_char_table (type);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1572
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1573 data = dataval;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1574 while (!NILP (data))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1575 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1576 Lisp_Object range = Fcar (data);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1577 Lisp_Object val = Fcar (Fcdr (data));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1578
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1579 data = Fcdr (Fcdr (data));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1580 if (CONSP (range))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1581 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1582 if (CHAR_OR_CHAR_INTP (XCAR (range)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1583 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1584 Emchar first = XCHAR_OR_CHAR_INT (Fcar (range));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1585 Emchar last = XCHAR_OR_CHAR_INT (Fcar (Fcdr (range)));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1586 Emchar i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1587
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1588 for (i = first; i <= last; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1589 Fput_char_table (make_char (i), val, chartab);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1590 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1591 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1592 abort ();
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1593 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1594 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1595 Fput_char_table (range, val, chartab);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1596 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1597
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1598 return chartab;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1599 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1600
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1601 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1602
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1603
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1604 /************************************************************************/
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1605 /* Category Tables, specifically */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1606 /************************************************************************/
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1607
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1608 DEFUN ("category-table-p", Fcategory_table_p, 1, 1, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1609 Return t if ARG is a category table.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1610 A category table is a type of char table used for keeping track of
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1611 categories. Categories are used for classifying characters for use
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1612 in regexps -- you can refer to a category rather than having to use
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1613 a complicated [] expression (and category lookups are significantly
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1614 faster).
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1615
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1616 There are 95 different categories available, one for each printable
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1617 character (including space) in the ASCII charset. Each category
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1618 is designated by one such character, called a \"category designator\".
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1619 They are specified in a regexp using the syntax \"\\cX\", where X is
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1620 a category designator.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1621
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1622 A category table specifies, for each character, the categories that
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1623 the character is in. Note that a character can be in more than one
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1624 category. More specifically, a category table maps from a character
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1625 to either the value nil (meaning the character is in no categories)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1626 or a 95-element bit vector, specifying for each of the 95 categories
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1627 whether the character is in that category.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1628
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1629 Special Lisp functions are provided that abstract this, so you do not
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1630 have to directly manipulate bit vectors.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1631 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1632 (obj))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1633 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1634 if (CHAR_TABLEP (obj) && XCHAR_TABLE_TYPE (obj) == CHAR_TABLE_TYPE_CATEGORY)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1635 return Qt;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1636 return Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1637 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1638
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1639 static Lisp_Object
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1640 check_category_table (Lisp_Object obj, Lisp_Object def)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1641 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1642 if (NILP (obj))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1643 obj = def;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1644 while (NILP (Fcategory_table_p (obj)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1645 obj = wrong_type_argument (Qcategory_table_p, obj);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1646 return (obj);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1647 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1648
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1649 int
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1650 check_category_char(Emchar ch, Lisp_Object table,
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1651 unsigned int designator, unsigned int not)
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1652 {
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1653 register Lisp_Object temp;
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1654 struct Lisp_Char_Table *ctbl;
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1655 #ifdef ERROR_CHECK_TYPECHECK
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1656 if (NILP (Fcategory_table_p (table)))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1657 signal_simple_error("Expected category table", table);
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1658 #endif
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1659 ctbl = XCHAR_TABLE(table);
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1660 temp = get_char_table(ch, ctbl);
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1661 if (EQ (temp, Qnil)) return not;
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1662
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1663 designator -= ' ';
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1664 return (bit_vector_bit(XBIT_VECTOR (temp), designator) ? !not : not);
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1665 }
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1666
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1667 DEFUN ("check-category-at", Fcheck_category_at, 2, 4, 0, /*
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1668 Return t if category of a character at POS includes DESIGNATOR,
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1669 else return nil. Optional third arg specifies which buffer
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1670 (defaulting to current), and fourth specifies the CATEGORY-TABLE,
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1671 (defaulting to the buffer's category table).
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1672 */
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1673 (pos, designator, buffer, category_table))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1674 {
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1675 Lisp_Object ctbl;
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1676 Emchar ch;
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1677 unsigned int des;
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1678 struct buffer *buf = decode_buffer(buffer, 0);
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1679
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1680 CHECK_INT (pos);
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1681 CHECK_CATEGORY_DESIGNATOR (designator);
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1682 des = XREALINT(designator);
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1683 ctbl = check_category_table (category_table, Vstandard_category_table);
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1684 ch = BUF_FETCH_CHAR (buf, XINT(pos));
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1685 return (check_category_char(ch, ctbl, des, 0)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1686 ? Qt : Qnil);
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1687 }
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1688
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1689 DEFUN ("char-in-category-p", Fchar_in_category_p, 2, 3, 0, /*
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1690 Return t if category of character CHR includes DESIGNATOR, else
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1691 return nil. Optional third arg specifies the CATEGORY-TABLE to use,
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1692
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1693 which defaults to the system default table.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1694 */
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1695 (chr, designator, category_table))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1696 {
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1697 Lisp_Object ctbl;
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1698 Emchar ch;
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1699 unsigned int des;
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1700
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1701 CHECK_CATEGORY_DESIGNATOR (designator);
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1702 des = XREALINT(designator);
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1703 CHECK_CHAR(chr);
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1704 ch = XCHAR(chr);
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1705 ctbl = check_category_table (category_table, Vstandard_category_table);
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1706 return (check_category_char(ch, ctbl, des, 0)
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1707 ? Qt : Qnil);
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1708 }
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1709
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1710 DEFUN ("category-table", Fcategory_table, 0, 1, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1711 Return the current category table.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1712 This is the one specified by the current buffer, or by BUFFER if it
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1713 is non-nil.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1714 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1715 (buffer))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1716 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1717 return decode_buffer (buffer, 0)->category_table;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1718 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1719
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1720 DEFUN ("standard-category-table", Fstandard_category_table, 0, 0, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1721 Return the standard category table.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1722 This is the one used for new buffers.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1723 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1724 ())
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1725 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1726 return Vstandard_category_table;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1727 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1728
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1729 DEFUN ("copy-category-table", Fcopy_category_table, 0, 1, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1730 Construct a new category table and return it.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1731 It is a copy of the TABLE, which defaults to the standard category table.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1732 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1733 (table))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1734 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1735 if (NILP (Vstandard_category_table))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1736 return Fmake_char_table (Qcategory);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1737
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1738 table = check_category_table (table, Vstandard_category_table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1739 return Fcopy_char_table (table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1740 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1741
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1742 DEFUN ("set-category-table", Fset_category_table, 1, 2, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1743 Select a new category table for BUFFER.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1744 One argument, a category table.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1745 BUFFER defaults to the current buffer if omitted.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1746 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1747 (table, buffer))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1748 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1749 struct buffer *buf = decode_buffer (buffer, 0);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1750 table = check_category_table (table, Qnil);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1751 buf->category_table = table;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1752 /* Indicate that this buffer now has a specified category table. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1753 buf->local_var_flags |= XINT (buffer_local_flags.category_table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1754 return table;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1755 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1756
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1757 DEFUN ("category-designator-p", Fcategory_designator_p, 1, 1, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1758 Return t if ARG is a category designator (a char in the range ' ' to '~').
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1759 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1760 (obj))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1761 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1762 if (CATEGORY_DESIGNATORP (obj))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1763 return Qt;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1764 return Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1765 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1766
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1767 DEFUN ("category-table-value-p", Fcategory_table_value_p, 1, 1, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1768 Return t if ARG is a category table value.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1769 Valid values are nil or a bit vector of size 95.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1770 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1771 (obj))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1772 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1773 if (CATEGORY_TABLE_VALUEP (obj))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1774 return Qt;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1775 return Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1776 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1777
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1778 #endif /* MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1779
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1780
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1781 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1782 syms_of_chartab (void)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1783 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1784 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1785 defsymbol (&Qcategory_table_p, "category-table-p");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1786 defsymbol (&Qcategory_designator_p, "category-designator-p");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1787 defsymbol (&Qcategory_table_value_p, "category-table-value-p");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1788 #endif /* MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1789
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1790 defsymbol (&Qchar_table, "char-table");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1791 defsymbol (&Qchar_tablep, "char-table-p");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1792
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1793 DEFSUBR (Fchar_table_p);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1794 DEFSUBR (Fchar_table_type_list);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1795 DEFSUBR (Fvalid_char_table_type_p);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1796 DEFSUBR (Fchar_table_type);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1797 DEFSUBR (Freset_char_table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1798 DEFSUBR (Fmake_char_table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1799 DEFSUBR (Fcopy_char_table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1800 DEFSUBR (Fget_char_table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1801 DEFSUBR (Fget_range_char_table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1802 DEFSUBR (Fvalid_char_table_value_p);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1803 DEFSUBR (Fcheck_valid_char_table_value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1804 DEFSUBR (Fput_char_table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1805 DEFSUBR (Fmap_char_table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1806
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1807 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1808 DEFSUBR (Fcategory_table_p);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1809 DEFSUBR (Fcategory_table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1810 DEFSUBR (Fstandard_category_table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1811 DEFSUBR (Fcopy_category_table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1812 DEFSUBR (Fset_category_table);
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
1813 DEFSUBR (Fcheck_category_at);
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1814 DEFSUBR (Fchar_in_category_p);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1815 DEFSUBR (Fcategory_designator_p);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1816 DEFSUBR (Fcategory_table_value_p);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1817 #endif /* MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1818
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1819 /* DO NOT staticpro this. It works just like Vweak_hash_tables. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1820 Vall_syntax_tables = Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1821 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1822
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1823 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1824 structure_type_create_chartab (void)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1825 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1826 struct structure_type *st;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1827
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1828 st = define_structure_type (Qchar_table, 0, chartab_instantiate);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1829
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1830 define_structure_type_keyword (st, Qtype, chartab_type_validate);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1831 define_structure_type_keyword (st, Qdata, chartab_data_validate);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1832 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1833
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1834 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1835 complex_vars_of_chartab (void)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1836 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1837 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1838 /* Set this now, so first buffer creation can refer to it. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1839 /* Make it nil before calling copy-category-table
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1840 so that copy-category-table will know not to try to copy from garbage */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1841 Vstandard_category_table = Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1842 Vstandard_category_table = Fcopy_category_table (Qnil);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1843 staticpro (&Vstandard_category_table);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1844 #endif /* MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1845 }