*** empty log message ***
[m17n/m17n-lib.git] / src / character.c
index 774cb94..a9b3569 100644 (file)
     to character C and whose key is K" may be shortened to "the K
     property of C".  */
 
-/***oldja
+/***ja
     @addtogroup m17nCharacter
-    @brief Ê¸»ú¥ª¥Ö¥¸¥§¥¯¥È¤È¤½¤ì¤Ë´Ø¤¹¤ë API
+    @brief Ê¸»ú¥ª¥Ö¥¸¥§¥¯¥È¤È¤½¤ì¤Ë´Ø¤¹¤ë API.
 
-    m17n ¥é¥¤¥Ö¥é¥ê¤Ï @e Ê¸»ú ¤òʸ»ú¥³¡¼¥É¡ÊÀ°¿ô¡Ë¤Çɽ¸½¤¹¤ë¡£ºÇ¾®¤Îʸ
-    »ú¥³¡¼¥É¤Ï @c 0 ¤Ç¡¢ºÇÂç¤Îʸ»ú¥³¡¼¥É¤Ï¥Þ¥¯¥í #MCHAR_MAX ¤Ë¤è¤Ã¤Æ
-    ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£#MCHAR_MAX ¤Ï @c 0x3FFFFF¡Ê22¥Ó¥Ã¥È¡Ë°Ê¾å¤Ç¤¢¤ë
-    ¤³¤È¤¬Êݾڤµ¤ì¤Æ¤¤¤ë¡£
+    m17n ¥é¥¤¥Ö¥é¥ê¤Ï @e Ê¸»ú ¤òʸ»ú¥³¡¼¥É¡ÊÀ°¿ô¡Ë¤Çɽ¸½¤¹¤ë¡£
+    ºÇ¾®¤Îʸ»ú¥³¡¼¥É¤Ï @c 0 ¤Ç¤¢¤ê¡¢ºÇÂç¤Îʸ»ú¥³¡¼¥É¤Ï¥Þ¥¯¥í #MCHAR_MAX 
+    ¤Ë¤è¤Ã¤ÆÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£#MCHAR_MAX ¤Ï @c 0x3FFFFF¡Ê22¥Ó¥Ã¥È¡Ë
+    °Ê¾å¤Ç¤¢¤ë¤³¤È¤¬Êݾڤµ¤ì¤Æ¤¤¤ë¡£
 
-    @c 0 ¤«¤é @c 0x10FFFF ¤Þ¤Ç¤Îʸ»ú¤Ï¡¢¤½¤ì¤ÈƱ¤¸Ãͤò»ý¤Ä Unicode ¤Î
-    Ê¸»ú¤Ë³ä¤êÅö¤Æ¤é¤ì¤Æ¤¤¤ë¡£
+    @c 0 ¤«¤é @c 0x10FFFF ¤Þ¤Ç¤Îʸ»ú¤Ï¡¢¤½¤ì¤ÈƱ¤¸Ãͤò»ý¤Ä Unicode 
+    ¤Îʸ»ú¤Ë³ä¤êÅö¤Æ¤é¤ì¤Æ¤¤¤ë¡£
 
-    ³Æʸ»ú¤Ï @e Ê¸»ú¥×¥í¥Ñ¥Æ¥£ ¤È¸Æ¤Ö¥×¥í¥Ñ¥Æ¥£¤ò0¸Ä°Ê¾å»ý¤Ä¤³¤È¤¬¤Ç¤­
-    ¤ë¡£Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Ï @e ¥­¡¼ ¤È @e ÃÍ ¤«¤é¤Ê¤ë¡£¥­¡¼¤Ï¥·¥ó¥Ü¥ë¤Ç¤¢
-    ¤ê¡¢ÃͤϠ<tt>(void *)</tt> ·¿¤Ë¥­¥ã¥¹¥È¤Ç¤­¤ë¤â¤Î¤Ê¤é²¿¤Ç¤â¤è¤¤¡£ 
-    ¡Öʸ»ú C ¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¤¦¤Á¥­¡¼¤¬ @c K ¤Ç¤¢¤ë¤â¤Î¡×¤ò´Êñ¤Ë
-    ¡Öʸ»ú C ¤Î K ¥×¥í¥Ñ¥Æ¥£¡×¤È¸Æ¤Ö¤³¤È¤¬¤¢¤ë¡£  */
+    ³Æʸ»ú¤Ï @e Ê¸»ú¥×¥í¥Ñ¥Æ¥£ ¤È¸Æ¤Ö¥×¥í¥Ñ¥Æ¥£¤ò 0 ¸Ä°Ê¾å»ý¤Ä¤³¤È¤¬¤Ç¤­¤ë¡£
+    Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Ï @e ¥­¡¼ ¤È @e ÃÍ ¤«¤é¤Ê¤ë¡£
+    ¥­¡¼¤Ï¥·¥ó¥Ü¥ë¤Ç¤¢¤ê¡¢ÃͤϠ<tt>(void *)</tt> ·¿¤Ë¥­¥ã¥¹¥È¤Ç¤­¤ë¤â¤Î¤Ê¤é²¿¤Ç¤â¤è¤¤¡£ 
+    ¡Öʸ»ú C ¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¤¦¤Á¥­¡¼¤¬ K ¤Ç¤¢¤ë¤â¤Î¡×¤ò´Êñ¤Ë¡Öʸ»ú C 
+    ¤Î K ¥×¥í¥Ñ¥Æ¥£¡×¤È¸Æ¤Ö¤³¤È¤¬¤¢¤ë¡£  */
 /*=*/
 
 #if !defined (FOR_DOXYGEN) || defined (DOXYGEN_INTERNAL_MODULE)
