From: tomo Date: Tue, 14 Dec 2004 15:32:58 +0000 (+0000) Subject: (decoding_table_put_char): Copied from char-ucs.h; changed to normal X-Git-Tag: r21-4-15-chise-0_21-32^2~86 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=614724a49443bec0091c9522103c214ec0b2d4d0;p=chise%2Fxemacs-chise.git (decoding_table_put_char): Copied from char-ucs.h; changed to normal function. (encode_char_2): Likewise. --- diff --git a/src/mule-charset.c b/src/mule-charset.c index aa09e70..30b720a 100644 --- a/src/mule-charset.c +++ b/src/mule-charset.c @@ -176,6 +176,93 @@ decoding_table_check_elements (Lisp_Object v, int dim, int ccs_len) return 0; } +void +decoding_table_put_char (Lisp_Object ccs, + int code_point, Lisp_Object character) +{ +#if 1 + Lisp_Object table1 = XCHARSET_DECODING_TABLE (ccs); + int dim = XCHARSET_DIMENSION (ccs); + + if (dim == 1) + XCHARSET_DECODING_TABLE (ccs) + = put_ccs_octet_table (table1, ccs, code_point, character); + else if (dim == 2) + { + Lisp_Object table2 + = get_ccs_octet_table (table1, ccs, (unsigned char)(code_point >> 8)); + + table2 = put_ccs_octet_table (table2, ccs, + (unsigned char)code_point, character); + XCHARSET_DECODING_TABLE (ccs) + = put_ccs_octet_table (table1, ccs, + (unsigned char)(code_point >> 8), table2); + } + else if (dim == 3) + { + Lisp_Object table2 + = get_ccs_octet_table (table1, ccs, (unsigned char)(code_point >> 16)); + Lisp_Object table3 + = get_ccs_octet_table (table2, ccs, (unsigned char)(code_point >> 8)); + + table3 = put_ccs_octet_table (table3, ccs, + (unsigned char)code_point, character); + table2 = put_ccs_octet_table (table2, ccs, + (unsigned char)(code_point >> 8), table3); + XCHARSET_DECODING_TABLE (ccs) + = put_ccs_octet_table (table1, ccs, + (unsigned char)(code_point >> 16), table2); + } + else /* if (dim == 4) */ + { + Lisp_Object table2 + = get_ccs_octet_table (table1, ccs, (unsigned char)(code_point >> 24)); + Lisp_Object table3 + = get_ccs_octet_table (table2, ccs, (unsigned char)(code_point >> 16)); + Lisp_Object table4 + = get_ccs_octet_table (table3, ccs, (unsigned char)(code_point >> 8)); + + table4 = put_ccs_octet_table (table4, ccs, + (unsigned char)code_point, character); + table3 = put_ccs_octet_table (table3, ccs, + (unsigned char)(code_point >> 8), table4); + table2 = put_ccs_octet_table (table2, ccs, + (unsigned char)(code_point >> 16), table3); + XCHARSET_DECODING_TABLE (ccs) + = put_ccs_octet_table (table1, ccs, + (unsigned char)(code_point >> 24), table2); + } +#else + Lisp_Object v = XCHARSET_DECODING_TABLE (ccs); + int dim = XCHARSET_DIMENSION (ccs); + int byte_offset = XCHARSET_BYTE_OFFSET (ccs); + int i = -1; + Lisp_Object nv; + int ccs_len = XVECTOR_LENGTH (v); + + while (dim > 0) + { + dim--; + i = ((code_point >> (8 * dim)) & 255) - byte_offset; + nv = XVECTOR_DATA(v)[i]; + if (dim > 0) + { + if (!VECTORP (nv)) + { + if (EQ (nv, character)) + return; + else + nv = (XVECTOR_DATA(v)[i] = make_vector (ccs_len, Qnil)); + } + v = nv; + } + else + break; + } + XVECTOR_DATA(v)[i] = character; +#endif +} + Lisp_Object put_char_ccs_code_point (Lisp_Object character, Lisp_Object ccs, Lisp_Object value) @@ -1223,6 +1310,55 @@ charset_code_point (Lisp_Object charset, Emchar ch, int defined_only) } int +encode_char_2 (Emchar ch, Lisp_Object* charset) +{ + Lisp_Object charsets = Vdefault_coded_charset_priority_list; + int code_point; + + while (!NILP (charsets)) + { + *charset = Ffind_charset (Fcar (charsets)); + if ( !NILP (*charset) + && (XCHARSET_DIMENSION (*charset) <= 2) ) + { + code_point = charset_code_point (*charset, ch, 0); + if (code_point >= 0) + return code_point; + + if ( !NILP (Vdisplay_coded_charset_priority_use_inheritance) && + NILP (Vdisplay_coded_charset_priority_use_hierarchy_order) ) + { + code_point = encode_char_2_search_children (ch, charset); + if (code_point >= 0) + return code_point; + } + } + charsets = Fcdr (charsets); + } + + if ( !NILP (Vdisplay_coded_charset_priority_use_inheritance) && + !NILP (Vdisplay_coded_charset_priority_use_hierarchy_order) ) + { + charsets = Vdefault_coded_charset_priority_list; + while (!NILP (charsets)) + { + *charset = Ffind_charset (Fcar (charsets)); + if ( !NILP (*charset) + && (XCHARSET_DIMENSION (*charset) <= 2) ) + { + code_point = encode_char_2_search_children (ch, charset); + if (code_point >= 0) + return code_point; + } + charsets = Fcdr (charsets); + } + } + + /* otherwise --- maybe for bootstrap */ + return encode_builtin_char_1 (ch, charset); +} + +int encode_builtin_char_1 (Emchar c, Lisp_Object* charset) { if (c <= MAX_CHAR_BASIC_LATIN)