aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2002-05-31 10:47:52 +0000
committerKenichi Handa2002-05-31 10:47:52 +0000
commit3b4f44460356b861b698c1ed177ec85e13f6e9eb (patch)
treead266a761c776b1e3aceea6366cc0a2589ad507a /src
parent69b588e4ba4b8ecc168e7bf2a9a43d05a4185ada (diff)
downloademacs-3b4f44460356b861b698c1ed177ec85e13f6e9eb.tar.gz
emacs-3b4f44460356b861b698c1ed177ec85e13f6e9eb.zip
(load_charset_map): Handle the case that from < to correctly.
Diffstat (limited to 'src')
-rw-r--r--src/charset.c84
1 files changed, 47 insertions, 37 deletions
diff --git a/src/charset.c b/src/charset.c
index 126b741aa57..e2ef9b08651 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -221,84 +221,94 @@ load_charset_map (charset, entries, n_entries, control_flag)
221 for (i = 0; i < n_entries; i++) 221 for (i = 0; i < n_entries; i++)
222 { 222 {
223 unsigned from, to; 223 unsigned from, to;
224 int c; 224 int from_index, to_index;
225 int from_c, to_c;
225 int idx = i % 0x10000; 226 int idx = i % 0x10000;
226 227
227 if (i > 0 && idx == 0) 228 if (i > 0 && idx == 0)
228 entries = entries->next; 229 entries = entries->next;
229 from = entries->entry[idx].from; 230 from = entries->entry[idx].from;
230 to = entries->entry[idx].to; 231 to = entries->entry[idx].to;
231 c = entries->entry[idx].c; 232 from_c = entries->entry[idx].c;
233 from_index = CODE_POINT_TO_INDEX (charset, from);
234 if (from == to)
235 {
236 to_index = from_index;
237 to_c = from_c;
238 }
239 else
240 {
241 to_index = CODE_POINT_TO_INDEX (charset, to);
242 to_c = from_c + (to_index - from_index);
243 }
244 if (from_index < 0 || to_index < 0)
245 continue;
232 246
233 if (control_flag < 2) 247 if (control_flag < 2)
234 { 248 {
249 int c;
250
251 if (to_c > max_char)
252 max_char = to_c;
253 else if (from_c < min_char)
254 min_char = from_c;
255 if (ascii_compatible_p)
256 {
257 if (! ASCII_BYTE_P (from_c))
258 {
259 if (from_c < nonascii_min_char)
260 nonascii_min_char = from_c;
261 }
262 else if (! ASCII_BYTE_P (to_c))
263 {
264 nonascii_min_char = 0x80;
265 }
266 }
267
268 for (c = from_c; c <= to_c; c++)
269 CHARSET_FAST_MAP_SET (c, fast_map);
270
235 if (control_flag == 1) 271 if (control_flag == 1)
236 { 272 {
237 unsigned code = from; 273 unsigned code = from;
238 int from_index, to_index;
239 274
240 from_index = CODE_POINT_TO_INDEX (charset, from);
241 if (from == to)
242 to_index = from_index;
243 else
244 to_index = CODE_POINT_TO_INDEX (charset, to);
245 if (from_index < 0 || to_index < 0)
246 continue;
247 if (CHARSET_COMPACT_CODES_P (charset)) 275 if (CHARSET_COMPACT_CODES_P (charset))
248 while (1) 276 while (1)
249 { 277 {
250 ASET (vec, from_index, make_number (c)); 278 ASET (vec, from_index, make_number (from_c));
251 CHAR_TABLE_SET (table, c, make_number (code)); 279 CHAR_TABLE_SET (table, from_c, make_number (code));
252 if (from_index == to_index) 280 if (from_index == to_index)
253 break; 281 break;
254 from_index++, c++; 282 from_index++, from_c++;
255 code = INDEX_TO_CODE_POINT (charset, from_index); 283 code = INDEX_TO_CODE_POINT (charset, from_index);
256 } 284 }
257 else 285 else
258 for (; from_index <= to_index; from_index++, c++) 286 for (; from_index <= to_index; from_index++, from_c++)
259 { 287 {
260 ASET (vec, from_index, make_number (c)); 288 ASET (vec, from_index, make_number (from_c));
261 CHAR_TABLE_SET (table, c, make_number (from_index)); 289 CHAR_TABLE_SET (table, from_c, make_number (from_index));
262 } 290 }
263 } 291 }
264
265 if (c > max_char)
266 max_char = c;
267 else if (c < min_char)
268 min_char = c;
269 if (ascii_compatible_p && ! ASCII_BYTE_P (c)
270 && c < nonascii_min_char)
271 nonascii_min_char = c;
272
273 CHARSET_FAST_MAP_SET (c, fast_map);
274 } 292 }
275 else 293 else
276 { 294 {
277 unsigned code = from; 295 unsigned code = from;
278 int from_index, to_index;
279 296
280 from_index = CODE_POINT_TO_INDEX (charset, from);
281 if (from == to)
282 to_index = from_index;
283 else
284 to_index = CODE_POINT_TO_INDEX (charset, to);
285 if (from_index < 0 || to_index < 0)
286 continue;
287 while (1) 297 while (1)
288 { 298 {
289 int c1 = DECODE_CHAR (charset, code); 299 int c1 = DECODE_CHAR (charset, code);
290 300
291 if (c1 >= 0) 301 if (c1 >= 0)
292 { 302 {
293 CHAR_TABLE_SET (table, c, make_number (c1)); 303 CHAR_TABLE_SET (table, from_c, make_number (c1));
294 CHAR_TABLE_SET (Vchar_unify_table, c1, c); 304 CHAR_TABLE_SET (Vchar_unify_table, c1, from_c);
295 if (CHAR_TABLE_P (Vchar_unified_charset_table)) 305 if (CHAR_TABLE_P (Vchar_unified_charset_table))
296 CHAR_TABLE_SET (Vchar_unified_charset_table, c1, 306 CHAR_TABLE_SET (Vchar_unified_charset_table, c1,
297 CHARSET_NAME (charset)); 307 CHARSET_NAME (charset));
298 } 308 }
299 if (from_index == to_index) 309 if (from_index == to_index)
300 break; 310 break;
301 from_index++, c++; 311 from_index++, from_c++;
302 code = INDEX_TO_CODE_POINT (charset, from_index); 312 code = INDEX_TO_CODE_POINT (charset, from_index);
303 } 313 }
304 } 314 }