@@ -95,22 +95,13 @@ free_string (int from, int to, void *str, void *arg)
 int
 mchar__init ()
 {
-  char_prop_list = mplist ();
-
-  Mname
-    = mchar_define_property ("name", Mstring);
-  Mcategory
-    = mchar_define_property ("category", Msymbol);
-  Mcombining_class
-    = mchar_define_property ("combining-class", Minteger);
-  Mbidi_category
-    = mchar_define_property ("bidirectional-category", Msymbol);
-  Msimple_case_folding
-    = mchar_define_property ("simple-case-folding", Minteger);
-  Mcomplicated_case_folding
-    = mchar_define_property ("complicated-case-folding", Mtext);
-  Mscript
-    = mchar_define_property ("script", Msymbol);
+  Mname = msymbol ("name");
+  Mcategory = msymbol ("category");
+  Mcombining_class = msymbol ("combining-class");
+  Mbidi_category = msymbol ("bidirectional-category");
+  Msimple_case_folding = msymbol ("simple-case-folding");
+  Mcomplicated_case_folding = msymbol ("complicated-case-folding");
+  Mscript = msymbol ("script");
 
   return 0;
 }
@@ -120,28 +111,68 @@ mchar__fini (void)
 {
   MPlist *p;
 
-  for (p = char_prop_list; mplist_key (p) != Mnil; p = mplist_next (p))
+  if (char_prop_list)
     {
-      MCharPropRecord *record = mplist_value (p);
-
-      if (record->table)
+      for (p = char_prop_list; mplist_key (p) != Mnil; p = mplist_next (p))
        {
-         if (record->type == Mstring)
-           mchartable_map (record->table, NULL, free_string, NULL);
-         M17N_OBJECT_UNREF (record->table);
+         MCharPropRecord *record = mplist_value (p);
+
+         if (record->table)
+           {
+             if (record->type == Mstring)
+               mchartable_map (record->table, NULL, free_string, NULL);
+             M17N_OBJECT_UNREF (record->table);
+           }
+         free (record);
        }
-      free (record);
+      M17N_OBJECT_UNREF (char_prop_list);
+    }
+}
+
+void
+mchar__define_prop (MSymbol key, MSymbol type, void *mdb)
+{
+  MCharPropRecord *record;
+
+  if (char_prop_list)
+    record = mplist_get (char_prop_list, key);
+  else
+    char_prop_list = mplist (), record = NULL;
+  if (record)
+    {
+      if (record->table)
+       M17N_OBJECT_UNREF (record->table);
+    }
+  else
+    {
+      MSTRUCT_CALLOC (record, MERROR_CHAR);
+      mplist_put (char_prop_list, key, record);
+    }
+
+  record->type = type;
+  record->mdb = mdb;
+  if (mdb)
+    {
+      record->table = NULL;
+    }
+  else
+    {
+      void *default_value = NULL;
+
+      if (type == Minteger)
+       default_value = (void *) -1;
+      record->table = mchartable (type, default_value);
     }
-  M17N_OBJECT_UNREF (char_prop_list);
 }
 
