update.
[chise/xemacs-chise.git.1] / src / mule-charset.c
index e039037..cff909a 100644 (file)
@@ -1,7 +1,7 @@
 /* Functions to handle multilingual characters.
    Copyright (C) 1992, 1995 Free Software Foundation, Inc.
    Copyright (C) 1995 Sun Microsystems, Inc.
-   Copyright (C) 1999,2000,2001,2002,2003,2004,2008 MORIOKA Tomohiko
+   Copyright (C) 1999,2000,2001,2002,2003,2004,2008,2009 MORIOKA Tomohiko
 
 This file is part of XEmacs.
 
@@ -57,7 +57,7 @@ Lisp_Object Vcharset_katakana_jisx0201;
 Lisp_Object Vcharset_latin_jisx0201;
 Lisp_Object Vcharset_cyrillic_iso8859_5;
 Lisp_Object Vcharset_latin_iso8859_9;
-Lisp_Object Vcharset_japanese_jisx0208_1978;
+/* Lisp_Object Vcharset_japanese_jisx0208_1978; */
 Lisp_Object Vcharset_chinese_gb2312;
 Lisp_Object Vcharset_chinese_gb12345;
 Lisp_Object Vcharset_japanese_jisx0208;
@@ -368,6 +368,7 @@ Lisp_Object Qleading_byte;
 Lisp_Object Qshort_name, Qlong_name;
 Lisp_Object Qiso_ir;
 #ifdef UTF2000
+Lisp_Object Qto_iso_ir;
 Lisp_Object Qpartial;
 Lisp_Object Qmin_code, Qmax_code, Qcode_offset;
 Lisp_Object Qmother, Qconversion, Q94x60, Q94x94x60, Qbig5_1, Qbig5_2;
@@ -387,7 +388,7 @@ Lisp_Object Qascii,
   Qlatin_jisx0201,
   Qcyrillic_iso8859_5,
   Qlatin_iso8859_9,
-  Qrep_jis_x0208_1978,
+/*  Qrep_jis_x0208_1978, */
   Qrep_gb2312,
   Qrep_gb12345,
   Qrep_jis_x0208_1983,
