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