+
 /*** @} */
 #endif /* !FOR_DOXYGEN || DOXYGEN_INTERNAL_MODULE */
 \f
 /* External API */
 
-/*** @addtogroup m17nCharacter */
-/*** @{ */
+/*** @addtogroup m17nCharacter
+     @{ */
 /*=*/
 
 #ifdef FOR_DOXYGEN
@@ -150,26 +181,25 @@ mchar__fini (void)
 
     The macro #MCHAR_MAX gives the maximum character code.  */
 
-/***oldja
-    @brief Ê¸»ú¥³¡¼¥É¤ÎºÇÂçÃÍ
+/***ja
+    @brief Ê¸»ú¥³¡¼¥É¤ÎºÇÂçÃÍ.
 
-    ¥Þ¥¯¥í #MCHAR_MAX ¤Ïʸ»ú¥³¡¼¥É¤ÎºÇÂçÃͤòÍ¿¤¨¤ë¡£  */
+    ¥Þ¥¯¥í #MCHAR_MAX ¤Ïʸ»ú¥³¡¼¥É¤ÎºÇÂçÃͤòɽ¤¹¡£  */
 
 #define MCHAR_MAX
 /*=*/
 #endif /* FOR_DOXYGEN */
 
 /***en
-    @ingroup m17nCharacter
     @name Variables: Keys of character properties
 
     These symbols are used as keys of character properties.  */
 
-/***oldja
-     @name ÊÑ¿ô: Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼
+/***ja
+    @ingroup m17nCharacter
+    @name ÊÑ¿ô: Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼
 
-     ¤³¤ì¤é¤Î¥·¥ó¥Ü¥ë¤Ïʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£*/
-/*=*/
+    ¤³¤ì¤é¤Î¥·¥ó¥Ü¥ë¤Ïʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£*/
 /*** @{ */
 
 /***en
@@ -182,12 +212,12 @@ mchar__fini (void)
     Each symbol that represents a script has one of the names listed in
     the <em>Unicode Technical Report #24</em>.  */
 
-/***oldja
-    @brief ¥¹¥¯¥ê¥×¥È¤òɽ¤ï¤¹¥­¡¼
+/***ja
+    @brief ¥¹¥¯¥ê¥×¥È¤òɽ¤ï¤¹¥­¡¼.
 
-    ¥·¥ó¥Ü¥ë #Mscript ¤Ï <tt>"script"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×
-    ¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢¤³¤Îʸ»ú¤Î°¤¹
-    ¤ë¥¹¥¯¥ê¥×¥È¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£
+    ¥·¥ó¥Ü¥ë #Mscript ¤Ï <tt>"script"</tt> 
+    ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£
+    ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢¤³¤Îʸ»ú¤Î°¤¹¤ë¥¹¥¯¥ê¥×¥È¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£
 
     ¥¹¥¯¥ê¥×¥È¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Î̾Á°¤Ï¡¢<em>Unicode Technical Report
     #24</em> ¤Ë¥ê¥¹¥È¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤Î¤¤¤º¤ì¤«¤Ç¤¢¤ë¡£  */
@@ -203,12 +233,12 @@ MSymbol Mscript;
     the key of a character property.  The value of such a property is a
     C-string representing the name of the character.  */
 
