Mercurial > hg > xemacs-beta
comparison src/mule-charset.c @ 337:fbbf69b4e8a7 r21-0-66
Import from CVS: tag r21-0-66
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:51:02 +0200 |
parents | 19dcec799385 |
children | 7c94d56991e1 |
comparison
equal
deleted
inserted
replaced
336:fe0a93612022 | 337:fbbf69b4e8a7 |
---|---|
56 Lisp_Object Vcharset_chinese_big5_1; | 56 Lisp_Object Vcharset_chinese_big5_1; |
57 Lisp_Object Vcharset_chinese_big5_2; | 57 Lisp_Object Vcharset_chinese_big5_2; |
58 Lisp_Object Vcharset_chinese_cns11643_1; | 58 Lisp_Object Vcharset_chinese_cns11643_1; |
59 Lisp_Object Vcharset_chinese_cns11643_2; | 59 Lisp_Object Vcharset_chinese_cns11643_2; |
60 Lisp_Object Vcharset_korean_ksc5601; | 60 Lisp_Object Vcharset_korean_ksc5601; |
61 | |
62 #ifdef ENABLE_COMPOSITE_CHARS | |
61 Lisp_Object Vcharset_composite; | 63 Lisp_Object Vcharset_composite; |
62 | 64 |
63 /* Hashtables for composite chars. One maps string representing | 65 /* Hashtables for composite chars. One maps string representing |
64 composed chars to their equivalent chars; one goes the | 66 composed chars to their equivalent chars; one goes the |
65 other way. */ | 67 other way. */ |
66 Lisp_Object Vcomposite_char_char2string_hashtable; | 68 Lisp_Object Vcomposite_char_char2string_hashtable; |
67 Lisp_Object Vcomposite_char_string2char_hashtable; | 69 Lisp_Object Vcomposite_char_string2char_hashtable; |
68 | 70 |
71 static int composite_char_row_next; | |
72 static int composite_char_col_next; | |
73 | |
74 #endif /* ENABLE_COMPOSITE_CHARS */ | |
75 | |
69 /* Table of charsets indexed by leading byte. */ | 76 /* Table of charsets indexed by leading byte. */ |
70 Lisp_Object charset_by_leading_byte[128]; | 77 Lisp_Object charset_by_leading_byte[128]; |
71 | 78 |
72 /* Table of charsets indexed by type/final-byte/direction. */ | 79 /* Table of charsets indexed by type/final-byte/direction. */ |
73 Lisp_Object charset_by_attributes[4][128][2]; | 80 Lisp_Object charset_by_attributes[4][128][2]; |
74 | |
75 static int composite_char_row_next; | |
76 static int composite_char_col_next; | |
77 | 81 |
78 /* Table of number of bytes in the string representation of a character | 82 /* Table of number of bytes in the string representation of a character |
79 indexed by the first byte of that representation. | 83 indexed by the first byte of that representation. |
80 | 84 |
81 rep_bytes_by_first_byte(c) is more efficient than the equivalent | 85 rep_bytes_by_first_byte(c) is more efficient than the equivalent |
275 f1 > MAX_CHAR_FIELD1_PRIVATE) | 279 f1 > MAX_CHAR_FIELD1_PRIVATE) |
276 return 0; | 280 return 0; |
277 if (f2 < 0x20 || f3 < 0x20) | 281 if (f2 < 0x20 || f3 < 0x20) |
278 return 0; | 282 return 0; |
279 | 283 |
284 | |
285 #ifdef ENABLE_COMPOSITE_CHARS | |
280 if (f1 + FIELD1_TO_OFFICIAL_LEADING_BYTE == LEADING_BYTE_COMPOSITE) | 286 if (f1 + FIELD1_TO_OFFICIAL_LEADING_BYTE == LEADING_BYTE_COMPOSITE) |
281 { | 287 { |
282 if (UNBOUNDP (Fgethash (make_int (ch), | 288 if (UNBOUNDP (Fgethash (make_int (ch), |
283 Vcomposite_char_char2string_hashtable, | 289 Vcomposite_char_char2string_hashtable, |
284 Qunbound))) | 290 Qunbound))) |
285 return 0; | 291 return 0; |
286 return 1; | 292 return 1; |
287 } | 293 } |
294 #endif /* ENABLE_COMPOSITE_CHARS */ | |
288 | 295 |
289 if (f2 != 0x20 && f2 != 0x7F && f3 != 0x20 && f3 != 0x7F) | 296 if (f2 != 0x20 && f2 != 0x7F && f3 != 0x20 && f3 != 0x7F) |
290 return 1; | 297 return 1; |
291 | 298 |
292 if (f1 <= MAX_CHAR_FIELD1_OFFICIAL) | 299 if (f1 <= MAX_CHAR_FIELD1_OFFICIAL) |
459 | 466 |
460 CHARSET_DIMENSION (cs) = (CHARSET_TYPE (cs) == CHARSET_TYPE_94 || | 467 CHARSET_DIMENSION (cs) = (CHARSET_TYPE (cs) == CHARSET_TYPE_94 || |
461 CHARSET_TYPE (cs) == CHARSET_TYPE_96) ? 1 : 2; | 468 CHARSET_TYPE (cs) == CHARSET_TYPE_96) ? 1 : 2; |
462 CHARSET_CHARS (cs) = (CHARSET_TYPE (cs) == CHARSET_TYPE_94 || | 469 CHARSET_CHARS (cs) = (CHARSET_TYPE (cs) == CHARSET_TYPE_94 || |
463 CHARSET_TYPE (cs) == CHARSET_TYPE_94X94) ? 94 : 96; | 470 CHARSET_TYPE (cs) == CHARSET_TYPE_94X94) ? 94 : 96; |
464 | 471 |
465 if (final) | 472 if (final) |
466 { | 473 { |
467 /* some charsets do not have final characters. This includes | 474 /* some charsets do not have final characters. This includes |
468 ASCII, Control-1, Composite, and the two faux private | 475 ASCII, Control-1, Composite, and the two faux private |
469 charsets. */ | 476 charsets. */ |
1066 BREAKUP_CHAR (XCHAR (ch), charset, c1, c2); | 1073 BREAKUP_CHAR (XCHAR (ch), charset, c1, c2); |
1067 return make_int (int_n == 0 ? c1 : c2); | 1074 return make_int (int_n == 0 ? c1 : c2); |
1068 } | 1075 } |
1069 | 1076 |
1070 | 1077 |
1078 #ifdef ENABLE_COMPOSITE_CHARS | |
1071 /************************************************************************/ | 1079 /************************************************************************/ |
1072 /* composite character functions */ | 1080 /* composite character functions */ |
1073 /************************************************************************/ | 1081 /************************************************************************/ |
1074 | 1082 |
1075 Emchar | 1083 Emchar |
1111 Qunbound); | 1119 Qunbound); |
1112 assert (!UNBOUNDP (str)); | 1120 assert (!UNBOUNDP (str)); |
1113 return str; | 1121 return str; |
1114 } | 1122 } |
1115 | 1123 |
1116 DEFUN ("make-composite-char", Fmake_composite_char, 1, 1, 0, /* | 1124 xxDEFUN ("make-composite-char", Fmake_composite_char, 1, 1, 0, /* |
1117 Convert a string into a single composite character. | 1125 Convert a string into a single composite character. |
1118 The character is the result of overstriking all the characters in | 1126 The character is the result of overstriking all the characters in |
1119 the string. | 1127 the string. |
1120 */ | 1128 */ |
1121 (string)) | 1129 (string)) |
1123 CHECK_STRING (string); | 1131 CHECK_STRING (string); |
1124 return make_char (lookup_composite_char (XSTRING_DATA (string), | 1132 return make_char (lookup_composite_char (XSTRING_DATA (string), |
1125 XSTRING_LENGTH (string))); | 1133 XSTRING_LENGTH (string))); |
1126 } | 1134 } |
1127 | 1135 |
1128 DEFUN ("composite-char-string", Fcomposite_char_string, 1, 1, 0, /* | 1136 xxDEFUN ("composite-char-string", Fcomposite_char_string, 1, 1, 0, /* |
1129 Return a string of the characters comprising a composite character. | 1137 Return a string of the characters comprising a composite character. |
1130 */ | 1138 */ |
1131 (ch)) | 1139 (ch)) |
1132 { | 1140 { |
1133 Emchar emch; | 1141 Emchar emch; |
1136 emch = XCHAR (ch); | 1144 emch = XCHAR (ch); |
1137 if (CHAR_LEADING_BYTE (emch) != LEADING_BYTE_COMPOSITE) | 1145 if (CHAR_LEADING_BYTE (emch) != LEADING_BYTE_COMPOSITE) |
1138 signal_simple_error ("Must be composite char", ch); | 1146 signal_simple_error ("Must be composite char", ch); |
1139 return composite_char_string (emch); | 1147 return composite_char_string (emch); |
1140 } | 1148 } |
1149 #endif /* ENABLE_COMPOSITE_CHARS */ | |
1141 | 1150 |
1142 | 1151 |
1143 /************************************************************************/ | 1152 /************************************************************************/ |
1144 /* initialization */ | 1153 /* initialization */ |
1145 /************************************************************************/ | 1154 /************************************************************************/ |
1165 | 1174 |
1166 DEFSUBR (Fmake_char); | 1175 DEFSUBR (Fmake_char); |
1167 DEFSUBR (Fchar_charset); | 1176 DEFSUBR (Fchar_charset); |
1168 DEFSUBR (Fchar_octet); | 1177 DEFSUBR (Fchar_octet); |
1169 | 1178 |
1179 #ifdef ENABLE_COMPOSITE_CHARS | |
1170 DEFSUBR (Fmake_composite_char); | 1180 DEFSUBR (Fmake_composite_char); |
1171 DEFSUBR (Fcomposite_char_string); | 1181 DEFSUBR (Fcomposite_char_string); |
1182 #endif | |
1172 | 1183 |
1173 defsymbol (&Qcharsetp, "charsetp"); | 1184 defsymbol (&Qcharsetp, "charsetp"); |
1174 defsymbol (&Qregistry, "registry"); | 1185 defsymbol (&Qregistry, "registry"); |
1175 defsymbol (&Qfinal, "final"); | 1186 defsymbol (&Qfinal, "final"); |
1176 defsymbol (&Qgraphic, "graphic"); | 1187 defsymbol (&Qgraphic, "graphic"); |
1395 make_charset (147, Qkorean_ksc5601, LEADING_BYTE_KOREAN_KSC5601, 3, | 1406 make_charset (147, Qkorean_ksc5601, LEADING_BYTE_KOREAN_KSC5601, 3, |
1396 CHARSET_TYPE_94X94, 2, 0, 'C', | 1407 CHARSET_TYPE_94X94, 2, 0, 'C', |
1397 CHARSET_LEFT_TO_RIGHT, | 1408 CHARSET_LEFT_TO_RIGHT, |
1398 build_string ("KS C5601 (Hangul and Korean Hanja)"), | 1409 build_string ("KS C5601 (Hangul and Korean Hanja)"), |
1399 build_string ("ksc5601")); | 1410 build_string ("ksc5601")); |
1411 | |
1412 #ifdef ENABLE_COMPOSITE_CHARS | |
1400 /* #### For simplicity, we put composite chars into a 96x96 charset. | 1413 /* #### For simplicity, we put composite chars into a 96x96 charset. |
1401 This is going to lead to problems because you can run out of | 1414 This is going to lead to problems because you can run out of |
1402 room, esp. as we don't yet recycle numbers. */ | 1415 room, esp. as we don't yet recycle numbers. */ |
1403 Vcharset_composite = | 1416 Vcharset_composite = |
1404 make_charset (-1, Qcomposite, LEADING_BYTE_COMPOSITE, 3, | 1417 make_charset (-1, Qcomposite, LEADING_BYTE_COMPOSITE, 3, |
1414 make_lisp_hashtable (500, HASHTABLE_NONWEAK, HASHTABLE_EQUAL); | 1427 make_lisp_hashtable (500, HASHTABLE_NONWEAK, HASHTABLE_EQUAL); |
1415 Vcomposite_char_char2string_hashtable = | 1428 Vcomposite_char_char2string_hashtable = |
1416 make_lisp_hashtable (500, HASHTABLE_NONWEAK, HASHTABLE_EQ); | 1429 make_lisp_hashtable (500, HASHTABLE_NONWEAK, HASHTABLE_EQ); |
1417 staticpro (&Vcomposite_char_string2char_hashtable); | 1430 staticpro (&Vcomposite_char_string2char_hashtable); |
1418 staticpro (&Vcomposite_char_char2string_hashtable); | 1431 staticpro (&Vcomposite_char_char2string_hashtable); |
1419 | 1432 #endif /* ENABLE_COMPOSITE_CHARS */ |
1420 } | 1433 |
1434 } |