Reformatted.
[chise/xemacs-chise.git.1] / src / mule-charset.c
index 6af8460..bcfe600 100644 (file)
@@ -180,10 +180,10 @@ Lisp_Object
 put_char_ccs_code_point (Lisp_Object character,
                         Lisp_Object ccs, Lisp_Object value)
 {
-  if ( !(EQ (XCHARSET_NAME (ccs), Qmap_ucs)
-        && INTP (value) && (XINT (value) < 0xF0000))
-       || !INTP (value)
-       /* || (XCHAR (character) != XINT (value)) */ )
+  if ( !( EQ (XCHARSET_NAME (ccs), Qmap_ucs)
+         && INTP (value) && (XINT (value) < 0xF0000)
+         && XCHAR (character) == XINT (value) )
+       || !INTP (value) )
     {
       Lisp_Object v = XCHARSET_DECODING_TABLE (ccs);
       int code_point;
@@ -970,7 +970,7 @@ decode_builtin_char (Lisp_Object charset, int code_point)
     {
       if ( CHARSETP (mother) )
        {
-         int code
+         EMACS_INT code
            = decode_ccs_conversion (XCHARSET_CONVERSION (charset),
                                     code_point);
 
@@ -2381,7 +2381,7 @@ Save properties of CHARSET.
   if ( open_chise_data_source_maybe () )
     return -1;
 
-  if (SYMBOLP (charset))
+  if ( SYMBOLP (charset) && !EQ (charset, XCHARSET_NAME (ccs)) )
     {
       property = chise_ds_get_property (default_chise_data_source,
                                        "true-name");
@@ -2395,6 +2395,20 @@ Save properties of CHARSET.
   charset = XCHARSET_NAME (ccs);
   feature_name = XSTRING_DATA (Fsymbol_name (charset));
 
+  property = chise_ds_get_property (default_chise_data_source,
+                                   "description");
+  chise_feature_set_property_value
+    (chise_ds_get_feature (default_chise_data_source, feature_name),
+     property, XSTRING_DATA (Fprin1_to_string
+                            (CHARSET_DOC_STRING (cs), Qnil)));
+  chise_property_sync (property);
+
+  property = chise_ds_get_property (default_chise_data_source, "type");
+  chise_feature_set_property_value
+    (chise_ds_get_feature (default_chise_data_source, feature_name),
+     property, "CCS");
+  chise_property_sync (property);
+
   property = chise_ds_get_property (default_chise_data_source, "chars");
   chise_feature_set_property_value
     (chise_ds_get_feature (default_chise_data_source, feature_name),
@@ -2410,6 +2424,105 @@ Save properties of CHARSET.
                                               (CHARSET_DIMENSION (cs)),
                                               Qnil)));
   chise_property_sync (property);
+
+  if ( CHARSET_FINAL (cs) != 0 )
+    {
+      property = chise_ds_get_property (default_chise_data_source,
+                                       "final-byte");
+      chise_feature_set_property_value
+       (chise_ds_get_feature (default_chise_data_source, feature_name),
+        property, XSTRING_DATA (Fprin1_to_string (make_int
+                                                  (CHARSET_FINAL (cs)),
+                                                  Qnil)));
+      chise_property_sync (property);
+    }
+
+  if ( !NILP (CHARSET_MOTHER (cs)) )
+    {
+      Lisp_Object mother = CHARSET_MOTHER (cs);
+
+      if ( CHARSETP (mother) )
+       mother = XCHARSET_NAME (mother);
+
+      property = chise_ds_get_property (default_chise_data_source,
+                                       "mother");
+      chise_feature_set_property_value
+       (chise_ds_get_feature (default_chise_data_source, feature_name),
+        property, XSTRING_DATA (Fprin1_to_string (mother, Qnil)));
+      chise_property_sync (property);
+    }
+
+  if ( CHARSET_MAX_CODE (cs) != 0 )
+    {
+      char str[16];
+
+      property = chise_ds_get_property (default_chise_data_source,
+                                       "mother-code-min");
+      if ( CHARSET_MIN_CODE (cs) == 0 )
+       chise_feature_set_property_value
+         (chise_ds_get_feature (default_chise_data_source, feature_name),
+          property, "0");
+      else
+       {
+         sprintf (str, "#x%X", CHARSET_MIN_CODE (cs));
+         chise_feature_set_property_value
+           (chise_ds_get_feature (default_chise_data_source, feature_name),
+            property, str);
+       }
+      chise_property_sync (property);
+
+      property = chise_ds_get_property (default_chise_data_source,
+                                       "mother-code-max");
+      sprintf (str, "#x%X", CHARSET_MAX_CODE (cs));
+      chise_feature_set_property_value
+       (chise_ds_get_feature (default_chise_data_source, feature_name),
+        property, str);
+      chise_property_sync (property);
+
+      property = chise_ds_get_property (default_chise_data_source,
+                                       "mother-code-offset");
+      if ( CHARSET_CODE_OFFSET (cs) == 0 )
+       chise_feature_set_property_value
+         (chise_ds_get_feature (default_chise_data_source, feature_name),
+          property, "0");
+      else
+       {
+         sprintf (str, "#x%X", CHARSET_CODE_OFFSET (cs));
+         chise_feature_set_property_value
+           (chise_ds_get_feature (default_chise_data_source, feature_name),
+            property, str);
+       }
+      chise_property_sync (property);
+
+      property = chise_ds_get_property (default_chise_data_source,
+                                       "mother-code-conversion");
+      if ( CHARSET_CONVERSION (cs) == CONVERSION_IDENTICAL )
+       chise_feature_set_property_value
+         (chise_ds_get_feature (default_chise_data_source, feature_name),
+          property, "identical");
+      else
+       {
+         Lisp_Object sym = Qnil;
+
+         if ( CHARSET_CONVERSION (cs) == CONVERSION_94x60 )
+           sym = Q94x60;
+         else if ( CHARSET_CONVERSION (cs) == CONVERSION_94x94x60 )
+           sym = Q94x94x60;
+         else if ( CHARSET_CONVERSION (cs) == CONVERSION_BIG5_1 )
+           sym = Qbig5_1;
+         else if ( CHARSET_CONVERSION (cs) == CONVERSION_BIG5_2 )
+           sym = Qbig5_2;
+         if ( !NILP (sym) )
+           chise_feature_set_property_value
+             (chise_ds_get_feature (default_chise_data_source, feature_name),
+              property, XSTRING_DATA (Fprin1_to_string (sym, Qnil)));
+         else
+           chise_feature_set_property_value
+             (chise_ds_get_feature (default_chise_data_source, feature_name),
+              property, "unknown");
+       }
+      chise_property_sync (property);
+    }
   return Qnil;
 }
 #endif /* HAVE_LIBCHISE */
@@ -2450,7 +2563,8 @@ Make a builtin character from CHARSET and code-point CODE.
 */
        (charset, code))
 {
-  int c;
+  EMACS_INT c;
+  Emchar ch;
 
   charset = Fget_charset (charset);
   CHECK_INT (code);
@@ -2484,9 +2598,9 @@ Make a builtin character from CHARSET and code-point CODE.
   if (XCHARSET_GRAPHIC (charset) == 1)
     c &= 0x7F7F7F7F;
 #endif
-  c = decode_builtin_char (charset, c);
+  ch = decode_builtin_char (charset, c);
   return
-    c >= 0 ? make_char (c) : Fdecode_char (charset, code, Qnil, Qnil);
+    ch >= 0 ? make_char (ch) : Fdecode_char (charset, code, Qnil, Qnil);
 }
 #endif
 
@@ -2754,10 +2868,10 @@ syms_of_mule_charset (void)
   DEFSUBR (Fset_charset_mapping_table);
 #ifdef HAVE_CHISE
   DEFSUBR (Fsave_charset_mapping_table);
+  DEFSUBR (Freset_charset_mapping_table);
 #ifdef HAVE_LIBCHISE
   DEFSUBR (Fsave_charset_properties);
 #endif /* HAVE_LIBCHISE */
-  DEFSUBR (Freset_charset_mapping_table);
 #endif /* HAVE_CHISE */
   DEFSUBR (Fdecode_char);
   DEFSUBR (Fdecode_builtin_char);