annotate src/chartab.c @ 5580:a0e81357194e

Move macros with shadows in bytecomp.el to the end of the files, cl-macs lisp/ChangeLog addition: 2011-10-08 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el: * cl-macs.el (load-time-value): * cl-macs.el (flet): * cl-macs.el (labels): * cl-macs.el (the): * cl-macs.el (declare): Move all these macros to the end of the file, since they're in byte-compile-initial-macro-environment, and we don't want their definitions to override that for the rest of the file during byte-compilation. Happens not to matter right now, but avoids surprises for anyone using the macros elsewhere in cl-macs down the line.
author Aidan Kehoe <kehoea@parhasard.net>
date Sat, 08 Oct 2011 12:26:09 +0100
parents 309e5631e4c8
children 56144c8593a8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* XEmacs routines to deal with char tables.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1992, 1995 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Copyright (C) 1995 Sun Microsystems, Inc.
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
4 Copyright (C) 1995, 1996, 2002, 2003 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 Copyright (C) 1995, 1997, 1999 Electrotechnical Laboratory, JAPAN.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 Licensed to the Free Software Foundation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5259
diff changeset
10 XEmacs is free software: you can redistribute it and/or modify it
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 under the terms of the GNU General Public License as published by the
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5259
diff changeset
12 Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5259
diff changeset
13 option) any later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5259
diff changeset
21 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 /* Synched up with: Mule 2.3. Not synched with FSF.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 This file was written independently of the FSF implementation,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 and is not compatible. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 /* Authorship:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 Ben Wing: wrote, for 19.13 (Mule). Some category table stuff
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 loosely based on the original Mule.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 Jareth Hein: fixed a couple of bugs in the implementation, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 added regex support for categories with check_category_at
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 #include "buffer.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 #include "chartab.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 #include "syntax.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42
5320
31be2a3d121d Move Qcount, Q_default, Q_test to general-slots.h; add SYMBOL_KEYWORD_GENERAL()
Aidan Kehoe <kehoea@parhasard.net>
parents: 5307
diff changeset
43 Lisp_Object Qchar_tablep, Qchar_table;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 Lisp_Object Vall_syntax_tables;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 Lisp_Object Qcategory_table_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 Lisp_Object Qcategory_designator_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 Lisp_Object Qcategory_table_value_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 Lisp_Object Vstandard_category_table;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 /* Variables to determine word boundary. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 Lisp_Object Vword_combining_categories, Vword_separating_categories;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
58 static int check_valid_char_table_value (Lisp_Object value,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
59 enum char_table_type type,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
60 Error_Behavior errb);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
61
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 /* A char table maps from ranges of characters to values.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 Implementing a general data structure that maps from arbitrary
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 ranges of numbers to values is tricky to do efficiently. As it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 happens, it should suffice (and is usually more convenient, anyway)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 when dealing with characters to restrict the sorts of ranges that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 can be assigned values, as follows:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 1) All characters.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 2) All characters in a charset.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 3) All characters in a particular row of a charset, where a "row"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 means all characters with the same first byte.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 4) A particular character in a charset.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 We use char tables to generalize the 256-element vectors now
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 littering the Emacs code.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 Possible uses (all should be converted at some point):
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 1) category tables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 2) syntax tables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 3) display tables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 4) case tables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 5) keyboard-translate-table?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 We provide an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 abstract type to generalize the Emacs vectors and Mule
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 vectors-of-vectors goo.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 /* Char Table object */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96
5560
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
97 static int
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
98 print_preprocess_mapper (struct chartab_range * UNUSED (range),
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
99 Lisp_Object UNUSED (table), Lisp_Object val,
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
100 void *extra_arg)
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
101 {
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
102 print_preprocess (val, ((preprocess_info_t *) extra_arg)->table,
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
103 ((preprocess_info_t *) extra_arg)->count);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
104 return 0;
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
105 }
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
106
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
107 static void
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
108 char_table_print_preprocess (Lisp_Object object, Lisp_Object print_number_table,
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
109 Elemcount *seen_object_count)
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
110 {
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
111 struct chartab_range ctr = { CHARTAB_RANGE_ALL, 0, Qnil, 0 };
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
112 preprocess_info_t preprocess_info = { print_number_table, seen_object_count };
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
113 map_char_table (object, &ctr, print_preprocess_mapper, &preprocess_info);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
114 }
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
115
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
116 static void decode_char_table_range (Lisp_Object range,
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
117 struct chartab_range *outrange);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
118
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
119 static int
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
120 nsubst_structures_mapper (struct chartab_range * range, Lisp_Object table,
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
121 Lisp_Object value, void *extra_arg)
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
122 {
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
123 Lisp_Object number_table
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
124 = ((nsubst_structures_info_t *) extra_arg)->number_table;
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
125 Lisp_Object new_ = ((nsubst_structures_info_t *) extra_arg)->new_;
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
126 Lisp_Object old = ((nsubst_structures_info_t *) extra_arg)->old;
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
127 Boolint test_not_unboundp
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
128 = ((nsubst_structures_info_t *) extra_arg)->test_not_unboundp;
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
129 struct chartab_range changed = { range->type, range->ch, range->charset,
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
130 range->row };
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
131
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
132 switch (range->type)
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
133 {
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
134 case CHARTAB_RANGE_ALL:
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
135 {
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
136 if (EQ (old, Qt) == test_not_unboundp)
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
137 {
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
138 decode_char_table_range (new_, &changed);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
139
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
140 put_char_table (table, range, Qunbound);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
141 put_char_table (table, &changed, value);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
142 }
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
143 break;
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
144 }
5563
309e5631e4c8 Don't use MULE-only cases in non-MULE build.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5560
diff changeset
145 #ifdef MULE
5560
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
146 case CHARTAB_RANGE_CHARSET:
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
147 {
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
148 if (EQ (old, range->charset) == test_not_unboundp)
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
149 {
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
150 CHECK_CHARSET (new_);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
151 changed.charset = new_;
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
152
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
153 put_char_table (table, range, Qunbound);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
154 put_char_table (table, &changed, value);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
155 }
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
156 else assert (!HAS_OBJECT_METH_P (range->charset,
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
157 nsubst_structures_descend));
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
158 break;
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
159 }
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
160 case CHARTAB_RANGE_ROW:
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
161 {
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
162 if (EQ (old, make_int (range->row)) == test_not_unboundp)
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
163 {
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
164 CHECK_INT (new_);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
165 changed.row = XINT (new_);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
166
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
167 put_char_table (table, range, Qunbound);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
168 put_char_table (table, &changed, value);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
169 }
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
170 break;
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
171 }
5563
309e5631e4c8 Don't use MULE-only cases in non-MULE build.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5560
diff changeset
172 #endif
5560
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
173 case CHARTAB_RANGE_CHAR:
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
174 {
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
175 if (EQ (old, make_char (range->ch)) == test_not_unboundp)
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
176 {
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
177 CHECK_CHAR (new_);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
178 changed.ch = XCHAR (new_);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
179
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
180 put_char_table (table, range, Qunbound);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
181 put_char_table (table, &changed, value);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
182 }
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
183 break;
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
184 }
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
185 }
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
186
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
187 if (EQ (old, value) == test_not_unboundp)
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
188 {
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
189 put_char_table (table, &changed, new_);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
190 }
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
191 else if (LRECORDP (value) &&
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
192 HAS_OBJECT_METH_P (value, nsubst_structures_descend))
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
193 {
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
194 nsubst_structures_descend (new_, old, value, number_table,
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
195 test_not_unboundp);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
196 }
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
197
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
198 return 0;
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
199 }
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
200
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
201 static void
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
202 char_table_nsubst_structures_descend (Lisp_Object new_, Lisp_Object old,
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
203 Lisp_Object object,
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
204 Lisp_Object number_table,
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
205 Boolint test_not_unboundp)
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
206 {
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
207 struct chartab_range ctr = { CHARTAB_RANGE_ALL, 0, Qnil, 0 };
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
208 nsubst_structures_info_t nsubst_structures_info
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
209 = { number_table, new_, old, object, test_not_unboundp };
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
210
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
211 map_char_table (object, &ctr, nsubst_structures_mapper,
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
212 &nsubst_structures_info);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
213 }
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
214
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 mark_char_table_entry (Lisp_Object obj)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
220 Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 for (i = 0; i < 96; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 mark_object (cte->level2[i]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 static int
4906
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4580
diff changeset
231 char_table_entry_equal (Lisp_Object obj1, Lisp_Object obj2, int depth,
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4580
diff changeset
232 int foldcase)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
234 Lisp_Char_Table_Entry *cte1 = XCHAR_TABLE_ENTRY (obj1);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
235 Lisp_Char_Table_Entry *cte2 = XCHAR_TABLE_ENTRY (obj2);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 for (i = 0; i < 96; i++)
4906
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4580
diff changeset
239 if (!internal_equal_0 (cte1->level2[i], cte2->level2[i], depth + 1,
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4580
diff changeset
240 foldcase))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
246 static Hashcode
5191
71ee43b8a74d Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents: 5127
diff changeset
247 char_table_entry_hash (Lisp_Object obj, int depth, Boolint equalp)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
249 Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250
5191
71ee43b8a74d Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents: 5127
diff changeset
251 return internal_array_hash (cte->level2, 96, depth + 1, equalp);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 934
diff changeset
254 static const struct memory_description char_table_entry_description[] = {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
255 { XD_LISP_OBJECT_ARRAY, offsetof (Lisp_Char_Table_Entry, level2), 96 },
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 { XD_END }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258
5118
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 4580
diff changeset
259 DEFINE_DUMPABLE_LISP_OBJECT ("char-table-entry", char_table_entry,
5124
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5120
diff changeset
260 mark_char_table_entry, internal_object_printer,
5118
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 4580
diff changeset
261 0, char_table_entry_equal,
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 4580
diff changeset
262 char_table_entry_hash,
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 4580
diff changeset
263 char_table_entry_description,
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 4580
diff changeset
264 Lisp_Char_Table_Entry);
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 867
diff changeset
265
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 mark_char_table (Lisp_Object obj)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
271 Lisp_Char_Table *ct = XCHAR_TABLE (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 for (i = 0; i < NUM_ASCII_CHARS; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 mark_object (ct->ascii[i]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 for (i = 0; i < NUM_LEADING_BYTES; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 mark_object (ct->level1[i]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 #endif
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 788
diff changeset
280 mark_object (ct->parent);
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 788
diff changeset
281 mark_object (ct->default_);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 return ct->mirror_table;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 /* WARNING: All functions of this nature need to be written extremely
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 carefully to avoid crashes during GC. Cf. prune_specifiers()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 and prune_weak_hash_tables(). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 prune_syntax_tables (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 Lisp_Object rest, prev = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 for (rest = Vall_syntax_tables;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 !NILP (rest);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 rest = XCHAR_TABLE (rest)->next_table)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 if (! marked_p (rest))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 /* This table is garbage. Remove it from the list. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 if (NILP (prev))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 Vall_syntax_tables = XCHAR_TABLE (rest)->next_table;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 XCHAR_TABLE (prev)->next_table =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 XCHAR_TABLE (rest)->next_table;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 char_table_type_to_symbol (enum char_table_type type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 switch (type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 {
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2367
diff changeset
315 default: ABORT();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 case CHAR_TABLE_TYPE_GENERIC: return Qgeneric;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 case CHAR_TABLE_TYPE_SYNTAX: return Qsyntax;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 case CHAR_TABLE_TYPE_DISPLAY: return Qdisplay;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 case CHAR_TABLE_TYPE_CHAR: return Qchar;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 case CHAR_TABLE_TYPE_CATEGORY: return Qcategory;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 static enum char_table_type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 symbol_to_char_table_type (Lisp_Object symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 CHECK_SYMBOL (symbol);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 if (EQ (symbol, Qgeneric)) return CHAR_TABLE_TYPE_GENERIC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 if (EQ (symbol, Qsyntax)) return CHAR_TABLE_TYPE_SYNTAX;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 if (EQ (symbol, Qdisplay)) return CHAR_TABLE_TYPE_DISPLAY;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 if (EQ (symbol, Qchar)) return CHAR_TABLE_TYPE_CHAR;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 if (EQ (symbol, Qcategory)) return CHAR_TABLE_TYPE_CATEGORY;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
339 invalid_constant ("Unrecognized char table type", symbol);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 934
diff changeset
340 RETURN_NOT_REACHED (CHAR_TABLE_TYPE_GENERIC);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 static void
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
344 decode_char_table_range (Lisp_Object range, struct chartab_range *outrange)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 {
4932
8b63e21b0436 fix compile issues with gcc 4
Ben Wing <ben@xemacs.org>
parents: 4580
diff changeset
346 xzero (*outrange);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
347 if (EQ (range, Qt))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
348 outrange->type = CHARTAB_RANGE_ALL;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
349 else if (CHAR_OR_CHAR_INTP (range))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
350 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
351 outrange->type = CHARTAB_RANGE_CHAR;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
352 outrange->ch = XCHAR_OR_CHAR_INT (range);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
353 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
354 #ifndef MULE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 else
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
356 sferror ("Range must be t or a character", range);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
357 #else /* MULE */
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
358 else if (VECTORP (range))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
359 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
360 Lisp_Vector *vec = XVECTOR (range);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
361 Lisp_Object *elts = vector_data (vec);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
362 if (vector_length (vec) != 2)
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
363 sferror ("Length of charset row vector must be 2",
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
364 range);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
365 outrange->type = CHARTAB_RANGE_ROW;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
366 outrange->charset = Fget_charset (elts[0]);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
367 CHECK_INT (elts[1]);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
368 outrange->row = XINT (elts[1]);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
369 switch (XCHARSET_TYPE (outrange->charset))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
370 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
371 case CHARSET_TYPE_94:
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
372 case CHARSET_TYPE_96:
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
373 sferror ("Charset in row vector must be multi-byte",
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
374 outrange->charset);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
375 case CHARSET_TYPE_94X94:
5307
c096d8051f89 Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5259
diff changeset
376 check_integer_range (make_int (outrange->row), make_int (33),
c096d8051f89 Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5259
diff changeset
377 make_int (126));
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
378 break;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
379 case CHARSET_TYPE_96X96:
5307
c096d8051f89 Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5259
diff changeset
380 check_integer_range (make_int (outrange->row), make_int (32),
c096d8051f89 Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5259
diff changeset
381 make_int (127));
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
382 break;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
383 default:
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2367
diff changeset
384 ABORT ();
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
385 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
386 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
387 else
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
388 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
389 if (!CHARSETP (range) && !SYMBOLP (range))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
390 sferror
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
391 ("Char table range must be t, charset, char, or vector", range);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
392 outrange->type = CHARTAB_RANGE_CHARSET;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
393 outrange->charset = Fget_charset (range);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
394 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
395 #endif /* MULE */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
398 static Lisp_Object
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
399 encode_char_table_range (struct chartab_range *range)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
401 switch (range->type)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
403 case CHARTAB_RANGE_ALL:
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
404 return Qt;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
405
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
406 #ifdef MULE
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
407 case CHARTAB_RANGE_CHARSET:
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
408 return XCHARSET_NAME (Fget_charset (range->charset));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
410 case CHARTAB_RANGE_ROW:
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
411 return vector2 (XCHARSET_NAME (Fget_charset (range->charset)),
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
412 make_int (range->row));
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
413 #endif
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
414 case CHARTAB_RANGE_CHAR:
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
415 return make_char (range->ch);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
416 default:
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2367
diff changeset
417 ABORT ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 }
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
419 return Qnil; /* not reached */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421
5259
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
422 static Lisp_Object
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
423 char_table_default_for_type (enum char_table_type type)
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
424 {
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
425 switch (type)
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
426 {
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
427 case CHAR_TABLE_TYPE_CHAR:
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
428 return make_char (0);
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
429 break;
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
430 case CHAR_TABLE_TYPE_DISPLAY:
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
431 case CHAR_TABLE_TYPE_GENERIC:
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
432 #ifdef MULE
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
433 case CHAR_TABLE_TYPE_CATEGORY:
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
434 #endif /* MULE */
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
435 return Qnil;
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
436 break;
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
437
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
438 case CHAR_TABLE_TYPE_SYNTAX:
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
439 return make_integer (Sinherit);
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
440 break;
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
441 }
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
442 ABORT();
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
443 return Qzero;
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
444 }
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
445
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
446 struct ptemap
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
448 Lisp_Object printcharfun;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
449 int first;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
450 };
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
452 static int
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1330
diff changeset
453 print_table_entry (struct chartab_range *range, Lisp_Object UNUSED (table),
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
454 Lisp_Object val, void *arg)
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
455 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
456 struct ptemap *a = (struct ptemap *) arg;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
457 struct gcpro gcpro1;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
458 Lisp_Object lisprange;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
459 if (!a->first)
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
460 write_ascstring (a->printcharfun, " ");
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
461 a->first = 0;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
462 lisprange = encode_char_table_range (range);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
463 GCPRO1 (lisprange);
4580
1d11ecca9cd0 Print char table values correctly.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4469
diff changeset
464 write_fmt_string_lisp (a->printcharfun, "%s %S", 2, lisprange, val);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
465 UNGCPRO;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
466 return 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1330
diff changeset
470 print_char_table (Lisp_Object obj, Lisp_Object printcharfun,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1330
diff changeset
471 int UNUSED (escapeflag))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
473 Lisp_Char_Table *ct = XCHAR_TABLE (obj);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
474 struct chartab_range range;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
475 struct ptemap arg;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
476
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
477 range.type = CHARTAB_RANGE_ALL;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
478 arg.printcharfun = printcharfun;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
479 arg.first = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480
5259
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
481 write_fmt_string_lisp (printcharfun,
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
482 "#s(char-table :type %s", 1,
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
483 char_table_type_to_symbol (ct->type));
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
484 if (!(EQ (ct->default_, char_table_default_for_type (ct->type))))
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
485 {
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
486 write_fmt_string_lisp (printcharfun, " :default %S", 1, ct->default_);
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
487 }
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
488
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
489 write_ascstring (printcharfun, " :data (");
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
490 map_char_table (obj, &range, print_table_entry, &arg);
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
491 write_ascstring (printcharfun, "))");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
493 /* #### need to print and read the default; but that will allow the
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
494 default to be modified, which we don't (yet) support -- but FSF does */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 static int
4906
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4580
diff changeset
498 char_table_equal (Lisp_Object obj1, Lisp_Object obj2, int depth, int foldcase)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
500 Lisp_Char_Table *ct1 = XCHAR_TABLE (obj1);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
501 Lisp_Char_Table *ct2 = XCHAR_TABLE (obj2);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 if (CHAR_TABLE_TYPE (ct1) != CHAR_TABLE_TYPE (ct2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 for (i = 0; i < NUM_ASCII_CHARS; i++)
4906
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4580
diff changeset
508 if (!internal_equal_0 (ct1->ascii[i], ct2->ascii[i], depth + 1, foldcase))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 for (i = 0; i < NUM_LEADING_BYTES; i++)
4906
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4580
diff changeset
513 if (!internal_equal_0 (ct1->level1[i], ct2->level1[i], depth + 1, foldcase))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516
4906
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4580
diff changeset
517 return internal_equal_0 (ct1->default_, ct2->default_, depth + 1, foldcase);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
520 static Hashcode
5191
71ee43b8a74d Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents: 5127
diff changeset
521 char_table_hash (Lisp_Object obj, int depth, Boolint equalp)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
523 Lisp_Char_Table *ct = XCHAR_TABLE (obj);
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
524 Hashcode hashval = internal_array_hash (ct->ascii, NUM_ASCII_CHARS,
5191
71ee43b8a74d Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents: 5127
diff changeset
525 depth + 1, equalp);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 hashval = HASH2 (hashval,
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
528 internal_array_hash (ct->level1, NUM_LEADING_BYTES,
5191
71ee43b8a74d Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents: 5127
diff changeset
529 depth + 1, equalp));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 #endif /* MULE */
5191
71ee43b8a74d Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents: 5127
diff changeset
531 return HASH2 (hashval, internal_hash (ct->default_, depth + 1, equalp));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 934
diff changeset
534 static const struct memory_description char_table_description[] = {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
535 { XD_LISP_OBJECT_ARRAY, offsetof (Lisp_Char_Table, ascii), NUM_ASCII_CHARS },
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 #ifdef MULE
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
537 { XD_LISP_OBJECT_ARRAY, offsetof (Lisp_Char_Table, level1), NUM_LEADING_BYTES },
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 #endif
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 788
diff changeset
539 { XD_LISP_OBJECT, offsetof (Lisp_Char_Table, parent) },
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 788
diff changeset
540 { XD_LISP_OBJECT, offsetof (Lisp_Char_Table, default_) },
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
541 { XD_LISP_OBJECT, offsetof (Lisp_Char_Table, mirror_table) },
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
542 { XD_LO_LINK, offsetof (Lisp_Char_Table, next_table) },
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 { XD_END }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545
5118
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 4580
diff changeset
546 DEFINE_DUMPABLE_LISP_OBJECT ("char-table", char_table,
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 4580
diff changeset
547 mark_char_table, print_char_table, 0,
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 4580
diff changeset
548 char_table_equal, char_table_hash,
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 4580
diff changeset
549 char_table_description,
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 4580
diff changeset
550 Lisp_Char_Table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 DEFUN ("char-table-p", Fchar_table_p, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 Return non-nil if OBJECT is a char table.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 (object))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 return CHAR_TABLEP (object) ? Qt : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 DEFUN ("char-table-type-list", Fchar_table_type_list, 0, 0, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 Return a list of the recognized char table types.
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
562 See `make-char-table'.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 ())
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 return list5 (Qchar, Qcategory, Qdisplay, Qgeneric, Qsyntax);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 return list4 (Qchar, Qdisplay, Qgeneric, Qsyntax);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 DEFUN ("valid-char-table-type-p", Fvalid_char_table_type_p, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 Return t if TYPE if a recognized char table type.
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
575 See `make-char-table'.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 (type))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 return (EQ (type, Qchar) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 EQ (type, Qcategory) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 EQ (type, Qdisplay) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 EQ (type, Qgeneric) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 EQ (type, Qsyntax)) ? Qt : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 DEFUN ("char-table-type", Fchar_table_type, 1, 1, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
589 Return the type of CHAR-TABLE.
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
590 See `make-char-table'.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
592 (char_table))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
594 CHECK_CHAR_TABLE (char_table);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
595 return char_table_type_to_symbol (XCHAR_TABLE (char_table)->type);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
598 static void
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
599 set_char_table_dirty (Lisp_Object table)
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
600 {
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
601 assert (!XCHAR_TABLE (table)->mirror_table_p);
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
602 XCHAR_TABLE (XCHAR_TABLE (table)->mirror_table)->dirty = 1;
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
603 }
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
604
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 void
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
606 set_char_table_default (Lisp_Object table, Lisp_Object value)
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
607 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
608 Lisp_Char_Table *ct = XCHAR_TABLE (table);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
609 ct->default_ = value;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
610 if (ct->type == CHAR_TABLE_TYPE_SYNTAX)
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
611 set_char_table_dirty (table);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
612 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
613
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
614 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
615 fill_char_table (Lisp_Char_Table *ct, Lisp_Object value)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 for (i = 0; i < NUM_ASCII_CHARS; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 ct->ascii[i] = value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 for (i = 0; i < NUM_LEADING_BYTES; i++)
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
623 {
1330
4542b72c005e [xemacs-hg @ 2003-03-01 07:25:26 by ben]
ben
parents: 1296
diff changeset
624 /* Don't get stymied when initting the table, or when trying to
4542b72c005e [xemacs-hg @ 2003-03-01 07:25:26 by ben]
ben
parents: 1296
diff changeset
625 free a pdump object. */
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
626 if (!EQ (ct->level1[i], Qnull_pointer) &&
1330
4542b72c005e [xemacs-hg @ 2003-03-01 07:25:26 by ben]
ben
parents: 1296
diff changeset
627 CHAR_TABLE_ENTRYP (ct->level1[i]) &&
4542b72c005e [xemacs-hg @ 2003-03-01 07:25:26 by ben]
ben
parents: 1296
diff changeset
628 !OBJECT_DUMPED_P (ct->level1[1]))
5127
a9c41067dd88 more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents: 5125
diff changeset
629 free_normal_lisp_object (ct->level1[i]);
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
630 ct->level1[i] = value;
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
631 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 if (ct->type == CHAR_TABLE_TYPE_SYNTAX)
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
635 set_char_table_dirty (wrap_char_table (ct));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 DEFUN ("reset-char-table", Freset_char_table, 1, 1, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
639 Reset CHAR-TABLE to its default state.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
641 (char_table))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
643 Lisp_Char_Table *ct;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
645 CHECK_CHAR_TABLE (char_table);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
646 ct = XCHAR_TABLE (char_table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
648 /* Avoid doubly updating the syntax table by setting the default ourselves,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
649 since set_char_table_default() also updates. */
5259
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
650 ct->default_ = char_table_default_for_type (ct->type);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
651 fill_char_table (ct, Qunbound);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
652
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 DEFUN ("make-char-table", Fmake_char_table, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 Return a new, empty char table of type TYPE.
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
658
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
659 A char table is a table that maps characters (or ranges of characters)
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
660 to values. Char tables are specialized for characters, only allowing
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
661 particular sorts of ranges to be assigned values. Although this
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
662 loses in generality, it makes for extremely fast (constant-time)
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
663 lookups, and thus is feasible for applications that do an extremely
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
664 large number of lookups (e.g. scanning a buffer for a character in
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
665 a particular syntax, where a lookup in the syntax table must occur
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
666 once per character).
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
667
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
668 When Mule support exists, the types of ranges that can be assigned
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
669 values are
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
670
2714
2eed1f34d39d [xemacs-hg @ 2005-04-06 03:47:16 by stephent]
stephent
parents: 2500
diff changeset
671 -- all characters (represented by t)
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
672 -- an entire charset
2714
2eed1f34d39d [xemacs-hg @ 2005-04-06 03:47:16 by stephent]
stephent
parents: 2500
diff changeset
673 -- a single row in a two-octet charset (represented by a vector of two
2eed1f34d39d [xemacs-hg @ 2005-04-06 03:47:16 by stephent]
stephent
parents: 2500
diff changeset
674 elements: a two-octet charset and a row number; the row must be an
2eed1f34d39d [xemacs-hg @ 2005-04-06 03:47:16 by stephent]
stephent
parents: 2500
diff changeset
675 integer, not a character)
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
676 -- a single character
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
677
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
678 When Mule support is not present, the types of ranges that can be
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
679 assigned values are
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
680
2714
2eed1f34d39d [xemacs-hg @ 2005-04-06 03:47:16 by stephent]
stephent
parents: 2500
diff changeset
681 -- all characters (represented by t)
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
682 -- a single character
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
683
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
684 To create a char table, use `make-char-table'.
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
685 To modify a char table, use `put-char-table' or `remove-char-table'.
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
686 To retrieve the value for a particular character, use `get-char-table'.
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
687 See also `map-char-table', `reset-char-table', `copy-char-table',
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
688 `char-table-p', `valid-char-table-type-p', `char-table-type-list',
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
689 `valid-char-table-value-p', and `check-char-table-value'.
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
690
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
691 Each char table type is used for a different purpose and allows different
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
692 sorts of values. The different char table types are
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
693
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
694 `category'
4469
c661944aa259 Fill out docstrings for #'translate-region, #'make-char-table.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3881
diff changeset
695 Used for category tables, which specify the regexp categories that a
c661944aa259 Fill out docstrings for #'translate-region, #'make-char-table.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3881
diff changeset
696 character is in. The valid values are nil or a bit vector of 95
c661944aa259 Fill out docstrings for #'translate-region, #'make-char-table.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3881
diff changeset
697 elements, and values default to nil. Higher-level Lisp functions
c661944aa259 Fill out docstrings for #'translate-region, #'make-char-table.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3881
diff changeset
698 are provided for working with category tables. Currently categories
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
699 and category tables only exist when Mule support is present.
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
700 `char'
4469
c661944aa259 Fill out docstrings for #'translate-region, #'make-char-table.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3881
diff changeset
701 A generalized char table, for mapping from one character to another.
c661944aa259 Fill out docstrings for #'translate-region, #'make-char-table.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3881
diff changeset
702 Used for case tables, syntax matching tables,
c661944aa259 Fill out docstrings for #'translate-region, #'make-char-table.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3881
diff changeset
703 `keyboard-translate-table', etc. The valid values are characters,
c661944aa259 Fill out docstrings for #'translate-region, #'make-char-table.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3881
diff changeset
704 and the default result given by `get-char-table' if a value hasn't
c661944aa259 Fill out docstrings for #'translate-region, #'make-char-table.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3881
diff changeset
705 been set for a given character or for a range that includes it, is
c661944aa259 Fill out docstrings for #'translate-region, #'make-char-table.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3881
diff changeset
706 ?\x00.
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
707 `generic'
4469
c661944aa259 Fill out docstrings for #'translate-region, #'make-char-table.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3881
diff changeset
708 An even more generalized char table, for mapping from a character to
c661944aa259 Fill out docstrings for #'translate-region, #'make-char-table.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3881
diff changeset
709 anything. The default result given by `get-char-table' is nil.
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
710 `display'
4469
c661944aa259 Fill out docstrings for #'translate-region, #'make-char-table.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3881
diff changeset
711 Used for display tables, which specify how a particular character is
c661944aa259 Fill out docstrings for #'translate-region, #'make-char-table.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3881
diff changeset
712 to appear when displayed. #### Not yet implemented; currently, the
c661944aa259 Fill out docstrings for #'translate-region, #'make-char-table.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3881
diff changeset
713 display table code uses generic char tables, and it's not clear that
c661944aa259 Fill out docstrings for #'translate-region, #'make-char-table.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3881
diff changeset
714 implementing this char table type would be useful.
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
715 `syntax'
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
716 Used for syntax tables, which specify the syntax of a particular
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
717 character. Higher-level Lisp functions are provided for
4469
c661944aa259 Fill out docstrings for #'translate-region, #'make-char-table.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3881
diff changeset
718 working with syntax tables. The valid values are integers, and the
c661944aa259 Fill out docstrings for #'translate-region, #'make-char-table.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3881
diff changeset
719 default result given by `get-char-table' is the syntax code for
c661944aa259 Fill out docstrings for #'translate-region, #'make-char-table.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3881
diff changeset
720 `inherit'.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 (type))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 {
5127
a9c41067dd88 more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents: 5125
diff changeset
724 Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (char_table);
5117
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3025
diff changeset
725 Lisp_Char_Table *ct = XCHAR_TABLE (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 enum char_table_type ty = symbol_to_char_table_type (type);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 ct->type = ty;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 if (ty == CHAR_TABLE_TYPE_SYNTAX)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
731 /* Qgeneric not Qsyntax because a syntax table has a mirror table
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
732 and we don't want infinite recursion */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 ct->mirror_table = Fmake_char_table (Qgeneric);
3145
d830788d6a2c [xemacs-hg @ 2005-12-18 10:59:12 by aidan]
aidan
parents: 3025
diff changeset
734 set_char_table_default (ct->mirror_table, make_int (Sword));
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
735 XCHAR_TABLE (ct->mirror_table)->mirror_table_p = 1;
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
736 XCHAR_TABLE (ct->mirror_table)->mirror_table = obj;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 ct->mirror_table = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 ct->next_table = Qnil;
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 788
diff changeset
741 ct->parent = Qnil;
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 788
diff changeset
742 ct->default_ = Qnil;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 if (ty == CHAR_TABLE_TYPE_SYNTAX)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 ct->next_table = Vall_syntax_tables;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 Vall_syntax_tables = obj;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 Freset_char_table (obj);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 return obj;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 make_char_table_entry (Lisp_Object initval)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 int i;
5127
a9c41067dd88 more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents: 5125
diff changeset
758 Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (char_table_entry);
5117
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3025
diff changeset
759 Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 for (i = 0; i < 96; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 cte->level2[i] = initval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763
5117
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3025
diff changeset
764 return obj;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 copy_char_table_entry (Lisp_Object entry)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
770 Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (entry);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 int i;
5127
a9c41067dd88 more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents: 5125
diff changeset
772 Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (char_table_entry);
5117
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3025
diff changeset
773 Lisp_Char_Table_Entry *ctenew = XCHAR_TABLE_ENTRY (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 for (i = 0; i < 96; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 {
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 3017
diff changeset
777 Lisp_Object new_ = cte->level2[i];
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 3017
diff changeset
778 if (CHAR_TABLE_ENTRYP (new_))
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 3017
diff changeset
779 ctenew->level2[i] = copy_char_table_entry (new_);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 else
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 3017
diff changeset
781 ctenew->level2[i] = new_;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783
5117
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3025
diff changeset
784 return obj;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 DEFUN ("copy-char-table", Fcopy_char_table, 1, 1, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
790 Return a new char table which is a copy of CHAR-TABLE.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 It will contain the same values for the same characters and ranges
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
792 as CHAR-TABLE. The values will not themselves be copied.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
794 (char_table))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
796 Lisp_Char_Table *ct, *ctnew;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 Lisp_Object obj;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
800 CHECK_CHAR_TABLE (char_table);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
801 ct = XCHAR_TABLE (char_table);
3879
f73b455b1472 [xemacs-hg @ 2007-03-25 15:34:59 by stephent]
stephent
parents: 3145
diff changeset
802 assert(!ct->mirror_table_p);
5127
a9c41067dd88 more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents: 5125
diff changeset
803 obj = ALLOC_NORMAL_LISP_OBJECT (char_table);
5117
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3025
diff changeset
804 ctnew = XCHAR_TABLE (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 ctnew->type = ct->type;
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 788
diff changeset
806 ctnew->parent = ct->parent;
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 788
diff changeset
807 ctnew->default_ = ct->default_;
3879
f73b455b1472 [xemacs-hg @ 2007-03-25 15:34:59 by stephent]
stephent
parents: 3145
diff changeset
808 ctnew->mirror_table_p = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 for (i = 0; i < NUM_ASCII_CHARS; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 {
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 3017
diff changeset
812 Lisp_Object new_ = ct->ascii[i];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 #ifdef MULE
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 3017
diff changeset
814 assert (! (CHAR_TABLE_ENTRYP (new_)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 #endif /* MULE */
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 3017
diff changeset
816 ctnew->ascii[i] = new_;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 for (i = 0; i < NUM_LEADING_BYTES; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 {
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 3017
diff changeset
823 Lisp_Object new_ = ct->level1[i];
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 3017
diff changeset
824 if (CHAR_TABLE_ENTRYP (new_))
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 3017
diff changeset
825 ctnew->level1[i] = copy_char_table_entry (new_);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 else
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 3017
diff changeset
827 ctnew->level1[i] = new_;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831
3881
1b6a5c6e012d [xemacs-hg @ 2007-03-25 17:05:51 by stephent]
stephent
parents: 3879
diff changeset
832 if (!EQ (ct->mirror_table, Qnil))
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
833 {
3879
f73b455b1472 [xemacs-hg @ 2007-03-25 15:34:59 by stephent]
stephent
parents: 3145
diff changeset
834 ctnew->mirror_table = Fmake_char_table (Qgeneric);
f73b455b1472 [xemacs-hg @ 2007-03-25 15:34:59 by stephent]
stephent
parents: 3145
diff changeset
835 set_char_table_default (ctnew->mirror_table, make_int (Sword));
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
836 XCHAR_TABLE (ctnew->mirror_table)->mirror_table = obj;
3879
f73b455b1472 [xemacs-hg @ 2007-03-25 15:34:59 by stephent]
stephent
parents: 3145
diff changeset
837 XCHAR_TABLE (ctnew->mirror_table)->mirror_table_p = 1;
f73b455b1472 [xemacs-hg @ 2007-03-25 15:34:59 by stephent]
stephent
parents: 3145
diff changeset
838 XCHAR_TABLE (ctnew->mirror_table)->dirty = 1;
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
839 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 else
3879
f73b455b1472 [xemacs-hg @ 2007-03-25 15:34:59 by stephent]
stephent
parents: 3145
diff changeset
841 ctnew->mirror_table = Qnil;
f73b455b1472 [xemacs-hg @ 2007-03-25 15:34:59 by stephent]
stephent
parents: 3145
diff changeset
842
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 ctnew->next_table = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 if (ctnew->type == CHAR_TABLE_TYPE_SYNTAX)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 ctnew->next_table = Vall_syntax_tables;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 Vall_syntax_tables = obj;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 return obj;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
854 /* called from get_char_table(). */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 Lisp_Object
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
856 get_non_ascii_char_table_value (Lisp_Char_Table *ct, int leading_byte,
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
857 Ichar c)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 Lisp_Object val;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
860 Lisp_Object charset = charset_by_leading_byte (leading_byte);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 int byte1, byte2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
863 BREAKUP_ICHAR_1_UNSAFE (c, charset, byte1, byte2);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 val = ct->level1[leading_byte - MIN_LEADING_BYTE];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 if (CHAR_TABLE_ENTRYP (val))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
867 Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (val);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 val = cte->level2[byte1 - 32];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 if (CHAR_TABLE_ENTRYP (val))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 cte = XCHAR_TABLE_ENTRY (val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 assert (byte2 >= 32);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 val = cte->level2[byte2 - 32];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 assert (!CHAR_TABLE_ENTRYP (val));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 return val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
883 DEFUN ("char-table-default", Fchar_table_default, 1, 1, 0, /*
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
884 Return the default value for CHAR-TABLE. When an entry for a character
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
885 does not exist, the default is returned.
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
886 */
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
887 (char_table))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
889 CHECK_CHAR_TABLE (char_table);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
890 return XCHAR_TABLE (char_table)->default_;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
893 DEFUN ("set-char-table-default", Fset_char_table_default, 2, 2, 0, /*
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
894 Set the default value for CHAR-TABLE to DEFAULT.
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
895 Currently, the default value for syntax tables cannot be changed.
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
896 (This policy might change in the future.)
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
897 */
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
898 (char_table, default_))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
899 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
900 CHECK_CHAR_TABLE (char_table);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
901 if (XCHAR_TABLE_TYPE (char_table) == CHAR_TABLE_TYPE_SYNTAX)
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
902 invalid_change ("Can't change default for syntax tables", char_table);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
903 check_valid_char_table_value (default_, XCHAR_TABLE_TYPE (char_table),
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
904 ERROR_ME);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
905 set_char_table_default (char_table, default_);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
906 return Qnil;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
907 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 DEFUN ("get-char-table", Fget_char_table, 2, 2, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
910 Find value for CHARACTER in CHAR-TABLE.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
912 (character, char_table))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
914 CHECK_CHAR_TABLE (char_table);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
915 CHECK_CHAR_COERCE_INT (character);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
917 return get_char_table (XCHAR (character), char_table);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
918 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
919
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
920 static int
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1330
diff changeset
921 copy_mapper (struct chartab_range *range, Lisp_Object UNUSED (table),
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
922 Lisp_Object val, void *arg)
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
923 {
5013
ae48681c47fa changes to VOID_TO_LISP et al.
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
924 put_char_table (GET_LISP_FROM_VOID (arg), range, val);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
925 return 0;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
926 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
927
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
928 void
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
929 copy_char_table_range (Lisp_Object from, Lisp_Object to,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
930 struct chartab_range *range)
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
931 {
5013
ae48681c47fa changes to VOID_TO_LISP et al.
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
932 map_char_table (from, range, copy_mapper, STORE_LISP_IN_VOID (to));
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
933 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
934
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
935 static Lisp_Object
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
936 get_range_char_table_1 (struct chartab_range *range, Lisp_Object table,
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
937 Lisp_Object multi)
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
938 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
939 Lisp_Char_Table *ct = XCHAR_TABLE (table);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
940 Lisp_Object retval = Qnil;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
941
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
942 switch (range->type)
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
943 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
944 case CHARTAB_RANGE_CHAR:
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
945 return get_char_table (range->ch, table);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
946
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
947 case CHARTAB_RANGE_ALL:
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
948 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
949 int i;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
950 retval = ct->ascii[0];
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
951
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
952 for (i = 1; i < NUM_ASCII_CHARS; i++)
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
953 if (!EQ (retval, ct->ascii[i]))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
954 return multi;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
955
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
956 #ifdef MULE
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
957 for (i = MIN_LEADING_BYTE; i < MIN_LEADING_BYTE + NUM_LEADING_BYTES;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
958 i++)
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
959 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
960 if (!CHARSETP (charset_by_leading_byte (i))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
961 || i == LEADING_BYTE_ASCII
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
962 || i == LEADING_BYTE_CONTROL_1)
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
963 continue;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
964 if (!EQ (retval, ct->level1[i - MIN_LEADING_BYTE]))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
965 return multi;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
966 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
967 #endif /* MULE */
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
968
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
969 break;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
970 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
971
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
972 #ifdef MULE
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
973 case CHARTAB_RANGE_CHARSET:
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
974 if (EQ (range->charset, Vcharset_ascii))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
975 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
976 int i;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
977 retval = ct->ascii[0];
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
978
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
979 for (i = 1; i < 128; i++)
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
980 if (!EQ (retval, ct->ascii[i]))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
981 return multi;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
982 break;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
983 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
984
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
985 if (EQ (range->charset, Vcharset_control_1))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
986 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
987 int i;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
988 retval = ct->ascii[128];
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
989
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
990 for (i = 129; i < 160; i++)
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
991 if (!EQ (retval, ct->ascii[i]))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
992 return multi;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
993 break;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
994 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
995
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
996 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
997 retval = ct->level1[XCHARSET_LEADING_BYTE (range->charset) -
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
998 MIN_LEADING_BYTE];
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
999 if (CHAR_TABLE_ENTRYP (retval))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1000 return multi;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1001 break;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1002 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1003
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1004 case CHARTAB_RANGE_ROW:
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1005 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1006 retval = ct->level1[XCHARSET_LEADING_BYTE (range->charset) -
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1007 MIN_LEADING_BYTE];
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1008 if (!CHAR_TABLE_ENTRYP (retval))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1009 break;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1010 retval = XCHAR_TABLE_ENTRY (retval)->level2[range->row - 32];
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1011 if (CHAR_TABLE_ENTRYP (retval))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1012 return multi;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1013 break;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1014 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1015 #endif /* not MULE */
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1016
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1017 default:
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2367
diff changeset
1018 ABORT ();
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1019 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1020
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1021 if (UNBOUNDP (retval))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1022 return ct->default_;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1023 return retval;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1026 Lisp_Object
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1027 get_range_char_table (struct chartab_range *range, Lisp_Object table,
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1028 Lisp_Object multi)
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1029 {
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1030 if (range->type == CHARTAB_RANGE_CHAR)
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1031 return get_char_table (range->ch, table);
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1032 else
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1033 return get_range_char_table_1 (range, table, multi);
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1034 }
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1035
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1036 #ifdef ERROR_CHECK_TYPES
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1037
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1038 /* Only exists so as not to trip an assert in get_char_table(). */
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1039 Lisp_Object
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1040 updating_mirror_get_range_char_table (struct chartab_range *range,
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1041 Lisp_Object table,
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1042 Lisp_Object multi)
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1043 {
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1044 if (range->type == CHARTAB_RANGE_CHAR)
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1045 return get_char_table_1 (range->ch, table);
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1046 else
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1047 return get_range_char_table_1 (range, table, multi);
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1048 }
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1049
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1050 #endif /* ERROR_CHECK_TYPES */
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1051
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 DEFUN ("get-range-char-table", Fget_range_char_table, 2, 3, 0, /*
2714
2eed1f34d39d [xemacs-hg @ 2005-04-06 03:47:16 by stephent]
stephent
parents: 2500
diff changeset
1053 Find value for RANGE in CHAR-TABLE.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054 If there is more than one value, return MULTI (defaults to nil).
2714
2eed1f34d39d [xemacs-hg @ 2005-04-06 03:47:16 by stephent]
stephent
parents: 2500
diff changeset
1055
2eed1f34d39d [xemacs-hg @ 2005-04-06 03:47:16 by stephent]
stephent
parents: 2500
diff changeset
1056 Valid values for RANGE are single characters, charsets, a row in a
2eed1f34d39d [xemacs-hg @ 2005-04-06 03:47:16 by stephent]
stephent
parents: 2500
diff changeset
1057 two-octet charset, and all characters. See `put-char-table'.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1059 (range, char_table, multi))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 struct chartab_range rainj;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 if (CHAR_OR_CHAR_INTP (range))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1064 return Fget_char_table (range, char_table);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1065 CHECK_CHAR_TABLE (char_table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067 decode_char_table_range (range, &rainj);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1068 return get_range_char_table (&rainj, char_table, multi);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 }
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1070
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 check_valid_char_table_value (Lisp_Object value, enum char_table_type type,
578
190b164ddcac [xemacs-hg @ 2001-05-25 11:26:50 by ben]
ben
parents: 563
diff changeset
1073 Error_Behavior errb)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075 switch (type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077 case CHAR_TABLE_TYPE_SYNTAX:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078 if (!ERRB_EQ (errb, ERROR_ME))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079 return INTP (value) || (CONSP (value) && INTP (XCAR (value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 && CHAR_OR_CHAR_INTP (XCDR (value)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 if (CONSP (value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083 Lisp_Object cdr = XCDR (value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 CHECK_INT (XCAR (value));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085 CHECK_CHAR_COERCE_INT (cdr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 CHECK_INT (value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092 case CHAR_TABLE_TYPE_CATEGORY:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093 if (!ERRB_EQ (errb, ERROR_ME))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094 return CATEGORY_TABLE_VALUEP (value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095 CHECK_CATEGORY_TABLE_VALUE (value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099 case CHAR_TABLE_TYPE_GENERIC:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102 case CHAR_TABLE_TYPE_DISPLAY:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103 /* #### fix this */
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
1104 maybe_signal_error (Qunimplemented,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
1105 "Display char tables not yet implemented",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
1106 value, Qchar_table, errb);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 case CHAR_TABLE_TYPE_CHAR:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 if (!ERRB_EQ (errb, ERROR_ME))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111 return CHAR_OR_CHAR_INTP (value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112 CHECK_CHAR_COERCE_INT (value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 default:
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2367
diff changeset
1116 ABORT ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118
801
2b676dc88c66 [xemacs-hg @ 2002-04-01 03:58:02 by ben]
ben
parents: 800
diff changeset
1119 return 0; /* not (usually) reached */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1122 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 canonicalize_char_table_value (Lisp_Object value, enum char_table_type type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 switch (type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1127 case CHAR_TABLE_TYPE_SYNTAX:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 if (CONSP (value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130 Lisp_Object car = XCAR (value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131 Lisp_Object cdr = XCDR (value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132 CHECK_CHAR_COERCE_INT (cdr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 return Fcons (car, cdr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 case CHAR_TABLE_TYPE_CHAR:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137 CHECK_CHAR_COERCE_INT (value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142 return value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145 DEFUN ("valid-char-table-value-p", Fvalid_char_table_value_p, 2, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 Return non-nil if VALUE is a valid value for CHAR-TABLE-TYPE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 (value, char_table_type))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150 enum char_table_type type = symbol_to_char_table_type (char_table_type);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 return check_valid_char_table_value (value, type, ERROR_ME_NOT) ? Qt : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 DEFUN ("check-valid-char-table-value", Fcheck_valid_char_table_value, 2, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156 Signal an error if VALUE is not a valid value for CHAR-TABLE-TYPE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 (value, char_table_type))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 enum char_table_type type = symbol_to_char_table_type (char_table_type);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162 check_valid_char_table_value (value, type, ERROR_ME);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1163 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1166 /* Assign VAL to all characters in RANGE in char table TABLE. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 void
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1169 put_char_table (Lisp_Object table, struct chartab_range *range,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170 Lisp_Object val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1171 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1172 Lisp_Char_Table *ct = XCHAR_TABLE (table);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1173
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174 switch (range->type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1175 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176 case CHARTAB_RANGE_ALL:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177 fill_char_table (ct, val);
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1178 return; /* fill_char_table() recorded the table as dirty. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1180 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1181 case CHARTAB_RANGE_CHARSET:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1182 if (EQ (range->charset, Vcharset_ascii))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1185 for (i = 0; i < 128; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1186 ct->ascii[i] = val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 else if (EQ (range->charset, Vcharset_control_1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191 for (i = 128; i < 160; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192 ct->ascii[i] = val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1194 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1195 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1196 int lb = XCHARSET_LEADING_BYTE (range->charset) - MIN_LEADING_BYTE;
1330
4542b72c005e [xemacs-hg @ 2003-03-01 07:25:26 by ben]
ben
parents: 1296
diff changeset
1197 if (CHAR_TABLE_ENTRYP (ct->level1[lb]) &&
4542b72c005e [xemacs-hg @ 2003-03-01 07:25:26 by ben]
ben
parents: 1296
diff changeset
1198 !OBJECT_DUMPED_P (ct->level1[lb]))
5127
a9c41067dd88 more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents: 5125
diff changeset
1199 free_normal_lisp_object (ct->level1[lb]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1200 ct->level1[lb] = val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1201 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1202 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 case CHARTAB_RANGE_ROW:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1206 Lisp_Char_Table_Entry *cte;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207 int lb = XCHARSET_LEADING_BYTE (range->charset) - MIN_LEADING_BYTE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208 /* make sure that there is a separate entry for the row. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209 if (!CHAR_TABLE_ENTRYP (ct->level1[lb]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1210 ct->level1[lb] = make_char_table_entry (ct->level1[lb]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1211 cte = XCHAR_TABLE_ENTRY (ct->level1[lb]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1212 cte->level2[range->row - 32] = val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1214 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1215 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217 case CHARTAB_RANGE_CHAR:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1220 Lisp_Object charset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1221 int byte1, byte2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1223 BREAKUP_ICHAR (range->ch, charset, byte1, byte2);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224 if (EQ (charset, Vcharset_ascii))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1225 ct->ascii[byte1] = val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1226 else if (EQ (charset, Vcharset_control_1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1227 ct->ascii[byte1 + 128] = val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1228 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1230 Lisp_Char_Table_Entry *cte;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1231 int lb = XCHARSET_LEADING_BYTE (charset) - MIN_LEADING_BYTE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1232 /* make sure that there is a separate entry for the row. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233 if (!CHAR_TABLE_ENTRYP (ct->level1[lb]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1234 ct->level1[lb] = make_char_table_entry (ct->level1[lb]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235 cte = XCHAR_TABLE_ENTRY (ct->level1[lb]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236 /* now CTE is a char table entry for the charset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237 each entry is for a single row (or character of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 a one-octet charset). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239 if (XCHARSET_DIMENSION (charset) == 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1240 cte->level2[byte1 - 32] = val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1242 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1243 /* assigning to one character in a two-octet charset. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1244 /* make sure that the charset row contains a separate
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1245 entry for each character. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1246 if (!CHAR_TABLE_ENTRYP (cte->level2[byte1 - 32]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1247 cte->level2[byte1 - 32] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1248 make_char_table_entry (cte->level2[byte1 - 32]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1249 cte = XCHAR_TABLE_ENTRY (cte->level2[byte1 - 32]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1250 cte->level2[byte2 - 32] = val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1251 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1252 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1253 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1254 #else /* not MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255 ct->ascii[(unsigned char) (range->ch)] = val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1256 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1257 #endif /* not MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1258 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1259
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1260 if (ct->type == CHAR_TABLE_TYPE_SYNTAX)
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 1204
diff changeset
1261 set_char_table_dirty (wrap_char_table (ct));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1262 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1263
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1264 DEFUN ("put-char-table", Fput_char_table, 3, 3, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1265 Set the value for chars in RANGE to be VALUE in CHAR-TABLE.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1266
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1267 RANGE specifies one or more characters to be affected and should be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1268 one of the following:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1269
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1270 -- t (all characters are affected)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1271 -- A charset (only allowed when Mule support is present)
2714
2eed1f34d39d [xemacs-hg @ 2005-04-06 03:47:16 by stephent]
stephent
parents: 2500
diff changeset
1272 -- A vector of two elements: a two-octet charset and a row number; the row
2eed1f34d39d [xemacs-hg @ 2005-04-06 03:47:16 by stephent]
stephent
parents: 2500
diff changeset
1273 must be an integer, not a character (only allowed when Mule support is
2eed1f34d39d [xemacs-hg @ 2005-04-06 03:47:16 by stephent]
stephent
parents: 2500
diff changeset
1274 present)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275 -- A single character
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1277 VALUE must be a value appropriate for the type of CHAR-TABLE.
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
1278 See `make-char-table'.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1279 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1280 (range, value, char_table))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1281 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1282 Lisp_Char_Table *ct;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1283 struct chartab_range rainj;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1284
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1285 CHECK_CHAR_TABLE (char_table);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1286 ct = XCHAR_TABLE (char_table);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1287 check_valid_char_table_value (value, ct->type, ERROR_ME);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1288 decode_char_table_range (range, &rainj);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1289 value = canonicalize_char_table_value (value, ct->type);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1290 put_char_table (char_table, &rainj, value);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1291 return Qnil;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1292 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1293
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1294 DEFUN ("remove-char-table", Fremove_char_table, 2, 2, 0, /*
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1295 Remove any value from chars in RANGE in CHAR-TABLE.
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1296
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1297 RANGE specifies one or more characters to be affected and should be
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1298 one of the following:
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1299
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1300 -- t (all characters are affected)
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1301 -- A charset (only allowed when Mule support is present)
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1302 -- A vector of two elements: a two-octet charset and a row number
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1303 (only allowed when Mule support is present)
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1304 -- A single character
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1305
2726
4bc213965183 [xemacs-hg @ 2005-04-11 05:15:04 by stephent]
stephent
parents: 2720
diff changeset
1306 With all values removed, the default value will be returned by
4bc213965183 [xemacs-hg @ 2005-04-11 05:15:04 by stephent]
stephent
parents: 2720
diff changeset
1307 `get-char-table' and `get-range-char-table'.
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1308 */
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1309 (range, char_table))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1310 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1311 struct chartab_range rainj;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1312
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1313 CHECK_CHAR_TABLE (char_table);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1314 decode_char_table_range (range, &rainj);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1315 put_char_table (char_table, &rainj, Qunbound);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1316 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1317 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1318
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1319 /* Map FN over the ASCII chars in CT. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1320
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1321 static int
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1322 map_over_charset_ascii_1 (Lisp_Char_Table *ct,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1323 int start, int stop,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1324 int (*fn) (struct chartab_range *range,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1325 Lisp_Object table, Lisp_Object val,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1326 void *arg),
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1327 void *arg)
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1328 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1329 struct chartab_range rainj;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1330 int i, retval;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1331
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1332 rainj.type = CHARTAB_RANGE_CHAR;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1333
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1334 for (i = start, retval = 0; i <= stop && retval == 0; i++)
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1335 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1336 rainj.ch = (Ichar) i;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1337 if (!UNBOUNDP (ct->ascii[i]))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1338 retval = (fn) (&rainj, wrap_char_table (ct), ct->ascii[i], arg);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1339 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1340
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1341 return retval;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1342 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1343
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1344
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1345 /* Map FN over the ASCII chars in CT. */
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1346
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1347 static int
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1348 map_over_charset_ascii (Lisp_Char_Table *ct,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1349 int (*fn) (struct chartab_range *range,
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1350 Lisp_Object table, Lisp_Object val,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1351 void *arg),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1352 void *arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1354 return map_over_charset_ascii_1 (ct, 0,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1355 #ifdef MULE
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1356 127,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357 #else
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1358 255,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1359 #endif
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1360 fn, arg);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1361 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1362
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1363 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1364
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1365 /* Map FN over the Control-1 chars in CT. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1366
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1367 static int
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1368 map_over_charset_control_1 (Lisp_Char_Table *ct,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1369 int (*fn) (struct chartab_range *range,
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1370 Lisp_Object table, Lisp_Object val,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1371 void *arg),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1372 void *arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1373 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1374 return map_over_charset_ascii_1 (ct, 128, 159, fn, arg);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1376
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1377 /* Map FN over the row ROW of two-byte charset CHARSET.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1378 There must be a separate value for that row in the char table.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379 CTE specifies the char table entry for CHARSET. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1380
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1381 static int
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1382 map_over_charset_row (Lisp_Char_Table *ct,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1383 Lisp_Char_Table_Entry *cte,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1384 Lisp_Object charset, int row,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1385 int (*fn) (struct chartab_range *range,
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1386 Lisp_Object table, Lisp_Object val,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1387 void *arg),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1388 void *arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1389 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1390 Lisp_Object val = cte->level2[row - 32];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1391
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1392 if (UNBOUNDP (val))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1393 return 0;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1394 else if (!CHAR_TABLE_ENTRYP (val))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1395 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1396 struct chartab_range rainj;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1397
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1398 rainj.type = CHARTAB_RANGE_ROW;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1399 rainj.charset = charset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1400 rainj.row = row;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1401 return (fn) (&rainj, wrap_char_table (ct), val, arg);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1402 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1403 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1404 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1405 struct chartab_range rainj;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1406 int i, retval;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1407 int start, stop;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1408
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1409 get_charset_limits (charset, &start, &stop);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1410
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1411 cte = XCHAR_TABLE_ENTRY (val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1412
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413 rainj.type = CHARTAB_RANGE_CHAR;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1414
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1415 for (i = start, retval = 0; i <= stop && retval == 0; i++)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1416 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1417 rainj.ch = make_ichar (charset, row, i);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1418 if (!UNBOUNDP (cte->level2[i - 32]))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1419 retval = (fn) (&rainj, wrap_char_table (ct), cte->level2[i - 32],
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1420 arg);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1421 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1422 return retval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1423 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1424 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1425
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1426
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1427 static int
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1428 map_over_other_charset (Lisp_Char_Table *ct, int lb,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1429 int (*fn) (struct chartab_range *range,
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1430 Lisp_Object table, Lisp_Object val,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1431 void *arg),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1432 void *arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1433 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1434 Lisp_Object val = ct->level1[lb - MIN_LEADING_BYTE];
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1435 Lisp_Object charset = charset_by_leading_byte (lb);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1436
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1437 if (!CHARSETP (charset)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1438 || lb == LEADING_BYTE_ASCII
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1439 || lb == LEADING_BYTE_CONTROL_1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1440 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1441
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1442 if (UNBOUNDP (val))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1443 return 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1444 if (!CHAR_TABLE_ENTRYP (val))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1445 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1446 struct chartab_range rainj;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1447
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1448 rainj.type = CHARTAB_RANGE_CHARSET;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1449 rainj.charset = charset;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1450 return (fn) (&rainj, wrap_char_table (ct), val, arg);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1451 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1452 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1453 Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (val);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1454 int start, stop;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1455 int i, retval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1456
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1457 get_charset_limits (charset, &start, &stop);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1458 if (XCHARSET_DIMENSION (charset) == 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1459 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1460 struct chartab_range rainj;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1461 rainj.type = CHARTAB_RANGE_CHAR;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1462
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1463 for (i = start, retval = 0; i <= stop && retval == 0; i++)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1464 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1465 rainj.ch = make_ichar (charset, i, 0);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1466 if (!UNBOUNDP (cte->level2[i - 32]))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1467 retval = (fn) (&rainj, wrap_char_table (ct), cte->level2[i - 32],
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1468 arg);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1469 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1470 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1471 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1472 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1473 for (i = start, retval = 0; i <= stop && retval == 0; i++)
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1474 retval = map_over_charset_row (ct, cte, charset, i, fn, arg);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1475 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1476
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1477 return retval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1478 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1479 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1480
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1481 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1482
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1483 /* Map FN (with client data ARG) over range RANGE in char table CT.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1484 Mapping stops the first time FN returns non-zero, and that value
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1485 becomes the return value of map_char_table().
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1486
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1487 #### This mapping code is way ugly. The FSF version, in contrast,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1488 is short and sweet, and much more recursive. There should be some way
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1489 of cleaning this up. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1490
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1491 int
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1492 map_char_table (Lisp_Object table,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1493 struct chartab_range *range,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1494 int (*fn) (struct chartab_range *range,
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1495 Lisp_Object table, Lisp_Object val, void *arg),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1496 void *arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1497 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1498 Lisp_Char_Table *ct = XCHAR_TABLE (table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1499 switch (range->type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1500 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1501 case CHARTAB_RANGE_ALL:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1502 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1503 int retval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1504
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1505 retval = map_over_charset_ascii (ct, fn, arg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1506 if (retval)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1507 return retval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1508 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1509 retval = map_over_charset_control_1 (ct, fn, arg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1510 if (retval)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1511 return retval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1512 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1513 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1514 int start = MIN_LEADING_BYTE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1515 int stop = start + NUM_LEADING_BYTES;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1516
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1517 for (i = start, retval = 0; i < stop && retval == 0; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1518 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1519 if (i != LEADING_BYTE_ASCII && i != LEADING_BYTE_CONTROL_1)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1520 retval = map_over_other_charset (ct, i, fn, arg);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1521 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1522 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1523 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1524 return retval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1525 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1526
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1527 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1528 case CHARTAB_RANGE_CHARSET:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1529 return map_over_other_charset (ct,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1530 XCHARSET_LEADING_BYTE (range->charset),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1531 fn, arg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1532
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1533 case CHARTAB_RANGE_ROW:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1534 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1535 Lisp_Object val = ct->level1[XCHARSET_LEADING_BYTE (range->charset) -
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1536 MIN_LEADING_BYTE];
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1537
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1538 if (CHAR_TABLE_ENTRYP (val))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1539 return map_over_charset_row (ct, XCHAR_TABLE_ENTRY (val),
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1540 range->charset, range->row, fn, arg);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1541 else if (!UNBOUNDP (val))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1542 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1543 struct chartab_range rainj;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1544
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1545 rainj.type = CHARTAB_RANGE_ROW;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1546 rainj.charset = range->charset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1547 rainj.row = range->row;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1548 return (fn) (&rainj, table, val, arg);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1549 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1550 else
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1551 return 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1552 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1553 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1554
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1555 case CHARTAB_RANGE_CHAR:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1556 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1557 Ichar ch = range->ch;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1558 Lisp_Object val = get_char_table (ch, table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1559 struct chartab_range rainj;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1560
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1561 if (!UNBOUNDP (val))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1562 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1563 rainj.type = CHARTAB_RANGE_CHAR;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1564 rainj.ch = ch;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1565 return (fn) (&rainj, table, val, arg);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1566 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1567 else
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1568 return 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1569 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1570
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1571 default:
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2367
diff changeset
1572 ABORT ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1573 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1574
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1575 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1576 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1577
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1578 struct slow_map_char_table_arg
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1579 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1580 Lisp_Object function;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1581 Lisp_Object retval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1582 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1583
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1584 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1585 slow_map_char_table_fun (struct chartab_range *range,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1330
diff changeset
1586 Lisp_Object UNUSED (table), Lisp_Object val,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1330
diff changeset
1587 void *arg)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1588 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1589 struct slow_map_char_table_arg *closure =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1590 (struct slow_map_char_table_arg *) arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1591
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1592 closure->retval = call2 (closure->function, encode_char_table_range (range),
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1593 val);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1594 return !NILP (closure->retval);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1595 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1596
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1597 DEFUN ("map-char-table", Fmap_char_table, 2, 3, 0, /*
2726
4bc213965183 [xemacs-hg @ 2005-04-11 05:15:04 by stephent]
stephent
parents: 2720
diff changeset
1598 Map FUNCTION over CHAR-TABLE until it returns non-nil; return that value.
4bc213965183 [xemacs-hg @ 2005-04-11 05:15:04 by stephent]
stephent
parents: 2720
diff changeset
1599 FUNCTION is called with two arguments, each key and entry in the table.
4bc213965183 [xemacs-hg @ 2005-04-11 05:15:04 by stephent]
stephent
parents: 2720
diff changeset
1600
4bc213965183 [xemacs-hg @ 2005-04-11 05:15:04 by stephent]
stephent
parents: 2720
diff changeset
1601 RANGE specifies a subrange to map over. If omitted or t, it defaults to
4bc213965183 [xemacs-hg @ 2005-04-11 05:15:04 by stephent]
stephent
parents: 2720
diff changeset
1602 the entire table.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1603
2726
4bc213965183 [xemacs-hg @ 2005-04-11 05:15:04 by stephent]
stephent
parents: 2720
diff changeset
1604 Both RANGE and the keys passed to FUNCTION are in the same format as the
4bc213965183 [xemacs-hg @ 2005-04-11 05:15:04 by stephent]
stephent
parents: 2720
diff changeset
1605 RANGE argument to `put-char-table'. N.B. This function does NOT map over
4bc213965183 [xemacs-hg @ 2005-04-11 05:15:04 by stephent]
stephent
parents: 2720
diff changeset
1606 all characters in RANGE, but over the subranges that have been assigned to.
4bc213965183 [xemacs-hg @ 2005-04-11 05:15:04 by stephent]
stephent
parents: 2720
diff changeset
1607 Thus this function is most suitable for searching a char-table, or for
4bc213965183 [xemacs-hg @ 2005-04-11 05:15:04 by stephent]
stephent
parents: 2720
diff changeset
1608 populating one char-table based on the contents of another. The current
4bc213965183 [xemacs-hg @ 2005-04-11 05:15:04 by stephent]
stephent
parents: 2720
diff changeset
1609 implementation does not coalesce ranges all of whose values are the same.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1610 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1611 (function, char_table, range))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1612 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1613 struct slow_map_char_table_arg slarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1614 struct gcpro gcpro1, gcpro2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1615 struct chartab_range rainj;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1616
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1617 CHECK_CHAR_TABLE (char_table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1618 if (NILP (range))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1619 range = Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1620 decode_char_table_range (range, &rainj);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1621 slarg.function = function;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1622 slarg.retval = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1623 GCPRO2 (slarg.function, slarg.retval);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1624 map_char_table (char_table, &rainj, slow_map_char_table_fun, &slarg);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1625 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1626
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1627 return slarg.retval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1628 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1629
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1630
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1631
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1632 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1633 /* Char table read syntax */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1634 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1635
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1636 static int
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1330
diff changeset
1637 chartab_type_validate (Lisp_Object UNUSED (keyword), Lisp_Object value,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1330
diff changeset
1638 Error_Behavior UNUSED (errb))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1639 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1640 /* #### should deal with ERRB */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1641 symbol_to_char_table_type (value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1642 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1643 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1644
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1645 /* #### Document the print/read format; esp. what's this cons element? */
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1646
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1647 static int
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1330
diff changeset
1648 chartab_data_validate (Lisp_Object UNUSED (keyword), Lisp_Object value,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1330
diff changeset
1649 Error_Behavior UNUSED (errb))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1650 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1651 /* #### should deal with ERRB */
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
1652 EXTERNAL_PROPERTY_LIST_LOOP_3 (range, data, value)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1653 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1654 struct chartab_range dummy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1655
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1656 if (CONSP (range))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1657 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1658 if (!CONSP (XCDR (range))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1659 || !NILP (XCDR (XCDR (range))))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
1660 sferror ("Invalid range format", range);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1661 decode_char_table_range (XCAR (range), &dummy);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1662 decode_char_table_range (XCAR (XCDR (range)), &dummy);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1663 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1664 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1665 decode_char_table_range (range, &dummy);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1666 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1667
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1668 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1669 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1670
5259
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
1671 static int
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
1672 chartab_default_validate (Lisp_Object UNUSED (keyword),
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
1673 Lisp_Object UNUSED (value),
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
1674 Error_Behavior UNUSED (errb))
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
1675 {
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
1676 /* We can't yet validate this, since we don't know what the type of the
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
1677 char table is. We do the validation below in chartab_instantiate(). */
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
1678 return 1;
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
1679 }
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
1680
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1681 static Lisp_Object
5222
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1682 chartab_instantiate (Lisp_Object plist)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1683 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1684 Lisp_Object chartab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1685 Lisp_Object type = Qgeneric;
5259
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
1686 Lisp_Object dataval = Qnil, default_ = Qunbound;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1687
5222
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1688 if (KEYWORDP (Fcar (plist)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1689 {
5222
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1690 PROPERTY_LIST_LOOP_3 (key, value, plist)
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1691 {
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1692 if (EQ (key, Q_data))
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1693 {
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1694 dataval = value;
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1695 }
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1696 else if (EQ (key, Q_type))
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1697 {
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1698 type = value;
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1699 }
5320
31be2a3d121d Move Qcount, Q_default, Q_test to general-slots.h; add SYMBOL_KEYWORD_GENERAL()
Aidan Kehoe <kehoea@parhasard.net>
parents: 5307
diff changeset
1700 else if (EQ (key, Q_default_))
5259
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
1701 {
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
1702 default_ = value;
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
1703 }
5222
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1704 else if (!KEYWORDP (key))
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1705 {
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1706 signal_error
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1707 (Qinvalid_read_syntax,
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1708 "can't mix keyword and non-keyword structure syntax",
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1709 key);
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1710 }
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1711 else
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1712 ABORT ();
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1713 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1714 }
5222
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1715 #ifdef NEED_TO_HANDLE_21_4_CODE
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1716 else
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1717 {
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1718 PROPERTY_LIST_LOOP_3 (key, value, plist)
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1719 {
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1720 if (EQ (key, Qdata))
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1721 {
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1722 dataval = value;
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1723 }
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1724 else if (EQ (key, Qtype))
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1725 {
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1726 type = value;
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1727 }
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1728 else if (KEYWORDP (key))
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1729 signal_error
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1730 (Qinvalid_read_syntax,
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1731 "can't mix keyword and non-keyword structure syntax",
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1732 key);
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1733 else
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1734 ABORT ();
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1735 }
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1736 }
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1737 #endif /* NEED_TO_HANDLE_21_4_CODE */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1738
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1739 chartab = Fmake_char_table (type);
5259
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
1740 if (!UNBOUNDP (default_))
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
1741 {
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
1742 check_valid_char_table_value (default_, XCHAR_TABLE_TYPE (chartab),
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
1743 ERROR_ME);
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
1744 set_char_table_default (chartab, default_);
5320
31be2a3d121d Move Qcount, Q_default, Q_test to general-slots.h; add SYMBOL_KEYWORD_GENERAL()
Aidan Kehoe <kehoea@parhasard.net>
parents: 5307
diff changeset
1745 if (!NILP (XCHAR_TABLE (chartab)->mirror_table))
31be2a3d121d Move Qcount, Q_default, Q_test to general-slots.h; add SYMBOL_KEYWORD_GENERAL()
Aidan Kehoe <kehoea@parhasard.net>
parents: 5307
diff changeset
1746 {
31be2a3d121d Move Qcount, Q_default, Q_test to general-slots.h; add SYMBOL_KEYWORD_GENERAL()
Aidan Kehoe <kehoea@parhasard.net>
parents: 5307
diff changeset
1747 set_char_table_default (XCHAR_TABLE (chartab)->mirror_table,
31be2a3d121d Move Qcount, Q_default, Q_test to general-slots.h; add SYMBOL_KEYWORD_GENERAL()
Aidan Kehoe <kehoea@parhasard.net>
parents: 5307
diff changeset
1748 default_);
31be2a3d121d Move Qcount, Q_default, Q_test to general-slots.h; add SYMBOL_KEYWORD_GENERAL()
Aidan Kehoe <kehoea@parhasard.net>
parents: 5307
diff changeset
1749 }
5259
02c282ae97cb Read and print char table defaults, chartab.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 5222
diff changeset
1750 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1751
5222
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1752 while (!NILP (dataval))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1753 {
5222
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1754 Lisp_Object range = Fcar (dataval);
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1755 Lisp_Object val = Fcar (Fcdr (dataval));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1756
5222
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1757 dataval = Fcdr (Fcdr (dataval));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1758 if (CONSP (range))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1759 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1760 if (CHAR_OR_CHAR_INTP (XCAR (range)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1761 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1762 Ichar first = XCHAR_OR_CHAR_INT (Fcar (range));
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1763 Ichar last = XCHAR_OR_CHAR_INT (Fcar (Fcdr (range)));
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1764 Ichar i;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1765
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1766 for (i = first; i <= last; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1767 Fput_char_table (make_char (i), val, chartab);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1768 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1769 else
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2367
diff changeset
1770 ABORT ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1771 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1772 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1773 Fput_char_table (range, val, chartab);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1774 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1775
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1776 return chartab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1777 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1778
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1779 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1780
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1781
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1782 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1783 /* Category Tables, specifically */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1784 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1785
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1786 DEFUN ("category-table-p", Fcategory_table_p, 1, 1, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1787 Return t if OBJECT is a category table.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1788 A category table is a type of char table used for keeping track of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1789 categories. Categories are used for classifying characters for use
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1790 in regexps -- you can refer to a category rather than having to use
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1791 a complicated [] expression (and category lookups are significantly
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1792 faster).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1793
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1794 There are 95 different categories available, one for each printable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1795 character (including space) in the ASCII charset. Each category
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1796 is designated by one such character, called a "category designator".
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1797 They are specified in a regexp using the syntax "\\cX", where X is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1798 a category designator.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1799
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1800 A category table specifies, for each character, the categories that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1801 the character is in. Note that a character can be in more than one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1802 category. More specifically, a category table maps from a character
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1803 to either the value nil (meaning the character is in no categories)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1804 or a 95-element bit vector, specifying for each of the 95 categories
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1805 whether the character is in that category.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1806
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1807 Special Lisp functions are provided that abstract this, so you do not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1808 have to directly manipulate bit vectors.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1809 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1810 (object))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1811 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1812 return (CHAR_TABLEP (object) &&
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1813 XCHAR_TABLE_TYPE (object) == CHAR_TABLE_TYPE_CATEGORY) ?
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1814 Qt : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1815 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1816
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1817 static Lisp_Object
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1818 check_category_table (Lisp_Object object, Lisp_Object default_)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1819 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1820 if (NILP (object))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1821 object = default_;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1822 while (NILP (Fcategory_table_p (object)))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1823 object = wrong_type_argument (Qcategory_table_p, object);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1824 return object;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1825 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1826
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1827 int
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1828 check_category_char (Ichar ch, Lisp_Object table,
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 578
diff changeset
1829 int designator, int not_p)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1830 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1831 REGISTER Lisp_Object temp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1832 if (NILP (Fcategory_table_p (table)))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
1833 wtaerror ("Expected category table", table);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1834 temp = get_char_table (ch, table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1835 if (NILP (temp))
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
1836 return not_p;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1837
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1838 designator -= ' ';
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
1839 return bit_vector_bit (XBIT_VECTOR (temp), designator) ? !not_p : not_p;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1840 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1841
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1842 DEFUN ("check-category-at", Fcheck_category_at, 2, 4, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1843 Return t if category of the character at POSITION includes DESIGNATOR.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1844 Optional third arg BUFFER specifies which buffer to use, and defaults
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1845 to the current buffer.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1846 Optional fourth arg CATEGORY-TABLE specifies the category table to
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1847 use, and defaults to BUFFER's category table.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1848 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1849 (position, designator, buffer, category_table))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1850 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1851 Lisp_Object ctbl;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1852 Ichar ch;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 578
diff changeset
1853 int des;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1854 struct buffer *buf = decode_buffer (buffer, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1855
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1856 CHECK_INT (position);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1857 CHECK_CATEGORY_DESIGNATOR (designator);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1858 des = XCHAR (designator);
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1859 ctbl = check_category_table (category_table, buf->category_table);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1860 ch = BUF_FETCH_CHAR (buf, XINT (position));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1861 return check_category_char (ch, ctbl, des, 0) ? Qt : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1862 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1863
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1864 DEFUN ("char-in-category-p", Fchar_in_category_p, 2, 3, 0, /*
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1865 Return non-nil if category of CHARACTER includes DESIGNATOR.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1866 Optional third arg CATEGORY-TABLE specifies the category table to use,
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1867 and defaults to the current buffer's category table.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1868 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1869 (character, designator, category_table))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1870 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1871 Lisp_Object ctbl;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1872 Ichar ch;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 578
diff changeset
1873 int des;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1874
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1875 CHECK_CATEGORY_DESIGNATOR (designator);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1876 des = XCHAR (designator);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1877 CHECK_CHAR (character);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1878 ch = XCHAR (character);
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1879 ctbl = check_category_table (category_table, current_buffer->category_table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1880 return check_category_char (ch, ctbl, des, 0) ? Qt : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1881 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1882
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1883 DEFUN ("category-table", Fcategory_table, 0, 1, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1884 Return BUFFER's current category table.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1885 BUFFER defaults to the current buffer.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1886 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1887 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1888 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1889 return decode_buffer (buffer, 0)->category_table;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1890 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1891
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1892 DEFUN ("standard-category-table", Fstandard_category_table, 0, 0, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1893 Return the standard category table.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1894 This is the one used for new buffers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1895 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1896 ())
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1897 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1898 return Vstandard_category_table;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1899 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1900
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1901 DEFUN ("copy-category-table", Fcopy_category_table, 0, 1, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1902 Return a new category table which is a copy of CATEGORY-TABLE.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1903 CATEGORY-TABLE defaults to the standard category table.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1904 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1905 (category_table))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1906 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1907 if (NILP (Vstandard_category_table))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1908 return Fmake_char_table (Qcategory);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1909
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1910 category_table =
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1911 check_category_table (category_table, Vstandard_category_table);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1912 return Fcopy_char_table (category_table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1913 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1914
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1915 DEFUN ("set-category-table", Fset_category_table, 1, 2, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1916 Select CATEGORY-TABLE as the new category table for BUFFER.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1917 BUFFER defaults to the current buffer if omitted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1918 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1919 (category_table, buffer))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1920 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1921 struct buffer *buf = decode_buffer (buffer, 0);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1922 category_table = check_category_table (category_table, Qnil);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1923 buf->category_table = category_table;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1924 /* Indicate that this buffer now has a specified category table. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1925 buf->local_var_flags |= XINT (buffer_local_flags.category_table);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1926 return category_table;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1927 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1928
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1929 DEFUN ("category-designator-p", Fcategory_designator_p, 1, 1, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1930 Return t if OBJECT is a category designator (a char in the range ' ' to '~').
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1931 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1932 (object))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1933 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1934 return CATEGORY_DESIGNATORP (object) ? Qt : Qnil;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1935 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1936
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1937 DEFUN ("category-table-value-p", Fcategory_table_value_p, 1, 1, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1938 Return t if OBJECT is a category table value.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1939 Valid values are nil or a bit vector of size 95.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1940 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1941 (object))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1942 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1943 return CATEGORY_TABLE_VALUEP (object) ? Qt : Qnil;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1944 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1945
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1946
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1947 #define CATEGORYP(x) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1948 (CHARP (x) && XCHAR (x) >= 0x20 && XCHAR (x) <= 0x7E)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1949
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
1950 #define CATEGORY_SET(c) get_char_table (c, current_buffer->category_table)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1951
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1952 /* Return 1 if CATEGORY_SET contains CATEGORY, else return 0.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1953 The faster version of `!NILP (Faref (category_set, category))'. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1954 #define CATEGORY_MEMBER(category, category_set) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1955 (bit_vector_bit(XBIT_VECTOR (category_set), category - 32))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1956
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1957 /* Return 1 if there is a word boundary between two word-constituent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1958 characters C1 and C2 if they appear in this order, else return 0.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1959 Use the macro WORD_BOUNDARY_P instead of calling this function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1960 directly. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1961
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1962 int
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1963 word_boundary_p (Ichar c1, Ichar c2)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1964 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1965 Lisp_Object category_set1, category_set2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1966 Lisp_Object tail;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1967 int default_result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1968
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1969 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1970 if (COMPOSITE_CHAR_P (c1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1971 c1 = cmpchar_component (c1, 0, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1972 if (COMPOSITE_CHAR_P (c2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1973 c2 = cmpchar_component (c2, 0, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1974 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1975
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1976 if (EQ (ichar_charset (c1), ichar_charset (c2)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1977 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1978 tail = Vword_separating_categories;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1979 default_result = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1980 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1981 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1982 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1983 tail = Vword_combining_categories;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1984 default_result = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1985 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1986
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1987 category_set1 = CATEGORY_SET (c1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1988 if (NILP (category_set1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1989 return default_result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1990 category_set2 = CATEGORY_SET (c2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1991 if (NILP (category_set2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1992 return default_result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1993
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
1994 for (; CONSP (tail); tail = XCDR (tail))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1995 {
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
1996 Lisp_Object elt = XCAR (tail);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1997
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1998 if (CONSP (elt)
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
1999 && CATEGORYP (XCAR (elt))
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
2000 && CATEGORYP (XCDR (elt))
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
2001 && CATEGORY_MEMBER (XCHAR (XCAR (elt)), category_set1)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
2002 && CATEGORY_MEMBER (XCHAR (XCDR (elt)), category_set2))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2003 return !default_result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2004 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2005 return default_result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2006 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2007 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2008
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2009
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2010 void
5560
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
2011 chartab_objects_create (void)
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
2012 {
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
2013 OBJECT_HAS_METHOD (char_table, print_preprocess);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
2014 OBJECT_HAS_METHOD (char_table, nsubst_structures_descend);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
2015 }
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
2016
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5445
diff changeset
2017 void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2018 syms_of_chartab (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2019 {
5117
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3025
diff changeset
2020 INIT_LISP_OBJECT (char_table);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2021
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2022 #ifdef MULE
5117
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3025
diff changeset
2023 INIT_LISP_OBJECT (char_table_entry);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2024
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
2025 DEFSYMBOL (Qcategory_table_p);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
2026 DEFSYMBOL (Qcategory_designator_p);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
2027 DEFSYMBOL (Qcategory_table_value_p);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2028 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2029
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
2030 DEFSYMBOL (Qchar_table);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
2031 DEFSYMBOL_MULTIWORD_PREDICATE (Qchar_tablep);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2032
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2033 DEFSUBR (Fchar_table_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2034 DEFSUBR (Fchar_table_type_list);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2035 DEFSUBR (Fvalid_char_table_type_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2036 DEFSUBR (Fchar_table_type);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
2037 DEFSUBR (Fchar_table_default);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
2038 DEFSUBR (Fset_char_table_default);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2039 DEFSUBR (Freset_char_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2040 DEFSUBR (Fmake_char_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2041 DEFSUBR (Fcopy_char_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2042 DEFSUBR (Fget_char_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2043 DEFSUBR (Fget_range_char_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2044 DEFSUBR (Fvalid_char_table_value_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2045 DEFSUBR (Fcheck_valid_char_table_value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2046 DEFSUBR (Fput_char_table);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 801
diff changeset
2047 DEFSUBR (Fremove_char_table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2048 DEFSUBR (Fmap_char_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2049
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2050 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2051 DEFSUBR (Fcategory_table_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2052 DEFSUBR (Fcategory_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2053 DEFSUBR (Fstandard_category_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2054 DEFSUBR (Fcopy_category_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2055 DEFSUBR (Fset_category_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2056 DEFSUBR (Fcheck_category_at);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2057 DEFSUBR (Fchar_in_category_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2058 DEFSUBR (Fcategory_designator_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2059 DEFSUBR (Fcategory_table_value_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2060 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2061
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2062 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2063
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2064 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2065 vars_of_chartab (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2066 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2067 /* DO NOT staticpro this. It works just like Vweak_hash_tables. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2068 Vall_syntax_tables = Qnil;
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 444
diff changeset
2069 dump_add_weak_object_chain (&Vall_syntax_tables);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2070 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2071
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2072 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2073 structure_type_create_chartab (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2074 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2075 struct structure_type *st;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2076
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2077 st = define_structure_type (Qchar_table, 0, chartab_instantiate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2078
5222
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
2079 #ifdef NEED_TO_HANDLE_21_4_CODE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2080 define_structure_type_keyword (st, Qtype, chartab_type_validate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2081 define_structure_type_keyword (st, Qdata, chartab_data_validate);
5222
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
2082 #endif /* NEED_TO_HANDLE_21_4_CODE */
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
2083
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
2084 define_structure_type_keyword (st, Q_type, chartab_type_validate);
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
2085 define_structure_type_keyword (st, Q_data, chartab_data_validate);
5320
31be2a3d121d Move Qcount, Q_default, Q_test to general-slots.h; add SYMBOL_KEYWORD_GENERAL()
Aidan Kehoe <kehoea@parhasard.net>
parents: 5307
diff changeset
2086 define_structure_type_keyword (st, Q_default_, chartab_default_validate);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2087 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2088
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2089 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2090 complex_vars_of_chartab (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2091 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2092 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2093 /* Set this now, so first buffer creation can refer to it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2094 /* Make it nil before calling copy-category-table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2095 so that copy-category-table will know not to try to copy from garbage */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2096 Vstandard_category_table = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2097 Vstandard_category_table = Fcopy_category_table (Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2098 staticpro (&Vstandard_category_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2099
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2100 DEFVAR_LISP ("word-combining-categories", &Vword_combining_categories /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2101 List of pair (cons) of categories to determine word boundary.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2102
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2103 Emacs treats a sequence of word constituent characters as a single
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2104 word (i.e. finds no word boundary between them) iff they belongs to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2105 the same charset. But, exceptions are allowed in the following cases.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2106
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2107 \(1) The case that characters are in different charsets is controlled
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2108 by the variable `word-combining-categories'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2109
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2110 Emacs finds no word boundary between characters of different charsets
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2111 if they have categories matching some element of this list.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2112
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2113 More precisely, if an element of this list is a cons of category CAT1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2114 and CAT2, and a multibyte character C1 which has CAT1 is followed by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2115 C2 which has CAT2, there's no word boundary between C1 and C2.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2116
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2117 For instance, to tell that ASCII characters and Latin-1 characters can
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2118 form a single word, the element `(?l . ?l)' should be in this list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2119 because both characters have the category `l' (Latin characters).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2120
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2121 \(2) The case that character are in the same charset is controlled by
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2122 the variable `word-separating-categories'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2123
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2124 Emacs find a word boundary between characters of the same charset
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2125 if they have categories matching some element of this list.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2126
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2127 More precisely, if an element of this list is a cons of category CAT1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2128 and CAT2, and a multibyte character C1 which has CAT1 is followed by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2129 C2 which has CAT2, there's a word boundary between C1 and C2.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2130
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2131 For instance, to tell that there's a word boundary between Japanese
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2132 Hiragana and Japanese Kanji (both are in the same charset), the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2133 element `(?H . ?C) should be in this list.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2134 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2135
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2136 Vword_combining_categories = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2137
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2138 DEFVAR_LISP ("word-separating-categories", &Vword_separating_categories /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2139 List of pair (cons) of categories to determine word boundary.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2140 See the documentation of the variable `word-combining-categories'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2141 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2142
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2143 Vword_separating_categories = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2144 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2145 }