comparison src/mule-charset.c @ 396:6719134a07c2 r21-2-13

Import from CVS: tag r21-2-13
author cvs
date Mon, 13 Aug 2007 11:12:05 +0200
parents 1f50e6fe4f3f
children 74fd4e045ea6
comparison
equal deleted inserted replaced
395:de2c2a7459d2 396:6719134a07c2
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 /* Hash tables for composite chars. One maps string representing 65 /* Hash tables 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_hash_table; 68 Lisp_Object Vcomposite_char_char2string_hash_table;
67 Lisp_Object Vcomposite_char_string2char_hash_table; 69 Lisp_Object Vcomposite_char_string2char_hash_table;
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
276 f1 > MAX_CHAR_FIELD1_PRIVATE) 280 f1 > MAX_CHAR_FIELD1_PRIVATE)
277 return 0; 281 return 0;
278 if (f2 < 0x20 || f3 < 0x20) 282 if (f2 < 0x20 || f3 < 0x20)
279 return 0; 283 return 0;
280 284
285 #ifdef ENABLE_COMPOSITE_CHARS
281 if (f1 + FIELD1_TO_OFFICIAL_LEADING_BYTE == LEADING_BYTE_COMPOSITE) 286 if (f1 + FIELD1_TO_OFFICIAL_LEADING_BYTE == LEADING_BYTE_COMPOSITE)
282 { 287 {
283 if (UNBOUNDP (Fgethash (make_int (ch), 288 if (UNBOUNDP (Fgethash (make_int (ch),
284 Vcomposite_char_char2string_hash_table, 289 Vcomposite_char_char2string_hash_table,
285 Qunbound))) 290 Qunbound)))
286 return 0; 291 return 0;
287 return 1; 292 return 1;
288 } 293 }
294 #endif /* ENABLE_COMPOSITE_CHARS */
289 295
290 if (f2 != 0x20 && f2 != 0x7F && f3 != 0x20 && f3 != 0x7F) 296 if (f2 != 0x20 && f2 != 0x7F && f3 != 0x20 && f3 != 0x7F)
291 return 1; 297 return 1;
292 298
293 if (f1 <= MAX_CHAR_FIELD1_OFFICIAL) 299 if (f1 <= MAX_CHAR_FIELD1_OFFICIAL)
1064 BREAKUP_CHAR (XCHAR (ch), charset, c1, c2); 1070 BREAKUP_CHAR (XCHAR (ch), charset, c1, c2);
1065 return make_int (int_n == 0 ? c1 : c2); 1071 return make_int (int_n == 0 ? c1 : c2);
1066 } 1072 }
1067 1073
1068 1074
1075 #ifdef ENABLE_COMPOSITE_CHARS
1069 /************************************************************************/ 1076 /************************************************************************/
1070 /* composite character functions */ 1077 /* composite character functions */
1071 /************************************************************************/ 1078 /************************************************************************/
1072 1079
1073 Emchar 1080 Emchar
1109 Qunbound); 1116 Qunbound);
1110 assert (!UNBOUNDP (str)); 1117 assert (!UNBOUNDP (str));
1111 return str; 1118 return str;
1112 } 1119 }
1113 1120
1114 DEFUN ("make-composite-char", Fmake_composite_char, 1, 1, 0, /* 1121 xxDEFUN ("make-composite-char", Fmake_composite_char, 1, 1, 0, /*
1115 Convert a string into a single composite character. 1122 Convert a string into a single composite character.
1116 The character is the result of overstriking all the characters in 1123 The character is the result of overstriking all the characters in
1117 the string. 1124 the string.
1118 */ 1125 */
1119 (string)) 1126 (string))
1121 CHECK_STRING (string); 1128 CHECK_STRING (string);
1122 return make_char (lookup_composite_char (XSTRING_DATA (string), 1129 return make_char (lookup_composite_char (XSTRING_DATA (string),
1123 XSTRING_LENGTH (string))); 1130 XSTRING_LENGTH (string)));
1124 } 1131 }
1125 1132
1126 DEFUN ("composite-char-string", Fcomposite_char_string, 1, 1, 0, /* 1133 xxDEFUN ("composite-char-string", Fcomposite_char_string, 1, 1, 0, /*
1127 Return a string of the characters comprising a composite character. 1134 Return a string of the characters comprising a composite character.
1128 */ 1135 */
1129 (ch)) 1136 (ch))
1130 { 1137 {
1131 Emchar emch; 1138 Emchar emch;
1134 emch = XCHAR (ch); 1141 emch = XCHAR (ch);
1135 if (CHAR_LEADING_BYTE (emch) != LEADING_BYTE_COMPOSITE) 1142 if (CHAR_LEADING_BYTE (emch) != LEADING_BYTE_COMPOSITE)
1136 signal_simple_error ("Must be composite char", ch); 1143 signal_simple_error ("Must be composite char", ch);
1137 return composite_char_string (emch); 1144 return composite_char_string (emch);
1138 } 1145 }
1146 #endif /* ENABLE_COMPOSITE_CHARS */
1139 1147
1140 1148
1141 /************************************************************************/ 1149 /************************************************************************/
1142 /* initialization */ 1150 /* initialization */
1143 /************************************************************************/ 1151 /************************************************************************/
1163 1171
1164 DEFSUBR (Fmake_char); 1172 DEFSUBR (Fmake_char);
1165 DEFSUBR (Fchar_charset); 1173 DEFSUBR (Fchar_charset);
1166 DEFSUBR (Fchar_octet); 1174 DEFSUBR (Fchar_octet);
1167 1175
1176 #ifdef ENABLE_COMPOSITE_CHARS
1168 DEFSUBR (Fmake_composite_char); 1177 DEFSUBR (Fmake_composite_char);
1169 DEFSUBR (Fcomposite_char_string); 1178 DEFSUBR (Fcomposite_char_string);
1179 #endif
1170 1180
1171 defsymbol (&Qcharsetp, "charsetp"); 1181 defsymbol (&Qcharsetp, "charsetp");
1172 defsymbol (&Qregistry, "registry"); 1182 defsymbol (&Qregistry, "registry");
1173 defsymbol (&Qfinal, "final"); 1183 defsymbol (&Qfinal, "final");
1174 defsymbol (&Qgraphic, "graphic"); 1184 defsymbol (&Qgraphic, "graphic");
1394 make_charset (147, Qkorean_ksc5601, LEADING_BYTE_KOREAN_KSC5601, 3, 1404 make_charset (147, Qkorean_ksc5601, LEADING_BYTE_KOREAN_KSC5601, 3,
1395 CHARSET_TYPE_94X94, 2, 0, 'C', 1405 CHARSET_TYPE_94X94, 2, 0, 'C',
1396 CHARSET_LEFT_TO_RIGHT, 1406 CHARSET_LEFT_TO_RIGHT,
1397 build_string ("KS C5601 (Hangul and Korean Hanja)"), 1407 build_string ("KS C5601 (Hangul and Korean Hanja)"),
1398 build_string ("ksc5601")); 1408 build_string ("ksc5601"));
1409
1410 #ifdef ENABLE_COMPOSITE_CHARS
1399 /* #### For simplicity, we put composite chars into a 96x96 charset. 1411 /* #### For simplicity, we put composite chars into a 96x96 charset.
1400 This is going to lead to problems because you can run out of 1412 This is going to lead to problems because you can run out of
1401 room, esp. as we don't yet recycle numbers. */ 1413 room, esp. as we don't yet recycle numbers. */
1402 Vcharset_composite = 1414 Vcharset_composite =
1403 make_charset (-1, Qcomposite, LEADING_BYTE_COMPOSITE, 3, 1415 make_charset (-1, Qcomposite, LEADING_BYTE_COMPOSITE, 3,
1413 make_lisp_hash_table (500, HASH_TABLE_NON_WEAK, HASH_TABLE_EQUAL); 1425 make_lisp_hash_table (500, HASH_TABLE_NON_WEAK, HASH_TABLE_EQUAL);
1414 Vcomposite_char_char2string_hash_table = 1426 Vcomposite_char_char2string_hash_table =
1415 make_lisp_hash_table (500, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ); 1427 make_lisp_hash_table (500, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ);
1416 staticpro (&Vcomposite_char_string2char_hash_table); 1428 staticpro (&Vcomposite_char_string2char_hash_table);
1417 staticpro (&Vcomposite_char_char2string_hash_table); 1429 staticpro (&Vcomposite_char_char2string_hash_table);
1418 1430 #endif /* ENABLE_COMPOSITE_CHARS */
1419 } 1431
1432 }