1 /* symbol.c -- symbol module.
2 Copyright (C) 2003, 2004
3 National Institute of Advanced Industrial Science and Technology (AIST)
4 Registration Number H15PRO112
6 This file is part of the m17n library.
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.
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.
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
24 @addtogroup m17nSymbol
26 @brief Symbol objects and API for them.
28 The m17n library uses objects called @e symbols as unambiguous
29 identifiers. Symbols are similar to atoms in the X library, but a
30 symbol can have zero or more @e symbol @e properties. A symbol
31 property consists of a @e key and a @e value, where key is also a
32 symbol and value is anything that can be cast to <tt>(void *)</tt>.
33 "The symbol property that belongs to the symbol S and
34 whose key is K" may be shortened to "K property of S".
36 Symbols are used mainly in the following three ways.
38 @li As keys of symbol properties and other properties.
40 @li To represent various objects, e.g. charsets, coding systems,
43 @li As arguments of the m17n library functions to control
46 There is a special kind of symbol, a @e managing @e key. The
47 value of a property whose key is a managing key must be a @e
48 managed @e object. See @ref m17nObject for the detail.
51 @addtogroup m17nSymbol ¥·¥ó¥Ü¥ë
53 @brief ¥·¥ó¥Ü¥ë¥ª¥Ö¥¸¥§¥¯¥È¤È¤½¤ì¤Ë´Ø¤¹¤ë API.
55 m17n ¥é¥¤¥Ö¥é¥ê¤Ï°ì°Õ¤Ë·è¤Þ¤ë¼±Ê̻ҤȤ·¤Æ @e ¥·¥ó¥Ü¥ë ¤È¸Æ¤Ö¥ª¥Ö¥¸¥§
56 ¥¯¥È¤òÍѤ¤¤ë¡£¥·¥ó¥Ü¥ë¤Ï X ¥é¥¤¥Ö¥é¥ê¤Î¥¢¥È¥à¤È»÷¤Æ¤¤¤ë¤¬¡¢0 ¸Ä°Ê
57 ¾å¤Î @e ¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£ ¤ò»ý¤Ä¤³¤È¤¬¤Ç¤¤ë¡£¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£
58 ¤Ï @e ¥¡¼ ¤È @e ÃÍ ¤«¤é¤Ê¤ë¡£¥¡¼¤Ï¤½¤ì¼«ÂÎ¥·¥ó¥Ü¥ë¤Ç¤¢¤ê¡¢ÃͤÏ
59 <tt>(void *)</tt> ·¿¤Ë¥¥ã¥¹¥È¤Ç¤¤ë¤â¤Î¤Ê¤é²¿¤Ç¤â¤è¤¤¡£¡Ö¥·¥ó¥Ü¥ë
60 S ¤¬»ý¤Ä¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤Î¤¦¤Á¥¡¼¤¬ K ¤Î¤â¤Î¡×¤ò´Êñ¤Ë¡ÖS ¤Î K
61 ¥×¥í¥Ñ¥Æ¥£¡×¤È¸Æ¤Ö¤³¤È¤¬¤¢¤ë¡£
63 ¥·¥ó¥Ü¥ë¤ÎÍÑÅӤϼç¤Ë°Ê²¼¤Î3Ä̤ê¤Ç¤¢¤ë¡£
65 @li ¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤ª¤è¤Ó¾¤Î¥×¥í¥Ñ¥Æ¥£¤Î¥¡¼¤òɽ¤ï¤¹¡£
67 @li ʸ»ú¥»¥Ã¥È¡¢¥³¡¼¥É·Ï¡¢¥Õ¥©¥ó¥È¥»¥Ã¥È¤Ê¤É¤Î³Æ¼ï¥ª¥Ö¥¸¥§¥¯¥È¤òɽ
70 @li m17n ¥é¥¤¥Ö¥é¥ê´Ø¿ô¤Î°ú¿ô¤È¤Ê¤ê¡¢´Ø¿ô¤ÎµóÆ°¤òÀ©¸æ¤¹¤ë¡£
72 @e ´ÉÍý¥¡¼ ¤È¸Æ¤Ð¤ì¤ëÆÃÊ̤ʥ·¥ó¥Ü¥ë¤¬¤¢¤ê¡¢´ÉÍý¥¡¼¤ò¥¡¼¤È¤·¤Æ»ý
73 ¤Ä¥×¥í¥Ñ¥Æ¥£¤ÎÃÍ¤Ï @e ´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È ¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£¾ÜºÙ
74 ¤Ï @ref m17nObject »²¾È¡£
79 #if !defined (FOR_DOXYGEN) || defined (DOXYGEN_INTERNAL_MODULE)
80 /*** @addtogroup m17nInternal
89 #include "m17n-misc.h"
92 #include "character.h"
96 static int num_symbols;
98 #define SYMBOL_TABLE_SIZE 1024
100 static MSymbol symbol_table[SYMBOL_TABLE_SIZE];
103 hash_string (const char *str, int len)
106 const char *end = str + len;
111 c = *((unsigned char *) str++);
114 hash = ((hash << 3) + (hash >> 28) + c);
116 return hash & (SYMBOL_TABLE_SIZE - 1);
121 serialize_symbol (void *val)
123 MPlist *plist = mplist ();
125 mplist_add (plist, Msymbol, val);
130 deserialize_symbol (MPlist *plist)
132 return (MPLIST_SYMBOL_P (plist) ? MPLIST_SYMBOL (plist) : Mnil);
144 Msymbol = msymbol ("symbol");
145 Mstring = msymbol ("string");
154 int freed_symbols = 0;
156 for (i = 0; i < SYMBOL_TABLE_SIZE; i++)
157 for (sym = symbol_table[i]; sym; sym = sym->next)
158 if (! MPLIST_TAIL_P (&sym->plist))
160 if (sym->plist.key->managing_key)
161 M17N_OBJECT_UNREF (sym->plist.val);
162 M17N_OBJECT_UNREF (sym->plist.next);
164 for (i = 0; i < SYMBOL_TABLE_SIZE; i++)
166 for (sym = symbol_table[i]; sym; sym = next)
173 symbol_table[i] = NULL;
175 if (mdebug__flag & MDEBUG_FINI)
176 fprintf (stderr, "%16s %7d %7d %7d\n", "Symbol",
177 num_symbols, freed_symbols, num_symbols - freed_symbols);
183 msymbol__with_len (const char *name, int len)
185 char *p = alloca (len + 1);
187 memcpy (p, name, len);
193 /** Canonicalize the name of SYM, and return a symbol of the
194 canonicalized name. Canonicalization is done by this rule:
195 o convert all uppercase characters to lowercase.
196 o remove all non alpha-numeric characters.
197 o change the leading "ibm" to "cp".
198 o change the leading "cp" to "ibm"
199 o remove the leading "iso".
201 "ISO-8859-2" -> "88592"
204 "CP1250" -> "ibm1250"
206 This function is used to canonicalize charset and coding system
210 msymbol__canonicalize (MSymbol sym)
212 char *name = sym->name;
213 /* Extra 2 bytes are for changing "cpXXX" to "ibmXXX" and
215 char *canon = (char *) alloca (strlen (name) + 2);
218 for (; *name; name++)
220 *p++ = TOLOWER (*name);
222 if (p - canon > 3 && canon[0] == 'i')
224 if (canon[1] == 'b' && canon[2] == 'm' && isdigit (canon[3]))
226 /* Change "ibmXXX" to "cpXXX". */
231 else if (canon[1] == 's' && canon[2] == 'o')
233 /* Change "isoXXX" to "XXX". */
237 else if (p - canon > 2
238 && canon[0] == 'c' && canon[1] == 'p' && isdigit (canon[2]))
240 /* Change "cpXXX" to "ibmXXX". */
241 for (; p >= canon + 2; p--)
248 return msymbol (canon);
251 MTextPropSerializeFunc msymbol__serializer = serialize_symbol;
252 MTextPropDeserializeFunc msymbol__deserializer = deserialize_symbol;
255 #endif /* !FOR_DOXYGEN || DOXYGEN_INTERNAL_MODULE */
260 /*** @addtogroup m17nSymbol */
265 @brief Symbol whose name is "nil".
267 The symbol #Mnil has the name <tt>"nil"</tt> and, in general,
268 represents @e false or @e no. When coerced to "int", its value is
269 zero. #Mnil can't have any symbol property. */
272 @brief "nil" ¤ò̾Á°¤È¤·¤Æ»ý¤Ä¥·¥ó¥Ü¥ë.
274 ¥·¥ó¥Ü¥ë #Mnil ¤Ï <tt>"nil"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢°ìÈ̤ˡֵ¶¡×¤Þ
275 ¤¿¤Ï¡ÖÈÝÄê¡×¤ò°ÕÌ£¤¹¤ë¡£"int" ¤ËÊÑ´¹¤µ¤ì¤¿¾ì¹ç¡¢ÃÍ¤Ï 0 ¤Ç¤¢¤ë¡£
276 #Mnil ¼«¿È¤Ï¤¤¤«¤Ê¤ë¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤â»ý¤¿¤Ê¤¤¡£ */
283 @brief Symbol whose name is "t".
285 The symbol #Mt has the name <tt>"t"</tt> and, in general,
286 represents @e true or @e yes. */
289 @brief "t" ¤ò̾Á°¤È¤·¤Æ»ý¤Ä¥·¥ó¥Ü¥ë.
291 ¥·¥ó¥Ü¥ë #Mt ¤Ï <tt>"t"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢°ìÈ̤ˡֿ¿¡×¤Þ¤¿¤Ï
292 ¡Ö¹ÎÄê¡×¤ò°ÕÌ£¤¹¤ë¡£ */
299 @brief Symbol whose name is "string".
301 The symbol #Mstring has the name <tt>"string"</tt> and is used
302 as an argument of the functions mchar_define_property (),
306 @brief "string" ¤ò̾Á°¤È¤·¤Æ»ý¤Ä¥·¥ó¥Ü¥ë.
308 ¥·¥ó¥Ü¥ë #Mstring ¤Ï <tt>"string"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢´Ø¿ô
309 mchar_define_property () ¤Î°ú¿ôÅù¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£ */
316 @brief Symbol whose name is "symbol".
318 The symbol #Msymbol has the name <tt>"symbol"</tt> and is used
319 as an argument of the functions mchar_define_property (),
323 @brief "symbol" ¤ò̾Á°¤È¤·¤Æ»ý¤Ä¥·¥ó¥Ü¥ë.
325 ÄêµÁºÑ¤ß¥·¥ó¥Ü¥ë #Msymbol ¤Ï <tt>"symbol"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢
326 ´Ø¿ô mchar_define_property () ¤Î°ú¿ôÅù¤È¤·¤Æ»È¤ï¤ì¤ë¡£ */
335 The msymbol () function returns the canonical symbol whose name is
336 $NAME. If there is none, one is created. The created one is not
339 Symbols whose name starts by two spaces are reserved by the m17n
340 library, and are used by the library only internally.
343 This function returns the found or created symbol.
346 This function never fails. */
349 @brief ¥·¥ó¥Ü¥ë¤òÆÀ¤ë.
351 ´Ø¿ô msymbol () ¤Ï $NAME ¤È¤¤¤¦Ì¾Á°¤ò»ý¤ÄÀµµ¬²½¤µ¤ì¤¿¥·¥ó¥Ü¥ë¤òÊÖ
352 ¤¹¡£¤½¤Î¤è¤¦¤Ê¥·¥ó¥Ü¥ë¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¤Ë¤Ï¡¢À¸À®¤¹¤ë¡£À¸À®¤µ¤ì¤¿¥·
353 ¥ó¥Ü¥ë¤Ï´ÉÍý¥¡¼¤Ç¤Ï¤Ê¤¤¡£
355 ¶õÇòʸ»úÆó¤Ä¤Ç»Ï¤Þ¤ë¥·¥ó¥Ü¥ë¤Ï m17n ¥é¥¤¥Ö¥é¥êÍѤǤ¢¤ê¡¢ÆâÉôŪ¤Ë¤Î
359 ¤³¤Î´Ø¿ô¤Ï¸«¤Ä¤±¤¿¤«À¸À®¤·¤¿¥·¥ó¥Ü¥ë¤òÊÖ¤¹¡£
362 ¤³¤Î´Ø¿ô¤Ï·è¤·¤Æ¼ºÇÔ¤·¤Ê¤¤¡£
364 @latexonly \IPAlabel{msymbol} @endlatexonly */
368 msymbol_as_managing_key (), msymbol_name (), msymbol_exist () */
371 msymbol (const char *name)
378 if (len == 3 && name[0] == 'n' && name[1] == 'i' && name[2] == 'l')
380 hash = hash_string (name, len);
382 for (sym = symbol_table[hash]; sym; sym = sym->next)
383 if (len == sym->length
384 && *name == *(sym->name)
385 && ! memcmp (name, sym->name, len))
389 MTABLE_CALLOC (sym, 1, MERROR_SYMBOL);
390 MTABLE_MALLOC (sym->name, len, MERROR_SYMBOL);
391 memcpy (sym->name, name, len);
393 sym->next = symbol_table[hash];
394 symbol_table[hash] = sym;
399 @brief Create a managing key.
401 The msymbol_as_managing_key () function returns a newly created
402 managing key whose name is $NAME. It there already exists a
403 symbol of name $NAME, it returns #Mnil.
405 Symbols whose name starts by two spaces are reserved by the m17n
406 library, and are used by the library only internally.
409 If the operation was successful, this function returns the created
410 symbol. Otherwise, it returns #Mnil. */
412 @brief ´ÉÍý¥¡¼¤òºî¤ë.
414 ´Ø¿ô msymbol_as_managing_key () ¤Ï̾Á° $NAME ¤ò»ý¤Ä¿·¤·¤¯ºî¤é¤ì¤¿
415 ´ÉÍý¥¡¼¤òÊÖ¤¹¡£¤¹¤Ç¤Ë̾Á° $NAME ¤ò»ý¤Ä¥·¥ó¥Ü¥ë¤¬¤¢¤ì¤Ð¡¢#Mnil ¤ò
418 ¶õÇòʸ»úÆó¤Ä¤Ç»Ï¤Þ¤ë¥·¥ó¥Ü¥ë¤Ï m17n ¥é¥¤¥Ö¥é¥êÍѤǤ¢¤ê¡¢ÆâÉôŪ¤Ë¤Î
422 ½èÍý¤ËÀ®¸ù¤¹¤ì¤Ð¡¢¤³¤Î´Ø¿ô¤ÏÀ¸À®¤·¤¿¥·¥ó¥Ü¥ë¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð
430 msymbol (), msymbol_exist () */
433 msymbol_as_managing_key (const char *name)
440 if (len == 3 && name[0] == 'n' && name[1] == 'i' && name[2] == 'l')
441 MERROR (MERROR_SYMBOL, Mnil);
442 hash = hash_string (name, len);
444 for (sym = symbol_table[hash]; sym; sym = sym->next)
445 if (len == sym->length
446 && *name == *(sym->name)
447 && ! memcmp (name, sym->name, len))
448 MERROR (MERROR_SYMBOL, Mnil);
451 MTABLE_CALLOC (sym, 1, MERROR_SYMBOL);
452 sym->managing_key = 1;
453 MTABLE_MALLOC (sym->name, len, MERROR_SYMBOL);
454 memcpy (sym->name, name, len);
456 sym->next = symbol_table[hash];
457 symbol_table[hash] = sym;
464 @brief Search for a symbol that has a specified name.
466 The msymbol_exist () function searches for the symbol whose name
470 If such a symbol exists, msymbol_exist () returns that symbol.
471 Otherwise it returns the predefined symbol #Mnil.
474 This function never fails. */
477 @brief »ØÄꤵ¤ì¤¿Ì¾Á°¤ò»ý¤Ä¥·¥ó¥Ü¥ë¤òõ¤¹.
479 ´Ø¿ô msymbol_exist () ¤Ï $NAME ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Ä¥·¥ó¥Ü¥ë¤òõ¤¹¡£
482 ¤â¤·¤½¤Î¤è¤¦¤Ê¥·¥ó¥Ü¥ë¤¬Â¸ºß¤¹¤ë¤Ê¤é¤Ð¤½¤Î¥·¥ó¥Ü¥ë¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê
483 ¤±¤ì¤Ð¡¢ÄêµÁºÑ¤ß¥·¥ó¥Ü¥ë #Mnil ¤òÊÖ¤¹¡£
486 ¤³¤Î´Ø¿ô¤Ï·è¤·¤Æ¼ºÇÔ¤·¤Ê¤¤¡£ */
489 msymbol_name (), msymbol () */
492 msymbol_exist (const char *name)
499 if (len == 3 && name[0] == 'n' && name[1] == 'i' && name[2] == 'l')
501 hash = hash_string (name, len);
503 for (sym = symbol_table[hash]; sym; sym = sym->next)
504 if (len == sym->length
505 && *name == *(sym->name)
506 && ! memcmp (name, sym->name, len))
514 @brief Get symbol name.
516 The msymbol_name () function returns a pointer to a string
517 containing the name of $SYMBOL.
520 This function never fails. */
522 @brief ¥·¥ó¥Ü¥ë¤Î̾Á°¤òÆÀ¤ë.
524 ´Ø¿ô msymbol_name () ¤Ï»ØÄꤵ¤ì¤¿¥·¥ó¥Ü¥ë $SYMBOL ¤Î̾Á°¤ò´Þ¤àʸ»ú
525 Îó¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£
528 ¤³¤Î´Ø¿ô¤Ï·è¤·¤Æ¼ºÇÔ¤·¤Ê¤¤¡£ */
531 msymbol (), msymbol_exist () */
534 msymbol_name (MSymbol symbol)
536 return (symbol == Mnil ? "nil" : symbol->name);
541 @brief Set the value of a symbol property.
543 The msymbol_put () function assigns $VAL to the value of the
544 symbol property that belongs to $SYMBOL and whose key is $KEY. If
545 the symbol property already has a value, $VAL overwrites the old
546 one. Both $SYMBOL and $KEY must not be #Mnil.
548 If $KEY is a managing key, $VAL must be a managed object. In this
549 case, the reference count of the old value, if not @c NULL, is
550 decremented by one, and that of $VAL is incremented by one.
553 If the operation was successful, msymbol_put () returns 0.
554 Otherwise it returns -1 and assigns an error code to the external
555 variable #merror_code. */
558 @brief ¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤ËÃͤòÀßÄꤹ¤ë.
560 ´Ø¿ô msymbol_put () ¤Ï¡¢¥·¥ó¥Ü¥ë $SYMBOL Ãæ¤Ç¥¡¼¤¬ $KEY ¤Ç¤¢¤ë¥·
561 ¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤ÎÃͤò $VAL ¤ËÀßÄꤹ¤ë¡£¤½¤Î¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤Ë¤¹
562 ¤Ç¤ËÃͤ¬¤¢¤ì¤Ð¾å½ñ¤¤¹¤ë¡£$SYMBOL, $KEY ¤È¤â #Mnil ¤Ç¤¢¤Ã¤Æ¤Ï¤Ê¤é
565 $KEY ¤¬´ÉÍý¥¡¼¤Ê¤é¤Ð¡¢$VAL ¤Ï´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
566 ¤³¤Î¾ì¹ç¡¢¸Å¤¤Ãͤλ²¾È¿ô¤Ï @c NULL ¤Ç¤Ê¤±¤ì¤Ð 1 ¸º¤é¤µ¤ì¡¢$VAL ¤Î
567 »²¾È¿ô¤Ï 1 Áý¤ä¤µ¤ì¤ë¡£
570 ½èÍý¤¬À®¸ù¤¹¤ì¤Ð¡¢msymbol_put () ¤Ï 0 ¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð -1 ¤ò
571 ÊÖ¤·¡¢³°ÉôÊÑ¿ô #merror_code ¤Ë¥¨¥é¡¼¥³¡¼¥É¤òÀßÄꤹ¤ë¡£ */
581 msymbol_put (MSymbol symbol, MSymbol key, void *val)
583 if (symbol == Mnil || key == Mnil)
584 MERROR (MERROR_SYMBOL, -1);
585 mplist_put (&symbol->plist, key, val);
592 @brief Get the value of a symbol property.
594 The msymbol_get () function searches for the value of the symbol
595 property that belongs to $SYMBOL and whose key is $KEY. If
596 $SYMBOL has such a symbol property, its value is returned.
597 Otherwise @c NULL is returned.
600 If an error is detected, msymbol_get () returns @c NULL and
601 assigns an error code to the external variable #merror_code. */
604 @brief ¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÆÀ¤ë.
606 ´Ø¿ô msymbol_get () ¤Ï¡¢¥·¥ó¥Ü¥ë $SYMBOL ¤¬»ý¤Ä¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£
607 ¤Î¤¦¤Á¡¢¥¡¼¤¬ $KEY ¤Ç¤¢¤ë¤â¤Î¤òõ¤¹¡£¤â¤·³ºÅö¤¹¤ë¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£
608 ¤¬Â¸ºß¤¹¤ì¤Ð¡¢¤½¤ì¤ÎÃͤòÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð @c NULL ¤òÊÖ¤¹¡£
611 ¥¨¥é¡¼¤¬¸¡½Ð¤µ¤ì¤¿¾ì¹ç¡¢msymbol_get () ¤Ï @c NULL ¤òÊÖ¤·¡¢
612 ³°ÉôÊÑ¿ô #merror_code ¤Ë¥¨¥é¡¼¥³¡¼¥É¤òÀßÄꤹ¤ë¡£ */
622 msymbol_get (MSymbol symbol, MSymbol key)
626 if (symbol == Mnil || key == Mnil)
628 plist = &symbol->plist;
629 MPLIST_FIND (plist, key);
630 return (MPLIST_TAIL_P (plist) ? NULL : MPLIST_VAL (plist));
637 /*** @addtogroup m17nDebug */
642 @brief Dump a symbol.
644 The mdebug_dump_symbol () function prints symbol $SYMBOL in a human
645 readable way to the stderr. $INDENT specifies how many columns to
646 indent the lines but the first one.
649 This function returns $SYMBOL.
654 @brief ¥·¥ó¥Ü¥ë¤ò¥À¥ó¥×¤¹¤ë.
656 ´Ø¿ô mdebug_dump_symbol () ¤Ï¥·¥ó¥Ü¥ë $symbol ¤ò stderr ¤Ë¿Í´Ö¤Ë²Ä
657 ÆÉ¤Ê ·Á¤Ç°õºþ¤¹¤ë¡£ $UNDENT ¤Ï£²¹ÔÌܰʹߤΥ¤¥ó¥Ç¥ó¥È¤ò»ØÄꤹ¤ë¡£
660 ¤³¤Î´Ø¿ô¤Ï $SYMBOL ¤òÊÖ¤¹¡£
666 mdebug_dump_symbol (MSymbol symbol, int indent)
673 MERROR (MERROR_DEBUG, Mnil);
674 prefix = (char *) alloca (indent + 1);
675 memset (prefix, 32, indent);
679 plist = NULL, name = "nil";
681 plist = &symbol->plist, name = symbol->name;
683 fprintf (stderr, "%s%s", prefix, name);
684 while (plist && MPLIST_KEY (plist) != Mnil)
686 fprintf (stderr, ":%s", MPLIST_KEY (plist)->name);
687 plist = MPLIST_NEXT (plist);
693 @brief Dump all symbol names.
695 The mdebug_dump_all_symbols () function prints names of all
696 symbols to the stderr. $INDENT specifies how many columns to
697 indent the lines but the first one.
700 This function returns #Mnil.
705 @brief ¤¹¤Ù¤Æ¤Î¥·¥ó¥Ü¥ë̾¤ò¥À¥ó¥×¤¹¤ë.
707 ´Ø¿ô mdebug_dump_all_symbols () ¤Ï¡¢¤¹¤Ù¤Æ¤Î¥·¥ó¥Ü¥ë¤Î̾Á°¤ò
708 stderr ¤Ë°õºþ¤¹¤ë¡£ $UNDENT ¤Ï£²¹ÔÌܰʹߤΥ¤¥ó¥Ç¥ó¥È¤ò»ØÄꤹ¤ë¡£
711 ¤³¤Î´Ø¿ô¤Ï #Mnil ¤òÊÖ¤¹¡£
718 mdebug_dump_all_symbols (int indent)
725 MERROR (MERROR_DEBUG, Mnil);
726 prefix = (char *) alloca (indent + 1);
727 memset (prefix, 32, indent);
730 fprintf (stderr, "(symbol-list");
731 for (i = 0; i < SYMBOL_TABLE_SIZE; i++)
732 if ((sym = symbol_table[i]))
734 fprintf (stderr, "\n%s (%4d", prefix, i);
735 for (; sym; sym = sym->next)
736 fprintf (stderr, " '%s'", sym->name);
737 fprintf (stderr, ")");
739 fprintf (stderr, ")");