(struct MInputContext): Fix typo in comment.
[m17n/m17n-lib.git] / src / character.c
index a9b3569..45ba1fd 100644 (file)
@@ -1,5 +1,5 @@
 /* character.c -- character module.
-   Copyright (C) 2003, 2004
+   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H15PRO112
 
@@ -17,7 +17,7 @@
 
    You should have received a copy of the GNU Lesser General Public
    License along with the m17n library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    02111-1307, USA.  */
 
 /***en
@@ -101,6 +101,10 @@ mchar__init ()
   Mbidi_category = msymbol ("bidirectional-category");
   Msimple_case_folding = msymbol ("simple-case-folding");
   Mcomplicated_case_folding = msymbol ("complicated-case-folding");
+  Mcased = msymbol ("cased");
+  Msoft_dotted = msymbol ("soft-dotted");
+  Mcase_mapping = msymbol ("case-mapping");
+  Mblock = msymbol ("block");
   Mscript = msymbol ("script");
 
   return 0;
@@ -200,6 +204,8 @@ mchar__define_prop (MSymbol key, MSymbol type, void *mdb)
     @name ÊÑ¿ô: Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼
 
     ¤³¤ì¤é¤Î¥·¥ó¥Ü¥ë¤Ïʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£*/
+
+/*=*/
 /*** @{ */
 
 /***en
@@ -346,6 +352,8 @@ MSymbol Mbidi_category;
     ¤È¤¤¤¦¥­¡¼¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£¤ò»ý¤Ä¡£  */
 
 MSymbol Msimple_case_folding;
+/*=*/
+
 /***en
     @brief Key for corresponding multiple lowercase characters.
 
@@ -367,6 +375,86 @@ MSymbol Msimple_case_folding;
 
 MSymbol Mcomplicated_case_folding;
 /*=*/
