From 3e6fb73124e10447539e204abcb9635d23186a52 Mon Sep 17 00:00:00 2001 From: tomo Date: Tue, 30 May 2000 05:31:34 +0000 Subject: [PATCH] (struct Lisp_Charset): Add new member `encoding_table'. (CHARSET_ENCODING_TABLE): New macro. (XCHARSET_ENCODING_TABLE): New macro. (charset_code_point): New implementation. (encode_char_1): Likewise. --- src/char-ucs.h | 56 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/src/char-ucs.h b/src/char-ucs.h index 9829e95..70bf735 100644 --- a/src/char-ucs.h +++ b/src/char-ucs.h @@ -278,9 +278,12 @@ struct Lisp_Charset /* Which half of font to be used to display this character set */ unsigned int graphic; - /* Byte->character mapping table */ + /* Code-point->character mapping table */ Lisp_Object decoding_table; + /* Character->code-point mapping table */ + Lisp_Object encoding_table; + /* Range of character code */ Emchar ucs_min, ucs_max; @@ -329,6 +332,7 @@ DECLARE_LRECORD (charset, Lisp_Charset); #define CHARSET_CHARS(cs) ((cs)->chars) #define CHARSET_REVERSE_DIRECTION_CHARSET(cs) ((cs)->reverse_direction_charset) #define CHARSET_DECODING_TABLE(cs) ((cs)->decoding_table) +#define CHARSET_ENCODING_TABLE(cs) ((cs)->encoding_table) #define CHARSET_UCS_MIN(cs) ((cs)->ucs_min) #define CHARSET_UCS_MAX(cs) ((cs)->ucs_max) #define CHARSET_CODE_OFFSET(cs) ((cs)->code_offset) @@ -351,6 +355,7 @@ DECLARE_LRECORD (charset, Lisp_Charset); #define XCHARSET_REVERSE_DIRECTION_CHARSET(cs) \ CHARSET_REVERSE_DIRECTION_CHARSET (XCHARSET (cs)) #define XCHARSET_DECODING_TABLE(cs) CHARSET_DECODING_TABLE(XCHARSET(cs)) +#define XCHARSET_ENCODING_TABLE(cs) CHARSET_ENCODING_TABLE(XCHARSET(cs)) #define XCHARSET_UCS_MIN(cs) CHARSET_UCS_MIN(XCHARSET(cs)) #define XCHARSET_UCS_MAX(cs) CHARSET_UCS_MAX(XCHARSET(cs)) #define XCHARSET_CODE_OFFSET(cs) CHARSET_CODE_OFFSET(XCHARSET(cs)) @@ -529,51 +534,50 @@ INLINE_HEADER int charset_code_point (Lisp_Object charset, Emchar ch); INLINE_HEADER int charset_code_point (Lisp_Object charset, Emchar ch) { - Lisp_Object cdef = get_char_id_table (ch, Vcharacter_attribute_table); - - if (!NILP (cdef)) - { - Lisp_Object field = Fassq (charset, cdef); + Lisp_Object encoding_table = XCHARSET_ENCODING_TABLE (charset); + Lisp_Object ret; - if (!NILP (field)) - return XINT (Fcdr (field)); - } - return range_charset_code_point (charset, ch); + if ( CHAR_ID_TABLE_P (encoding_table) + && INTP (ret = get_char_id_table (ch, encoding_table)) ) + return XINT (ret); + else + return range_charset_code_point (charset, ch); } extern Lisp_Object Vdefault_coded_charset_priority_list; EXFUN (Ffind_charset, 1); -INLINE_HEADER int encode_char_1 (Emchar c, Lisp_Object* charset); +INLINE_HEADER int encode_char_1 (Emchar ch, Lisp_Object* charset); INLINE_HEADER int -encode_char_1 (Emchar c, Lisp_Object* charset) +encode_char_1 (Emchar ch, Lisp_Object* charset) { - Lisp_Object cdef = get_char_id_table (c, Vcharacter_attribute_table); + Lisp_Object charsets = Vdefault_coded_charset_priority_list; - if (!EQ (cdef, Qnil)) + while (!NILP (charsets)) { - Lisp_Object charsets = Vdefault_coded_charset_priority_list; - Lisp_Object field; - - while (!EQ (charsets, Qnil)) + *charset = Ffind_charset (Fcar (charsets)); + if (!NILP (*charset)) { - *charset = Ffind_charset (Fcar (charsets)); - if (!EQ (*charset, Qnil)) + Lisp_Object encoding_table = XCHARSET_ENCODING_TABLE (*charset); + Lisp_Object ret; + + if ( CHAR_ID_TABLE_P (encoding_table) + && INTP (ret = get_char_id_table (ch, encoding_table)) ) + return XINT (ret); + else { int code_point; - if (!NILP (field = Fassq (*charset, cdef))) - return XINT (Fcdr (field)); - else if ((code_point - = range_charset_code_point (*charset, c)) >= 0) + if ((code_point + = range_charset_code_point (*charset, ch)) >= 0) return code_point; } - charsets = Fcdr (charsets); } + charsets = Fcdr (charsets); } /* otherwise --- maybe for bootstrap */ - return encode_builtin_char_1 (c, charset); + return encode_builtin_char_1 (ch, charset); } INLINE_HEADER int encode_char_2 (Emchar ch, Lisp_Object* charset); -- 1.7.10.4