-/***oldja
-    @brief Ì¾Á°¤òɽ¤ï¤¹¥­¡¼
+/***ja
+    @brief Ì¾Á°¤òɽ¤ï¤¹¥­¡¼.
 
-    ¥·¥ó¥Ü¥ë #Mname ¤Ï <tt>"name"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ
-    ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϠC-string ¤Ç¤¢¤ê¡¢¤½
-    ¤Îʸ»ú¤Î̾Á°¤òɽ¤ï¤¹¡£  */
+    ¥·¥ó¥Ü¥ë #Mname ¤Ï <tt>"name"</tt> 
+    ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£
+    ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϤ½¤Îʸ»ú¤Î̾Á°¤òɽ¤ï¤¹ C ¤Îʸ»úÎó¤Ç¤¢¤ë¡£  */
 
 MSymbol Mname;
 
@@ -226,15 +256,15 @@ MSymbol Mname;
     names listed as abbreviations for <em>General Category</em> in
     Unicode.  */
 
-/***oldja
-    @brief °ìÈÌ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥­¡¼
+/***ja
+    @brief °ìÈÌ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥­¡¼.
 
-    ¥·¥ó¥Ü¥ë #Mcategory ¤Ï <tt>"category"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸
-    »ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë
-    <em>°ìÈÌ¥«¥Æ¥´¥ê</em> ¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£
+    ¥·¥ó¥Ü¥ë #Mcategory ¤Ï <tt>"category"</tt> 
+    ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£
+    ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë <em>°ìÈÌ¥«¥Æ¥´¥ê</em> ¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£
 
-    °ìÈÌ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Î̾Á°¤Ï¡¢<em>General Category</em>¤Î
-    ¾Êά·Á¤È¤·¤Æ Unicode ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤Ç¤¢¤ë¡£  */
+    °ìÈÌ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Î̾Á°¤Ï¡¢<em>General Category</em> 
+    ¤Î¾Êά·Á¤È¤·¤Æ Unicode ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤Ç¤¢¤ë¡£  */
 
 MSymbol Mcategory;
 
@@ -251,15 +281,15 @@ MSymbol Mcategory;
     The meaning of each integer that represents a canonical combining
     class is identical to the one defined in Unicode.  */
 
-/***oldja
-    @brief É¸½à·ë¹ç¥¯¥é¥¹¤òɽ¤ï¤¹¥­¡¼
+/***ja
+    @brief É¸½à·ë¹ç¥¯¥é¥¹¤òɽ¤ï¤¹¥­¡¼.
 
-    ¥·¥ó¥Ü¥ë #Mcombining_class ¤Ï <tt>"combining-class"</tt> ¤È¤¤¤¦
-    Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃÍ
-    ¤Ï¡¢Âбþ¤¹¤ë @e É¸½à·ë¹ç¥¯¥é¥¹ ¤òɽ¤ï¤¹ÈóÉéÀ°¿ô¤Ç¤¢¤ë¡£
+    ¥·¥ó¥Ü¥ë #Mcombining_class ¤Ï <tt>"combining-class"</tt> 
+    ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£
+    ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë @e É¸½à·ë¹ç¥¯¥é¥¹ ¤òɽ¤ï¤¹À°¿ô¤Ç¤¢¤ë¡£
 
-    É¸½à·ë¹ç¥¯¥é¥¹¤òɽ¤ï¤¹ÈóÉéÀ°¿ô¤Î°ÕÌ£¤Ï¡¢Unicode ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤â¤Î
-    ¤ÈƱ¤¸¤Ç¤¢¤ë¡£  */
+    É¸½à·ë¹ç¥¯¥é¥¹¤òɽ¤ï¤¹À°¿ô¤Î°ÕÌ£¤Ï¡¢Unicode 
+    ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤ÈƱ¤¸¤Ç¤¢¤ë¡£  */
 
 MSymbol Mcombining_class;
 /*=*/
@@ -276,12 +306,12 @@ MSymbol Mcombining_class;
     the names listed as types of <em>Bidirectional Category</em> in
     Unicode.  */
 
