aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2002-05-10 03:54:48 +0000
committerKenichi Handa2002-05-10 03:54:48 +0000
commit69f8de5b05d006686ef2b9c244bd4370a09d21ff (patch)
tree5b00a7a30bead42c99751d4d747b784017d4f063 /src
parentb74e4686d549abe1ff888e92d77b7e1d8e90b897 (diff)
downloademacs-69f8de5b05d006686ef2b9c244bd4370a09d21ff.tar.gz
emacs-69f8de5b05d006686ef2b9c244bd4370a09d21ff.zip
(load_charset_map): Fix previous change.
(read_hex): Don't treat SPC as a comment starter. (decode_char): If CODE_POINT_TO_INDEX retruns -1, always return -1. (Fdecode_char): Fix typo. (CODE_POINT_TO_INDEX): Utilize `code_space_mask' member to check if CODE is valid or not. (Fdefine_charset_internal): Initialize `code_space_mask' member. (encode_char): Before calling CODE_POINT_TO_INDEX, check if CODE is within the range of charset->min_code and carset->max_code.
Diffstat (limited to 'src')
-rw-r--r--src/charset.c69
1 files changed, 48 insertions, 21 deletions
diff --git a/src/charset.c b/src/charset.c
index 46f7c717e46..1e139fb3630 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -118,20 +118,20 @@ Lisp_Object Vcharset_map_directory;
118 118
119Lisp_Object Vchar_unified_charset_table; 119Lisp_Object Vchar_unified_charset_table;
120 120
121#define CODE_POINT_TO_INDEX(charset, code) \ 121#define CODE_POINT_TO_INDEX(charset, code) \
122 ((charset)->code_linear_p \ 122 ((charset)->code_linear_p \
123 ? (code) - (charset)->min_code \ 123 ? (code) - (charset)->min_code \
124 : ((((code) >> 24) <= (charset)->code_space[13]) \ 124 : (((charset)->code_space_mask[(code) >> 24] & 0x8) \
125 && ((((code) >> 16) & 0xFF) <= (charset)->code_space[9]) \ 125 && ((charset)->code_space_mask[((code) >> 16) & 0xFF] & 0x4) \
126 && ((((code) >> 8) & 0xFF) <= (charset)->code_space[5]) \ 126 && ((charset)->code_space_mask[((code) >> 8) & 0xFF] & 0x2) \
127 && (((code) & 0xFF) <= (charset)->code_space[1])) \ 127 && ((charset)->code_space_mask[(code) & 0xFF] & 0x1)) \
128 ? (((((code) >> 24) - (charset)->code_space[12]) \ 128 ? (((((code) >> 24) - (charset)->code_space[12]) \
129 * (charset)->code_space[11]) \ 129 * (charset)->code_space[11]) \
130 + (((((code) >> 16) & 0xFF) - (charset)->code_space[8]) \ 130 + (((((code) >> 16) & 0xFF) - (charset)->code_space[8]) \
131 * (charset)->code_space[7]) \ 131 * (charset)->code_space[7]) \
132 + (((((code) >> 8) & 0xFF) - (charset)->code_space[4]) \ 132 + (((((code) >> 8) & 0xFF) - (charset)->code_space[4]) \
133 * (charset)->code_space[3]) \ 133 * (charset)->code_space[3]) \
134 + (((code) & 0xFF) - (charset)->code_space[0])) \ 134 + (((code) & 0xFF) - (charset)->code_space[0])) \
135 : -1) 135 : -1)
136 136
137 137
@@ -268,10 +268,20 @@ load_charset_map (charset, entries, n_entries, control_flag)
268 } 268 }
269 else 269 else
270 { 270 {
271 for (; from <= to; from++) 271 unsigned code = from;
272 { 272 int from_index, to_index;
273 int c1 = DECODE_CHAR (charset, from);
274 273
274 from_index = CODE_POINT_TO_INDEX (charset, from);
275 if (from == to)
276 to_index = from_index;
277 else
278 to_index = CODE_POINT_TO_INDEX (charset, to);
279 if (from_index < 0 || to_index < 0)
280 continue;
281 while (1)
282 {
283 int c1 = DECODE_CHAR (charset, code);
284
275 if (c1 >= 0) 285 if (c1 >= 0)
276 { 286 {
277 CHAR_TABLE_SET (table, c, make_number (c1)); 287 CHAR_TABLE_SET (table, c, make_number (c1));
@@ -280,6 +290,10 @@ load_charset_map (charset, entries, n_entries, control_flag)
280 CHAR_TABLE_SET (Vchar_unified_charset_table, c1, 290 CHAR_TABLE_SET (Vchar_unified_charset_table, c1,
281 CHARSET_NAME (charset)); 291 CHARSET_NAME (charset));
282 } 292 }
293 if (from_index == to_index)
294 break;
295 from_index++, c++;
296 code = INDEX_TO_CODE_POINT (charset, from_index);
283 } 297 }
284 } 298 }
285 } 299 }
@@ -313,7 +327,7 @@ read_hex (fp, eof)
313 327
314 while ((c = getc (fp)) != EOF) 328 while ((c = getc (fp)) != EOF)
315 { 329 {
316 if (c == '#' || c == ' ') 330 if (c == '#')
317 { 331 {
318 while ((c = getc (fp)) != EOF && c != '\n'); 332 while ((c = getc (fp)) != EOF && c != '\n');
319 } 333 }
@@ -648,7 +662,7 @@ DEFUN ("define-charset-internal", Fdefine_charset_internal,
648 Lisp_Object val; 662 Lisp_Object val;
649 unsigned hash_code; 663 unsigned hash_code;
650 struct Lisp_Hash_Table *hash_table = XHASH_TABLE (Vcharset_hash_table); 664 struct Lisp_Hash_Table *hash_table = XHASH_TABLE (Vcharset_hash_table);
651 int i; 665 int i, j;
652 struct charset charset; 666 struct charset charset;
653 int id; 667 int id;
654 int dimension; 668 int dimension;
@@ -702,6 +716,16 @@ DEFUN ("define-charset-internal", Fdefine_charset_internal,
702 && (charset.dimension == 3 716 && (charset.dimension == 3
703 || charset.code_space[10] == 256))))); 717 || charset.code_space[10] == 256)))));
704 718
719 if (! charset.code_linear_p)
720 {
721 charset.code_space_mask = (unsigned char *) xmalloc (256);
722 bzero (charset.code_space_mask, sizeof (charset.code_space_mask));
723 for (i = 0; i < 4; i++)
724 for (j = charset.code_space[i * 4]; j <= charset.code_space[i * 4 + 1];
725 j++)
726 charset.code_space_mask[j] |= (1 << i);
727 }
728
705 charset.iso_chars_96 = charset.code_space[2] == 96; 729 charset.iso_chars_96 = charset.code_space[2] == 96;
706 730
707 charset.min_code = (charset.code_space[0] 731 charset.min_code = (charset.code_space[0]
@@ -1277,6 +1301,8 @@ decode_char (charset, code)
1277 else 1301 else
1278 { 1302 {
1279 char_index = CODE_POINT_TO_INDEX (charset, code); 1303 char_index = CODE_POINT_TO_INDEX (charset, code);
1304 if (char_index < 0)
1305 return -1;
1280 1306
1281 if (method == CHARSET_METHOD_MAP) 1307 if (method == CHARSET_METHOD_MAP)
1282 { 1308 {
@@ -1350,7 +1376,8 @@ encode_char (charset, c)
1350 && (code_offset < 0 || code >= code_offset)) 1376 && (code_offset < 0 || code >= code_offset))
1351 { 1377 {
1352 code -= code_offset; 1378 code -= code_offset;
1353 if (CODE_POINT_TO_INDEX (charset, code) >= 0) 1379 if (code >= charset->min_code && code <= charset->max_code
1380 && CODE_POINT_TO_INDEX (charset, code) >= 0)
1354 return code; 1381 return code;
1355 } 1382 }
1356 } 1383 }
@@ -1406,7 +1433,7 @@ and CODE-POINT to a chracter. Currently not supported and just ignored. */)
1406 { 1433 {
1407 CHECK_NATNUM (XCAR (code_point)); 1434 CHECK_NATNUM (XCAR (code_point));
1408 CHECK_NATNUM (XCDR (code_point)); 1435 CHECK_NATNUM (XCDR (code_point));
1409 code = (XINT (XCAR (code_point)) << 16) | (XINT (XCAR (code_point))); 1436 code = (XINT (XCAR (code_point)) << 16) | (XINT (XCDR (code_point)));
1410 } 1437 }
1411 else 1438 else
1412 { 1439 {