XEmacs 21.2.13
[chise/xemacs-chise.git.1] / src / mule-charset.c
index d9b39b8..96b01bc 100644 (file)
@@ -58,13 +58,20 @@ Lisp_Object Vcharset_chinese_big5_2;
 Lisp_Object Vcharset_chinese_cns11643_1;
 Lisp_Object Vcharset_chinese_cns11643_2;
 Lisp_Object Vcharset_korean_ksc5601;
+
+#ifdef ENABLE_COMPOSITE_CHARS
 Lisp_Object Vcharset_composite;
 
-/* Hashtables for composite chars.  One maps string representing
+/* Hash tables for composite chars.  One maps string representing
    composed chars to their equivalent chars; one goes the
    other way. */
-Lisp_Object Vcomposite_char_char2string_hashtable;
-Lisp_Object Vcomposite_char_string2char_hashtable;
+Lisp_Object Vcomposite_char_char2string_hash_table;
+Lisp_Object Vcomposite_char_string2char_hash_table;
+
+static int composite_char_row_next;
+static int composite_char_col_next;
+
+#endif /* ENABLE_COMPOSITE_CHARS */
 
 /* Table of charsets indexed by leading byte. */
 Lisp_Object charset_by_leading_byte[128];
@@ -72,9 +79,6 @@ Lisp_Object charset_by_leading_byte[128];
 /* Table of charsets indexed by type/final-byte/direction. */
 Lisp_Object charset_by_attributes[4][128][2];
 
-static int composite_char_row_next;
-static int composite_char_col_next;
-
 /* Table of number of bytes in the string representation of a character
    indexed by the first byte of that representation.
 
@@ -108,6 +112,7 @@ Lisp_Object Qregistry, Qfinal, Qgraphic;
 Lisp_Object Qdirection;
 Lisp_Object Qreverse_direction_charset;
 Lisp_Object Qccl_program;
+Lisp_Object Qleading_byte;
 
 Lisp_Object Qascii, Qcontrol_1,
 
@@ -136,7 +141,7 @@ Lisp_Object Qascii, Qcontrol_1,
 
 Lisp_Object Ql2r, Qr2l;
 
-Lisp_Object Vcharset_hashtable;
+Lisp_Object Vcharset_hash_table;
 
 static Bufbyte next_allocated_1_byte_leading_byte;
 static Bufbyte next_allocated_2_byte_leading_byte;
@@ -277,14 +282,16 @@ non_ascii_valid_char_p (Emchar ch)
       if (f2 < 0x20 || f3 < 0x20)
        return 0;
 
+#ifdef ENABLE_COMPOSITE_CHARS
       if (f1 + FIELD1_TO_OFFICIAL_LEADING_BYTE == LEADING_BYTE_COMPOSITE)
        {
          if (UNBOUNDP (Fgethash (make_int (ch),
-                                 Vcomposite_char_char2string_hashtable,
+                                 Vcomposite_char_char2string_hash_table,
                                  Qunbound)))
            return 0;
          return 1;
        }
+#endif /* ENABLE_COMPOSITE_CHARS */
 
       if (f2 != 0x20 && f2 != 0x7F && f3 != 0x20 && f3 != 0x7F)
        return 1;
@@ -391,9 +398,9 @@ mark_charset (Lisp_Object obj, void (*markobj) (Lisp_Object))
 {
   struct Lisp_Charset *cs = XCHARSET (obj);
 
-  (markobj) (cs->doc_string);
-  (markobj) (cs->registry);
-  (markobj) (cs->ccl_program);
+  markobj (cs->doc_string);
+  markobj (cs->registry);
+  markobj (cs->ccl_program);
   return cs->name;
 }
 
@@ -461,7 +468,7 @@ make_charset (int id, Lisp_Object name, Bufbyte leading_byte, unsigned char rep_
                                CHARSET_TYPE (cs) == CHARSET_TYPE_96) ? 1 : 2;
   CHARSET_CHARS         (cs) = (CHARSET_TYPE (cs) == CHARSET_TYPE_94 ||
                                CHARSET_TYPE (cs) == CHARSET_TYPE_94X94) ? 94 : 96;
-    
+
   if (final)
     {
       /* some charsets do not have final characters.  This includes
@@ -480,7 +487,7 @@ make_charset (int id, Lisp_Object name, Bufbyte leading_byte, unsigned char rep_
   /* Some charsets are "faux" and don't have names or really exist at
      all except in the leading-byte table. */
   if (!NILP (name))
-    Fputhash (name, obj, Vcharset_hashtable);
+    Fputhash (name, obj, Vcharset_hash_table);
   return obj;
 }
 
