X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fmule-charset.c;h=751fd32c25a2b6fbf9d10d14da1297e43b806e3d;hb=4faa92777f0b49cc67da8ab24a5d6e66e845f963;hp=7f57ba40cbbb8c498808b111ceeb3342f4128806;hpb=dfb41edd6e83bd32b4245cc6c7172ce6ece52b01;p=chise%2Fxemacs-chise.git- diff --git a/src/mule-charset.c b/src/mule-charset.c index 7f57ba4..751fd32 100644 --- a/src/mule-charset.c +++ b/src/mule-charset.c @@ -906,12 +906,52 @@ get_unallocated_leading_byte (int dimension) #define BIG5_SAME_ROW (0xFF - 0xA1 + 0x7F - 0x40) Emchar +decode_defined_char (Lisp_Object ccs, int code_point) +{ + int dim = XCHARSET_DIMENSION (ccs); + Lisp_Object decoding_table = XCHARSET_DECODING_TABLE (ccs); + Emchar char_id = -1; + Lisp_Object mother; + + while (dim > 0) + { + dim--; + decoding_table + = get_ccs_octet_table (decoding_table, ccs, + (code_point >> (dim * 8)) & 255); + } + if (CHARP (decoding_table)) + return XCHAR (decoding_table); +#ifdef HAVE_DATABASE + if (EQ (decoding_table, Qunloaded) || + EQ (decoding_table, Qunbound) || + NILP (decoding_table) ) + { + char_id = load_char_decoding_entry_maybe (ccs, code_point); + } +#endif + if (char_id >= 0) + return char_id; + else if ( CHARSETP (mother = XCHARSET_MOTHER (ccs)) ) + { + if ( XCHARSET_CONVERSION (ccs) == CONVERSION_IDENTICAL ) + { + if ( EQ (mother, Vcharset_ucs) ) + return DECODE_CHAR (mother, code_point); + else + return decode_defined_char (mother, code_point); + } + } + return -1; +} + +Emchar decode_builtin_char (Lisp_Object charset, int code_point) { Lisp_Object mother = XCHARSET_MOTHER (charset); int final; - if ( CHARSETP (mother) ) + if ( CHARSETP (mother) && (XCHARSET_MAX_CODE (charset) > 0) ) { int code = code_point; @@ -950,8 +990,10 @@ decode_builtin_char (Lisp_Object charset, int code_point) + (row - (18 + 32)) * 94 + cell - 33; } - return DECODE_CHAR (mother, code + XCHARSET_CODE_OFFSET(charset)); + return + decode_builtin_char (mother, code + XCHARSET_CODE_OFFSET(charset)); } +#if 0 else if (EQ (charset, Vcharset_chinese_big5)) { int c1 = code_point >> 8; @@ -978,6 +1020,7 @@ decode_builtin_char (Lisp_Object charset, int code_point) code_point = ((I / 94 + 33) << 8) | (I % 94 + 33); } } +#endif if ((final = XCHARSET_FINAL (charset)) >= '0') { if (XCHARSET_DIMENSION (charset) == 1) @@ -1056,7 +1099,8 @@ charset_code_point (Lisp_Object charset, Emchar ch) code = charset_code_point (mother, ch); else code = ch; - if ( (min <= code) && (code <= max) ) + if ( ((max == 0) && CHARSETP (mother)) || + ((min <= code) && (code <= max)) ) { int d = code - XCHARSET_CODE_OFFSET (charset); @@ -2040,8 +2084,8 @@ Save mapping-table of CHARSET. db_file = char_attribute_system_db_file (CHARSET_NAME (cs), Qsystem_char_id, 1); - db = Fopen_database (db_file, Qnil, Qnil, Qnil, Qnil); - + db = Fopen_database (db_file, Qnil, Qnil, build_string ("w+"), Qnil); + byte_min = CHARSET_BYTE_OFFSET (cs); byte_max = byte_min + CHARSET_BYTE_SIZE (cs); switch (CHARSET_DIMENSION (cs)) @@ -2178,7 +2222,7 @@ load_char_decoding_entry_maybe (Lisp_Object ccs, int code_point) = char_attribute_system_db_file (XCHARSET_NAME(ccs), Qsystem_char_id, 0); - db = Fopen_database (db_file, Qnil, Qnil, Qnil, Qnil); + db = Fopen_database (db_file, Qnil, Qnil, build_string ("r"), Qnil); if (!NILP (db)) { Lisp_Object ret @@ -2224,7 +2268,7 @@ If corresponding character is not found, nil is returned. if (NILP (defined_only)) c = DECODE_CHAR (charset, c); else - c = DECODE_DEFINED_CHAR (charset, c); + c = decode_defined_char (charset, c); return c >= 0 ? make_char (c) : Qnil; } @@ -2720,7 +2764,7 @@ complex_vars_of_mule_charset (void) build_string ("UCS"), build_string ("ISO/IEC 10646"), build_string (""), - Qnil, 0, 0xFFFFFFF, 0, 0, Qnil, CONVERSION_IDENTICAL); + Qnil, 0, 0x7FFFFFFF, 0, 0, Qnil, CONVERSION_IDENTICAL); staticpro (&Vcharset_ucs_bmp); Vcharset_ucs_bmp = make_charset (LEADING_BYTE_UCS_BMP, Qucs_bmp, 256, 2, @@ -2759,17 +2803,17 @@ complex_vars_of_mule_charset (void) build_string ("UCS for CNS 11643"), build_string ("ISO/IEC 10646 for CNS 11643"), build_string (""), - Qnil, 0, 0, 0, 0, - Qnil, CONVERSION_IDENTICAL); + Qnil, 0, 0, 0, 0, Vcharset_ucs, CONVERSION_IDENTICAL); staticpro (&Vcharset_ucs_jis); Vcharset_ucs_jis = make_charset (LEADING_BYTE_UCS_JIS, Qucs_jis, 256, 3, 2, 2, 0, CHARSET_LEFT_TO_RIGHT, build_string ("UCS for JIS"), build_string ("UCS for JIS X 0208, 0212 and 0213"), - build_string ("ISO/IEC 10646 for JIS X 0208, 0212 and 0213"), + build_string + ("ISO/IEC 10646 for JIS X 0208, 0212 and 0213"), build_string (""), - Qnil, 0, 0, 0, 0, Qnil, CONVERSION_IDENTICAL); + Qnil, 0, 0, 0, 0, Vcharset_ucs, CONVERSION_IDENTICAL); staticpro (&Vcharset_ucs_ks); Vcharset_ucs_ks = make_charset (LEADING_BYTE_UCS_KS, Qucs_ks, 256, 3, @@ -2778,7 +2822,7 @@ complex_vars_of_mule_charset (void) build_string ("UCS for CCS defined by KS"), build_string ("ISO/IEC 10646 for Korean Standards"), build_string (""), - Qnil, 0, 0, 0, 0, Qnil, CONVERSION_IDENTICAL); + Qnil, 0, 0, 0, 0, Vcharset_ucs, CONVERSION_IDENTICAL); staticpro (&Vcharset_ucs_big5); Vcharset_ucs_big5 = make_charset (LEADING_BYTE_UCS_BIG5, Qucs_big5, 256, 3, @@ -2787,7 +2831,7 @@ complex_vars_of_mule_charset (void) build_string ("UCS for Big5"), build_string ("ISO/IEC 10646 for Big5"), build_string (""), - Qnil, 0, 0, 0, 0, Qnil, CONVERSION_IDENTICAL); + Qnil, 0, 0, 0, 0, Vcharset_ucs, CONVERSION_IDENTICAL); #else # define MIN_CHAR_THAI 0 # define MAX_CHAR_THAI 0 @@ -3063,11 +3107,10 @@ complex_vars_of_mule_charset (void) build_string ("Big5"), build_string ("Big5"), build_string ("Big5 Chinese traditional"), - build_string ("big5"), + build_string ("big5-0"), Qnil, - 0 /* MIN_CHAR_BIG5_CDP */, - 0 /* MAX_CHAR_BIG5_CDP */, 0, 0, - Qnil, CONVERSION_IDENTICAL); + MIN_CHAR_BIG5_CDP, MAX_CHAR_BIG5_CDP, + MIN_CHAR_BIG5_CDP, 0, Qnil, CONVERSION_IDENTICAL); #if 0 staticpro (&Vcharset_chinese_big5_cdp); Vcharset_chinese_big5_cdp =