-/***oldja
-    @brief ÁÐÊý¸þ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥­¡¼
+/***ja
+    @brief ÁÐÊý¸þ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥­¡¼.
 
-    ¥·¥ó¥Ü¥ë #Mbidi_category ¤Ï <tt>"bidi-category"</tt> ¤È¤¤¤¦Ì¾Á°
-    ¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢
-    Âбþ¤¹¤ë @e ÁÐÊý¸þ¥«¥Æ¥´¥ê ¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£
+    ¥·¥ó¥Ü¥ë #Mbidi_category ¤Ï <tt>"bidi-category"</tt> 
+    ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£
+    ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë @e ÁÐÊý¸þ¥«¥Æ¥´¥ê ¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£
 
     ÁÐÊý¸þ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Î̾Á°¤Ï¡¢<em>Bidirectional
     Category</em> ¤Î·¿¤È¤·¤Æ Unicode ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤Ç¤¢¤ë¡£  */
@@ -303,21 +333,21 @@ MSymbol Mbidi_category;
     of such a property is @c 0xFFFF.  In this case, the character has
     another property whose key is #Mcomplicated_case_folding.  */
 
-/***oldja
-    @brief Âбþ¤¹¤ë¾®Ê¸»ú°ìʸ»ú¤òɽ¤ï¤¹¥­¡¼
+/***ja
+    @brief Âбþ¤¹¤ë¾®Ê¸»ú°ìʸ»ú¤òɽ¤ï¤¹¥­¡¼.
 
     ¥·¥ó¥Ü¥ë #Msimple_case_folding ¤Ï <tt>"simple-case-folding"</tt> 
-    ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£
-    ¤ÎÃͤϡ¢Âбþ¤¹¤ë¾®Ê¸»ú°ìʸ»ú¤Ç¤¢¤ê¡¢Âçʸ»ú¡¿¾®Ê¸»ú¤Î¶èÊ̤ò̵»ë¤·¤¿
-    Ê¸»úÎóÈæ³Ó¤ÎºÝ¤Ë»È¤ï¤ì¤ë¡£
+    ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£
+    ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë¾®Ê¸»ú°ìʸ»ú¤Ç¤¢¤ê¡¢Âçʸ»ú¡¿¾®Ê¸»ú¤Î¶èÊ̤ò̵»ë¤·¤¿Ê¸»úÎóÈæ³Ó¤ÎºÝ¤Ë»È¤ï¤ì¤ë¡£
 
-    ¤â¤·¤½¤Î¤è¤¦¤ÊÈæ³Ó¤Ë»ÈÍѤ·ÆÀ¤ëñ°ì¤Î¾®Ê¸»ú¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¡¢¤³¤Î¥×
-    ¥í¥Ñ¥Æ¥£¤ÎÃͤϠ0xFFFF ¤Ë¤Ê¤ë¡£¤³¤Î¾ì¹ç¤½¤Îʸ»ú¤Ï¡¢
-    #Mcomplicated_case_folding ¤È¤¤¤¦¥­¡¼¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£¤ò»ý¤Ä¡£  */
+    Ê£»¨¤ÊÈæ³ÓÊýË¡¤òɬÍפȤ¹¤ëʸ»ú¤Ç¤¢¤Ã¤¿¾ì¹ç
+    ¡ÊÊ̤ΰìʸ»ú¤ÈÂбþÉÕ¤±¤ë¤³¤È¤Ë¤è¤Ã¤ÆÈæ³Ó¤Ç¤­¤Ê¤¤¾ì¹ç¡Ë¡¢¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϠ
+    @c 0xFFFF ¤Ë¤Ê¤ë¡£¤³¤Î¾ì¹ç¤½¤Îʸ»ú¤Ï¡¢#Mcomplicated_case_folding
+    ¤È¤¤¤¦¥­¡¼¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£¤ò»ý¤Ä¡£  */
 
 MSymbol Msimple_case_folding;
 /***en
-    @brief Key for corresponding multiple lowercase characters
+    @brief Key for corresponding multiple lowercase characters.
 
     The symbol #Mcomplicated_case_folding has the name
     <tt>"complicated-case-folding"</tt> and is used as the key of a
@@ -325,13 +355,13 @@ MSymbol Msimple_case_folding;
     corresponding M-text that contains a sequence of lowercase
     characters to be used for comparing M-texts ignoring case.  */
 