@@ -537,7 +544,7 @@ nil is returned.  Otherwise the associated charset object is returned.
     return charset_or_name;
 
   CHECK_SYMBOL (charset_or_name);
-  return Fgethash (charset_or_name, Vcharset_hashtable, Qnil);
+  return Fgethash (charset_or_name, Vcharset_hash_table, Qnil);
 }
 
 DEFUN ("get-charset", Fget_charset, 1, 1, 0, /*
@@ -563,19 +570,15 @@ struct charset_list_closure
 };
 
 static int
-add_charset_to_list_mapper (CONST void *hash_key, void *hash_contents,
+add_charset_to_list_mapper (Lisp_Object key, Lisp_Object value,
                            void *charset_list_closure)
 {
   /* This function can GC */
-  Lisp_Object key, contents;
-  Lisp_Object *charset_list;
   struct charset_list_closure *chcl =
     (struct charset_list_closure*) charset_list_closure;
-  CVOID_TO_LISP (key, hash_key);
-  VOID_TO_LISP (contents, hash_contents);
-  charset_list = chcl->charset_list;
+  Lisp_Object *charset_list = chcl->charset_list;
 
-  *charset_list = Fcons (XCHARSET_NAME (contents), *charset_list);
+  *charset_list = Fcons (XCHARSET_NAME (value), *charset_list);
   return 0;
 }
 
@@ -590,7 +593,7 @@ Return a list of the names of all defined charsets.
 
   GCPRO1 (charset_list);
   charset_list_closure.charset_list = &charset_list;
