From 31c757f1f48c650ddfd7ec317dc62f763256114e Mon Sep 17 00:00:00 2001 From: tomo Date: Mon, 13 Sep 1999 02:09:57 +0000 Subject: [PATCH] (charset_get_byte1): New function. (XCHARSET_GET_BYTE1): Deleted. (charset_get_byte2): New function. (XCHARSET_GET_BYTE2): Deleted. (Vdefault_preferred_coded_charset_list): New external variable. (breakup_char_1): Use `charset_get_byte1', `charset_get_byte2' and `Vdefault_preferred_coded_charset_list'. --- src/char-ucs.h | 143 ++++++++++---------------------------------------------- 1 file changed, 24 insertions(+), 119 deletions(-) diff --git a/src/char-ucs.h b/src/char-ucs.h index e404fc7..93fe8c6 100644 --- a/src/char-ucs.h +++ b/src/char-ucs.h @@ -414,94 +414,11 @@ extern Charset_ID latin_a_char_to_charset[128]; extern unsigned char latin_a_char_to_byte1[128]; extern unsigned char latin_a_char_to_byte2[128]; -INLINE unsigned char XCHARSET_GET_BYTE1 (Lisp_Object charset, Emchar ch); -INLINE unsigned char -XCHARSET_GET_BYTE1 (Lisp_Object charset, Emchar ch) -{ - Emchar_to_byte_table* table; +unsigned char charset_get_byte1 (Lisp_Object charset, Emchar ch); +unsigned char charset_get_byte2 (Lisp_Object charset, Emchar ch); - if ((table = XCHARSET_TO_BYTE1_TABLE (charset)) != NULL) - return get_byte_from_character_table (ch, table); - else if (EQ (charset, Vcharset_ascii)) - return ch <= 0x7f ? ch : 0; - else if (EQ (charset, Vcharset_control_1)) - return (0x80 <= ch) && (ch < 0xA0) ? ch & 0x7f : 0; - else if (EQ (charset, Vcharset_latin_iso8859_1)) - return (0xA0 <= ch) && (ch <= 0xff) ? ch & 0x7f : 0; - else if (EQ (charset, Vcharset_cyrillic_iso8859_5)) - return (MIN_CHAR_GREEK <= ch) && (ch <= MAX_CHAR_CYRILLIC) ? - ch - MIN_CHAR_CYRILLIC + 0x20 : 0; - else if (EQ (charset, Vcharset_greek_iso8859_7)) - return (MIN_CHAR_GREEK <= ch) && (ch <= MAX_CHAR_GREEK) ? - ch - MIN_CHAR_GREEK + 0x20 : 0; - else if (EQ (charset, Vcharset_hebrew_iso8859_8)) - return (MIN_CHAR_HEBREW <= ch) && (ch <= MAX_CHAR_HEBREW) ? - ch - MIN_CHAR_HEBREW + 0x20 : 0; - else if (EQ (charset, Vcharset_thai_tis620)) - return (MIN_CHAR_THAI <= ch) && (ch <= MAX_CHAR_THAI) ? - ch - MIN_CHAR_THAI + 0x20 : 0; - else if (EQ (charset, Vcharset_katakana_jisx0201)) - return (MIN_CHAR_HALFWIDTH_KATAKANA <= ch) - && (ch <= MAX_CHAR_HALFWIDTH_KATAKANA) ? - ch - MIN_CHAR_HALFWIDTH_KATAKANA + 0x20 : 0; - else if (EQ (charset, Vcharset_ucs_bmp)) - return ch & 0xff; - else if (XCHARSET_DIMENSION (charset) == 1) - { - if (XCHARSET_CHARS (charset) == 94) - return (MIN_CHAR_94 + (XCHARSET_FINAL (charset) - '0') * 94 <= ch) - && (ch < MIN_CHAR_94 + (XCHARSET_FINAL (charset) - '0' + 1) * 94) ? - ((ch - MIN_CHAR_94) % 94) + 33 : 0; - else /* if (XCHARSET_CHARS (charset) == 96) */ - return (MIN_CHAR_96 + (XCHARSET_FINAL (charset) - '0') * 96 <= ch) - && (ch < MIN_CHAR_96 + (XCHARSET_FINAL (charset) - '0' + 1) * 96) ? - ((ch - MIN_CHAR_94) % 96) + 32 : 0; - } - else /* if (XCHARSET_DIMENSION (charset) == 2) */ - { - if (XCHARSET_CHARS (charset) == 94) - return (MIN_CHAR_94x94 - + (XCHARSET_FINAL (charset) - '0') * 94 * 94 <= ch) - && (ch < MIN_CHAR_94x94 - + (XCHARSET_FINAL (charset) - '0' + 1) * 94 * 94) ? - (((ch - MIN_CHAR_94x94) / 94) % 94) + 33 : 0; - else /* if (XCHARSET_CHARS (charset) == 96) */ - return (MIN_CHAR_96x96 - + (XCHARSET_FINAL (charset) - '0') * 96 * 96 <= ch) - && (ch < MIN_CHAR_96x96 - + (XCHARSET_FINAL (charset) - '0' + 1) * 96 * 96) ? - (((ch - MIN_CHAR_96x96) / 96) % 96) + 32 : 0; - } -} - -INLINE unsigned char XCHARSET_GET_BYTE2 (Lisp_Object charset, Emchar ch); -INLINE unsigned char -XCHARSET_GET_BYTE2 (Lisp_Object charset, Emchar ch) -{ - if (XCHARSET_DIMENSION (charset) == 1) - return 0; - else - { - Emchar_to_byte_table* table; - - if ((table = XCHARSET_TO_BYTE2_TABLE (charset)) != NULL) - return get_byte_from_character_table (ch, table); - else if (EQ (charset, Vcharset_ucs_bmp)) - return (ch >> 8) & 0xff; - else if (XCHARSET_CHARS (charset) == 94) - return (MIN_CHAR_94x94 - + (XCHARSET_FINAL (charset) - '0') * 94 * 94 <= ch) - && (ch < MIN_CHAR_94x94 - + (XCHARSET_FINAL (charset) - '0' + 1) * 94 * 94) ? - ((ch - MIN_CHAR_94x94) % 94) + 33 : 0; - else /* if (XCHARSET_CHARS (charset) == 96) */ - return (MIN_CHAR_96x96 - + (XCHARSET_FINAL (charset) - '0') * 96 * 96 <= ch) - && (ch < MIN_CHAR_96x96 - + (XCHARSET_FINAL (charset) - '0' + 1) * 96 * 96) ? - ((ch - MIN_CHAR_96x96) % 96) + 32 : 0; - } -} +extern Lisp_Object Vdefault_preferred_coded_charset_list; +EXFUN (Ffind_charset, 1); INLINE void breakup_char_1 (Emchar c, Lisp_Object *charset, int *c1, int *c2); INLINE void @@ -510,20 +427,20 @@ breakup_char_1 (Emchar c, Lisp_Object *charset, int *c1, int *c2) if (c <= MAX_CHAR_BASIC_LATIN) { *charset = Vcharset_ascii; - *c1 = c; - *c2 = 0; + *c1 = charset_get_byte1 (*charset, c); + *c2 = charset_get_byte2 (*charset, c); } else if (c < 0xA0) { *charset = Vcharset_control_1; - *c1 = c & 0x7f; - *c2 = 0; + *c1 = charset_get_byte1 (*charset, c); + *c2 = charset_get_byte2 (*charset, c); } else if (c <= 0xff) { *charset = Vcharset_latin_iso8859_1; - *c1 = c & 0x7f; - *c2 = 0; + *c1 = charset_get_byte1 (*charset, c); + *c2 = charset_get_byte2 (*charset, c); } else if (c <= 0x17f) { @@ -531,8 +448,8 @@ breakup_char_1 (Emchar c, Lisp_Object *charset, int *c1, int *c2) = CHARSET_BY_LEADING_BYTE (latin_a_char_to_charset[c - 0x100]); if (XCHARSET_TO_BYTE1_TABLE (*charset) != NULL) { - *c1 = XCHARSET_GET_BYTE1 (*charset, c); - *c2 = 0; + *c1 = charset_get_byte1 (*charset, c); + *c2 = charset_get_byte2 (*charset, c); } else { @@ -542,22 +459,15 @@ breakup_char_1 (Emchar c, Lisp_Object *charset, int *c1, int *c2) } else if (c < MIN_CHAR_GREEK) { - Lisp_Object charsets = list6 (Vcharset_latin_iso8859_2, - Vcharset_latin_iso8859_3, - Vcharset_latin_iso8859_4, - Vcharset_latin_iso8859_9, - Vcharset_latin_viscii_lower, - Vcharset_latin_viscii_upper); + Lisp_Object charsets = Vdefault_preferred_coded_charset_list; while (!EQ (charsets, Qnil)) { - *charset = Fcar (charsets); - if (XCHARSET_TO_BYTE1_TABLE (*charset) != NULL) + *charset = Ffind_charset (Fcar (charsets)); + if (!EQ (*charset, Qnil) + && (*c1 = charset_get_byte1 (*charset, c)) ) { - if ( (*c1 = XCHARSET_GET_BYTE1 (*charset, c)) ) - { - *c2 = 0; - return; - } + *c2 = charset_get_byte2 (*charset, c); + return; } charsets = Fcdr (charsets); } @@ -610,19 +520,15 @@ breakup_char_1 (Emchar c, Lisp_Object *charset, int *c1, int *c2) } else if (c < MIN_CHAR_HALFWIDTH_KATAKANA) { - Lisp_Object charsets = list3 (Vcharset_latin_jisx0201, - Vcharset_latin_viscii_lower, - Vcharset_latin_viscii_upper); + Lisp_Object charsets = Vdefault_preferred_coded_charset_list; while (!EQ (charsets, Qnil)) { - *charset = Fcar (charsets); - if (XCHARSET_TO_BYTE1_TABLE (*charset) != NULL) + *charset = Ffind_charset (Fcar (charsets)); + if (!EQ (*charset, Qnil) + && (*c1 = charset_get_byte1 (*charset, c)) ) { - if ( (*c1 = XCHARSET_GET_BYTE1 (*charset, c)) ) - { - *c2 = 0; - return; - } + *c2 = charset_get_byte2 (*charset, c); + return; } charsets = Fcdr (charsets); } @@ -703,7 +609,6 @@ CHAR_CHARSET (Emchar ch) /* Exported functions */ /************************************************************************/ -EXFUN (Ffind_charset, 1); EXFUN (Fget_charset, 1); extern Lisp_Object Vcharset_chinese_big5_1; -- 1.7.10.4