428
|
1 /* XEmacs routines to deal with case tables.
|
|
2 Copyright (C) 1987, 1992, 1993, 1994 Free Software Foundation, Inc.
|
|
3 Copyright (C) 1995 Sun Microsystems, Inc.
|
793
|
4 Copyright (C) 2002 Ben Wing.
|
428
|
5
|
|
6 This file is part of XEmacs.
|
|
7
|
|
8 XEmacs is free software; you can redistribute it and/or modify it
|
|
9 under the terms of the GNU General Public License as published by the
|
|
10 Free Software Foundation; either version 2, or (at your option) any
|
|
11 later version.
|
|
12
|
|
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
16 for more details.
|
|
17
|
|
18 You should have received a copy of the GNU General Public License
|
|
19 along with XEmacs; see the file COPYING. If not, write to
|
|
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
21 Boston, MA 02111-1307, USA. */
|
|
22
|
771
|
23 /* Synched up with: FSF 19.28. Between FSF 19.28 and 19.30, casetab.c
|
428
|
24 was rewritten to use junky FSF char tables. Meanwhile I rewrote it
|
771
|
25 to use more logical char tables. --ben */
|
428
|
26
|
826
|
27 /* Written by Howard Gayle. */
|
428
|
28
|
|
29 /* Modified for Mule by Ben Wing. */
|
|
30
|
826
|
31 /* The four tables in a case table are downcase, upcase, canon, and eqv.
|
|
32 Each is a char-table. Their workings are rather non-obvious.
|
|
33
|
|
34 (1) `downcase' is the only obvious table: Map a character to its
|
|
35 lowercase equivalent.
|
771
|
36
|
826
|
37 (2) `upcase' does *NOT* map a character to its uppercase equivalent,
|
|
38 despite its name. Rather, it maps lowercase characters to their
|
|
39 uppercase equivalent, and uppercase characters to *ANYTHING BUT* their
|
|
40 uppercase equivalent (currently, their lowercase equivalent), and
|
|
41 characters without case to themselves. It is used to determine if a
|
|
42 character "has no case" (no uppercase or lowercase mapping). #### This
|
|
43 is way bogus. Just use the obvious implementation of uppercase mapping
|
|
44 and of NOCASE_P.
|
446
|
45
|
826
|
46 (3) `canon' maps each character to a "canonical" lowercase, such that if
|
|
47 two different uppercase characters map to the same lowercase character,
|
|
48 or vice versa, both characters will have the same entry in the canon
|
|
49 table.
|
446
|
50
|
826
|
51 (4) `equiv' lists the "equivalence classes" defined by `canon'. Imagine
|
|
52 that all characters are divided into groups having the same `canon'
|
|
53 entry; these groups are called "equivalence classes" and `equiv' lists
|
|
54 them by linking the characters in each equivalence class together in a
|
|
55 circular list.
|
|
56
|
|
57 `canon' is used when doing case-insensitive comparisons. `equiv' is
|
|
58 used in the Boyer-Moore search code.
|
|
59 */
|
428
|
60
|
|
61 #include <config.h>
|
|
62 #include "lisp.h"
|
|
63 #include "buffer.h"
|
|
64 #include "opaque.h"
|
446
|
65 #include "chartab.h"
|
|
66 #include "casetab.h"
|
428
|
67
|
446
|
68 Lisp_Object Qcase_tablep, Qdowncase, Qupcase;
|
|
69 Lisp_Object Vstandard_case_table;
|
428
|
70
|
446
|
71 Lisp_Object case_table_char (Lisp_Object ch, Lisp_Object table);
|
428
|
72
|
826
|
73 #define STRING256_P(obj) ((STRINGP (obj) && string_char_length (obj) == 256))
|
446
|
74
|
|
75 static Lisp_Object
|
|
76 mark_case_table (Lisp_Object obj)
|
|
77 {
|
|
78 Lisp_Case_Table *ct = XCASE_TABLE (obj);
|
|
79
|
|
80 mark_object (CASE_TABLE_DOWNCASE (ct));
|
|
81 mark_object (CASE_TABLE_UPCASE (ct));
|
|
82 mark_object (CASE_TABLE_CANON (ct));
|
|
83 mark_object (CASE_TABLE_EQV (ct));
|
|
84 return Qnil;
|
|
85 }
|
|
86
|
|
87 static void
|
2286
|
88 print_case_table (Lisp_Object obj, Lisp_Object printcharfun,
|
|
89 int UNUSED (escapeflag))
|
446
|
90 {
|
|
91 Lisp_Case_Table *ct = XCASE_TABLE (obj);
|
|
92 if (print_readably)
|
826
|
93 printing_unreadable_object ("#<case-table 0x%x>", ct->header.uid);
|
|
94 write_fmt_string_lisp
|
|
95 (printcharfun, "#<case-table downcase=%s upcase=%s canon=%s eqv=%s ", 4,
|
|
96 CASE_TABLE_DOWNCASE (ct), CASE_TABLE_UPCASE (ct),
|
|
97 CASE_TABLE_CANON (ct), CASE_TABLE_EQV (ct));
|
|
98 write_fmt_string (printcharfun, "0x%x>", ct->header.uid);
|
446
|
99 }
|
|
100
|
1204
|
101 static const struct memory_description case_table_description [] = {
|
446
|
102 { XD_LISP_OBJECT, offsetof (Lisp_Case_Table, downcase_table) },
|
|
103 { XD_LISP_OBJECT, offsetof (Lisp_Case_Table, upcase_table) },
|
|
104 { XD_LISP_OBJECT, offsetof (Lisp_Case_Table, case_canon_table) },
|
|
105 { XD_LISP_OBJECT, offsetof (Lisp_Case_Table, case_eqv_table) },
|
|
106 { XD_END }
|
|
107 };
|
|
108
|
934
|
109
|
|
110 DEFINE_LRECORD_IMPLEMENTATION("case-table", case_table,
|
|
111 1, /*dumpable-flag*/
|
|
112 mark_case_table, print_case_table, 0,
|
|
113 0, 0, case_table_description, Lisp_Case_Table);
|
446
|
114
|
|
115 static Lisp_Object
|
826
|
116 allocate_case_table (int init_tables)
|
446
|
117 {
|
|
118 Lisp_Case_Table *ct =
|
|
119 alloc_lcrecord_type (Lisp_Case_Table, &lrecord_case_table);
|
|
120
|
826
|
121 if (init_tables)
|
|
122 {
|
|
123 SET_CASE_TABLE_DOWNCASE (ct, MAKE_TRT_TABLE ());
|
|
124 SET_CASE_TABLE_UPCASE (ct, MAKE_TRT_TABLE ());
|
|
125 SET_CASE_TABLE_CANON (ct, MAKE_TRT_TABLE ());
|
|
126 SET_CASE_TABLE_EQV (ct, MAKE_TRT_TABLE ());
|
|
127 }
|
|
128 else
|
|
129 {
|
|
130 SET_CASE_TABLE_DOWNCASE (ct, Qnil);
|
|
131 SET_CASE_TABLE_UPCASE (ct, Qnil);
|
|
132 SET_CASE_TABLE_CANON (ct, Qnil);
|
|
133 SET_CASE_TABLE_EQV (ct, Qnil);
|
|
134 }
|
|
135 return wrap_case_table (ct);
|
|
136 }
|
446
|
137
|
826
|
138 DEFUN ("make-case-table", Fmake_case_table, 0, 0, 0, /*
|
|
139 Create a new, empty case table.
|
|
140 */
|
|
141 ())
|
|
142 {
|
|
143 return allocate_case_table (1);
|
446
|
144 }
|
428
|
145
|
|
146 DEFUN ("case-table-p", Fcase_table_p, 1, 1, 0, /*
|
444
|
147 Return t if OBJECT is a case table.
|
428
|
148 See `set-case-table' for more information on these data structures.
|
|
149 */
|
444
|
150 (object))
|
428
|
151 {
|
446
|
152 if (CASE_TABLEP (object))
|
|
153 return Qt;
|
|
154 else
|
|
155 {
|
|
156 Lisp_Object down, up, canon, eqv;
|
|
157 if (!CONSP (object))
|
|
158 return Qnil;
|
|
159 down = XCAR (object); object = XCDR (object);
|
|
160 if (!CONSP (object))
|
|
161 return Qnil;
|
|
162 up = XCAR (object); object = XCDR (object);
|
|
163 if (!CONSP (object))
|
|
164 return Qnil;
|
|
165 canon = XCAR (object); object = XCDR (object);
|
|
166 if (!CONSP (object))
|
|
167 return Qnil;
|
|
168 eqv = XCAR (object);
|
428
|
169
|
446
|
170 return ((STRING256_P (down)
|
|
171 && (NILP (up) || STRING256_P (up))
|
|
172 && ((NILP (canon) && NILP (eqv))
|
|
173 || STRING256_P (canon))
|
|
174 && (NILP (eqv) || STRING256_P (eqv)))
|
|
175 ? Qt : Qnil);
|
|
176
|
|
177 }
|
428
|
178 }
|
|
179
|
|
180 static Lisp_Object
|
444
|
181 check_case_table (Lisp_Object object)
|
428
|
182 {
|
446
|
183 /* This function can GC */
|
444
|
184 while (NILP (Fcase_table_p (object)))
|
|
185 object = wrong_type_argument (Qcase_tablep, object);
|
|
186 return object;
|
428
|
187 }
|
|
188
|
446
|
189 Lisp_Object
|
|
190 case_table_char (Lisp_Object ch, Lisp_Object table)
|
|
191 {
|
|
192 Lisp_Object ct_char;
|
826
|
193 ct_char = get_char_table (XCHAR (ch), table);
|
446
|
194 if (NILP (ct_char))
|
|
195 return ch;
|
|
196 else
|
|
197 return ct_char;
|
|
198 }
|
|
199
|
|
200 DEFUN ("get-case-table", Fget_case_table, 3, 3, 0, /*
|
|
201 Return CHAR-CASE version of CHARACTER in CASE-TABLE.
|
|
202
|
826
|
203 CHAR-CASE is either `downcase' or `upcase'.
|
446
|
204 */
|
|
205 (char_case, character, case_table))
|
|
206 {
|
|
207 CHECK_CHAR (character);
|
|
208 CHECK_CASE_TABLE (case_table);
|
|
209 if (EQ (char_case, Qdowncase))
|
|
210 return case_table_char (character, XCASE_TABLE_DOWNCASE (case_table));
|
|
211 else if (EQ (char_case, Qupcase))
|
|
212 return case_table_char (character, XCASE_TABLE_UPCASE (case_table));
|
|
213 else
|
563
|
214 invalid_constant ("Char case must be downcase or upcase", char_case);
|
446
|
215
|
|
216 return Qnil; /* Not reached. */
|
|
217 }
|
|
218
|
|
219 DEFUN ("put-case-table", Fput_case_table, 4, 4, 0, /*
|
|
220 Set CHAR-CASE version of CHARACTER to be VALUE in CASE-TABLE.
|
|
221
|
826
|
222 CHAR-CASE is either `downcase' or `upcase'.
|
446
|
223 See also `put-case-table-pair'.
|
|
224 */
|
|
225 (char_case, character, value, case_table))
|
|
226 {
|
|
227 CHECK_CHAR (character);
|
|
228 CHECK_CHAR (value);
|
|
229
|
|
230 if (EQ (char_case, Qdowncase))
|
|
231 {
|
|
232 Fput_char_table (character, value, XCASE_TABLE_DOWNCASE (case_table));
|
826
|
233 /* This one is not at all intuitive. See comment at top of file. */
|
446
|
234 Fput_char_table (character, value, XCASE_TABLE_UPCASE (case_table));
|
|
235 }
|
|
236 else if (EQ (char_case, Qupcase))
|
|
237 {
|
|
238 Fput_char_table (character, value, XCASE_TABLE_UPCASE (case_table));
|
826
|
239 Fput_char_table (character, character,
|
|
240 XCASE_TABLE_DOWNCASE (case_table));
|
446
|
241 }
|
|
242 else
|
826
|
243 invalid_constant ("CHAR-CASE must be downcase or upcase", char_case);
|
446
|
244
|
826
|
245 XCASE_TABLE (case_table)->dirty = 1;
|
446
|
246 return Qnil;
|
|
247 }
|
|
248
|
|
249 DEFUN ("put-case-table-pair", Fput_case_table_pair, 3, 3, 0, /*
|
|
250 Make UC and LC a pair of inter-case-converting letters in CASE-TABLE.
|
|
251 UC is an uppercase character and LC is a downcase character.
|
|
252 */
|
|
253 (uc, lc, case_table))
|
|
254 {
|
|
255 CHECK_CHAR (uc);
|
|
256 CHECK_CHAR (lc);
|
|
257 CHECK_CASE_TABLE (case_table);
|
|
258
|
|
259 Fput_char_table (lc, lc, XCASE_TABLE_DOWNCASE (case_table));
|
|
260 Fput_char_table (uc, lc, XCASE_TABLE_UPCASE (case_table));
|
|
261 Fput_char_table (uc, lc, XCASE_TABLE_DOWNCASE (case_table));
|
|
262 Fput_char_table (lc, uc, XCASE_TABLE_UPCASE (case_table));
|
|
263
|
826
|
264 XCASE_TABLE (case_table)->dirty = 1;
|
446
|
265 return Qnil;
|
|
266 }
|
|
267
|
|
268 DEFUN ("copy-case-table", Fcopy_case_table, 1, 1, 0, /*
|
|
269 Return a new case table which is a copy of CASE-TABLE
|
|
270 */
|
|
271 (case_table))
|
|
272 {
|
|
273 Lisp_Object new_obj;
|
|
274 CHECK_CASE_TABLE (case_table);
|
|
275
|
826
|
276 new_obj = allocate_case_table (0);
|
446
|
277 XSET_CASE_TABLE_DOWNCASE
|
|
278 (new_obj, Fcopy_char_table (XCASE_TABLE_DOWNCASE (case_table)));
|
|
279 XSET_CASE_TABLE_UPCASE
|
|
280 (new_obj, Fcopy_char_table (XCASE_TABLE_UPCASE (case_table)));
|
|
281 XSET_CASE_TABLE_CANON
|
|
282 (new_obj, Fcopy_char_table (XCASE_TABLE_CANON (case_table)));
|
|
283 XSET_CASE_TABLE_EQV
|
|
284 (new_obj, Fcopy_char_table (XCASE_TABLE_EQV (case_table)));
|
|
285 return new_obj;
|
|
286 }
|
|
287
|
826
|
288 static int
|
|
289 compute_canon_mapper (struct chartab_range *range,
|
2286
|
290 Lisp_Object UNUSED (table), Lisp_Object val, void *arg)
|
826
|
291 {
|
|
292 Lisp_Object casetab = VOID_TO_LISP (arg);
|
|
293 if (range->type == CHARTAB_RANGE_CHAR)
|
|
294 SET_TRT_TABLE_OF (XCASE_TABLE_CANON (casetab), range->ch,
|
|
295 TRT_TABLE_OF (XCASE_TABLE_DOWNCASE (casetab),
|
|
296 TRT_TABLE_OF (XCASE_TABLE_UPCASE (casetab),
|
|
297 XCHAR (val))));
|
|
298
|
|
299 return 0;
|
|
300 }
|
|
301
|
|
302 static int
|
|
303 initialize_identity_mapper (struct chartab_range *range,
|
2286
|
304 Lisp_Object UNUSED (table),
|
|
305 Lisp_Object UNUSED (val), void *arg)
|
826
|
306 {
|
|
307 Lisp_Object trt = VOID_TO_LISP (arg);
|
|
308 if (range->type == CHARTAB_RANGE_CHAR)
|
|
309 SET_TRT_TABLE_OF (trt, range->ch, range->ch);
|
|
310
|
|
311 return 0;
|
|
312 }
|
|
313
|
|
314 static int
|
|
315 compute_up_or_eqv_mapper (struct chartab_range *range,
|
2286
|
316 Lisp_Object UNUSED (table),
|
|
317 Lisp_Object val, void *arg)
|
826
|
318 {
|
|
319 Lisp_Object inverse = VOID_TO_LISP (arg);
|
867
|
320 Ichar toch = XCHAR (val);
|
826
|
321
|
|
322 if (range->type == CHARTAB_RANGE_CHAR && range->ch != toch)
|
|
323 {
|
867
|
324 Ichar c = TRT_TABLE_OF (inverse, toch);
|
826
|
325 SET_TRT_TABLE_OF (inverse, toch, range->ch);
|
|
326 SET_TRT_TABLE_OF (inverse, range->ch, c);
|
|
327 }
|
|
328
|
|
329 return 0;
|
|
330 }
|
|
331
|
|
332 /* Recomputing the canonical and equivalency tables from scratch is a
|
|
333 lengthy process, and doing them incrementally is extremely difficult or
|
|
334 perhaps impossible -- and certainly not worth it. To avoid lots of
|
|
335 excessive recomputation when lots of stuff is incrementally added, we
|
|
336 just store a dirty flag and then recompute when a value from the canon
|
|
337 or eqv tables is actually needed. */
|
|
338
|
|
339 void
|
|
340 recompute_case_table (Lisp_Object casetab)
|
|
341 {
|
|
342 struct chartab_range range;
|
|
343
|
|
344 range.type = CHARTAB_RANGE_ALL;
|
|
345 /* Turn off dirty flag first so we don't get infinite recursion when
|
|
346 retrieving the values below! */
|
|
347 XCASE_TABLE (casetab)->dirty = 0;
|
|
348 map_char_table (XCASE_TABLE_DOWNCASE (casetab), &range,
|
|
349 compute_canon_mapper, LISP_TO_VOID (casetab));
|
|
350 map_char_table (XCASE_TABLE_CANON (casetab), &range,
|
|
351 initialize_identity_mapper,
|
|
352 LISP_TO_VOID (XCASE_TABLE_EQV (casetab)));
|
|
353 map_char_table (XCASE_TABLE_CANON (casetab), &range,
|
|
354 compute_up_or_eqv_mapper,
|
|
355 LISP_TO_VOID (XCASE_TABLE_EQV (casetab)));
|
|
356 }
|
|
357
|
428
|
358 DEFUN ("current-case-table", Fcurrent_case_table, 0, 1, 0, /*
|
|
359 Return the case table of BUFFER, which defaults to the current buffer.
|
|
360 */
|
|
361 (buffer))
|
|
362 {
|
|
363 struct buffer *buf = decode_buffer (buffer, 0);
|
|
364
|
446
|
365 return buf->case_table;
|
428
|
366 }
|
|
367
|
|
368 DEFUN ("standard-case-table", Fstandard_case_table, 0, 0, 0, /*
|
|
369 Return the standard case table.
|
|
370 This is the one used for new buffers.
|
|
371 */
|
|
372 ())
|
|
373 {
|
446
|
374 return Vstandard_case_table;
|
428
|
375 }
|
|
376
|
826
|
377 static void
|
|
378 convert_old_style_syntax_string (Lisp_Object table, Lisp_Object string)
|
|
379 {
|
867
|
380 Ichar i;
|
826
|
381
|
|
382 for (i = 0; i < 256; i++)
|
867
|
383 SET_TRT_TABLE_OF (table, i, string_ichar (string, i));
|
826
|
384 }
|
|
385
|
|
386 static Lisp_Object
|
|
387 set_case_table (Lisp_Object table, int standard)
|
|
388 {
|
|
389 /* This function can GC */
|
|
390 struct buffer *buf =
|
|
391 standard ? XBUFFER (Vbuffer_defaults) : current_buffer;
|
|
392
|
|
393 check_case_table (table);
|
|
394
|
|
395 if (CASE_TABLEP (table))
|
|
396 {
|
|
397 if (standard)
|
|
398 Vstandard_case_table = table;
|
|
399
|
|
400 buf->case_table = table;
|
|
401 }
|
|
402 else
|
|
403 {
|
|
404 /* For backward compatibility. */
|
|
405 Lisp_Object down, up, canon, eqv, tail = table;
|
|
406 Lisp_Object casetab =
|
|
407 standard ? Vstandard_case_table : buf->case_table;
|
|
408 struct chartab_range range;
|
|
409
|
|
410 range.type = CHARTAB_RANGE_ALL;
|
|
411
|
|
412 Freset_char_table (XCASE_TABLE_DOWNCASE (casetab));
|
|
413 Freset_char_table (XCASE_TABLE_UPCASE (casetab));
|
|
414 Freset_char_table (XCASE_TABLE_CANON (casetab));
|
|
415 Freset_char_table (XCASE_TABLE_EQV (casetab));
|
|
416
|
|
417 down = XCAR (tail); tail = XCDR (tail);
|
|
418 up = XCAR (tail); tail = XCDR (tail);
|
|
419 canon = XCAR (tail); tail = XCDR (tail);
|
|
420 eqv = XCAR (tail);
|
|
421
|
|
422 convert_old_style_syntax_string (XCASE_TABLE_DOWNCASE (casetab), down);
|
|
423
|
|
424 if (NILP (up))
|
|
425 {
|
|
426 map_char_table (XCASE_TABLE_DOWNCASE (casetab), &range,
|
|
427 initialize_identity_mapper,
|
|
428 LISP_TO_VOID (XCASE_TABLE_UPCASE (casetab)));
|
|
429 map_char_table (XCASE_TABLE_DOWNCASE (casetab), &range,
|
|
430 compute_up_or_eqv_mapper,
|
|
431 LISP_TO_VOID (XCASE_TABLE_UPCASE (casetab)));
|
|
432 }
|
|
433 else
|
|
434 convert_old_style_syntax_string (XCASE_TABLE_UPCASE (casetab), up);
|
|
435
|
|
436 if (NILP (canon))
|
|
437 map_char_table (XCASE_TABLE_DOWNCASE (casetab), &range,
|
|
438 compute_canon_mapper, LISP_TO_VOID (casetab));
|
|
439 else
|
|
440 convert_old_style_syntax_string (XCASE_TABLE_CANON (casetab), canon);
|
|
441
|
|
442 if (NILP (eqv))
|
|
443 {
|
|
444 map_char_table (XCASE_TABLE_CANON (casetab), &range,
|
|
445 initialize_identity_mapper,
|
|
446 LISP_TO_VOID (XCASE_TABLE_EQV (casetab)));
|
|
447 map_char_table (XCASE_TABLE_CANON (casetab), &range,
|
|
448 compute_up_or_eqv_mapper,
|
|
449 LISP_TO_VOID (XCASE_TABLE_EQV (casetab)));
|
|
450 }
|
|
451 else
|
|
452 convert_old_style_syntax_string (XCASE_TABLE_CANON (casetab), eqv);
|
|
453 }
|
|
454
|
|
455 return buf->case_table;
|
|
456 }
|
428
|
457
|
|
458 DEFUN ("set-case-table", Fset_case_table, 1, 1, 0, /*
|
444
|
459 Select CASE-TABLE as the new case table for the current buffer.
|
446
|
460 A case table is a case-table object or list
|
|
461 (DOWNCASE UPCASE CANONICALIZE EQUIVALENCES)
|
428
|
462 where each element is either nil or a string of length 256.
|
446
|
463 The latter is provided for backward-compatibility.
|
428
|
464 DOWNCASE maps each character to its lower-case equivalent.
|
|
465 UPCASE maps each character to its upper-case equivalent;
|
|
466 if lower and upper case characters are in 1-1 correspondence,
|
|
467 you may use nil and the upcase table will be deduced from DOWNCASE.
|
|
468 CANONICALIZE maps each character to a canonical equivalent;
|
|
469 any two characters that are related by case-conversion have the same
|
|
470 canonical equivalent character; it may be nil, in which case it is
|
|
471 deduced from DOWNCASE and UPCASE.
|
|
472 EQUIVALENCES is a map that cyclicly permutes each equivalence class
|
|
473 (of characters with the same canonical equivalent); it may be nil,
|
|
474 in which case it is deduced from CANONICALIZE.
|
|
475
|
446
|
476 See also `get-case-table', `put-case-table' and `put-case-table-pair'.
|
428
|
477 */
|
444
|
478 (case_table))
|
428
|
479 {
|
446
|
480 /* This function can GC */
|
444
|
481 return set_case_table (case_table, 0);
|
428
|
482 }
|
|
483
|
|
484 DEFUN ("set-standard-case-table", Fset_standard_case_table, 1, 1, 0, /*
|
444
|
485 Select CASE-TABLE as the new standard case table for new buffers.
|
428
|
486 See `set-case-table' for more info on case tables.
|
|
487 */
|
444
|
488 (case_table))
|
428
|
489 {
|
446
|
490 /* This function can GC */
|
444
|
491 return set_case_table (case_table, 1);
|
428
|
492 }
|
|
493
|
|
494
|
|
495 void
|
|
496 syms_of_casetab (void)
|
|
497 {
|
446
|
498 INIT_LRECORD_IMPLEMENTATION (case_table);
|
|
499
|
563
|
500 DEFSYMBOL_MULTIWORD_PREDICATE (Qcase_tablep);
|
|
501 DEFSYMBOL (Qdowncase);
|
|
502 DEFSYMBOL (Qupcase);
|
428
|
503
|
826
|
504 DEFSUBR (Fmake_case_table);
|
428
|
505 DEFSUBR (Fcase_table_p);
|
446
|
506 DEFSUBR (Fget_case_table);
|
|
507 DEFSUBR (Fput_case_table);
|
|
508 DEFSUBR (Fput_case_table_pair);
|
428
|
509 DEFSUBR (Fcurrent_case_table);
|
|
510 DEFSUBR (Fstandard_case_table);
|
446
|
511 DEFSUBR (Fcopy_case_table);
|
428
|
512 DEFSUBR (Fset_case_table);
|
|
513 DEFSUBR (Fset_standard_case_table);
|
|
514 }
|
|
515
|
|
516 void
|
|
517 complex_vars_of_casetab (void)
|
|
518 {
|
867
|
519 REGISTER Ichar i;
|
428
|
520
|
446
|
521 staticpro (&Vstandard_case_table);
|
428
|
522
|
826
|
523 Vstandard_case_table = allocate_case_table (1);
|
428
|
524
|
|
525 for (i = 0; i < 256; i++)
|
|
526 {
|
|
527 unsigned char lowered = tolower (i);
|
|
528
|
826
|
529 SET_TRT_TABLE_OF (XCASE_TABLE_DOWNCASE (Vstandard_case_table), i,
|
|
530 lowered);
|
428
|
531 }
|
|
532
|
|
533 for (i = 0; i < 256; i++)
|
|
534 {
|
|
535 unsigned char flipped = (isupper (i) ? tolower (i)
|
|
536 : (islower (i) ? toupper (i) : i));
|
|
537
|
826
|
538 SET_TRT_TABLE_OF (XCASE_TABLE_UPCASE (Vstandard_case_table), i,
|
|
539 flipped);
|
428
|
540 }
|
826
|
541
|
|
542 recompute_case_table (Vstandard_case_table);
|
428
|
543 }
|