-  elisp_maphash (add_charset_to_list_mapper, Vcharset_hashtable,
+  elisp_maphash (add_charset_to_list_mapper, Vcharset_hash_table,
                 &charset_list_closure);
   UNGCPRO;
 
@@ -926,6 +929,7 @@ Recognized properties are those listed in `make-charset', as well as
   if (EQ (prop, Qchars))       return make_int (CHARSET_CHARS (cs));
   if (EQ (prop, Qregistry))    return CHARSET_REGISTRY (cs);
   if (EQ (prop, Qccl_program)) return CHARSET_CCL_PROGRAM (cs);
+  if (EQ (prop, Qleading_byte)) return make_char (CHARSET_LEADING_BYTE (cs));
   if (EQ (prop, Qdirection))
     return CHARSET_DIRECTION (cs) == CHARSET_LEFT_TO_RIGHT ? Ql2r : Qr2l;
   if (EQ (prop, Qreverse_direction_charset))
@@ -966,13 +970,13 @@ static void
 invalidate_charset_font_caches (Lisp_Object charset)
 {
   /* Invalidate font cache entries for charset on all devices. */
-  Lisp_Object devcons, concons, hashtab;
+  Lisp_Object devcons, concons, hash_table;
   DEVICE_LOOP_NO_BREAK (devcons, concons)
     {
       struct device *d = XDEVICE (XCAR (devcons));
-      hashtab = Fgethash (charset, d->charset_font_cache, Qunbound);
-      if (!UNBOUNDP (hashtab))
-        Fclrhash (hashtab);
+      hash_table = Fgethash (charset, d->charset_font_cache, Qunbound);
+      if (!UNBOUNDP (hash_table))
+        Fclrhash (hash_table);
     }
 }
 
@@ -1068,6 +1072,7 @@ N defaults to 0 if omitted.
 }
 
 \f
+#ifdef ENABLE_COMPOSITE_CHARS
 /************************************************************************/
 /*                     composite character functions                    */
 /************************************************************************/
@@ -1077,7 +1082,7 @@ lookup_composite_char (Bufbyte *str, int len)
 {
   Lisp_Object lispstr = make_string (str, len);
   Lisp_Object ch = Fgethash (lispstr,
-                            Vcomposite_char_string2char_hashtable,
+                            Vcomposite_char_string2char_hash_table,
                             Qunbound);
   Emchar emch;
 
@@ -1088,9 +1093,9 @@ lookup_composite_char (Bufbyte *str, int len)
       emch = MAKE_CHAR (Vcharset_composite, composite_char_row_next,
                        composite_char_col_next);
       Fputhash (make_char (emch), lispstr,
-               Vcomposite_char_char2string_hashtable);
+               Vcomposite_char_char2string_hash_table);
       Fputhash (lispstr, make_char (emch),
-               Vcomposite_char_string2char_hashtable);
+               Vcomposite_char_string2char_hash_table);
       composite_char_col_next++;
       if (composite_char_col_next >= 128)
        {
@@ -1107,13 +1112,13 @@ Lisp_Object
 composite_char_string (Emchar ch)
 {
   Lisp_Object str = Fgethash (make_char (ch),
-                             Vcomposite_char_char2string_hashtable,
+                             Vcomposite_char_char2string_hash_table,
                              Qunbound);
   assert (!UNBOUNDP (str));
   return str;
 }
 
-DEFUN ("make-composite-char", Fmake_composite_char, 1, 1, 0, /*
+xxDEFUN ("make-composite-char", Fmake_composite_char, 1, 1, 0, /*
 Convert a string into a single composite character.
 The character is the result of overstriking all the characters in
 the string.
@@ -1125,7 +1130,7 @@ the string.
                                           XSTRING_LENGTH (string)));
 }
 
-DEFUN ("composite-char-string", Fcomposite_char_string, 1, 1, 0, /*
+xxDEFUN ("composite-char-string", Fcomposite_char_string, 1, 1, 0, /*
 Return a string of the characters comprising a composite character.
 */
        (ch))
@@ -1138,6 +1143,7 @@ Return a string of the characters comprising a composite character.
     signal_simple_error ("Must be composite char", ch);
   return composite_char_string (emch);
 }
+#endif /* ENABLE_COMPOSITE_CHARS */
 
 \f
 /************************************************************************/
@@ -1167,8 +1173,10 @@ syms_of_mule_charset (void)
   DEFSUBR (Fchar_charset);
   DEFSUBR (Fchar_octet);
 
+#ifdef ENABLE_COMPOSITE_CHARS
   DEFSUBR (Fmake_composite_char);
   DEFSUBR (Fcomposite_char_string);
+#endif
 
   defsymbol (&Qcharsetp, "charsetp");
   defsymbol (&Qregistry, "registry");
@@ -1177,6 +1185,7 @@ syms_of_mule_charset (void)
   defsymbol (&Qdirection, "direction");
   defsymbol (&Qreverse_direction_charset, "reverse-direction-charset");
   defsymbol (&Qccl_program, "ccl-program");
+  defsymbol (&Qleading_byte, "leading-byte");
 
   defsymbol (&Ql2r, "l2r");
   defsymbol (&Qr2l, "r2l");
@@ -1234,9 +1243,9 @@ vars_of_mule_charset (void)
 void
 complex_vars_of_mule_charset (void)
 {
-  staticpro (&Vcharset_hashtable);
-  Vcharset_hashtable = make_lisp_hashtable (50, HASHTABLE_NONWEAK,
-                                           HASHTABLE_EQ);
+  staticpro (&Vcharset_hash_table);
+  Vcharset_hash_table =
+    make_lisp_hash_table (50, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ);
 
   /* Predefined character sets.  We store them into variables for
      ease of access. */
@@ -1397,6 +1406,8 @@ complex_vars_of_mule_charset (void)
                  CHARSET_LEFT_TO_RIGHT,
                  build_string ("KS C5601 (Hangul and Korean Hanja)"),
                  build_string ("ksc5601"));
+
+#ifdef ENABLE_COMPOSITE_CHARS
   /* #### For simplicity, we put composite chars into a 96x96 charset.
      This is going to lead to problems because you can run out of
      room, esp. as we don't yet recycle numbers. */
@@ -1410,11 +1421,12 @@ complex_vars_of_mule_charset (void)
   composite_char_row_next = 32;
   composite_char_col_next = 32;
 
-  Vcomposite_char_string2char_hashtable =
-    make_lisp_hashtable (500, HASHTABLE_NONWEAK, HASHTABLE_EQUAL);
-  Vcomposite_char_char2string_hashtable =
-    make_lisp_hashtable (500, HASHTABLE_NONWEAK, HASHTABLE_EQ);
-  staticpro (&Vcomposite_char_string2char_hashtable);
-  staticpro (&Vcomposite_char_char2string_hashtable);
+  Vcomposite_char_string2char_hash_table =
+    make_lisp_hash_table (500, HASH_TABLE_NON_WEAK, HASH_TABLE_EQUAL);
+  Vcomposite_char_char2string_hash_table =
+    make_lisp_hash_table (500, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ);
+  staticpro (&Vcomposite_char_string2char_hash_table);
+  staticpro (&Vcomposite_char_char2string_hash_table);
+#endif /* ENABLE_COMPOSITE_CHARS */
 
 }