(C1-636E): Add `ideographic-strokes'.
[chise/xemacs-chise.git] / src / mule-charset.c
index bd56719..4626e60 100644 (file)
@@ -20,10 +20,10 @@ 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.  */
 
-/* Synched up with: FSF 20.3.  Not in FSF. */
-
 /* Rewritten by Ben Wing <ben@xemacs.org>. */
 
+/* Rewritten by MORIOKA Tomohiko <tomo@m17n.org> for XEmacs UTF-2000. */
+
 #include <config.h>
 #ifdef UTF2000
 #include <limits.h>
@@ -67,11 +67,13 @@ Lisp_Object Vcharset_chinese_cns11643_2;
 Lisp_Object Vcharset_ucs;
 Lisp_Object Vcharset_ucs_bmp;
 Lisp_Object Vcharset_ucs_cns;
+Lisp_Object Vcharset_ucs_big5;
 Lisp_Object Vcharset_latin_viscii;
 Lisp_Object Vcharset_latin_tcvn5712;
 Lisp_Object Vcharset_latin_viscii_lower;
 Lisp_Object Vcharset_latin_viscii_upper;
 Lisp_Object Vcharset_chinese_big5;
+Lisp_Object Vcharset_chinese_big5_cdp;
 Lisp_Object Vcharset_ideograph_gt;
 Lisp_Object Vcharset_ideograph_gt_pj_1;
 Lisp_Object Vcharset_ideograph_gt_pj_2;
@@ -887,6 +889,7 @@ Lisp_Object Vcharacter_variant_table;
 Lisp_Object Qideograph_daikanwa;
 Lisp_Object Q_decomposition;
 Lisp_Object Qucs;
+Lisp_Object Qto_ucs;
 Lisp_Object Q_ucs;
 Lisp_Object Qcompat;
 Lisp_Object Qisolated;
@@ -1230,7 +1233,7 @@ Store CHARACTER's ATTRIBUTE with VALUE.
        }
       value = seq;
     }
-  else if (EQ (attribute, Q_ucs))
+  else if (EQ (attribute, Qto_ucs) || EQ (attribute, Q_ucs))
     {
       Lisp_Object ret;
       Emchar c;
@@ -1246,6 +1249,10 @@ Store CHARACTER's ATTRIBUTE with VALUE.
          put_char_id_table (c, Fcons (character, ret),
                             Vcharacter_variant_table);
        }
+#if 0
+      if (EQ (attribute, Q_ucs))
+       attribute = Qto_ucs;
+#endif
     }
   {
     Lisp_Object table = Fgethash (attribute,
@@ -1525,7 +1532,9 @@ Store character's ATTRIBUTES.
            }
          rest = Fcdr (rest);
        }
-      if (!NILP (code = Fcdr (Fassq (Q_ucs, attributes))))
+      if ( (!NILP (code = Fcdr (Fassq (Qto_ucs, attributes)))) ||
+          (!NILP (code = Fcdr (Fassq (Q_ucs, attributes)))) )
+       
        {
          if (!INTP (code))
            signal_simple_error ("Invalid argument", attributes);
@@ -1555,6 +1564,42 @@ Store character's ATTRIBUTES.
   return character;
 }
 
+DEFUN ("find-char", Ffind_char, 1, 1, 0, /*
+Retrieve the character of the given ATTRIBUTES.
+*/
+       (attributes))
+{
+  Lisp_Object rest = attributes;
+  Lisp_Object code;
+
+  while (CONSP (rest))
+    {
+      Lisp_Object cell = Fcar (rest);
+      Lisp_Object ccs;
+
+      if (!LISTP (cell))
+       signal_simple_error ("Invalid argument", attributes);
+      if (!NILP (ccs = Ffind_charset (Fcar (cell))))
+       {
+         cell = Fcdr (cell);
+         if (CONSP (cell))
+           return Fmake_char (ccs, Fcar (cell), Fcar (Fcdr (cell)));
+         else
+           return Fdecode_char (ccs, cell);
+       }
+      rest = Fcdr (rest);
+    }
+  if ( (!NILP (code = Fcdr (Fassq (Qto_ucs, attributes)))) ||
+       (!NILP (code = Fcdr (Fassq (Q_ucs, attributes)))) )
+    {
+      if (!INTP (code))
+       signal_simple_error ("Invalid argument", attributes);
+      else
+       return make_char (XINT (code) + 0x100000);
+    }
+  return Qnil;
+}
+
 Lisp_Object Vutf_2000_version;
 #endif
 
@@ -1597,6 +1642,7 @@ Lisp_Object Qascii,
 #ifdef UTF2000
   Qucs_bmp,
   Qucs_cns,
+  Qucs_big5,
   Qlatin_viscii,
   Qlatin_tcvn5712,
   Qlatin_viscii_lower,
@@ -1604,6 +1650,7 @@ Lisp_Object Qascii,
   Qvietnamese_viscii_lower,
   Qvietnamese_viscii_upper,
   Qchinese_big5,
+  Qchinese_big5_cdp,
   Qideograph_gt,
   Qideograph_gt_pj_1,
   Qideograph_gt_pj_2,
@@ -2369,22 +2416,12 @@ encode_builtin_char_1 (Emchar c, Lisp_Object* charset)
       return c & 0x7F;
     }
   /*
-  else if ((MIN_CHAR_GREEK <= c) && (c <= MAX_CHAR_GREEK))
-    {
-      *charset = Vcharset_greek_iso8859_7;
-      return c - MIN_CHAR_GREEK + 0x20;
-    }
-  else if ((MIN_CHAR_CYRILLIC <= c) && (c <= MAX_CHAR_CYRILLIC))
-    {
-      *charset = Vcharset_cyrillic_iso8859_5;
-      return c - MIN_CHAR_CYRILLIC + 0x20;
-    }
-  */
   else if ((MIN_CHAR_HEBREW <= c) && (c <= MAX_CHAR_HEBREW))
     {
       *charset = Vcharset_hebrew_iso8859_8;
       return c - MIN_CHAR_HEBREW + 0x20;
     }
+  */
   else if ((MIN_CHAR_THAI <= c) && (c <= MAX_CHAR_THAI))
     {
       *charset = Vcharset_thai_tis620;
@@ -3161,7 +3198,7 @@ Make a character from CHARSET and code-point CODE.
   if (XCHARSET_GRAPHIC (charset) == 1)
     c &= 0x7F7F7F7F;
   c = DECODE_CHAR (charset, c);
-  return c ? make_char (c) : Qnil;
+  return c >= 0 ? make_char (c) : Qnil;
 }
 
 DEFUN ("decode-builtin-char", Fdecode_builtin_char, 2, 2, 0, /*
@@ -3461,6 +3498,7 @@ syms_of_mule_charset (void)
   DEFSUBR (Fput_char_attribute);
   DEFSUBR (Fremove_char_attribute);
   DEFSUBR (Fdefine_char);
+  DEFSUBR (Ffind_char);
   DEFSUBR (Fchar_variants);
   DEFSUBR (Fget_composite_char);
   DEFSUBR (Fcharset_mapping_table);
@@ -3519,6 +3557,7 @@ syms_of_mule_charset (void)
   defsymbol (&Qchinese_cns11643_1,     "chinese-cns11643-1");
   defsymbol (&Qchinese_cns11643_2,     "chinese-cns11643-2");
 #ifdef UTF2000
+  defsymbol (&Qto_ucs,                 "=>ucs");
   defsymbol (&Q_ucs,                   "->ucs");
   defsymbol (&Q_decomposition,         "->decomposition");
   defsymbol (&Qcompat,                 "compat");
@@ -3540,6 +3579,7 @@ syms_of_mule_charset (void)
   defsymbol (&Qucs,                    "ucs");
   defsymbol (&Qucs_bmp,                        "ucs-bmp");
   defsymbol (&Qucs_cns,                        "ucs-cns");
+  defsymbol (&Qucs_big5,               "ucs-big5");
   defsymbol (&Qlatin_viscii,           "latin-viscii");
   defsymbol (&Qlatin_tcvn5712,         "latin-tcvn5712");
   defsymbol (&Qlatin_viscii_lower,     "latin-viscii-lower");
@@ -3560,6 +3600,7 @@ syms_of_mule_charset (void)
   defsymbol (&Qideograph_gt_pj_11,     "ideograph-gt-pj-11");
   defsymbol (&Qideograph_daikanwa,     "ideograph-daikanwa");
   defsymbol (&Qchinese_big5,           "chinese-big5");
+  defsymbol (&Qchinese_big5_cdp,       "chinese-big5-cdp");
   defsymbol (&Qmojikyo,                        "mojikyo");
   defsymbol (&Qmojikyo_2022_1,         "mojikyo-2022-1");
   defsymbol (&Qmojikyo_pj_1,           "mojikyo-pj-1");
@@ -3696,11 +3737,20 @@ complex_vars_of_mule_charset (void)
                  build_string ("ISO/IEC 10646 for CNS 11643"),
                  build_string (""),
                  Qnil, 0, 0, 0, 0);
+  staticpro (&Vcharset_ucs_big5);
+  Vcharset_ucs_big5 =
+    make_charset (LEADING_BYTE_UCS_BIG5, Qucs_big5, 256, 3,
+                 1, 2, 0, CHARSET_LEFT_TO_RIGHT,
+                 build_string ("UCS for Big5"),
+                 build_string ("UCS for Big5"),
+                 build_string ("ISO/IEC 10646 for Big5"),
+                 build_string (""),
+                 Qnil, 0, 0, 0, 0);
 #else
 # define MIN_CHAR_THAI 0
 # define MAX_CHAR_THAI 0
-# define MIN_CHAR_HEBREW 0
-# define MAX_CHAR_HEBREW 0
+  /* # define MIN_CHAR_HEBREW 0 */
+  /* # define MAX_CHAR_HEBREW 0 */
 # define MIN_CHAR_HALFWIDTH_KATAKANA 0
 # define MAX_CHAR_HALFWIDTH_KATAKANA 0
 #endif
@@ -3775,9 +3825,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("ISO8859-7 (Greek)"),
                  build_string ("ISO8859-7 (Greek)"),
                  build_string ("iso8859-7"),
-                 Qnil,
-                 0 /* MIN_CHAR_GREEK */,
-                 0 /* MAX_CHAR_GREEK */, 0, 32);
+                 Qnil, 0, 0, 0, 32);
   staticpro (&Vcharset_arabic_iso8859_6);
   Vcharset_arabic_iso8859_6 =
     make_charset (LEADING_BYTE_ARABIC_ISO8859_6, Qarabic_iso8859_6, 96, 1,
@@ -3795,7 +3843,9 @@ complex_vars_of_mule_charset (void)
                  build_string ("ISO8859-8 (Hebrew)"),
                  build_string ("ISO8859-8 (Hebrew)"),
                  build_string ("iso8859-8"),
-                 Qnil, MIN_CHAR_HEBREW, MAX_CHAR_HEBREW, 0, 32);
+                 Qnil,
+                 0 /* MIN_CHAR_HEBREW */,
+                 0 /* MAX_CHAR_HEBREW */, 0, 32);
   staticpro (&Vcharset_katakana_jisx0201);
   Vcharset_katakana_jisx0201 =
     make_charset (LEADING_BYTE_KATAKANA_JISX0201, Qkatakana_jisx0201, 94, 1,
@@ -3822,9 +3872,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("ISO8859-5 (Cyrillic)"),
                  build_string ("ISO8859-5 (Cyrillic)"),
                  build_string ("iso8859-5"),
-                 Qnil,
-                 0 /* MIN_CHAR_CYRILLIC */,
-                 0 /* MAX_CHAR_CYRILLIC */, 0, 32);
+                 Qnil, 0, 0, 0, 32);
   staticpro (&Vcharset_latin_iso8859_9);
   Vcharset_latin_iso8859_9 =
     make_charset (LEADING_BYTE_LATIN_ISO8859_9, Qlatin_iso8859_9, 96, 1,
@@ -3934,7 +3982,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("TCVN 5712"),
                  build_string ("TCVN 5712 (VSCII-2)"),
                  build_string ("Vietnamese TCVN 5712:1983 (VSCII-2)"),
-                 build_string ("tcvn5712-1"),
+                 build_string ("tcvn5712\\(\\.1993\\)?-1"),
                  Qnil, 0, 0, 0, 32);
   staticpro (&Vcharset_latin_viscii_lower);
   Vcharset_latin_viscii_lower =
@@ -3972,6 +4020,15 @@ complex_vars_of_mule_charset (void)
                  build_string ("Big5 Chinese traditional"),
                  build_string ("big5"),
                  Qnil, 0, 0, 0, 0);
+  staticpro (&Vcharset_chinese_big5_cdp);
+  Vcharset_chinese_big5_cdp =
+    make_charset (LEADING_BYTE_CHINESE_BIG5_CDP, Qchinese_big5_cdp, 256, 2,
+                 2, 2, 0, CHARSET_LEFT_TO_RIGHT,
+                 build_string ("Big5-CDP"),
+                 build_string ("Big5 + CDP extension"),
+                 build_string ("Big5 with CDP extension"),
+                 build_string ("big5\\.cdp-0"),
+                 Qnil, 0, 0, 0, 0);
   staticpro (&Vcharset_ideograph_gt);
   Vcharset_ideograph_gt =
     make_charset (LEADING_BYTE_GT, Qideograph_gt, 256, 3,
@@ -3990,7 +4047,7 @@ complex_vars_of_mule_charset (void)
                  build_string ("GT (pseudo JIS encoding) part "#n),    \
                  build_string ("GT 2000 (pseudo JIS encoding) part "#n), \
                  build_string                                          \
-                 ("\\(GT2000PJ-"#n "\\|jisx0208\\.GT2000-"#n "\\)$"),  \
+                 ("\\(GTpj-"#n "\\|jisx0208\\.GT-"#n "\\)$"),  \
                  Qnil, 0, 0, 0, 33);
   DEF_GT_PJ (1);
   DEF_GT_PJ (2);