Mercurial > hg > xemacs-beta
comparison src/casetab.c @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | 859a2309aef8 |
children | 3d6bfa290dbd |
comparison
equal
deleted
inserted
replaced
69:804d1389bcd6 | 70:131b0175ea99 |
---|---|
43 #include "opaque.h" | 43 #include "opaque.h" |
44 | 44 |
45 Lisp_Object Qcase_table_p; | 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 | |
49 Lisp_Object Vmirror_ascii_downcase_table, Vmirror_ascii_upcase_table; | |
50 Lisp_Object Vmirror_ascii_canon_table, Vmirror_ascii_eqv_table; | |
51 #endif | |
48 Lisp_Object Qtranslate_table; | 52 Lisp_Object Qtranslate_table; |
49 | 53 |
50 static void compute_trt_inverse (Lisp_Object trt, Lisp_Object inverse); | 54 static void compute_trt_inverse (Lisp_Object trt, Lisp_Object inverse); |
51 | 55 |
52 #define STRING256_P(obj) \ | 56 #define STRING256_P(obj) \ |
127 canonical equivalent character; it may be nil, in which case it is | 131 canonical equivalent character; it may be nil, in which case it is |
128 deduced from DOWNCASE and UPCASE. | 132 deduced from DOWNCASE and UPCASE. |
129 EQUIVALENCES is a map that cyclicly permutes each equivalence class | 133 EQUIVALENCES is a map that cyclicly permutes each equivalence class |
130 (of characters with the same canonical equivalent); it may be nil, | 134 (of characters with the same canonical equivalent); it may be nil, |
131 in which case it is deduced from CANONICALIZE. | 135 in which case it is deduced from CANONICALIZE. |
136 | |
137 BUG: Under XEmacs/Mule, translations to or from non-ASCII characters | |
138 (this includes chars in the range 128 - 255) are ignored by | |
139 the string/buffer-searching routines. Thus, `case-fold-search' | |
140 will not correctly conflate a-umlaut and A-umlaut even if the | |
141 case tables call for this. | |
132 */ | 142 */ |
133 (table)) | 143 (table)) |
134 { | 144 { |
135 return set_case_table (table, 0); | 145 return set_case_table (table, 0); |
136 } | 146 } |
141 */ | 151 */ |
142 (table)) | 152 (table)) |
143 { | 153 { |
144 return set_case_table (table, 1); | 154 return set_case_table (table, 1); |
145 } | 155 } |
156 | |
157 #ifdef MULE | |
158 | |
159 static Lisp_Object | |
160 make_mirror_trt_table (Lisp_Object table) | |
161 { | |
162 Lisp_Object new_table; | |
163 | |
164 if (!STRING256_P (table)) | |
165 { | |
166 #ifdef DEBUG_XEMACS | |
167 /* This should be caught farther up. */ | |
168 abort (); | |
169 #else | |
170 signal_simple_error ("Invalid translate table", table); | |
171 #endif | |
172 } | |
173 | |
174 new_table = MAKE_MIRROR_TRT_TABLE (); | |
175 { | |
176 int i; | |
177 | |
178 for (i = 0; i < 256; i++) | |
179 { | |
180 Emchar newval = string_char (XSTRING (table), i); | |
181 if ((i >= 128 && newval != i) | |
182 || (i < 128 && newval >= 128)) | |
183 { | |
184 newval = (Emchar) i; | |
185 } | |
186 SET_MIRROR_TRT_TABLE_CHAR_1 (new_table, i, newval); | |
187 } | |
188 } | |
189 return new_table; | |
190 } | |
191 | |
192 #endif /* MULE */ | |
146 | 193 |
147 static Lisp_Object | 194 static Lisp_Object |
148 set_case_table (Lisp_Object table, int standard) | 195 set_case_table (Lisp_Object table, int standard) |
149 { | 196 { |
150 Lisp_Object down, up, canon, eqv; | 197 Lisp_Object down, up, canon, eqv; |
192 { | 239 { |
193 Vascii_downcase_table = down; | 240 Vascii_downcase_table = down; |
194 Vascii_upcase_table = up; | 241 Vascii_upcase_table = up; |
195 Vascii_canon_table = canon; | 242 Vascii_canon_table = canon; |
196 Vascii_eqv_table = eqv; | 243 Vascii_eqv_table = eqv; |
244 #ifdef MULE | |
245 Vmirror_ascii_downcase_table = make_mirror_trt_table (down); | |
246 Vmirror_ascii_upcase_table = make_mirror_trt_table (up); | |
247 Vmirror_ascii_canon_table = make_mirror_trt_table (canon); | |
248 Vmirror_ascii_eqv_table = make_mirror_trt_table (eqv); | |
249 #endif | |
197 } | 250 } |
198 else | 251 else |
199 { | 252 { |
200 buf->downcase_table = down; | 253 buf->downcase_table = down; |
201 buf->upcase_table = up; | 254 buf->upcase_table = up; |
202 buf->case_canon_table = canon; | 255 buf->case_canon_table = canon; |
203 buf->case_eqv_table = eqv; | 256 buf->case_eqv_table = eqv; |
257 #ifdef MULE | |
258 buf->mirror_downcase_table = make_mirror_trt_table (down); | |
259 buf->mirror_upcase_table = make_mirror_trt_table (up); | |
260 buf->mirror_case_canon_table = make_mirror_trt_table (canon); | |
261 buf->mirror_case_eqv_table = make_mirror_trt_table (eqv); | |
262 #endif | |
204 } | 263 } |
205 return table; | 264 return table; |
206 } | 265 } |
207 | 266 |
208 /* Given a translate table TRT, store the inverse mapping into INVERSE. | 267 /* Given a translate table TRT, store the inverse mapping into INVERSE. |
266 { | 325 { |
267 unsigned char lowered = tolower (i); | 326 unsigned char lowered = tolower (i); |
268 | 327 |
269 SET_TRT_TABLE_CHAR_1 (tem, i, lowered); | 328 SET_TRT_TABLE_CHAR_1 (tem, i, lowered); |
270 } | 329 } |
330 | |
331 #ifdef MULE | |
332 tem = make_mirror_trt_table (tem); | |
333 Vmirror_ascii_downcase_table = tem; | |
334 Vmirror_ascii_canon_table = tem; | |
335 #endif | |
271 | 336 |
272 tem = MAKE_TRT_TABLE (); | 337 tem = MAKE_TRT_TABLE (); |
273 Vascii_upcase_table = tem; | 338 Vascii_upcase_table = tem; |
274 Vascii_eqv_table = tem; | 339 Vascii_eqv_table = tem; |
275 | 340 |
279 : (islower (i) ? toupper (i) : i)); | 344 : (islower (i) ? toupper (i) : i)); |
280 | 345 |
281 SET_TRT_TABLE_CHAR_1 (tem, i, flipped); | 346 SET_TRT_TABLE_CHAR_1 (tem, i, flipped); |
282 } | 347 } |
283 | 348 |
284 } | 349 #ifdef MULE |
350 tem = make_mirror_trt_table (tem); | |
351 Vmirror_ascii_upcase_table = tem; | |
352 Vmirror_ascii_eqv_table = tem; | |
353 #endif | |
354 } |