X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fcharacter.c;h=45ba1fd139d6a72c98809353d2203330988e3011;hb=d1f4e58c580e5422474bf1d8e1e5aa8ef0fe4035;hp=6f667e1a4b62cdfcb86dd95d71f25554ecbfa1c3;hpb=68ce3967e926ad341df6171f8abe6bdd954cf3c7;p=m17n%2Fm17n-lib.git diff --git a/src/character.c b/src/character.c index 6f667e1..45ba1fd 100644 --- a/src/character.c +++ b/src/character.c @@ -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 @@ -42,21 +42,21 @@ /***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 ÃÍ ¤«¤é¤Ê¤ë¡£¥­¡¼¤Ï¥·¥ó¥Ü¥ë¤Ç - ¤¢¤ê¡¢ÃÍ¤Ï (void *) ·¿¤Ë¥­¥ã¥¹¥È¤Ç¤­¤ë¤â¤Î¤Ê¤é²¿¤Ç¤â¤è¤¤¡£ - ¡Öʸ»ú C ¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¤¦¤Á¥­¡¼¤¬ @c K ¤Ç¤¢¤ë¤â¤Î¡×¤ò´Êñ¤Ë - ¡Öʸ»ú C ¤Î K ¥×¥í¥Ñ¥Æ¥£¡×¤È¸Æ¤Ö¤³¤È¤¬¤¢¤ë¡£ */ + ³Æʸ»ú¤Ï @e ʸ»ú¥×¥í¥Ñ¥Æ¥£ ¤È¸Æ¤Ö¥×¥í¥Ñ¥Æ¥£¤ò 0 ¸Ä°Ê¾å»ý¤Ä¤³¤È¤¬¤Ç¤­¤ë¡£ + ʸ»ú¥×¥í¥Ñ¥Æ¥£¤Ï @e ¥­¡¼ ¤È @e ÃÍ ¤«¤é¤Ê¤ë¡£ + ¥­¡¼¤Ï¥·¥ó¥Ü¥ë¤Ç¤¢¤ê¡¢ÃÍ¤Ï (void *) ·¿¤Ë¥­¥ã¥¹¥È¤Ç¤­¤ë¤â¤Î¤Ê¤é²¿¤Ç¤â¤è¤¤¡£ + ¡Öʸ»ú C ¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¤¦¤Á¥­¡¼¤¬ K ¤Ç¤¢¤ë¤â¤Î¡×¤ò´Êñ¤Ë¡Öʸ»ú C + ¤Î K ¥×¥í¥Ñ¥Æ¥£¡×¤È¸Æ¤Ö¤³¤È¤¬¤¢¤ë¡£ */ /*=*/ #if !defined (FOR_DOXYGEN) || defined (DOXYGEN_INTERNAL_MODULE) @@ -95,22 +95,17 @@ 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"); + Mcased = msymbol ("cased"); + Msoft_dotted = msymbol ("soft-dotted"); + Mcase_mapping = msymbol ("case-mapping"); + Mblock = msymbol ("block"); + Mscript = msymbol ("script"); return 0; } @@ -120,28 +115,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 */ /* External API */ -/*** @addtogroup m17nCharacter */ -/*** @{ */ +/*** @addtogroup m17nCharacter + @{ */ /*=*/ #ifdef FOR_DOXYGEN @@ -153,22 +188,23 @@ mchar__fini (void) /***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. */ /***ja - @name ÊÑ¿ô: ʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼ + @ingroup m17nCharacter + @name ÊÑ¿ô: ʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼ + + ¤³¤ì¤é¤Î¥·¥ó¥Ü¥ë¤Ïʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£*/ - ¤³¤ì¤é¤Î¥·¥ó¥Ü¥ë¤Ïʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£*/ /*=*/ /*** @{ */ @@ -185,9 +221,9 @@ mchar__fini (void) /***ja @brief ¥¹¥¯¥ê¥×¥È¤òɽ¤ï¤¹¥­¡¼. - ¥·¥ó¥Ü¥ë #Mscript ¤Ï "script" ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥× - ¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢¤³¤Îʸ»ú¤Î°¤¹ - ¤ë¥¹¥¯¥ê¥×¥È¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£ + ¥·¥ó¥Ü¥ë #Mscript ¤Ï "script" + ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£ + ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢¤³¤Îʸ»ú¤Î°¤¹¤ë¥¹¥¯¥ê¥×¥È¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£ ¥¹¥¯¥ê¥×¥È¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Î̾Á°¤Ï¡¢Unicode Technical Report #24 ¤Ë¥ê¥¹¥È¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤Î¤¤¤º¤ì¤«¤Ç¤¢¤ë¡£ */ @@ -206,9 +242,9 @@ MSymbol Mscript; /***ja @brief ̾Á°¤òɽ¤ï¤¹¥­¡¼. - ¥·¥ó¥Ü¥ë #Mname ¤Ï "name" ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ - ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃÍ¤Ï C-string ¤Ç¤¢¤ê¡¢¤½ - ¤Îʸ»ú¤Î̾Á°¤òɽ¤ï¤¹¡£ */ + ¥·¥ó¥Ü¥ë #Mname ¤Ï "name" + ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£ + ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϤ½¤Îʸ»ú¤Î̾Á°¤òɽ¤ï¤¹ C ¤Îʸ»úÎó¤Ç¤¢¤ë¡£ */ MSymbol Mname; @@ -229,12 +265,12 @@ MSymbol Mname; /***ja @brief °ìÈÌ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥­¡¼. - ¥·¥ó¥Ü¥ë #Mcategory ¤Ï "category" ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸ - »ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë - °ìÈÌ¥«¥Æ¥´¥ê ¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£ + ¥·¥ó¥Ü¥ë #Mcategory ¤Ï "category" + ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£ + ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë °ìÈÌ¥«¥Æ¥´¥ê ¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£ - °ìÈÌ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Î̾Á°¤Ï¡¢General Category¤Î - ¾Êά·Á¤È¤·¤Æ Unicode ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤Ç¤¢¤ë¡£ */ + °ìÈÌ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Î̾Á°¤Ï¡¢General Category + ¤Î¾Êά·Á¤È¤·¤Æ Unicode ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤Ç¤¢¤ë¡£ */ MSymbol Mcategory; @@ -254,12 +290,12 @@ MSymbol Mcategory; /***ja @brief ɸ½à·ë¹ç¥¯¥é¥¹¤òɽ¤ï¤¹¥­¡¼. - ¥·¥ó¥Ü¥ë #Mcombining_class ¤Ï "combining-class" ¤È¤¤¤¦ - ̾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃÍ - ¤Ï¡¢Âбþ¤¹¤ë @e ɸ½à·ë¹ç¥¯¥é¥¹ ¤òɽ¤ï¤¹ÈóÉéÀ°¿ô¤Ç¤¢¤ë¡£ + ¥·¥ó¥Ü¥ë #Mcombining_class ¤Ï "combining-class" + ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£ + ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë @e ɸ½à·ë¹ç¥¯¥é¥¹ ¤òɽ¤ï¤¹À°¿ô¤Ç¤¢¤ë¡£ - ɸ½à·ë¹ç¥¯¥é¥¹¤òɽ¤ï¤¹ÈóÉéÀ°¿ô¤Î°ÕÌ£¤Ï¡¢Unicode ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤â¤Î - ¤ÈƱ¤¸¤Ç¤¢¤ë¡£ */ + ɸ½à·ë¹ç¥¯¥é¥¹¤òɽ¤ï¤¹À°¿ô¤Î°ÕÌ£¤Ï¡¢Unicode + ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤ÈƱ¤¸¤Ç¤¢¤ë¡£ */ MSymbol Mcombining_class; /*=*/ @@ -279,9 +315,9 @@ MSymbol Mcombining_class; /***ja @brief ÁÐÊý¸þ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥­¡¼. - ¥·¥ó¥Ü¥ë #Mbidi_category ¤Ï "bidi-category" ¤È¤¤¤¦Ì¾Á° - ¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢ - Âбþ¤¹¤ë @e ÁÐÊý¸þ¥«¥Æ¥´¥ê ¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£ + ¥·¥ó¥Ü¥ë #Mbidi_category ¤Ï "bidi-category" + ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£ + ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë @e ÁÐÊý¸þ¥«¥Æ¥´¥ê ¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£ ÁÐÊý¸þ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Î̾Á°¤Ï¡¢Bidirectional Category ¤Î·¿¤È¤·¤Æ Unicode ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤Ç¤¢¤ë¡£ */ @@ -307,15 +343,17 @@ MSymbol Mbidi_category; @brief Âбþ¤¹¤ë¾®Ê¸»ú°ìʸ»ú¤òɽ¤ï¤¹¥­¡¼. ¥·¥ó¥Ü¥ë #Msimple_case_folding ¤Ï "simple-case-folding" - ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£ - ¤ÎÃͤϡ¢Âбþ¤¹¤ë¾®Ê¸»ú°ìʸ»ú¤Ç¤¢¤ê¡¢Âçʸ»ú¡¿¾®Ê¸»ú¤Î¶èÊ̤ò̵»ë¤·¤¿ - ʸ»úÎóÈæ³Ó¤ÎºÝ¤Ë»È¤ï¤ì¤ë¡£ + ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£ + ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë¾®Ê¸»ú°ìʸ»ú¤Ç¤¢¤ê¡¢Âçʸ»ú¡¿¾®Ê¸»ú¤Î¶èÊ̤ò̵»ë¤·¤¿Ê¸»úÎóÈæ³Ó¤ÎºÝ¤Ë»È¤ï¤ì¤ë¡£ - ¤â¤·¤½¤Î¤è¤¦¤ÊÈæ³Ó¤Ë»ÈÍѤ·ÆÀ¤ëñ°ì¤Î¾®Ê¸»ú¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¡¢¤³¤Î¥× - ¥í¥Ñ¥Æ¥£¤ÎÃÍ¤Ï 0xFFFF ¤Ë¤Ê¤ë¡£¤³¤Î¾ì¹ç¤½¤Îʸ»ú¤Ï¡¢ - #Mcomplicated_case_folding ¤È¤¤¤¦¥­¡¼¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£¤ò»ý¤Ä¡£ */ + Ê£»¨¤ÊÈæ³ÓÊýË¡¤òɬÍפȤ¹¤ëʸ»ú¤Ç¤¢¤Ã¤¿¾ì¹ç + ¡ÊÊ̤ΰìʸ»ú¤ÈÂбþÉÕ¤±¤ë¤³¤È¤Ë¤è¤Ã¤ÆÈæ³Ó¤Ç¤­¤Ê¤¤¾ì¹ç¡Ë¡¢¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃÍ¤Ï + @c 0xFFFF ¤Ë¤Ê¤ë¡£¤³¤Î¾ì¹ç¤½¤Îʸ»ú¤Ï¡¢#Mcomplicated_case_folding + ¤È¤¤¤¦¥­¡¼¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£¤ò»ý¤Ä¡£ */ MSymbol Msimple_case_folding; +/*=*/ + /***en @brief Key for corresponding multiple lowercase characters. @@ -329,14 +367,94 @@ MSymbol Msimple_case_folding; @brief Âбþ¤¹¤ë¾®Ê¸»ú¤ÎÎó¤òɽ¤ï¤¹¥­¡¼. ¥·¥ó¥Ü¥ë #Mcomplicated_case_folding ¤Ï - "complicated-case-folding" ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£ - ¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë¾®Ê¸»úÎ󤫤é¤Ê - ¤ë M-text ¤Ç¤¢¤ê¡¢Âçʸ»ú¡¿¾®Ê¸»ú¤Î¶èÊ̤ò̵»ë¤·¤¿Ê¸»úÎóÈæ³Ó¤ÎºÝ¤Ë»È + "complicated-case-folding" + ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£ + ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë¾®Ê¸»úÎ󤫤é¤Ê¤ë M-text ¤Ç¤¢¤ê¡¢Âçʸ»ú¡¿¾®Ê¸»ú¤Î¶èÊ̤ò̵»ë¤·¤¿Ê¸»úÎóÈæ³Ó¤ÎºÝ¤Ë»È ¤ï¤ì¤ë¡£ */ MSymbol Mcomplicated_case_folding; /*=*/ + +/***en + @brief Key for values used in case operation. + + The symbol #Mcased has the name "cased" 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 ¤Ï¡¢"cased" ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ + ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤÏÀ°¿ôÃÍ 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 "soft-dotted" 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 ¤Ï¡¢"soft-dotted" ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢ + ʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Ê¸»ú¤¬ + "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 "case-mapping" 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 ¤Ï¡¢"case-mapping" ¤È¤¤¤¦Ì¾Á°¤ò¤â + ¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢£³¤Ä + ¤Î 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 "block" 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 ¤Ï¡¢"block" ¤È¤¤¤¦Ì¾Á°¤ò¤â¤Á¡¢Ê¸»ú¥×¥í¥Ñ + ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢¤½¤Îʸ»ú¤Î¥¹¥¯¥ê¥× + ¥È¥Ö¥í¥Ã¥¯Ì¾¤òɽ¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£*/ +MSymbol Mblock; + /*** @} */ /*=*/ @@ -356,8 +474,8 @@ MSymbol Mcomplicated_case_folding; @brief ʸ»ú¥×¥í¥Ñ¥Æ¥£¤òÄêµÁ¤¹¤ë. ´Ø¿ô mchar_define_property () ¤Ï¡¢ \<#Mchar_table, $TYPE, $SYM \> - ¤È¤¤¤¦¥¿¥°¤ò»ý¤Ã¤¿¥Ç¡¼¥¿¥Ù¡¼¥¹¤ò m17n ¸À¸ì¾ðÊó¥Ù¡¼¥¹¤«¤éõ¤¹¡£ ¤³ - ¤³¤Ç $SYM ¤Ï $NAME ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£$TYPE ¤Ï#Mstring, + ¤È¤¤¤¦¥¿¥°¤ò»ý¤Ã¤¿¥Ç¡¼¥¿¥Ù¡¼¥¹¤ò m17n ¸À¸ì¾ðÊó¥Ù¡¼¥¹¤«¤éõ¤¹¡£ + ¤³¤³¤Ç $SYM ¤Ï $NAME ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£$TYPE ¤Ï#Mstring, #Mtext, #Msymbol, #Minteger, #Mplist ¤Î¤¤¤º¤ì¤«¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£ @return @@ -372,39 +490,15 @@ 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); - } - - record->type = type; - if (mdatabase__finder - && (record->mdb = (*mdatabase__finder) (Mchar_table, type, key, Mnil))) - { - record->table = NULL; - } - else - { - void *default_value = NULL; - - record->mdb = NULL; - if (type == Minteger) - default_value = (void *) -1; - record->table = mchartable (type, default_value); - } + void *mdb; + mdb = mdatabase_find (Mchar_table, type, key, Mnil); + if (! mdb) + return Mnil; + mchar__define_prop (key, type, mdb); return key; } @@ -421,19 +515,18 @@ mchar_define_property (char *name, MSymbol type) value of the character property. Otherwise it returns @c NULL. */ -/**ja +/***ja @brief ʸ»ú¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÆÀ¤ë. ´Ø¿ô mchar_get_prop () ¤Ï¡¢Ê¸»ú $C ¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¤¦¤Á¥­¡¼¤¬ $KEY ¤Ç¤¢¤ë¤â¤Î¤òõ¤¹¡£ @return - ½èÍý¤¬À®¸ù¤¹¤ì¤Ð mchar_get_prop () ¤Ï¸«¤Ä¤«¤Ã¤¿¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÊÖ - ¤¹¡£¼ºÇÔ¤·¤¿¾ì¹ç¤Ï @c NULL ¤òÊÖ¤¹¡£ + ½èÍý¤¬À®¸ù¤¹¤ì¤Ð mchar_get_prop () ¤Ï¸«¤Ä¤«¤Ã¤¿¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÊÖ¤¹¡£ + ¼ºÇÔ¤·¤¿¾ì¹ç¤Ï @c NULL ¤òÊÖ¤¹¡£ @latexonly \IPAlabel{mchar_get_prop} @endlatexonly */ - /*** @errors @c MERROR_SYMBOL, @c MERROR_DB @@ -446,12 +539,14 @@ 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; 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; @@ -471,17 +566,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 ʸ»ú¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÀßÄꤹ¤ë. - ´Ø¿ô 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,20 +586,70 @@ 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; if (record->mdb) { - record->table = (*mdatabase__loader) (record->mdb); + record->table = mdatabase_load (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_load (record->mdb); + if (! record->table) + MERROR (MERROR_DB, NULL); + record->mdb = NULL; + } + if (type) + *type = record->type; + return record->table; +} + /*** @} */ /*