comparison src/casetab.c @ 412:697ef44129c6 r21-2-14

Import from CVS: tag r21-2-14
author cvs
date Mon, 13 Aug 2007 11:20:41 +0200
parents de805c49cfc1
children 11054d720c21
comparison
equal deleted inserted replaced
411:12e008d41344 412:697ef44129c6
40 #include <config.h> 40 #include <config.h>
41 #include "lisp.h" 41 #include "lisp.h"
42 #include "buffer.h" 42 #include "buffer.h"
43 #include "opaque.h" 43 #include "opaque.h"
44 44
45 Lisp_Object Qcase_tablep; 45 Lisp_Object Qcase_table_p;
46 Lisp_Object Vascii_downcase_table, Vascii_upcase_table; 46 Lisp_Object Vascii_downcase_table, Vascii_upcase_table;
47 Lisp_Object Vascii_canon_table, Vascii_eqv_table; 47 Lisp_Object Vascii_canon_table, Vascii_eqv_table;
48 #ifdef MULE 48 #ifdef MULE
49 Lisp_Object Vmirror_ascii_downcase_table, Vmirror_ascii_upcase_table; 49 Lisp_Object Vmirror_ascii_downcase_table, Vmirror_ascii_upcase_table;
50 Lisp_Object Vmirror_ascii_canon_table, Vmirror_ascii_eqv_table; 50 Lisp_Object Vmirror_ascii_canon_table, Vmirror_ascii_eqv_table;
51 #endif 51 #endif
52 Lisp_Object Qtranslate_table;
52 53
53 static void compute_trt_inverse (Lisp_Object trt, Lisp_Object inverse); 54 static void compute_trt_inverse (Lisp_Object trt, Lisp_Object inverse);
54 55
55 #define STRING256_P(obj) (STRINGP (obj) && XSTRING_CHAR_LENGTH (obj) == 256) 56 #define STRING256_P(obj) (STRINGP (obj) && XSTRING_CHAR_LENGTH (obj) == 256)
56 57
78 check_case_table (Lisp_Object obj) 79 check_case_table (Lisp_Object obj)
79 { 80 {
80 REGISTER Lisp_Object tem; 81 REGISTER Lisp_Object tem;
81 82
82 while (tem = Fcase_table_p (obj), NILP (tem)) 83 while (tem = Fcase_table_p (obj), NILP (tem))
83 obj = wrong_type_argument (Qcase_tablep, obj); 84 obj = wrong_type_argument (Qcase_table_p, obj);
84 return (obj); 85 return (obj);
85 } 86 }
86 87
87 DEFUN ("current-case-table", Fcurrent_case_table, 0, 1, 0, /* 88 DEFUN ("current-case-table", Fcurrent_case_table, 0, 1, 0, /*
88 Return the case table of BUFFER, which defaults to the current buffer. 89 Return the case table of BUFFER, which defaults to the current buffer.
187 188
188 static Lisp_Object 189 static Lisp_Object
189 set_case_table (Lisp_Object table, int standard) 190 set_case_table (Lisp_Object table, int standard)
190 { 191 {
191 Lisp_Object down, up, canon, eqv, tail = table; 192 Lisp_Object down, up, canon, eqv, tail = table;
192 struct buffer *buf = 193 struct buffer *buf = current_buffer;
193 standard ? XBUFFER(Vbuffer_defaults) : current_buffer;
194 194
195 check_case_table (table); 195 check_case_table (table);
196 196
197 down = XCAR (tail); tail = XCDR (tail); 197 down = XCAR (tail); tail = XCDR (tail);
198 up = XCAR (tail); tail = XCDR (tail); 198 up = XCAR (tail); tail = XCDR (tail);
241 Vmirror_ascii_upcase_table = make_mirror_trt_table (up); 241 Vmirror_ascii_upcase_table = make_mirror_trt_table (up);
242 Vmirror_ascii_canon_table = make_mirror_trt_table (canon); 242 Vmirror_ascii_canon_table = make_mirror_trt_table (canon);
243 Vmirror_ascii_eqv_table = make_mirror_trt_table (eqv); 243 Vmirror_ascii_eqv_table = make_mirror_trt_table (eqv);
244 #endif 244 #endif
245 } 245 }
246 buf->downcase_table = down; 246 else
247 buf->upcase_table = up; 247 {
248 buf->case_canon_table = canon; 248 buf->downcase_table = down;
249 buf->case_eqv_table = eqv; 249 buf->upcase_table = up;
250 #ifdef MULE 250 buf->case_canon_table = canon;
251 buf->mirror_downcase_table = make_mirror_trt_table (down); 251 buf->case_eqv_table = eqv;
252 buf->mirror_upcase_table = make_mirror_trt_table (up); 252 #ifdef MULE
253 buf->mirror_case_canon_table = make_mirror_trt_table (canon); 253 buf->mirror_downcase_table = make_mirror_trt_table (down);
254 buf->mirror_case_eqv_table = make_mirror_trt_table (eqv); 254 buf->mirror_upcase_table = make_mirror_trt_table (up);
255 #endif 255 buf->mirror_case_canon_table = make_mirror_trt_table (canon);
256 256 buf->mirror_case_eqv_table = make_mirror_trt_table (eqv);
257 #endif
258 }
257 return table; 259 return table;
258 } 260 }
259 261
260 /* Given a translate table TRT, store the inverse mapping into INVERSE. 262 /* Given a translate table TRT, store the inverse mapping into INVERSE.
261 Since TRT is not one-to-one, INVERSE is not a simple mapping. 263 Since TRT is not one-to-one, INVERSE is not a simple mapping.
285 287
286 288
287 void 289 void
288 syms_of_casetab (void) 290 syms_of_casetab (void)
289 { 291 {
290 defsymbol (&Qcase_tablep, "case-table-p"); 292 defsymbol (&Qcase_table_p, "case-table-p");
293 defsymbol (&Qtranslate_table, "translate-table");
291 294
292 DEFSUBR (Fcase_table_p); 295 DEFSUBR (Fcase_table_p);
293 DEFSUBR (Fcurrent_case_table); 296 DEFSUBR (Fcurrent_case_table);
294 DEFSUBR (Fstandard_case_table); 297 DEFSUBR (Fstandard_case_table);
295 DEFSUBR (Fset_case_table); 298 DEFSUBR (Fset_case_table);
305 staticpro (&Vascii_downcase_table); 308 staticpro (&Vascii_downcase_table);
306 staticpro (&Vascii_upcase_table); 309 staticpro (&Vascii_upcase_table);
307 staticpro (&Vascii_canon_table); 310 staticpro (&Vascii_canon_table);
308 staticpro (&Vascii_eqv_table); 311 staticpro (&Vascii_eqv_table);
309 312
310 #ifdef MULE
311 staticpro (&Vmirror_ascii_downcase_table);
312 staticpro (&Vmirror_ascii_upcase_table);
313 staticpro (&Vmirror_ascii_canon_table);
314 staticpro (&Vmirror_ascii_eqv_table);
315 #endif
316
317 tem = MAKE_TRT_TABLE (); 313 tem = MAKE_TRT_TABLE ();
318 Vascii_downcase_table = tem; 314 Vascii_downcase_table = tem;
319 Vascii_canon_table = tem; 315 Vascii_canon_table = tem;
320 316
321 /* Under Mule, can't do set_string_char() until Vcharset_control_1 317 /* Under Mule, can't do set_string_char() until Vcharset_control_1