(mchar_define_property): Add const to an arg.
[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 ¤Ç¤¢¤ë¤â¤Î¡×¤ò´Êñ¤Ë
59     ¡Öʸ»ú C ¤Î 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     @ingroup m17nCharacter
164     @name Variables: Keys of character properties
165
166     These symbols are used as keys of character properties.  */
167
168 /***ja
169      @name ÊÑ¿ô: Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼
170
171      ¤³¤ì¤é¤Î¥·¥ó¥Ü¥ë¤Ïʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£*/
172 /*=*/
173 /*** @{ */
174
175 /***en
176     @brief Key for script.
177
178     The symbol #Mscript has the name <tt>"script"</tt> and is used as the key
179     of a character property.  The value of such a property is a symbol
180     representing the script to which the character belongs.
181
182     Each symbol that represents a script has one of the names listed in
183     the <em>Unicode Technical Report #24</em>.  */
184
185 /***ja
186     @brief ¥¹¥¯¥ê¥×¥È¤òɽ¤ï¤¹¥­¡¼.
187
188     ¥·¥ó¥Ü¥ë #Mscript ¤Ï <tt>"script"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×
189     ¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢¤³¤Îʸ»ú¤Î°¤¹
190     ¤ë¥¹¥¯¥ê¥×¥È¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£
191
192     ¥¹¥¯¥ê¥×¥È¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Î̾Á°¤Ï¡¢<em>Unicode Technical Report
193     #24</em> ¤Ë¥ê¥¹¥È¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤Î¤¤¤º¤ì¤«¤Ç¤¢¤ë¡£  */
194
195 MSymbol Mscript;
196
197 /*=*/
198
199 /***en
200     @brief Key for character name.
201
202     The symbol #Mname has the name <tt>"name"</tt> and is used as
203     the key of a character property.  The value of such a property is a
204     C-string representing the name of the character.  */
205
206 /***ja
207     @brief Ì¾Á°¤òɽ¤ï¤¹¥­¡¼.
208
209     ¥·¥ó¥Ü¥ë #Mname ¤Ï <tt>"name"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ
210     ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϠC-string ¤Ç¤¢¤ê¡¢¤½
211     ¤Îʸ»ú¤Î̾Á°¤òɽ¤ï¤¹¡£  */
212
213 MSymbol Mname;
214
215 /*=*/
216
217 /***en
218     @brief Key for general category.
219
220     The symbol #Mcategory has the name <tt>"category"</tt> and is
221     used as the key of a character property.  The value of such a
222     property is a symbol representing the <em>general category</em> of
223     the character.
224
225     Each symbol that represents a general category has one of the
226     names listed as abbreviations for <em>General Category</em> in
227     Unicode.  */
228
229 /***ja
230     @brief °ìÈÌ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥­¡¼.
231
232     ¥·¥ó¥Ü¥ë #Mcategory ¤Ï <tt>"category"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸
233     »ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë
234     <em>°ìÈÌ¥«¥Æ¥´¥ê</em> ¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£
235
236     °ìÈÌ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Î̾Á°¤Ï¡¢<em>General Category</em>¤Î
237     ¾Êά·Á¤È¤·¤Æ Unicode ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤Ç¤¢¤ë¡£  */
238
239 MSymbol Mcategory;
240
241 /*=*/
242
243 /***en
244     @brief Key for canonical combining class.
245
246     The symbol #Mcombining_class has the name
247     <tt>"combining-class"</tt> and is used as the key of a character
248     property.  The value of such a property is an integer that
249     represents the <em>canonical combining class</em> of the character.
250
251     The meaning of each integer that represents a canonical combining
252     class is identical to the one defined in Unicode.  */
253
254 /***ja
255     @brief É¸½à·ë¹ç¥¯¥é¥¹¤òɽ¤ï¤¹¥­¡¼.
256
257     ¥·¥ó¥Ü¥ë #Mcombining_class ¤Ï <tt>"combining-class"</tt> ¤È¤¤¤¦
258     Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃÍ
259     ¤Ï¡¢Âбþ¤¹¤ë @e É¸½à·ë¹ç¥¯¥é¥¹ ¤òɽ¤ï¤¹À°¿ô¤Ç¤¢¤ë¡£
260
261     É¸½à·ë¹ç¥¯¥é¥¹¤òɽ¤ï¤¹À°¿ô¤Î°ÕÌ£¤Ï¡¢Unicode ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤â¤Î
262     ¤ÈƱ¤¸¤Ç¤¢¤ë¡£  */
263
264 MSymbol Mcombining_class;
265 /*=*/
266
267 /***en
268     @brief Key for bidi category.
269
270     The symbol #Mbidi_category has the name <tt>"bidi-category"</tt>
271     and is used as the key of a character property.  The value of such
272     a property is a symbol that represents the <em>bidirectional
273     category</em> of the character.
274
275     Each symbol that represents a bidirectional category has one of
276     the names listed as types of <em>Bidirectional Category</em> in
277     Unicode.  */
278
279 /***ja
280     @brief ÁÐÊý¸þ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥­¡¼.
281
282     ¥·¥ó¥Ü¥ë #Mbidi_category ¤Ï <tt>"bidi-category"</tt> ¤È¤¤¤¦Ì¾Á°
283     ¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢
284     Âбþ¤¹¤ë @e ÁÐÊý¸þ¥«¥Æ¥´¥ê ¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£
285
286     ÁÐÊý¸þ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Î̾Á°¤Ï¡¢<em>Bidirectional
287     Category</em> ¤Î·¿¤È¤·¤Æ Unicode ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤Ç¤¢¤ë¡£  */
288
289 MSymbol Mbidi_category;
290 /*=*/
291
292 /***en
293     @brief Key for corresponding single lowercase character.
294
295     The symbol #Msimple_case_folding has the name
296     <tt>"simple-case-folding"</tt> and is used as the key of a
297     character property.  The value of such a property is the
298     corresponding single lowercase character that is used when
299     comparing M-texts ignoring cases.
300
301     If a character requires a complicated comparison (i.e. cannot be
302     compared by simply mapping to another single character), the value
303     of such a property is @c 0xFFFF.  In this case, the character has
304     another property whose key is #Mcomplicated_case_folding.  */
305
306 /***ja
307     @brief Âбþ¤¹¤ë¾®Ê¸»ú°ìʸ»ú¤òɽ¤ï¤¹¥­¡¼.
308
309     ¥·¥ó¥Ü¥ë #Msimple_case_folding ¤Ï <tt>"simple-case-folding"</tt> 
310     ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£
311     ¤ÎÃͤϡ¢Âбþ¤¹¤ë¾®Ê¸»ú°ìʸ»ú¤Ç¤¢¤ê¡¢Âçʸ»ú¡¿¾®Ê¸»ú¤Î¶èÊ̤ò̵»ë¤·¤¿
312     Ê¸»úÎóÈæ³Ó¤ÎºÝ¤Ë»È¤ï¤ì¤ë¡£
313
314     Ê£»¨¤ÊÈæ³ÓÊýË¡¤òɬÍפȤ¹¤ëʸ»ú¤Ç¤¢¤Ã¤¿¾ì¹ç¡ÊÊ̤ΰìʸ»ú¤ÈÂбþÉÕ¤±¤ë
315     ¤³¤È¤Ë¤è¤Ã¤ÆÈæ³Ó¤Ç¤­¤Ê¤¤¾ì¹ç¡Ë¡¢¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϠ@c 0xFFFF ¤Ë
316     ¤Ê¤ë¡£¤³¤Î¾ì¹ç¤½¤Îʸ»ú¤Ï¡¢#Mcomplicated_case_folding ¤È¤¤¤¦¥­¡¼¤Î
317     Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤ò»ý¤Ä¡£  */
318
319 MSymbol Msimple_case_folding;
320 /***en
321     @brief Key for corresponding multiple lowercase characters.
322
323     The symbol #Mcomplicated_case_folding has the name
324     <tt>"complicated-case-folding"</tt> and is used as the key of a
325     character property.  The value of such a property is the
326     corresponding M-text that contains a sequence of lowercase
327     characters to be used for comparing M-texts ignoring case.  */
328
329 /***ja
330     @brief Âбþ¤¹¤ë¾®Ê¸»ú¤ÎÎó¤òɽ¤ï¤¹¥­¡¼.
331
332     ¥·¥ó¥Ü¥ë #Mcomplicated_case_folding ¤Ï 
333     <tt>"complicated-case-folding"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£
334     ¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë¾®Ê¸»úÎ󤫤é¤Ê
335     ¤ë M-text ¤Ç¤¢¤ê¡¢Âçʸ»ú¡¿¾®Ê¸»ú¤Î¶èÊ̤ò̵»ë¤·¤¿Ê¸»úÎóÈæ³Ó¤ÎºÝ¤Ë»È
336     ¤ï¤ì¤ë¡£
337       */
338
339 MSymbol Mcomplicated_case_folding;
340 /*=*/
341 /*** @} */
342 /*=*/
343
344 /***en
345     @brief Define a character property.
346
347     The mchar_define_property () function searches the m17n database
348     for a data whose tags are \<#Mchar_table, $TYPE, $SYM \>.
349     Here, $SYM is a symbol whose name is $NAME.  $TYPE must be
350     #Mstring, #Mtext, #Msymbol, #Minteger, or #Mplist.
351
352     @return
353     If the operation was successful, mchar_define_property () returns
354     $SYM.  Otherwise it returns #Mnil.  */
355
356 /***ja
357     @brief Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤òÄêµÁ¤¹¤ë.
358
359     ´Ø¿ô mchar_define_property () ¤Ï¡¢ \<#Mchar_table, $TYPE, $SYM \>
360     ¤È¤¤¤¦¥¿¥°¤ò»ý¤Ã¤¿¥Ç¡¼¥¿¥Ù¡¼¥¹¤ò m17n ¸À¸ì¾ðÊó¥Ù¡¼¥¹¤«¤éõ¤¹¡£  ¤³
361     ¤³¤Ç $SYM ¤Ï $NAME ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£$TYPE ¤Ï#Mstring,
362     #Mtext, #Msymbol, #Minteger, #Mplist ¤Î¤¤¤º¤ì¤«¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
363
364     @return
365     ½èÍý¤ËÀ®¸ù¤¹¤ì¤Ð mchar_define_property () ¤Ï$SYM ¤òÊÖ¤¹¡£
366     ¼ºÇÔ¤·¤¿¾ì¹ç¤Ï #Mnil ¤òÊÖ¤¹¡£  */
367
368 /***
369     @errors
370     @c MERROR_DB
371
372     @seealso
373     mchar_get_prop (), mchar_put_prop ()  */
374
375 MSymbol
376 mchar_define_property (const char *name, MSymbol type)
377 {
378   MSymbol key = msymbol (name);
379   MCharPropRecord *record;
380
381   record = mplist_get (char_prop_list, key);
382   if (record)
383     {
384       if (record->table)
385         M17N_OBJECT_UNREF (record->table);
386     }
387   else
388     {
389       MSTRUCT_CALLOC (record, MERROR_CHAR);
390       mplist_put (char_prop_list, key, record);
391     }
392
393   record->type = type;
394   if (mdatabase__finder
395       && (record->mdb = (*mdatabase__finder) (Mchar_table, type, key, Mnil)))
396     {
397       record->table = NULL;
398     }
399   else
400     {
401       void *default_value = NULL;
402
403       record->mdb = NULL;
404       if (type == Minteger)
405         default_value = (void *) -1;
406       record->table = mchartable (type, default_value);
407     }
408
409   return key;
410 }
411
412 /*=*/
413
414 /***en
415     @brief Get the value of a character property.
416
417     The mchar_get_prop () function searches character $C for the
418     character property whose key is $KEY.
419
420     @return
421     If the operation was successful, mchar_get_prop () returns the
422     value of the character property.  Otherwise it returns @c
423     NULL.  */
424
425 /***ja
426     @brief Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÆÀ¤ë.
427
428     ´Ø¿ô mchar_get_prop () ¤Ï¡¢Ê¸»ú $C ¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¤¦¤Á¥­¡¼¤¬ 
429     $KEY ¤Ç¤¢¤ë¤â¤Î¤òõ¤¹¡£
430
431     @return
432     ½èÍý¤¬À®¸ù¤¹¤ì¤Ð mchar_get_prop () ¤Ï¸«¤Ä¤«¤Ã¤¿¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÊÖ
433     ¤¹¡£¼ºÇÔ¤·¤¿¾ì¹ç¤Ï @c NULL ¤òÊÖ¤¹¡£
434
435     @latexonly \IPAlabel{mchar_get_prop} @endlatexonly
436 */
437 /***
438     @errors
439     @c MERROR_SYMBOL, @c MERROR_DB
440
441     @seealso
442     mchar_define_property (), mchar_put_prop ()  */
443
444 void *
445 mchar_get_prop (int c, MSymbol key)
446 {
447   MCharPropRecord *record;
448
449   record = mplist_get (char_prop_list, key);
450   if (! record)
451     return NULL;
452   if (record->mdb)
453     {
454       record->table = (*mdatabase__loader) (record->mdb);
455       if (! record->table)
456         MERROR (MERROR_DB, NULL);
457       record->mdb = NULL;
458     }
459   return mchartable_lookup (record->table, c);
460 }
461
462 /*=*/
463
464 /***en
465     @brief Set the value of a character property.
466
467     The mchar_put_prop () function searches character $C for the
468     character property whose key is $KEY and assigns $VAL to the value
469     of the found property.
470
471     @return
472     If the operation was successful, mchar_put_prop () returns 0.
473     Otherwise, it returns -1.  */
474 /***ja
475     @brief Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÀßÄꤹ¤ë.
476
477     ´Ø¿ô mchar_put_prop () ¤Ï¡¢Ê¸»ú $C ¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¤¦¤Á¥­¡¼¤¬ $KEY ¤Ç
478     ¤¢¤ë¤â¤Î¤òõ¤·¡¢¤½¤ÎÃͤȤ·¤Æ $VAL ¤òÀßÄꤹ¤ë¡£
479
480     @return
481     ½èÍý¤¬À®¸ù¤¹¤ì¤Ð mchar_put_prop () ¤Ï0¤òÊÖ¤¹¡£¼ºÇÔ¤·¤¿¾ì¹ç¤Ï-1¤òÊÖ
482     ¤¹¡£  */
483 /***
484     @errors
485     @c MERROR_SYMBOL, @c MERROR_DB
486
487     @seealso
488     mchar_define_property (), mchar_get_prop ()   */
489
490 int
491 mchar_put_prop (int c, MSymbol key, void *val)
492 {
493   MCharPropRecord *record;
494
495   record = mplist_get (char_prop_list, key);
496   if (! record)
497     return -1;
498   if (record->mdb)
499     {
500       record->table = (*mdatabase__loader) (record->mdb);
501       if (! record->table)
502         MERROR (MERROR_DB, -1);
503       record->mdb = NULL;
504     }
505   return mchartable_set (record->table, c, val);
506 }
507
508 /*** @} */
509
510 /*
511   Local Variables:
512   coding: euc-japan
513   End:
514 */