X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fchar-ucs.h;h=7f40f2942fc8eb6d444900866f064cf55e8ed843;hb=2cbece6401b2279497293e6dc54cda607f49db2f;hp=70bf735e1a99fc9cff2062a6018e5341a6ac540f;hpb=3e6fb73124e10447539e204abcb9635d23186a52;p=chise%2Fxemacs-chise.git- diff --git a/src/char-ucs.h b/src/char-ucs.h index 70bf735..7f40f29 100644 --- a/src/char-ucs.h +++ b/src/char-ucs.h @@ -18,8 +18,6 @@ along with XEmacs; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* Rewritten by MORIOKA Tomohiko . */ - #ifndef INCLUDED_char_ucs_h_ #define INCLUDED_char_ucs_h_ @@ -73,7 +71,7 @@ extern Lisp_Object Vcharset_latin_jisx0201; /* Definition of leading bytes */ /************************************************************************/ -typedef int Charset_ID; +typedef short Charset_ID; #define MIN_LEADING_BYTE -0x60 #define CHARSET_ID_OFFSET 0x00 @@ -580,40 +578,14 @@ encode_char_1 (Emchar ch, Lisp_Object* charset) return encode_builtin_char_1 (ch, charset); } -INLINE_HEADER int encode_char_2 (Emchar ch, Lisp_Object* charset); -INLINE_HEADER int -encode_char_2 (Emchar ch, Lisp_Object* charset) -{ - int code_point = encode_char_1 (ch, charset); - - if (EQ (*charset, Vcharset_mojikyo)) - { - int plane, byte1, byte2; - - code_point--; - plane = code_point / (94 * 60); - byte1 = (code_point % (94 * 60)) / 94; - if (byte1 < 30) - byte1 += 16 + 32; - else - byte1 += 18 + 32; - byte2 = code_point % 94 + 33; - *charset - = CHARSET_BY_LEADING_BYTE (LEADING_BYTE_MOJIKYO_PJ_1 - plane); - return (byte1 << 8) | byte2; - } - else - return code_point; -} - -#define ENCODE_CHAR(ch, charset) encode_char_2 (ch, &(charset)) +#define ENCODE_CHAR(ch, charset) encode_char_1 (ch, &(charset)) INLINE_HEADER void breakup_char_1 (Emchar c, Lisp_Object *charset, int *c1, int *c2); INLINE_HEADER void breakup_char_1 (Emchar c, Lisp_Object *charset, int *c1, int *c2) { - int code_point = encode_char_2 (c, charset); + int code_point = encode_char_1 (c, charset); if (code_point >= 0) { @@ -651,6 +623,39 @@ CHAR_CHARSET (Emchar ch) #define CHAR_CHARSET_ID(c) (XCHARSET_ID(CHAR_CHARSET(c))) #define CHAR_COLUMNS(c) (CHARSET_COLUMNS(XCHARSET(CHAR_CHARSET(c)))) + +typedef struct Charc +{ + Lisp_Object charset; + int code_point; +} Charc; + +INLINE_HEADER Charc CHAR_TO_CHARC (Emchar ch); +INLINE_HEADER Charc +CHAR_TO_CHARC (Emchar ch) +{ + Charc cc; + + cc.code_point = encode_char_1 (ch, &cc.charset); + if (EQ (cc.charset, Vcharset_mojikyo)) + { + int plane, byte1, byte2; + + cc.code_point--; + plane = cc.code_point / (94 * 60); + byte1 = (cc.code_point % (94 * 60)) / 94; + if (byte1 < 30) + byte1 += 16 + 32; + else + byte1 += 18 + 32; + byte2 = cc.code_point % 94 + 33; + cc.charset + = CHARSET_BY_LEADING_BYTE (LEADING_BYTE_MOJIKYO_PJ_1 - plane); + cc.code_point = (byte1 << 8) | byte2; + } + return cc; +} + /************************************************************************/ /* Exported functions */