+
+/***en
+    @brief Key for values used in case operation.
+
+    The symbol #Mcased has the name <tt>"cased"</tt> and is used as
+    the key of charater property.  The value of such a property is an
+    integer value 1, 2, or 3 representing "cased", "case-ignorable",
+    and both of them respective.  See the Unicode Standard 5.0
+    (Section 3.13 Default Case Algorithm) for the detail.
+ */
+
+/***ja
+    @brief Case ½èÍý¤ËÍѤ¤¤é¤ì¤ëÃͤΥ­¡¼.
+
+    ¥·¥ó¥Ü¥ë #Mcased ¤Ï¡¢<tt>"cased"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ
+    ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤÏÀ°¿ôÃÍ 1, 2, 3 ¤Î¤¤¤º
+    ¤ì¤«¤Ç¤¢¤ê¡¢¤½¤ì¤¾¤ì "cased", "case-ignorable", ¤½¤ÎξÊý¤ò°ÕÌ£¤¹¤ë¡£
+    ¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¡¢the Unicode Standard 5.0 (Section 3.13 Default
+    Case Algorithm) »²¾È¡£
+ */
+MSymbol Mcased;
+
+/*=*/
+/***en
+    @brief Key for values used in case operation.
+
+    The symbol #Msoft_dotted has the name <tt>"soft-dotted"</tt> and
+    is used as the key of charater property.  The value of such a
+    property is #Mt if a character has "Soft_Dotted" property, and
+    #Mnil otherwise.  See the Unicode Standard 5.0 (Section 3.13
+    Default Case Algorithm) for the detail.  */
+
+/***ja
+    @brief Case ½èÍý¤ËÍѤ¤¤é¤ì¤ëÃͤΥ­¡¼.
+
+    ¥·¥ó¥Ü¥ë #Msoft_dotted ¤Ï¡¢<tt>"soft-dotted"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢
+    Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Ê¸»ú¤¬
+    "Soft_Dotted"¥×¥í¥Ñ¥Æ¥£¤ò»ý¤Ä¾ì¹ç¤Ë¤Ï #Mt, ¤½¤¦¤Ç¤Ê¤±¤ì¤Ð #Mnil ¤Ç
+    ¤¢¤ë¡£ ¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¡¢the Unicode Standard 5.0 (Section 3.13
+    Default Case Algorithm) »²¾È¡£
+ */
+MSymbol Msoft_dotted;
+
+/*=*/
+/***en 
+    @brief Key for values used in case operation.
+
+    The symbol #Mcase_mapping has the name <tt>"case-mapping"</tt> and
+    is used as the key of charater property.  The value of such a
+    property is a plist of three M-Texts; lower, title, and upper of
+    the corresponding character.  See the Unicode Standard 5.0
+    (Section 5.18 Case Mappings) for the detail.  */
+
+/***ja
+    @brief Case ½èÍý¤ËÍѤ¤¤é¤ì¤ëÃͤΥ­¡¼.
+
+    ¥·¥ó¥Ü¥ë #Mcase_mapping ¤Ï¡¢<tt>"case-mapping"</tt> ¤È¤¤¤¦Ì¾Á°¤ò¤â
+    ¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢£³¤Ä
+    ¤Î M-text¡¢¤¹¤Ê¤ï¤Á¤½¤Îʸ»ú¤Î lower, title, ¤È upper¤«¤é¤Ê¤ë plist
+    ¤Ç¤¢¤ë¡£ ¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¡¢the Unicode Standard 5.0 (Section 3.13
+    Default Case Algorithm) »²¾È¡£
+*/
+MSymbol Mcase_mapping;
+
+/*=*/
+/***en 
+    @brief Key for script block name.
+
+    The symbol #Mblock the name <tt>"block"</tt> and is used as the
+    key of charater property.  The value of such a property is a
+    symbol representing a script block of the corresponding
+    character.  */
+/***ja
+    @brief ¥¹¥¯¥ê¥×¥È¥Ö¥í¥Ã¥¯Ì¾¤òɽ¤¹¥­¡¼.
+
+    ¥·¥ó¥Ü¥ë #Mblock ¤Ï¡¢<tt>"block"</tt> ¤È¤¤¤¦Ì¾Á°¤ò¤â¤Á¡¢Ê¸»ú¥×¥í¥Ñ
+    ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢¤½¤Îʸ»ú¤Î¥¹¥¯¥ê¥×
+    ¥È¥Ö¥í¥Ã¥¯Ì¾¤òɽ¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£*/
+MSymbol Mblock;
+
 /*** @} */
 /*=*/
 
@@ -407,10 +495,9 @@ mchar_define_property (const char *name, MSymbol type)
   MSymbol key = msymbol (name);
   void *mdb;
 
-  if (mdatabase__finder)
-    mdb = (*mdatabase__finder) (Mchar_table, type, key, Mnil);
-  else
-    mdb = NULL;
+  mdb = mdatabase_find (Mchar_table, type, key, Mnil);
+  if (! mdb)
+    return Mnil;
   mchar__define_prop (key, type, mdb);
   return key;
 }
@@ -459,7 +546,7 @@ mchar_get_prop (int c, MSymbol key)
     return NULL;
   if (record->mdb)
     {
-      record->table = (*mdatabase__loader) (record->mdb);
+      record->table = mdatabase_load (record->mdb);
       if (! record->table)
        MERROR (MERROR_DB, NULL);
       record->mdb = NULL;
@@ -506,7 +593,7 @@ mchar_put_prop (int c, MSymbol key, void *val)
     return -1;
   if (record->mdb)
     {
-      record->table = (*mdatabase__loader) (record->mdb);
+      record->table = mdatabase_load (record->mdb);
       if (! record->table)
        MERROR (MERROR_DB, -1);
       record->mdb = NULL;
@@ -553,7 +640,7 @@ mchar_get_prop_table (MSymbol key, MSymbol *type)
     return NULL;
   if (record->mdb)
     {
-      record->table = (*mdatabase__loader) (record->mdb);
+      record->table = mdatabase_load (record->mdb);
       if (! record->table)
        MERROR (MERROR_DB, NULL);
       record->mdb = NULL;