Add Japanese documentation for mchar_get_prop_table ().
[m17n/m17n-lib.git] / src / character.c
1 /* character.c -- character module.
2    Copyright (C) 2003, 2004
3      National Institute of Advanced Industrial Science and Technology (AIST)
4      Registration Number H15PRO112
5
6    This file is part of the m17n library.
7
8    The m17n library is free software; you can redistribute it and/or
9    modify it under the terms of the GNU Lesser General Public License
10    as published by the Free Software Foundation; either version 2.1 of
11    the License, or (at your option) any later version.
12
13    The m17n library is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    Lesser General Public License for more details.
17
18    You should have received a copy of the GNU Lesser General Public
19    License along with the m17n library; if not, write to the Free
20    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21    02111-1307, USA.  */
22
23 /***en
24     @addtogroup m17nCharacter
25     @brief Character objects and API for them.
26
27     The m17n library represents a @e character by a character code (an
28     integer).  The minimum character code is @c 0.  The maximum
29     character code is defined by the macro #MCHAR_MAX.  It is
30     assured that #MCHAR_MAX is not smaller than @c 0x3FFFFF (22
31     bits).
32
33     Characters @c 0 to @c 0x10FFFF are equivalent to the Unicode
34     characters of the same code values.
35
36     A character can have zero or more properties called @e character
37     @e properties.  A character property consists of a @e key and a
38     @e value, where key is a symbol and value is anything that can be
39     cast to <tt>(void *)</tt>.  "The character property that belongs
40     to character C and whose key is K" may be shortened to "the K
41     property of C".  */
42
43 /***ja
44     @addtogroup m17nCharacter
45     @brief Ê¸»ú¥ª¥Ö¥¸¥§¥¯¥È¤È¤½¤ì¤Ë´Ø¤¹¤ë API.
46
47     m17n ¥é¥¤¥Ö¥é¥ê¤Ï @e Ê¸»ú ¤òʸ»ú¥³¡¼¥É¡ÊÀ°¿ô¡Ë¤Çɽ¸½¤¹¤ë¡£
48     ºÇ¾®¤Îʸ»ú¥³¡¼¥É¤Ï @c 0 ¤Ç¤¢¤ê¡¢ºÇÂç¤Îʸ»ú¥³¡¼¥É¤Ï¥Þ¥¯¥í #MCHAR_MAX 
49     ¤Ë¤è¤Ã¤ÆÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£#MCHAR_MAX ¤Ï @c 0x3FFFFF¡Ê22¥Ó¥Ã¥È¡Ë
50     °Ê¾å¤Ç¤¢¤ë¤³¤È¤¬Êݾڤµ¤ì¤Æ¤¤¤ë¡£
51
52     @c 0 ¤«¤é @c 0x10FFFF ¤Þ¤Ç¤Îʸ»ú¤Ï¡¢¤½¤ì¤ÈƱ¤¸Ãͤò»ý¤Ä Unicode 
53     ¤Îʸ»ú¤Ë³ä¤êÅö¤Æ¤é¤ì¤Æ¤¤¤ë¡£
54
55     ³Æʸ»ú¤Ï @e Ê¸»ú¥×¥í¥Ñ¥Æ¥£ ¤È¸Æ¤Ö¥×¥í¥Ñ¥Æ¥£¤ò 0 ¸Ä°Ê¾å»ý¤Ä¤³¤È¤¬¤Ç¤­¤ë¡£
56     Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Ï @e ¥­¡¼ ¤È @e ÃÍ ¤«¤é¤Ê¤ë¡£
57     ¥­¡¼¤Ï¥·¥ó¥Ü¥ë¤Ç¤¢¤ê¡¢ÃͤϠ<tt>(void *)</tt> ·¿¤Ë¥­¥ã¥¹¥È¤Ç¤­¤ë¤â¤Î¤Ê¤é²¿¤Ç¤â¤è¤¤¡£ 
58     ¡Öʸ»ú C ¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¤¦¤Á¥­¡¼¤¬ K ¤Ç¤¢¤ë¤â¤Î¡×¤ò´Êñ¤Ë¡Öʸ»ú C 
59     ¤Î K ¥×¥í¥Ñ¥Æ¥£¡×¤È¸Æ¤Ö¤³¤È¤¬¤¢¤ë¡£  */
60 /*=*/
61
62 #if !defined (FOR_DOXYGEN) || defined (DOXYGEN_INTERNAL_MODULE)
63 /*** @addtogroup m17nInternal
64      @{ */
65
66 #include <config.h>
67 #include <stdlib.h>
68 #include <string.h>
69 #include <limits.h>
70 #include <ctype.h>
71 #include <stdio.h>
72
73 #include "m17n-core.h"
74 #include "m17n-misc.h"
75 #include "internal.h"
76
77 typedef struct
78 {
79   MSymbol type;
80   void *mdb;
81   MCharTable *table;
82 } MCharPropRecord;
83
84 static MPlist *char_prop_list;
85
86 static void
87 free_string (int from, int to, void *str, void *arg)
88 {
89   free (str);
90 }
91
92 \f
93 /* Internal API */
94
95 int
96 mchar__init ()
97 {
98   char_prop_list = mplist ();
99
100   Mname
101     = mchar_define_property ("name", Mstring);
102   Mcategory
103     = mchar_define_property ("category", Msymbol);
104   Mcombining_class
105     = mchar_define_property ("combining-class", Minteger);
106   Mbidi_category
107     = mchar_define_property ("bidirectional-category", Msymbol);
108   Msimple_case_folding
109     = mchar_define_property ("simple-case-folding", Minteger);
110   Mcomplicated_case_folding
111     = mchar_define_property ("complicated-case-folding", Mtext);
112   Mscript
113     = mchar_define_property ("script", Msymbol);
114
115   return 0;
116 }
117
118 void
119 mchar__fini (void)
120 {
121   MPlist *p;
122
123   for (p = char_prop_list; mplist_key (p) != Mnil; p = mplist_next (p))
124     {
125       MCharPropRecord *record = mplist_value (p);
126
127       if (record->table)
128         {
129           if (record->type == Mstring)
130             mchartable_map (record->table, NULL, free_string, NULL);
131           M17N_OBJECT_UNREF (record->table);
132         }
133       free (record);
134     }
135   M17N_OBJECT_UNREF (char_prop_list);
136 }
137
138 /*** @} */
139 #endif /* !FOR_DOXYGEN || DOXYGEN_INTERNAL_MODULE */
140 \f
141 /* External API */
142
143 /*** @addtogroup m17nCharacter
144      @{ */
145 /*=*/
146
147 #ifdef FOR_DOXYGEN
148 /***en
149     @brief Maximum character code.
150
151     The macro #MCHAR_MAX gives the maximum character code.  */
152
153 /***ja
154     @brief Ê¸»ú¥³¡¼¥É¤ÎºÇÂçÃÍ.
155
156     ¥Þ¥¯¥í #MCHAR_MAX ¤Ïʸ»ú¥³¡¼¥É¤ÎºÇÂçÃͤòɽ¤¹¡£  */
157
158 #define MCHAR_MAX
159 /*=*/
160 #endif /* FOR_DOXYGEN */
161
162 /***en
163     @name Variables: Keys of character properties
164
165     These symbols are used as keys of character properties.  */
166
167 /***ja
168     @ingroup m17nCharacter
169     @name ÊÑ¿ô: Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼
170
171     ¤³¤ì¤é¤Î¥·¥ó¥Ü¥ë¤Ïʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£*/
172 /*** @{ */
173
174 /***en
175     @brief Key for script.
176
177     The symbol #Mscript has the name <tt>"script"</tt> and is used as the key
178     of a character property.  The value of such a property is a symbol
179     representing the script to which the character belongs.
180
181     Each symbol that represents a script has one of the names listed in
182     the <em>Unicode Technical Report #24</em>.  */
183
184 /***ja
185     @brief ¥¹¥¯¥ê¥×¥È¤òɽ¤ï¤¹¥­¡¼.
186
187     ¥·¥ó¥Ü¥ë #Mscript ¤Ï <tt>"script"</tt> 
188     ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£
189     ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢¤³¤Îʸ»ú¤Î°¤¹¤ë¥¹¥¯¥ê¥×¥È¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£
190
191     ¥¹¥¯¥ê¥×¥È¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Î̾Á°¤Ï¡¢<em>Unicode Technical Report
192     #24</em> ¤Ë¥ê¥¹¥È¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤Î¤¤¤º¤ì¤«¤Ç¤¢¤ë¡£  */
193
194 MSymbol Mscript;
195
196 /*=*/
197
198 /***en
199     @brief Key for character name.
200
201     The symbol #Mname has the name <tt>"name"</tt> and is used as
202     the key of a character property.  The value of such a property is a
203     C-string representing the name of the character.  */
204
205 /***ja
206     @brief Ì¾Á°¤òɽ¤ï¤¹¥­¡¼.
207
208     ¥·¥ó¥Ü¥ë #Mname ¤Ï <tt>"name"</tt> 
209     ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£
210     ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϤ½¤Îʸ»ú¤Î̾Á°¤òɽ¤ï¤¹ C ¤Îʸ»úÎó¤Ç¤¢¤ë¡£  */
211
212 MSymbol Mname;
213
214 /*=*/
215
216 /***en
217     @brief Key for general category.
218
219     The symbol #Mcategory has the name <tt>"category"</tt> and is
220     used as the key of a character property.  The value of such a
221     property is a symbol representing the <em>general category</em> of
222     the character.
223
224     Each symbol that represents a general category has one of the
225     names listed as abbreviations for <em>General Category</em> in
226     Unicode.  */
227
228 /***ja
229     @brief °ìÈÌ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥­¡¼.
230
231     ¥·¥ó¥Ü¥ë #Mcategory ¤Ï <tt>"category"</tt> 
232     ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£
233     ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë <em>°ìÈÌ¥«¥Æ¥´¥ê</em> ¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£
234
235     °ìÈÌ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Î̾Á°¤Ï¡¢<em>General Category</em> 
236     ¤Î¾Êά·Á¤È¤·¤Æ Unicode ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤Ç¤¢¤ë¡£  */
237
238 MSymbol Mcategory;
239
240 /*=*/
241
242 /***en
243     @brief Key for canonical combining class.
244
245     The symbol #Mcombining_class has the name
246     <tt>"combining-class"</tt> and is used as the key of a character
247     property.  The value of such a property is an integer that
248     represents the <em>canonical combining class</em> of the character.
249
250     The meaning of each integer that represents a canonical combining
251     class is identical to the one defined in Unicode.  */
252
253 /***ja
254     @brief É¸½à·ë¹ç¥¯¥é¥¹¤òɽ¤ï¤¹¥­¡¼.
255
256     ¥·¥ó¥Ü¥ë #Mcombining_class ¤Ï <tt>"combining-class"</tt> 
257     ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£
258     ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë @e É¸½à·ë¹ç¥¯¥é¥¹ ¤òɽ¤ï¤¹À°¿ô¤Ç¤¢¤ë¡£
259
260     É¸½à·ë¹ç¥¯¥é¥¹¤òɽ¤ï¤¹À°¿ô¤Î°ÕÌ£¤Ï¡¢Unicode 
261     ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤ÈƱ¤¸¤Ç¤¢¤ë¡£  */
262
263 MSymbol Mcombining_class;
264 /*=*/
265
266 /***en
267     @brief Key for bidi category.
268
269     The symbol #Mbidi_category has the name <tt>"bidi-category"</tt>
270     and is used as the key of a character property.  The value of such
271     a property is a symbol that represents the <em>bidirectional
272     category</em> of the character.
273
274     Each symbol that represents a bidirectional category has one of
275     the names listed as types of <em>Bidirectional Category</em> in
276     Unicode.  */
277
278 /***ja
279     @brief ÁÐÊý¸þ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥­¡¼.
280
281     ¥·¥ó¥Ü¥ë #Mbidi_category ¤Ï <tt>"bidi-category"</tt> 
282     ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£
283     ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë @e ÁÐÊý¸þ¥«¥Æ¥´¥ê ¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£
284
285     ÁÐÊý¸þ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Î̾Á°¤Ï¡¢<em>Bidirectional
286     Category</em> ¤Î·¿¤È¤·¤Æ Unicode ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤Ç¤¢¤ë¡£  */
287
288 MSymbol Mbidi_category;
289 /*=*/
290
291 /***en
292     @brief Key for corresponding single lowercase character.
293
294     The symbol #Msimple_case_folding has the name
295     <tt>"simple-case-folding"</tt> and is used as the key of a
296     character property.  The value of such a property is the
297     corresponding single lowercase character that is used when
298     comparing M-texts ignoring cases.
299
300     If a character requires a complicated comparison (i.e. cannot be
301     compared by simply mapping to another single character), the value
302     of such a property is @c 0xFFFF.  In this case, the character has
303     another property whose key is #Mcomplicated_case_folding.  */
304
305 /***ja
306     @brief Âбþ¤¹¤ë¾®Ê¸»ú°ìʸ»ú¤òɽ¤ï¤¹¥­¡¼.
307
308     ¥·¥ó¥Ü¥ë #Msimple_case_folding ¤Ï <tt>"simple-case-folding"</tt> 
309     ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£
310     ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë¾®Ê¸»ú°ìʸ»ú¤Ç¤¢¤ê¡¢Âçʸ»ú¡¿¾®Ê¸»ú¤Î¶èÊ̤ò̵»ë¤·¤¿Ê¸»úÎóÈæ³Ó¤ÎºÝ¤Ë»È¤ï¤ì¤ë¡£
311
312     Ê£»¨¤ÊÈæ³ÓÊýË¡¤òɬÍפȤ¹¤ëʸ»ú¤Ç¤¢¤Ã¤¿¾ì¹ç
313     ¡ÊÊ̤ΰìʸ»ú¤ÈÂбþÉÕ¤±¤ë¤³¤È¤Ë¤è¤Ã¤ÆÈæ³Ó¤Ç¤­¤Ê¤¤¾ì¹ç¡Ë¡¢¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϠ
314     @c 0xFFFF ¤Ë¤Ê¤ë¡£¤³¤Î¾ì¹ç¤½¤Îʸ»ú¤Ï¡¢#Mcomplicated_case_folding
315     ¤È¤¤¤¦¥­¡¼¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£¤ò»ý¤Ä¡£  */
316
317 MSymbol Msimple_case_folding;
318 /***en
319     @brief Key for corresponding multiple lowercase characters.
320
321     The symbol #Mcomplicated_case_folding has the name
322     <tt>"complicated-case-folding"</tt> and is used as the key of a
323     character property.  The value of such a property is the
324     corresponding M-text that contains a sequence of lowercase
325     characters to be used for comparing M-texts ignoring case.  */
326
327 /***ja
328     @brief Âбþ¤¹¤ë¾®Ê¸»ú¤ÎÎó¤òɽ¤ï¤¹¥­¡¼.
329
330     ¥·¥ó¥Ü¥ë #Mcomplicated_case_folding ¤Ï 
331     <tt>"complicated-case-folding"</tt> 
332     ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£
333     ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë¾®Ê¸»úÎ󤫤é¤Ê¤ë M-text ¤Ç¤¢¤ê¡¢Âçʸ»ú¡¿¾®Ê¸»ú¤Î¶èÊ̤ò̵»ë¤·¤¿Ê¸»úÎóÈæ³Ó¤ÎºÝ¤Ë»È
334     ¤ï¤ì¤ë¡£
335       */
336
337 MSymbol Mcomplicated_case_folding;
338 /*=*/
339 /*** @} */
340 /*=*/
341
342 /***en
343     @brief Define a character property.
344
345     The mchar_define_property () function searches the m17n database
346     for a data whose tags are \<#Mchar_table, $TYPE, $SYM \>.
347     Here, $SYM is a symbol whose name is $NAME.  $TYPE must be
348     #Mstring, #Mtext, #Msymbol, #Minteger, or #Mplist.
349
350     @return
351     If the operation was successful, mchar_define_property () returns
352     $SYM.  Otherwise it returns #Mnil.  */
353
354 /***ja
355     @brief Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤òÄêµÁ¤¹¤ë.
356
357     ´Ø¿ô mchar_define_property () ¤Ï¡¢ \<#Mchar_table, $TYPE, $SYM \>
358     ¤È¤¤¤¦¥¿¥°¤ò»ý¤Ã¤¿¥Ç¡¼¥¿¥Ù¡¼¥¹¤ò m17n ¸À¸ì¾ðÊó¥Ù¡¼¥¹¤«¤éõ¤¹¡£  
359     ¤³¤³¤Ç $SYM ¤Ï $NAME ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£$TYPE ¤Ï#Mstring,
360     #Mtext, #Msymbol, #Minteger, #Mplist ¤Î¤¤¤º¤ì¤«¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
361
362     @return
363     ½èÍý¤ËÀ®¸ù¤¹¤ì¤Ð mchar_define_property () ¤Ï$SYM ¤òÊÖ¤¹¡£
364     ¼ºÇÔ¤·¤¿¾ì¹ç¤Ï #Mnil ¤òÊÖ¤¹¡£  */
365
366 /***
367     @errors
368     @c MERROR_DB
369
370     @seealso
371     mchar_get_prop (), mchar_put_prop ()  */
372
373 MSymbol
374 mchar_define_property (const char *name, MSymbol type)
375 {
376   MSymbol key = msymbol (name);
377   MCharPropRecord *record;
378
379   record = mplist_get (char_prop_list, key);
380   if (record)
381     {
382       if (record->table)
383         M17N_OBJECT_UNREF (record->table);
384     }
385   else
386     {
387       MSTRUCT_CALLOC (record, MERROR_CHAR);
388       mplist_put (char_prop_list, key, record);
389     }
390
391   record->type = type;
392   if (mdatabase__finder
393       && (record->mdb = (*mdatabase__finder) (Mchar_table, type, key, Mnil)))
394     {
395       record->table = NULL;
396     }
397   else
398     {
399       void *default_value = NULL;
400
401       record->mdb = NULL;
402       if (type == Minteger)
403         default_value = (void *) -1;
404       record->table = mchartable (type, default_value);
405     }
406
407   return key;
408 }
409
410 /*=*/
411
412 /***en
413     @brief Get the value of a character property.
414
415     The mchar_get_prop () function searches character $C for the
416     character property whose key is $KEY.
417
418     @return
419     If the operation was successful, mchar_get_prop () returns the
420     value of the character property.  Otherwise it returns @c
421     NULL.  */
422
423 /***ja
424     @brief Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÆÀ¤ë.
425
426     ´Ø¿ô mchar_get_prop () ¤Ï¡¢Ê¸»ú $C ¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¤¦¤Á¥­¡¼¤¬ 
427     $KEY ¤Ç¤¢¤ë¤â¤Î¤òõ¤¹¡£
428
429     @return
430     ½èÍý¤¬À®¸ù¤¹¤ì¤Ð mchar_get_prop () ¤Ï¸«¤Ä¤«¤Ã¤¿¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÊÖ¤¹¡£
431     ¼ºÇÔ¤·¤¿¾ì¹ç¤Ï @c NULL ¤òÊÖ¤¹¡£
432
433     @latexonly \IPAlabel{mchar_get_prop} @endlatexonly
434 */
435 /***
436     @errors
437     @c MERROR_SYMBOL, @c MERROR_DB
438
439     @seealso
440     mchar_define_property (), mchar_put_prop ()  */
441
442 void *
443 mchar_get_prop (int c, MSymbol key)
444 {
445   MCharPropRecord *record;
446
447   record = mplist_get (char_prop_list, key);
448   if (! record)
449     return NULL;
450   if (record->mdb)
451     {
452       record->table = (*mdatabase__loader) (record->mdb);
453       if (! record->table)
454         MERROR (MERROR_DB, NULL);
455       record->mdb = NULL;
456     }
457   return mchartable_lookup (record->table, c);
458 }
459
460 /*=*/
461
462 /***en
463     @brief Set the value of a character property.
464
465     The mchar_put_prop () function searches character $C for the
466     character property whose key is $KEY and assigns $VAL to the value
467     of the found property.
468
469     @return
470     If the operation was successful, mchar_put_prop () returns 0.
471     Otherwise, it returns -1.  */
472 /***ja
473     @brief Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÀßÄꤹ¤ë.
474
475     ´Ø¿ô mchar_put_prop () ¤Ï¡¢Ê¸»ú $C ¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¤¦¤Á¥­¡¼¤¬ $KEY 
476     ¤Ç¤¢¤ë¤â¤Î¤òõ¤·¡¢¤½¤ÎÃͤȤ·¤Æ $VAL ¤òÀßÄꤹ¤ë¡£
477
478     @return
479     ½èÍý¤¬À®¸ù¤¹¤ì¤Ð mchar_put_prop () ¤Ï0¤òÊÖ¤¹¡£¼ºÇÔ¤·¤¿¾ì¹ç¤Ï-1¤òÊÖ¤¹¡£  */
480 /***
481     @errors
482     @c MERROR_SYMBOL, @c MERROR_DB
483
484     @seealso
485     mchar_define_property (), mchar_get_prop ()   */
486
487 int
488 mchar_put_prop (int c, MSymbol key, void *val)
489 {
490   MCharPropRecord *record;
491
492   record = mplist_get (char_prop_list, key);
493   if (! record)
494     return -1;
495   if (record->mdb)
496     {
497       record->table = (*mdatabase__loader) (record->mdb);
498       if (! record->table)
499         MERROR (MERROR_DB, -1);
500       record->mdb = NULL;
501     }
502   return mchartable_set (record->table, c, val);
503 }
504
505 /*=*/
506
507 /***en
508     @brief Get the char-table for a character property.
509
510     The mchar_get_prop_table () function returns a char-table that
511     contains the character property whose key is $KEY.  If $TYPE is
512     not NULL, this function stores the type of the property in the
513     place pointed by $TYPE.  See mchar_define_property () for types of
514     character property.
515
516     @return
517     If $KEY is a valid character property key, this function returns a
518     char-table.  Otherwise NULL is retuned.  */
519
520 /***ja
521     @brief Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Îʸ»ú¥Æ¡¼¥Ö¥ë¤òÆÀ¤ë.
522
523     ´Ø¿ô mchar_get_prop_table () ¤Ï¡¢¥­¡¼¤¬ $KEY ¤Ç¤¢¤ëʸ»ú¥×¥í¥Ñ¥Æ¥£
524     ¤ò´Þ¤àʸ»ú¥Æ¡¼¥Ö¥ë¤òÊÖ¤¹¡£¤â¤· $TYPE ¤¬ NULL ¤Ç¤Ê¤±¤ì¤Ð¡¢ $TYPE ¤Ç
525     »Ø¤µ¤ì¤ë¾ì½ê¤Ë¤½¤Îʸ»ú¤Î¥×¥í¥Ñ¥Æ¥£¤ò³ÊǼ¤¹¤ë¡£Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¼ïÎà
526     ¤Ë´Ø¤·¤Æ¤Ï mchar_define_property () ¤ò¸«¤è¡£
527
528     @return
529     ¤â¤· $KEY ¤¬ÀµÅö¤Êʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤Ç¤¢¤ì¤Ð¡¢Ê¸»ú¥Æ¡¼¥Ö¥ë¤¬ÊÖ¤µ
530     ¤ì¤ë¡£¤½¤¦¤Ç¤Ê¤¤¾ì¹ç¤Ï NULL ¤¬ÊÖ¤µ¤ì¤ë¡£  */
531
532 MCharTable *
533 mchar_get_prop_table (MSymbol key, MSymbol *type)
534 {
535   MCharPropRecord *record;
536
537   record = mplist_get (char_prop_list, key);
538   if (! record)
539     return NULL;
540   if (record->mdb)
541     {
542       record->table = (*mdatabase__loader) (record->mdb);
543       if (! record->table)
544         MERROR (MERROR_DB, NULL);
545       record->mdb = NULL;
546     }
547   if (type)
548     *type = record->type;
549   return record->table;
550 }
551
552 /*** @} */
553
554 /*
555   Local Variables:
556   coding: euc-japan
557   End:
558 */