X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fmule-charset.c;h=c3e12f0df0eab691e1246b61ff113593c11d5459;hb=988c23bf605446c466cb1dc1a0d430ee31358c4d;hp=79d1319740802eb0b4b0ceb64af2b1cf8f0310a6;hpb=2d8e6927bb8f6eb194418903d2b9dd76713fb0b2;p=chise%2Fxemacs-chise.git- diff --git a/src/mule-charset.c b/src/mule-charset.c index 79d1319..c3e12f0 100644 --- a/src/mule-charset.c +++ b/src/mule-charset.c @@ -32,6 +32,7 @@ Boston, MA 02111-1307, USA. */ #include "lstream.h" #include "device.h" #include "faces.h" +#include "mule-ccl.h" /* The various pre-defined charsets. */ @@ -74,11 +75,12 @@ static int composite_char_col_next; #endif /* ENABLE_COMPOSITE_CHARS */ /* Table of charsets indexed by leading byte. */ -Lisp_Object charset_by_leading_byte[128]; +Lisp_Object charset_by_leading_byte[NUM_LEADING_BYTES]; /* Table of charsets indexed by type/final-byte/direction. */ Lisp_Object charset_by_attributes[4][128][2]; +#ifndef UTF2000 /* Table of number of bytes in the string representation of a character indexed by the first byte of that representation. @@ -98,12 +100,17 @@ Bytecount rep_bytes_by_first_byte[0xA0] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x80 - 0x8f are for Dimension-1 official charsets */ +#ifdef CHAR_IS_UCS4 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, +#else + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, +#endif /* 0x90 - 0x9d are for Dimension-2 official charsets */ /* 0x9e is for Dimension-1 private charsets */ /* 0x9f is for Dimension-2 private charsets */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4 }; +#endif Lisp_Object Vutf_2000_version; @@ -115,7 +122,6 @@ Lisp_Object Qcharsetp; Lisp_Object Qregistry, Qfinal, Qgraphic; Lisp_Object Qdirection; Lisp_Object Qreverse_direction_charset; -Lisp_Object Qccl_program; Lisp_Object Qleading_byte; Lisp_Object Qshort_name, Qlong_name; @@ -548,8 +554,13 @@ print_charset (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) write_c_string (buf, printcharfun); } +static const struct lrecord_description charset_description[] = { + { XD_LISP_OBJECT, offsetof(struct Lisp_Charset, name), 7 }, + { XD_END } +}; + DEFINE_LRECORD_IMPLEMENTATION ("charset", charset, - mark_charset, print_charset, 0, 0, 0, + mark_charset, print_charset, 0, 0, 0, charset_description, struct Lisp_Charset); /* Make a new charset. */ @@ -594,11 +605,13 @@ make_charset (int id, Lisp_Object name, unsigned char rep_bytes, charset_by_attributes[type][final][direction] = obj; } - assert (NILP (charset_by_leading_byte[id - 128])); - charset_by_leading_byte[id - 128] = obj; + assert (NILP (charset_by_leading_byte[id - MIN_LEADING_BYTE])); + charset_by_leading_byte[id - MIN_LEADING_BYTE] = obj; +#ifndef UTF2000 if (id < 0xA0) /* official leading byte */ rep_bytes_by_first_byte[id] = rep_bytes; +#endif /* Some charsets are "faux" and don't have names or really exist at all except in the leading-byte table. */ @@ -1212,27 +1225,33 @@ Return the character set of char CH. (CHAR_LEADING_BYTE (XCHAR (ch)))); } -DEFUN ("char-octet", Fchar_octet, 1, 2, 0, /* -Return the octet numbered N (should be 0 or 1) of char CH. -N defaults to 0 if omitted. +DEFUN ("split-char", Fsplit_char, 1, 1, 0, /* +Return list of charset and one or two position-codes of CHAR. */ - (ch, n)) + (character)) { - Lisp_Object charset; - int c1, c2, int_n; + /* This function can GC */ + struct gcpro gcpro1, gcpro2; + Lisp_Object charset = Qnil; + Lisp_Object rc = Qnil; + int c1, c2; - CHECK_CHAR_COERCE_INT (ch); - if (NILP (n)) - int_n = 0; + GCPRO2 (charset, rc); + CHECK_CHAR_COERCE_INT (character); + + BREAKUP_CHAR (XCHAR (character), charset, c1, c2); + + if (XCHARSET_DIMENSION (Fget_charset (charset)) == 2) + { + rc = list3 (XCHARSET_NAME (charset), make_int (c1), make_int (c2)); + } else { - CHECK_INT (n); - int_n = XINT (n); - if (int_n != 0 && int_n != 1) - signal_simple_error ("Octet number must be 0 or 1", n); + rc = list2 (XCHARSET_NAME (charset), make_int (c1)); } - BREAKUP_CHAR (XCHAR (ch), charset, c1, c2); - return make_int (int_n == 0 ? c1 : c2); + UNGCPRO; + + return rc; } @@ -1337,7 +1356,7 @@ syms_of_mule_charset (void) DEFSUBR (Fmake_char); DEFSUBR (Fchar_charset); - DEFSUBR (Fchar_octet); + DEFSUBR (Fsplit_char); #ifdef ENABLE_COMPOSITE_CHARS DEFSUBR (Fmake_composite_char); @@ -1350,7 +1369,6 @@ syms_of_mule_charset (void) defsymbol (&Qgraphic, "graphic"); defsymbol (&Qdirection, "direction"); defsymbol (&Qreverse_direction_charset, "reverse-direction-charset"); - defsymbol (&Qccl_program, "ccl-program"); defsymbol (&Qshort_name, "short-name"); defsymbol (&Qlong_name, "long-name"); @@ -1386,7 +1404,7 @@ syms_of_mule_charset (void) defsymbol (&Qcomposite, "composite"); #ifdef UTF2000 - Vutf_2000_version = build_string("0.2"); + Vutf_2000_version = build_string("0.4 (Shin-Imamiya)"); DEFVAR_LISP ("utf-2000-version", &Vutf_2000_version /* Version number of UTF-2000. */ );