-/***oldja
-    @brief Âбþ¤¹¤ë¾®Ê¸»ú¤ÎÎó¤òɽ¤ï¤¹¥­¡¼
+/***ja
+    @brief Âбþ¤¹¤ë¾®Ê¸»ú¤ÎÎó¤òɽ¤ï¤¹¥­¡¼.
 
     ¥·¥ó¥Ü¥ë #Mcomplicated_case_folding ¤Ï 
-    <tt>"complicated-case-folding"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£
-    ¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë¾®Ê¸»úÎ󤫤é¤Ê
-    ¤ë M-text ¤Ç¤¢¤ê¡¢Âçʸ»ú¡¿¾®Ê¸»ú¤Î¶èÊ̤ò̵»ë¤·¤¿Ê¸»úÎóÈæ³Ó¤ÎºÝ¤Ë»È
+    <tt>"complicated-case-folding"</tt> 
+    ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£
+    ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë¾®Ê¸»úÎ󤫤é¤Ê¤ë M-text ¤Ç¤¢¤ê¡¢Âçʸ»ú¡¿¾®Ê¸»ú¤Î¶èÊ̤ò̵»ë¤·¤¿Ê¸»úÎóÈæ³Ó¤ÎºÝ¤Ë»È
     ¤ï¤ì¤ë¡£
       */
 
@@ -352,16 +382,16 @@ MSymbol Mcomplicated_case_folding;
     If the operation was successful, mchar_define_property () returns
     $SYM.  Otherwise it returns #Mnil.  */
 
-/***oldja
-    @brief Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤òÄêµÁ¤¹¤ë
+/***ja
+    @brief Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤òÄêµÁ¤¹¤ë.
 
     ´Ø¿ô mchar_define_property () ¤Ï¡¢ \<#Mchar_table, $TYPE, $SYM \>
-    ¤È¤¤¤¦¥¿¥°¤ò»ý¤Ã¤¿¥Ç¡¼¥¿¥Ù¡¼¥¹¤ò m17n ¸À¸ì¾ðÊó¥Ù¡¼¥¹¤«¤éõ¤¹¡£  ¤³
-    ¤³¤Ç $SYM ¤Ï $NAME ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£$TYPE ¤Ï#Mstring,
+    ¤È¤¤¤¦¥¿¥°¤ò»ý¤Ã¤¿¥Ç¡¼¥¿¥Ù¡¼¥¹¤ò m17n ¸À¸ì¾ðÊó¥Ù¡¼¥¹¤«¤éõ¤¹¡£  
+    ¤³¤³¤Ç $SYM ¤Ï $NAME ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£$TYPE ¤Ï#Mstring,
     #Mtext, #Msymbol, #Minteger, #Mplist ¤Î¤¤¤º¤ì¤«¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
 
     @return
-    ½èÍý¤ËÀ®¸ù¤¹¤ì¤Ð $SYM ¤òÊÖ¤¹¡£
+    ½èÍý¤ËÀ®¸ù¤¹¤ì¤Ð mchar_define_property () ¤Ï$SYM ¤òÊÖ¤¹¡£
     ¼ºÇÔ¤·¤¿¾ì¹ç¤Ï #Mnil ¤òÊÖ¤¹¡£  */
 
 /***
@@ -372,39 +402,16 @@ MSymbol Mcomplicated_case_folding;
     mchar_get_prop (), mchar_put_prop ()  */
 
 MSymbol