@@ -821,6 +822,7 @@ make_charset (Charset_ID id, Lisp_Object name,
              Bufbyte final, unsigned char direction, Lisp_Object short_name,
              Lisp_Object long_name, Lisp_Object doc,
              Lisp_Object reg,
+             int iso_ir,
              Lisp_Object decoding_table,
              Emchar min_code, Emchar max_code,
              Emchar code_offset, unsigned char byte_offset,
@@ -849,6 +851,7 @@ make_charset (Charset_ID id, Lisp_Object name,
   CHARSET_CCL_PROGRAM  (cs) = Qnil;
   CHARSET_REVERSE_DIRECTION_CHARSET (cs) = Qnil;
 #ifdef UTF2000
+  CHARSET_ISO_IR       (cs) = iso_ir;
   CHARSET_DECODING_TABLE(cs) = Qunbound;
   CHARSET_MIN_CODE     (cs) = min_code;
   CHARSET_MAX_CODE     (cs) = max_code;
@@ -1643,6 +1646,7 @@ character set.  Recognized properties are:
        (name, doc_string, props))
 {
   int id = 0, dimension = 1, chars = 94, graphic = 0, final = 0, columns = -1;
+  int iso_ir = 0;
   int direction = CHARSET_LEFT_TO_RIGHT;
   Lisp_Object registry = Qnil;
   Lisp_Object charset;
@@ -1681,10 +1685,19 @@ character set.  Recognized properties are:
          {
 #ifdef UTF2000
            CHECK_INT (value);
-           id = - XINT (value);
+           iso_ir = XINT (value);
+           id = - iso_ir;
 #endif
          }
 
+#ifdef UTF2000
+       else if (EQ (keyword, Qto_iso_ir))
+         {
+           CHECK_INT (value);
+           iso_ir = XINT (value);
+         }
+#endif
+
        else if (EQ (keyword, Qdimension))
          {
            CHECK_INT (value);
@@ -1861,7 +1874,7 @@ character set.  Recognized properties are:
 
   charset = make_charset (id, name, chars, dimension, columns, graphic,
                          final, direction, short_name, long_name,
-                         doc_string, registry,
+                         doc_string, registry, iso_ir,
                          Qnil, min_code, max_code, code_offset, byte_offset,
                          mother, conversion, partial);
   if (!NILP (ccl_program))
@@ -1912,6 +1925,7 @@ NEW-NAME is the name of the new charset.  Return the new charset.
                              graphic, final, direction, short_name, long_name,
                              doc_string, registry,
 #ifdef UTF2000
+                             CHARSET_ISO_IR(cs),
                              CHARSET_DECODING_TABLE(cs),
                              CHARSET_MIN_CODE(cs),
                              CHARSET_MAX_CODE(cs),
@@ -2072,6 +2086,13 @@ Recognized properties are those listed in `make-charset', as well as
       return CHARSETP (obj) ? XCHARSET_NAME (obj) : obj;
     }
 #ifdef UTF2000
+  if (EQ (prop, Qiso_ir))
+    {
+      if ( CHARSET_ISO_IR (cs) > 0 )
+       return make_int (CHARSET_ISO_IR (cs));
+      else
+       return Qnil;
+    }
   if (EQ (prop, Qmother))
     return CHARSET_MOTHER (cs);
   if (EQ (prop, Qmin_code))
@@ -2703,7 +2724,8 @@ If corresponding character is not found, nil is returned.
   charset = Fget_charset (charset);
   CHECK_INT (code);
   c = XINT (code);
-  if (XCHARSET_GRAPHIC (charset) == 1)
+  if ( (XCHARSET_GRAPHIC (charset) == 0) ||
+       (XCHARSET_GRAPHIC (charset) == 1) )
     c &= 0x7F7F7F7F;
   if (NILP (defined_only))
     c = DECODE_CHAR (charset, c, !NILP (without_inheritance));
@@ -3052,6 +3074,7 @@ syms_of_mule_charset (void)
   defsymbol (&Qlong_name, "long-name");
   defsymbol (&Qiso_ir, "iso-ir");
 #ifdef UTF2000
+  defsymbol (&Qto_iso_ir, "=>iso-ir");
   defsymbol (&Qpartial, "partial");
   defsymbol (&Qmother, "mother");
   defsymbol (&Qmin_code, "min-code");
@@ -3083,7 +3106,7 @@ syms_of_mule_charset (void)
   defsymbol (&Qlatin_jisx0201,         "latin-jisx0201");
   defsymbol (&Qcyrillic_iso8859_5,     "cyrillic-iso8859-5");
   defsymbol (&Qlatin_iso8859_9,                "latin-iso8859-9");
-  defsymbol (&Qrep_jis_x0208_1978,     "=jis-x0208@1978");
+  /* defsymbol (&Qrep_jis_x0208_1978,  "=jis-x0208@1978"); */
   defsymbol (&Qrep_gb2312,             "=gb2312");
   defsymbol (&Qrep_gb12345,            "=gb12345");
   defsymbol (&Qrep_jis_x0208_1983,     "=jis-x0208@1983");
@@ -3196,6 +3219,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("CHAR-ID"),
                  build_string ("System char-id"),
                  build_string (""),
+                 0,
                  Qnil, 0, 0x7FFFFFFF, 0, 0, Qnil, CONVERSION_IDENTICAL,
                  0);
   staticpro (&Vcharset_ucs);
@@ -3206,6 +3230,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("UCS"),
                  build_string ("ISO/IEC 10646"),
                  build_string (""),
+                 - LEADING_BYTE_UCS,
                  Qnil, 0, 0xEFFFF, 0, 0, Qnil, CONVERSION_IDENTICAL,
                  0);
   staticpro (&Vcharset_ucs_bmp);
@@ -3217,6 +3242,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("ISO/IEC 10646 Group 0 Plane 0 (BMP)"),
                  build_string
                  ("\\(ISO10646\\(\\.[0-9]+\\)?-[01]\\|UCS00-0\\|UNICODE[23]?-0\\)"),
+                 - LEADING_BYTE_UCS_BMP,
                  Qnil, 0, 0xFFFF, 0, 0, Qnil, CONVERSION_IDENTICAL,
                  0);
   staticpro (&Vcharset_ucs_smp);
@@ -3227,6 +3253,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("UCS-SMP"),
                  build_string ("ISO/IEC 10646 Group 0 Plane 1 (SMP)"),
                  build_string ("UCS00-1"),
+                 0,
                  Qnil, MIN_CHAR_SMP, MAX_CHAR_SMP,
                  MIN_CHAR_SMP, 0, Qnil, CONVERSION_IDENTICAL,
                  0);
@@ -3238,6 +3265,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("UCS-SIP"),
                  build_string ("ISO/IEC 10646 Group 0 Plane 2 (SIP)"),
                  build_string ("\\(ISO10646.*-2\\|UCS00-2\\)"),
+                 0,
                  Qnil, MIN_CHAR_SIP, MAX_CHAR_SIP,
                  MIN_CHAR_SIP, 0, Qnil, CONVERSION_IDENTICAL,
                  0);
@@ -3257,6 +3285,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("ASCII)"),
                  build_string ("ASCII (ISO646 IRV)"),
                  build_string ("\\(iso8859-[0-9]*\\|-ascii\\)"),
+                 - LEADING_BYTE_ASCII,
                  Qnil, 0, 0x7F, 0, 0, Qnil, CONVERSION_IDENTICAL,
                  0);
   staticpro (&Vcharset_control_1);
@@ -3267,6 +3296,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("Control characters"),
                  build_string ("Control characters 128-191"),
                  build_string (""),
+                 - LEADING_BYTE_CONTROL_1,
                  Qnil, 0x80, 0x9F, 0x80, 0, Qnil, CONVERSION_IDENTICAL,
                  0);
   staticpro (&Vcharset_latin_iso8859_1);
@@ -3277,6 +3307,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("ISO8859-1 (Latin-1)"),
                  build_string ("ISO8859-1 (Latin-1)"),
                  build_string ("iso8859-1"),
+                 - LEADING_BYTE_LATIN_ISO8859_1,
                  Qnil, 0, 0, 0, 32, Qnil, CONVERSION_IDENTICAL,
                  0);
   staticpro (&Vcharset_latin_iso8859_2);
@@ -3287,6 +3318,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("ISO8859-2 (Latin-2)"),
                  build_string ("ISO8859-2 (Latin-2)"),
                  build_string ("iso8859-2"),
+                 - LEADING_BYTE_LATIN_ISO8859_2,
                  Qnil, 0, 0, 0, 32, Qnil, CONVERSION_IDENTICAL,
                  0);
   staticpro (&Vcharset_latin_iso8859_3);
@@ -3297,6 +3329,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("ISO8859-3 (Latin-3)"),
                  build_string ("ISO8859-3 (Latin-3)"),
                  build_string ("iso8859-3"),
+                 - LEADING_BYTE_LATIN_ISO8859_3,
                  Qnil, 0, 0, 0, 32, Qnil, CONVERSION_IDENTICAL,
                  0);
   staticpro (&Vcharset_latin_iso8859_4);
@@ -3307,6 +3340,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("ISO8859-4 (Latin-4)"),
                  build_string ("ISO8859-4 (Latin-4)"),
                  build_string ("iso8859-4"),
+                 - LEADING_BYTE_LATIN_ISO8859_4,
                  Qnil, 0, 0, 0, 32, Qnil, CONVERSION_IDENTICAL,
                  0);
   staticpro (&Vcharset_thai_tis620);
@@ -3317,6 +3351,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("TIS620 (Thai)"),
                  build_string ("TIS620.2529 (Thai)"),
                  build_string ("tis620"),
+                 - LEADING_BYTE_THAI_TIS620,
                  Qnil, 0, 0, 0, 32, Qnil, CONVERSION_IDENTICAL,
                  0);
   staticpro (&Vcharset_greek_iso8859_7);
@@ -3327,6 +3362,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("ISO8859-7 (Greek)"),
                  build_string ("ISO8859-7 (Greek)"),
                  build_string ("iso8859-7"),
+                 - LEADING_BYTE_GREEK_ISO8859_7,
                  Qnil, 0, 0, 0, 32, Qnil, CONVERSION_IDENTICAL,
                  0);
   staticpro (&Vcharset_arabic_iso8859_6);
@@ -3337,6 +3373,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("ISO8859-6 (Arabic)"),
                  build_string ("ISO8859-6 (Arabic)"),
                  build_string ("iso8859-6"),
+                 - LEADING_BYTE_ARABIC_ISO8859_6,
                  Qnil, 0, 0, 0, 32, Qnil, CONVERSION_IDENTICAL,
                  0);
   staticpro (&Vcharset_hebrew_iso8859_8);
@@ -3347,6 +3384,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("ISO8859-8 (Hebrew)"),
                  build_string ("ISO8859-8 (Hebrew)"),
                  build_string ("iso8859-8"),
+                 - LEADING_BYTE_HEBREW_ISO8859_8,
                  Qnil,
                  0 /* MIN_CHAR_HEBREW */,
                  0 /* MAX_CHAR_HEBREW */, 0, 32,
@@ -3360,6 +3398,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("JISX0201.1976 (Japanese Kana)"),
                  build_string ("JISX0201.1976 Japanese Kana"),
                  build_string ("jisx0201\\.1976"),
+                 - LEADING_BYTE_KATAKANA_JISX0201,
                  Qnil, 0, 0, 0, 33, Qnil, CONVERSION_IDENTICAL,
                  0);
   staticpro (&Vcharset_latin_jisx0201);
@@ -3370,6 +3409,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("JISX0201.1976 (Japanese Roman)"),
                  build_string ("JISX0201.1976 Japanese Roman"),
                  build_string ("jisx0201\\.1976"),
+                 - LEADING_BYTE_LATIN_JISX0201,
                  Qnil, 0, 0, 0, 33, Qnil, CONVERSION_IDENTICAL,
                  0);
   staticpro (&Vcharset_cyrillic_iso8859_5);
@@ -3380,6 +3420,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("ISO8859-5 (Cyrillic)"),
                  build_string ("ISO8859-5 (Cyrillic)"),
                  build_string ("iso8859-5"),
+                 - LEADING_BYTE_CYRILLIC_ISO8859_5,
                  Qnil, 0, 0, 0, 32, Qnil, CONVERSION_IDENTICAL,
                  0);
   staticpro (&Vcharset_latin_iso8859_9);
@@ -3390,6 +3431,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("ISO8859-9 (Latin-5)"),
                  build_string ("ISO8859-9 (Latin-5)"),
                  build_string ("iso8859-9"),
+                 - LEADING_BYTE_LATIN_ISO8859_9,
                  Qnil, 0, 0, 0, 32, Qnil, CONVERSION_IDENTICAL,
                  0);
 #ifdef UTF2000
@@ -3402,12 +3444,14 @@ complex_vars_of_mule_charset (void)
                  build_string ("JIS X0208 Common"),
                  build_string ("JIS X0208 Common part"),
                  build_string ("jisx0208\\.1990"),
+                 - LEADING_BYTE_JAPANESE_JISX0208_1978,
                  Qnil,
                  MIN_CHAR_JIS_X0208_1990,
                  MAX_CHAR_JIS_X0208_1990, MIN_CHAR_JIS_X0208_1990, 33,
                  Qnil, CONVERSION_94x94,
                  1);
 #endif
+#if 0
   staticpro (&Vcharset_japanese_jisx0208_1978);
   Vcharset_japanese_jisx0208_1978 =
     make_charset (LEADING_BYTE_JAPANESE_JISX0208_1978,
@@ -3418,6 +3462,7 @@ complex_vars_of_mule_charset (void)
                  build_string
                  ("JIS X0208:1978 Japanese Kanji (so called \"old JIS\")"),
                  build_string ("\\(jisx0208\\|jisc6226\\)\\.1978"),
+                 - LEADING_BYTE_JAPANESE_JISX0208_1978,
                  Qnil, 0, 0, 0, 33,
 #ifdef UTF2000
                  Vcharset_jis_x0208,
@@ -3426,6 +3471,7 @@ complex_vars_of_mule_charset (void)
 #endif
                  CONVERSION_IDENTICAL,
                  0);
+#endif
   staticpro (&Vcharset_chinese_gb2312);
   Vcharset_chinese_gb2312 =
     make_charset (LEADING_BYTE_CHINESE_GB2312, Qrep_gb2312, 94, 2,
@@ -3434,6 +3480,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("GB2312)"),
                  build_string ("GB2312 Chinese simplified"),
                  build_string ("gb2312"),
+                 - LEADING_BYTE_CHINESE_GB2312,
                  Qnil, 0, 0, 0, 33, Qnil, CONVERSION_IDENTICAL,
                  0);
   staticpro (&Vcharset_chinese_gb12345);
@@ -3444,6 +3491,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("GB 12345)"),
                  build_string ("GB 12345-1990"),
                  build_string ("GB12345\\(\\.1990\\)?-0"),
+                 0,
                  Qnil, 0, 0, 0, 33, Qnil, CONVERSION_IDENTICAL,
                  0);
   staticpro (&Vcharset_japanese_jisx0208);
@@ -3454,6 +3502,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("JIS X0208:1983 (Japanese)"),
                  build_string ("JIS X0208:1983 Japanese Kanji"),
                  build_string ("jisx0208\\.1983"),
+                 - LEADING_BYTE_JAPANESE_JISX0208,
                  Qnil, 0, 0, 0, 33,
 #ifdef UTF2000
                  Vcharset_jis_x0208,
@@ -3472,6 +3521,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("JIS X0208:1990 (Japanese)"),
                  build_string ("JIS X0208:1990 Japanese Kanji"),
                  build_string ("jisx0208\\.1990"),
+                 - LEADING_BYTE_JAPANESE_JISX0208_1990,
                  Qnil,
                  0x2121 /* MIN_CHAR_JIS_X0208_1990 */,
                  0x7426 /* MAX_CHAR_JIS_X0208_1990 */,
@@ -3488,6 +3538,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("KSC5601 (Korean"),
                  build_string ("KSC5601 Korean Hangul and Hanja"),
                  build_string ("ksc5601"),
+                 - LEADING_BYTE_KOREAN_KSC5601,
                  Qnil, 0, 0, 0, 33, Qnil, CONVERSION_IDENTICAL,
                  0);
   staticpro (&Vcharset_japanese_jisx0212);
@@ -3498,6 +3549,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("JISX0212 (Japanese)"),
                  build_string ("JISX0212 Japanese Supplement"),
                  build_string ("jisx0212"),
+                 - LEADING_BYTE_JAPANESE_JISX0212,
                  Qnil, 0, 0, 0, 33, Qnil, CONVERSION_IDENTICAL,
                  0);
 
@@ -3511,6 +3563,7 @@ complex_vars_of_mule_charset (void)
                  build_string
                  ("CNS 11643 Plane 1 Chinese traditional"),
                  build_string (CHINESE_CNS_PLANE_RE("1")),
+                 - LEADING_BYTE_CHINESE_CNS11643_1,
                  Qnil, 0, 0, 0, 33, Qnil, CONVERSION_IDENTICAL,
                  0);
   staticpro (&Vcharset_chinese_cns11643_2);
@@ -3522,6 +3575,7 @@ complex_vars_of_mule_charset (void)
                  build_string
                  ("CNS 11643 Plane 2 Chinese traditional"),
                  build_string (CHINESE_CNS_PLANE_RE("2")),
+                 - LEADING_BYTE_CHINESE_CNS11643_2,
                  Qnil, 0, 0, 0, 33, Qnil, CONVERSION_IDENTICAL,
                  0);
 #ifdef UTF2000
@@ -3533,6 +3587,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("TCVN 5712 (VSCII-2)"),
                  build_string ("Vietnamese TCVN 5712:1983 (VSCII-2)"),
                  build_string ("tcvn5712\\(\\.1993\\)?-1"),
+                 - LEADING_BYTE_LATIN_TCVN5712,
                  Qnil, 0, 0, 0, 32, Qnil, CONVERSION_IDENTICAL,
                  0);
   staticpro (&Vcharset_latin_viscii_lower);
@@ -3543,6 +3598,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("VISCII lower (Vietnamese)"),
                  build_string ("VISCII lower (Vietnamese)"),
                  build_string ("MULEVISCII-LOWER"),
+                 0,
                  Qnil, 0, 0, 0, 32, Qnil, CONVERSION_IDENTICAL,
                  0);
   staticpro (&Vcharset_latin_viscii_upper);
@@ -3553,6 +3609,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("VISCII upper (Vietnamese)"),
                  build_string ("VISCII upper (Vietnamese)"),
                  build_string ("MULEVISCII-UPPER"),
+                 0,
                  Qnil, 0, 0, 0, 32, Qnil, CONVERSION_IDENTICAL,
                  0);
   staticpro (&Vcharset_latin_viscii);
@@ -3563,6 +3620,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("VISCII 1.1 (Vietnamese)"),
                  build_string ("VISCII 1.1 (Vietnamese)"),
                  build_string ("VISCII1\\.1"),
+                 0,
                  Qnil, 0, 0, 0, 0, Qnil, CONVERSION_IDENTICAL,
                  0);
   staticpro (&Vcharset_chinese_big5);
@@ -3573,6 +3631,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("Big5"),
                  build_string ("Big5 Chinese traditional"),
                  build_string ("big5-0"),
+                 0,
                  Qnil,
                  MIN_CHAR_BIG5_CDP, MAX_CHAR_BIG5_CDP,
                  MIN_CHAR_BIG5_CDP, 0, Qnil, CONVERSION_IDENTICAL,
@@ -3586,6 +3645,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("Ethiopic (UCS)"),
                  build_string ("Ethiopic of UCS"),
                  build_string ("Ethiopic-Unicode"),
+                 0,
                  Qnil, 0x1200, 0x137F, 0, 0,
                  Qnil, CONVERSION_IDENTICAL,
                  0);
@@ -3599,6 +3659,7 @@ complex_vars_of_mule_charset (void)
                  build_string
                  ("Big5 Level-1 Chinese traditional"),
                  build_string ("big5"),
+                 0,
                  Qnil, 0, 0, 0, 33, /* Qnil, CONVERSION_IDENTICAL */
                  Vcharset_chinese_big5, CONVERSION_BIG5_1,
                  0);
@@ -3611,6 +3672,7 @@ complex_vars_of_mule_charset (void)
                  build_string
                  ("Big5 Level-2 Chinese traditional"),
                  build_string ("big5"),
+                 0,
                  Qnil, 0, 0, 0, 33, /* Qnil, CONVERSION_IDENTICAL */
                  Vcharset_chinese_big5, CONVERSION_BIG5_2,
                  0);