-mchar_define_property (char *name, MSymbol type)
+mchar_define_property (const char *name, MSymbol type)
 {
   MSymbol key = msymbol (name);
-  MCharPropRecord *record;
-
-  record = mplist_get (char_prop_list, key);
-  if (record)
-    {
-      if (record->table)
-       M17N_OBJECT_UNREF (record->table);
-    }
-  else
-    {
-      MSTRUCT_CALLOC (record, MERROR_CHAR);
-      mplist_put (char_prop_list, key, record);
-    }
+  void *mdb;
 
-  record->type = type;
-  if (mdatabase__finder
-      && (record->mdb = (*mdatabase__finder) (Mchar_table, type, key, Mnil)))
-    {
-      record->table = NULL;
-    }
+  if (mdatabase__finder)
+    mdb = (*mdatabase__finder) (Mchar_table, type, key, Mnil);
   else
-    {
-      void *default_value = NULL;
-
-      record->mdb = NULL;
-      if (type == Minteger)
-       default_value = (void *) -1;
-      record->table = mchartable (type, default_value);
-    }
-
+    mdb = NULL;
+  mchar__define_prop (key, type, mdb);
   return key;
 }
 
@@ -421,19 +428,18 @@ mchar_define_property (char *name, MSymbol type)
     value of the character property.  Otherwise it returns @c
     NULL.  */
 
-/***oldja
-    @brief Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÆÀ¤ë
+/***ja
+    @brief Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÆÀ¤ë.
 
-    ´Ø¿ô mchar_get_prop () ¤Ï¡¢Ê¸»ú $C ¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£Ãæ¡¢¥­¡¼¤¬ $KEY 
-    ¤Ç¤¢¤ë¤â¤Î¤òõ¤¹¡£
+    ´Ø¿ô mchar_get_prop () ¤Ï¡¢Ê¸»ú $C ¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¤¦¤Á¥­¡¼¤¬ 
+    $KEY ¤Ç¤¢¤ë¤â¤Î¤òõ¤¹¡£
 
     @return
-    ½èÍý¤¬À®¸ù¤¹¤ì¤Ð mchar_get_prop () ¤Ï¸«¤Ä¤«¤Ã¤¿¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÊÖ
-    ¤¹¡£¼ºÇÔ¤·¤¿¾ì¹ç¤Ï #Mnil ¤òÊÖ¤¹¡£
+    ½èÍý¤¬À®¸ù¤¹¤ì¤Ð mchar_get_prop () ¤Ï¸«¤Ä¤«¤Ã¤¿¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÊÖ¤¹¡£
+    ¼ºÇÔ¤·¤¿¾ì¹ç¤Ï @c NULL ¤òÊÖ¤¹¡£
 
     @latexonly \IPAlabel{mchar_get_prop} @endlatexonly
 */
-
 /***
     @errors
     @c MERROR_SYMBOL, @c MERROR_DB
@@ -446,6 +452,8 @@ mchar_get_prop (int c, MSymbol key)
 {
   MCharPropRecord *record;
 
+  if (! char_prop_list)
+    return NULL;
   record = mplist_get (char_prop_list, key);
   if (! record)
     return NULL;
@@ -471,17 +479,14 @@ mchar_get_prop (int c, MSymbol key)
     @return
     If the operation was successful, mchar_put_prop () returns 0.
     Otherwise, it returns -1.  */
+/***ja
+    @brief Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÀßÄꤹ¤ë.
 
-/***oldja
-    @brief Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÀßÄꤹ¤ë
-
-    ´Ø¿ô mchar_put_prop () ¤Ïʸ»ú $C ¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£Ãæ¡¢¥­¡¼¤¬ $KEY ¤Ç
-    ¤¢¤ë¤â¤Î¤òõ¤·¡¢¤½¤ÎÃͤȤ·¤Æ $VAL ¤òÀßÄꤹ¤ë¡£
+    ´Ø¿ô mchar_put_prop () ¤Ï¡¢Ê¸»ú $C ¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¤¦¤Á¥­¡¼¤¬ $KEY 
+    ¤Ç¤¢¤ë¤â¤Î¤òõ¤·¡¢¤½¤ÎÃͤȤ·¤Æ $VAL ¤òÀßÄꤹ¤ë¡£
 
     @return
-    ½èÍý¤¬À®¸ù¤¹¤ì¤Ð mchar_put_prop () ¤Ï0¤òÊÖ¤¹¡£¼ºÇÔ¤·¤¿¾ì¹ç¤Ï-1¤òÊÖ
-    ¤¹¡£  */
-
+    ½èÍý¤¬À®¸ù¤¹¤ì¤Ð mchar_put_prop () ¤Ï0¤òÊÖ¤¹¡£¼ºÇÔ¤·¤¿¾ì¹ç¤Ï-1¤òÊÖ¤¹¡£  */
 /***
     @errors
     @c MERROR_SYMBOL, @c MERROR_DB
@@ -494,6 +499,8 @@ mchar_put_prop (int c, MSymbol key, void *val)
 {
   MCharPropRecord *record;
 
+  if (! char_prop_list)
+    MERROR (MERROR_CHAR, -1);
   record = mplist_get (char_prop_list, key);
   if (! record)
     return -1;
@@ -502,12 +509,60 @@ mchar_put_prop (int c, MSymbol key, void *val)
       record->table = (*mdatabase__loader) (record->mdb);
       if (! record->table)
        MERROR (MERROR_DB, -1);
-      M17N_OBJECT_REF (record->table);
       record->mdb = NULL;
     }
   return mchartable_set (record->table, c, val);
 }
 
+/*=*/
+
+/***en
+    @brief Get the char-table for a character property.
+
+    The mchar_get_prop_table () function returns a char-table that
+    contains the character property whose key is $KEY.  If $TYPE is
+    not NULL, this function stores the type of the property in the
+    place pointed by $TYPE.  See mchar_define_property () for types of
+    character property.
+
+    @return
+    If $KEY is a valid character property key, this function returns a
+    char-table.  Otherwise NULL is retuned.  */
+
+/***ja
+    @brief Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Îʸ»ú¥Æ¡¼¥Ö¥ë¤òÆÀ¤ë.
+
+    ´Ø¿ô mchar_get_prop_table () ¤Ï¡¢¥­¡¼¤¬ $KEY ¤Ç¤¢¤ëʸ»ú¥×¥í¥Ñ¥Æ¥£
+    ¤ò´Þ¤àʸ»ú¥Æ¡¼¥Ö¥ë¤òÊÖ¤¹¡£¤â¤· $TYPE ¤¬ NULL ¤Ç¤Ê¤±¤ì¤Ð¡¢ $TYPE ¤Ç
+    »Ø¤µ¤ì¤ë¾ì½ê¤Ë¤½¤Îʸ»ú¤Î¥×¥í¥Ñ¥Æ¥£¤ò³ÊǼ¤¹¤ë¡£Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¼ïÎà
+    ¤Ë´Ø¤·¤Æ¤Ï mchar_define_property () ¤ò¸«¤è¡£
+
+    @return
+    ¤â¤· $KEY ¤¬ÀµÅö¤Êʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤Ç¤¢¤ì¤Ð¡¢Ê¸»ú¥Æ¡¼¥Ö¥ë¤¬ÊÖ¤µ
+    ¤ì¤ë¡£¤½¤¦¤Ç¤Ê¤¤¾ì¹ç¤Ï NULL ¤¬ÊÖ¤µ¤ì¤ë¡£  */
+
+MCharTable *
+mchar_get_prop_table (MSymbol key, MSymbol *type)
+{
+  MCharPropRecord *record;
+
+  if (! char_prop_list)
+    return NULL;
+  record = mplist_get (char_prop_list, key);
+  if (! record)
+    return NULL;
+  if (record->mdb)
+    {
+      record->table = (*mdatabase__loader) (record->mdb);
+      if (! record->table)
+       MERROR (MERROR_DB, NULL);
+      record->mdb = NULL;
+    }
+  if (type)
+    *type = record->type;
+  return record->table;
+}
+
 /*** @} */
 
 /*