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
33 *)</tt>. "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.
52 @addtogroup m17nSymbol ¥·¥ó¥Ü¥ë
54 @brief ¥·¥ó¥Ü¥ë¥ª¥Ö¥¸¥§¥¯¥È¤È¤½¤ì¤Ë´Ø¤¹¤ë API
56 m17n ¥é¥¤¥Ö¥é¥ê¤Ï°ì°Õ¤Ë·è¤Þ¤ëµ½Ò»Ò¤È¤·¤Æ @e ¥·¥ó¥Ü¥ë ¤È¸Æ¤Ö¥ª¥Ö¥¸¥§
57 ¥¯¥È¤òÍѤ¤¤ë¡£¥·¥ó¥Ü¥ë¤Ï X ¥é¥¤¥Ö¥é¥ê¤Î¥¢¥È¥à¤È»÷¤Æ¤¤¤ë¤¬¡¢0 ¸Ä°Ê
58 ¾å¤Î @e ¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£ ¤ò»ý¤Ä¤³¤È¤¬¤Ç¤¤ëÅÀ¤Ç¡¢¥¢¥È¥à¤è¤ê¹âµ¡
59 ǽ¤Ç¤¢¤ë¡£¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤Ï @e ¥¡¼ ¤È @e ÃÍ ¤«¤é¤Ê¤ë¡£¥¡¼¤Ï¤½
60 ¤ì¼«ÂÎ¥·¥ó¥Ü¥ë¤Ç¤¢¤ê¡¢ÃÍ¤Ï <tt>(void *)</tt> ·¿¤Ë¥¥ã¥¹¥È¤Ç¤¤ë¤â
61 ¤Î¤Ê¤é²¿¤Ç¤â¤è¤¤¡£¡Ö¥·¥ó¥Ü¥ë S ¤¬»ý¤Ä¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤Î¤¦¤Á¥¡¼
62 ¤¬ K ¤Î¤â¤Î¡×¤ò´Êñ¤Ë¡ÖS ¤Î K ¥×¥í¥Ñ¥Æ¥£¡×¤È¸Æ¤Ö¤³¤È¤¬¤¢¤ë¡£
64 ¥·¥ó¥Ü¥ë¤ÎÍÑÅӤϼç¤Ë°Ê²¼¤Î3Ä̤ê¤Ç¤¢¤ë¡£
66 @li ¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£ (¤ª¤è¤Ó¾¤Î¥×¥í¥Ñ¥Æ¥£) ¤Î¥¡¼¤òɽ¤ï¤¹¡£
68 @li ʸ»ú¥»¥Ã¥È¡¢¥³¡¼¥É·Ï¡¢¥Õ¥©¥ó¥È¥»¥Ã¥È¤Ê¤É¤Î³Æ¼ï¥ª¥Ö¥¸¥§¥¯¥È¤òɽ
71 @li m17n ¥é¥¤¥Ö¥é¥ê´Ø¿ô¤Î°ú¿ô¤È¤Ê¤ê¡¢´Ø¿ô¤ÎµóÆ°¤òÀ©¸æ¤¹¤ë¡£
73 ¥¡¼¤¬ @c Mmanaging_key ¤ÇÃͤ¬ @c NULL °Ê³°¤Î¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤ò
74 »ý¤Ä¥·¥ó¥Ü¥ë¤Ï¡¢@e ´ÉÍý¥¡¼ ¤È¸Æ¤Ð¤ì¤ë¡£¤¢¤ë¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤Î¥¡¼
75 ¤¬´ÉÍý¥¡¼¤Î¾ì¹ç¡¢¤½¤ÎÃÍ¤Ï @e ´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È ¤È¤·¤Æ°·¤ï¤ì¤ë¡£
76 ´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤Ë´Ø¤¹¤ë¾ÜºÙ¤Ï @e ´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È ¤Î¾Ï¤ò»²¾È
79 ¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤Ë¤ÏÃͤÎÂå¤ê¤Ë @e ¥×¥í¥Ð¥¤¥À´Ø¿ô ¤ò»ý¤¿¤»¤ë¤³¤È
80 ¤â¤Ç¤¤ë¡£¥×¥í¥Ð¥¤¥À´Ø¿ô¤Ï¤½¤Î¥¡¼¤ÎÃͤòÆÀ¤è¤¦¤È¤¹¤ë»þ¤Ë¸Æ¤Ð¤ì¡¢¤½
81 ¤ÎÊÖ¤êÃͤ¬µá¤á¤ë¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤ÎÃͤȤʤ롣¤³¤Î»ÅÁȤߤˤè¤Ã¤Æ¥·
82 ¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤ÎÃÙ±äɾ²Á¤¬²Äǽ¤Ë¤Ê¤ë¡£¥×¥í¥Ð¥¤¥À´Ø¿ô¤ÏÃͤòÊÖ¤¹¤È
83 Ʊ»þ¤ËÃͤòÀßÄꤹ¤ë¤³¤È¤â¤Ç¤¡¢¤³¤Î¾ì¹ç¤Ë¤Ï¡¢¥×¥í¥Ð¥¤¥À´Ø¿ô¼«ÂΤÏÃÍ
84 ¤ÎÀßÄê°Ê¹ß¤Ï̵¸ú¤È¤Ê¤ë¡£ */
88 #if !defined (FOR_DOXYGEN) || defined (DOXYGEN_INTERNAL_MODULE)
89 /*** @addtogroup m17nInternal
98 #include "m17n-misc.h"
101 #include "character.h"
105 static int num_symbols;
107 #define SYMBOL_TABLE_SIZE 1024
109 static MSymbol symbol_table[SYMBOL_TABLE_SIZE];
112 hash_string (const char *str, int len)
115 const char *end = str + len;
120 c = *((unsigned char *) str++);
123 hash = ((hash << 3) + (hash >> 28) + c);
125 return hash & (SYMBOL_TABLE_SIZE - 1);
130 serialize_symbol (void *val)
132 MPlist *plist = mplist ();
134 mplist_add (plist, Msymbol, val);
139 deserialize_symbol (MPlist *plist)
141 return (MPLIST_SYMBOL_P (plist) ? MPLIST_SYMBOL (plist) : Mnil);
153 Msymbol = msymbol ("symbol");
154 Mstring = msymbol ("string");
163 int freed_symbols = 0;
165 for (i = 0; i < SYMBOL_TABLE_SIZE; i++)
166 for (sym = symbol_table[i]; sym; sym = sym->next)
167 if (! MPLIST_TAIL_P (&sym->plist))
169 if (sym->plist.key->managing_key)
170 M17N_OBJECT_UNREF (sym->plist.val);
171 M17N_OBJECT_UNREF (sym->plist.next);
173 for (i = 0; i < SYMBOL_TABLE_SIZE; i++)
175 for (sym = symbol_table[i]; sym; sym = next)
182 symbol_table[i] = NULL;
184 if (mdebug__flag & MDEBUG_FINI)
185 fprintf (stderr, "%16s %7d %7d %7d\n", "Symbol",
186 num_symbols, freed_symbols, num_symbols - freed_symbols);
192 msymbol__with_len (const char *name, int len)
194 char *p = alloca (len + 1);
196 memcpy (p, name, len);
202 /** Canonicalize the name of SYM, and return a symbol of the
203 canonicalized name. Canonicalization is done by this rule:
204 o convert all uppercase characters to lowercase.
205 o remove all non alpha-numeric characters.
206 o change the leading "ibm" to "cp".
207 o change the leading "cp" to "ibm"
208 o remove the leading "iso".
210 "ISO-8859-2" -> "88592"
213 "CP1250" -> "ibm1250"
215 This function is used to canonicalize charset and coding system
219 msymbol__canonicalize (MSymbol sym)
221 char *name = sym->name;
222 /* Extra 2 bytes are for changing "cpXXX" to "ibmXXX" and
224 char *canon = (char *) alloca (strlen (name) + 2);
227 for (; *name; name++)
229 *p++ = TOLOWER (*name);
231 if (p - canon > 3 && canon[0] == 'i')
233 if (canon[1] == 'b' && canon[2] == 'm' && isdigit (canon[3]))
235 /* Change "ibmXXX" to "cpXXX". */
240 else if (canon[1] == 's' && canon[2] == 'o')
242 /* Change "isoXXX" to "XXX". */
246 else if (p - canon > 2
247 && canon[0] == 'c' && canon[1] == 'p' && isdigit (canon[2]))
249 /* Change "cpXXX" to "ibmXXX". */
250 for (; p >= canon + 2; p--)
257 return msymbol (canon);
260 MTextPropSerializeFunc msymbol__serializer = serialize_symbol;
261 MTextPropDeserializeFunc msymbol__deserializer = deserialize_symbol;
264 #endif /* !FOR_DOXYGEN || DOXYGEN_INTERNAL_MODULE */
269 /*** @addtogroup m17nSymbol */
274 @brief Symbol whose name is "nil".
276 The symbol #Mnil has the name <tt>"nil"</tt> and, in general,
277 represents @e false or @e no. When coerced to "int", its value is
278 zero. #Mnil can't have any symbol property. */
281 @brief ÄêµÁºÑ¥·¥ó¥Ü¥ë Mnil
283 ¥·¥ó¥Ü¥ë #Mnil ¤Ï <tt>"nil"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢°ìÈ̤ˡֵ¶¡×
284 ¤ò°ÕÌ£¤¹¤ë¡£#Mnil ¼«¿È¤Ï¤¤¤«¤Ê¤ë¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤â»ý¤¿¤Ê¤¤¡£ */
291 @brief Symbol whose name is "t".
293 The symbol #Mt has the name <tt>"t"</tt> and, in general,
294 represents @e true or @e yes. */
297 @brief ÄêµÁºÑ¥·¥ó¥Ü¥ë Mt
299 ¥·¥ó¥Ü¥ë #Mt ¤Ï <tt>"t"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢°ìÈ̤ˡֿ¿¡×¤ò°Õ
307 @brief Symbol whose name is "string".
309 The symbol #Mstring has the name <tt>"string"</tt> and is used
310 as an argument of the functions mchar_define_property (),
314 @brief "string" ¤ò̾Á°¤È¤·¤Æ»ý¤Ä¥·¥ó¥Ü¥ë
316 ÄêµÁºÑ¤ß¥·¥ó¥Ü¥ë #Mstring ¤Ï <tt>"string"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢
317 ´Ø¿ô mchar_define_property () Åù¤Î°ú¿ô¤È¤·¤Æ»È¤ï¤ì¤ë¡£ */
324 @brief Symbol whose name is "symbol".
326 The symbol #Msymbol has the name <tt>"symbol"</tt> and is used
327 as an argument of the functions mchar_define_property (),
331 @brief "symbol" ¤ò̾Á°¤È¤·¤Æ»ý¤Ä¥·¥ó¥Ü¥ë
333 ÄêµÁºÑ¤ß¥·¥ó¥Ü¥ë #Msymbol ¤Ï <tt>"symbol"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢
334 ´Ø¿ô mchar_define_property () Åù¤Î°ú¿ô¤È¤·¤Æ»È¤ï¤ì¤ë¡£ */
343 The msymbol () function returns the canonical symbol whose name is
344 $NAME. If there is none, one is created. The created one is not
347 Symbols whose name starts by two spaces are reserved by the m17n
348 library, and are used by the library only internally.
351 This function returns the found or created symbol.
354 This function never fails. */
357 @brief »ØÄꤵ¤ì¤¿Ì¾Á°¤ò»ý¤Ä¥·¥ó¥Ü¥ë¤òÊÖ¤¹
359 ´Ø¿ô msymbol () ¤Ï $NAME ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤òÊÖ¤¹¡£¤½¤Î¤è¤¦¤Ê¥·
360 ¥ó¥Ü¥ë¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¤Ë¤Ï¡¢¿·¤·¤¤¥·¥ó¥Ü¥ë¤¬¼«Æ°Åª¤Ëºî¤é¤ì¤ë¡£
362 @latexonly \IPAlabel{msymbol} @endlatexonly */
366 msymbol_as_managing_key (), msymbol_name (), msymbol_exist () */
369 msymbol (const char *name)
376 if (len == 3 && name[0] == 'n' && name[1] == 'i' && name[2] == 'l')
378 hash = hash_string (name, len);
380 for (sym = symbol_table[hash]; sym; sym = sym->next)
381 if (len == sym->length
382 && *name == *(sym->name)
383 && ! memcmp (name, sym->name, len))
387 MTABLE_CALLOC (sym, 1, MERROR_SYMBOL);
388 MTABLE_MALLOC (sym->name, len, MERROR_SYMBOL);
389 memcpy (sym->name, name, len);
391 sym->next = symbol_table[hash];
392 symbol_table[hash] = sym;
397 @brief Create a managing key.
399 The msymbol_as_managing_key () function returns a newly created
400 managing key whose name is $NAME. It there already exists a
401 symbol of name $NAME, it returns #Mnil.
403 Symbols whose name starts by two spaces are reserved by the m17n
404 library, and are used by the library only internally.
407 If the operation was successful, this function returns the created
408 symbol. Otherwise, it returns #Mnil. */
415 msymbol (), msymbol_exist () */
418 msymbol_as_managing_key (const char *name)
425 if (len == 3 && name[0] == 'n' && name[1] == 'i' && name[2] == 'l')
426 MERROR (MERROR_SYMBOL, Mnil);
427 hash = hash_string (name, len);
429 for (sym = symbol_table[hash]; sym; sym = sym->next)
430 if (len == sym->length
431 && *name == *(sym->name)
432 && ! memcmp (name, sym->name, len))
433 MERROR (MERROR_SYMBOL, Mnil);
436 MTABLE_CALLOC (sym, 1, MERROR_SYMBOL);
437 sym->managing_key = 1;
438 MTABLE_MALLOC (sym->name, len, MERROR_SYMBOL);
439 memcpy (sym->name, name, len);
441 sym->next = symbol_table[hash];
442 symbol_table[hash] = sym;
449 @brief Search for a symbol that has a specified name.
451 The msymbol_exist () function searches for the symbol whose name
455 If such a symbol exists, msymbol_exist () returns that symbol.
456 Otherwise it returns the predefined symbol #Mnil.
459 This function never fails. */
462 @brief »ØÄꤵ¤ì¤¿Ì¾Á°¤ò»ý¤Ä¥·¥ó¥Ü¥ë¤òõ¤¹
464 ´Ø¿ô msymbol_exist () ¤Ï $NAME ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤òõ¤¹¡£
467 ¤â¤·¤½¤Î¤è¤¦¤Ê¥·¥ó¥Ü¥ë¤¬Â¸ºß¤¹¤ë¤Ê¤é¤Ð¤½¤Î¥·¥ó¥Ü¥ë¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê
468 ¤±¤ì¤Ð¡¢ÄêµÁºÑ¤ß¥·¥ó¥Ü¥ë #Mnil ¤òÊÖ¤¹¡£ */
471 msymbol_name (), msymbol () */
474 msymbol_exist (const char *name)
481 if (len == 3 && name[0] == 'n' && name[1] == 'i' && name[2] == 'l')
483 hash = hash_string (name, len);
485 for (sym = symbol_table[hash]; sym; sym = sym->next)
486 if (len == sym->length
487 && *name == *(sym->name)
488 && ! memcmp (name, sym->name, len))
496 @brief Get symbol name.
498 The msymbol_name () function returns a pointer to a string
499 containing the name of $SYMBOL.
502 Name of the specified symbol.
505 This function never fails. */
507 @brief ¥·¥ó¥Ü¥ë¤Î̾Á°¤òÊÖ¤¹
509 ´Ø¿ô msymbol_name () ¤Ï»ØÄꤵ¤ì¤¿¥·¥ó¥Ü¥ë $SYMBOL ¤Î̾Á°¤òÊÖ¤¹¡£ */
512 msymbol (), msymbol_exist () */
515 msymbol_name (MSymbol symbol)
517 return (symbol == Mnil ? "nil" : symbol->name);
522 @brief Set the value of a symbol property.
524 The msymbol_put () function assigns $VAL to the value of the
525 symbol property that belongs to $SYMBOL and whose key is $KEY. If
526 the symbol property already has a value, $VAL overwrites the old
527 one. Both $SYMBOL and $KEY must not be #Mnil.
529 If $KEY is a managing key, $VAL must be a managed object. In this
530 case, the reference count of the old value, if not @c NULL, is
531 decremented by one, and that of $VAL is incremented by one.
534 If the operation was successful, msymbol_put () returns 0.
535 Otherwise it returns -1 and assigns an error code to the external
536 variable #merror_code. */
539 @brief ¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤ËÃͤòÀßÄꤹ¤ë
541 ´Ø¿ô msymbol_put () ¤Ï¡¢¥·¥ó¥Ü¥ë $SYMBOL Ãæ¤Ç¥¡¼¤¬ $KEY ¤Ç¤¢¤ë¥·
542 ¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤ÎÃͤò $VAL ¤ËÀßÄꤹ¤ë¡£¤½¤Î¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤Ë¤¹
543 ¤Ç¤ËÃͤ¬¤¢¤ì¤Ð¾å½ñ¤¤¹¤ë¡£$SYMBOL, $KEY ¤È¤â´û¤ËÀ¸À®¤µ¤ì¤¿¥·¥ó¥Ü
544 ¥ë¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
547 ½èÍý¤¬À®¸ù¤¹¤ì¤Ð¡¢msymbol_put () ¤Ï 0 ¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð -1 ¤ò
548 ÊÖ¤·¡¢³°ÉôÊÑ¿ô #merror_code ¤Ë¥¨¥é¡¼¥³¡¼¥É¤òÀßÄꤹ¤ë¡£ */
558 msymbol_put (MSymbol symbol, MSymbol key, void *val)
560 if (symbol == Mnil || key == Mnil)
561 MERROR (MERROR_SYMBOL, -1);
562 mplist_put (&symbol->plist, key, val);
569 @brief Get the value of a symbol property.
571 The msymbol_get () function searches for the value of the symbol
572 property that belongs to $SYMBOL and whose key is $KEY. If
573 $SYMBOL has such a symbol property, its value is returned.
574 Otherwise @c NULL is returned.
578 If an error is detected, msymbol_get () returns @c NULL and
579 assigns an error code to the external variable #merror_code. */
582 @brief ¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòõ¤¹
584 ´Ø¿ô msymbol_get () ¤Ï¡¢¥·¥ó¥Ü¥ë $SYMBOL ¤¬»ý¤Ä¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£
585 ¤Î¤¦¤Á¡¢¥¡¼¤¬ $KEY ¤Ç¤¢¤ë¤â¤Î¤òõ¤¹¡£¤â¤·³ºÅö¤¹¤ë¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£
586 ¤¬Â¸ºß¤¹¤ì¤Ð¡¢¤½¤ì¤ÎÃͤòÊÖ¤¹¡£¤â¤·³ºÅö¤¹¤ë¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤¬Â¸ºß
587 ¤»¤º¡¢¤«¤Ä $KEY ¤ËÂФ¹¤ë¥×¥í¥Ð¥¤¥À´Ø¿ô¤¬Â¸ºß¤¹¤ì¤Ð¡¢¤½¤Î´Ø¿ô¤ò¸Æ¤ó
588 ¤Ç¤½¤ÎÌá¤êÃͤòÊÖ¤¹¡£³ºÅö¤¹¤ë¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤â¥×¥í¥Ð¥¤¥À´Ø¿ô¤â¸
589 ºß¤·¤Ê¤¤¾ì¹ç¤Ï³°ÉôÊÑ¿ô #merror_code ¤òÊѤ¨¤º¤Ë @c NULL ¤òÊÖ¤¹¡£
591 ¥¨¥é¡¼¤¬¸¡½Ð¤µ¤ì¤¿¾ì¹ç¤Ï @c NULL ¤òÊÖ¤·¡¢³°ÉôÊÑ¿ô
592 #merror_code ¤Ë¥¨¥é¡¼¥³¡¼¥É¤òÀßÄꤹ¤ë¡£ */
602 msymbol_get (MSymbol symbol, MSymbol key)
606 if (symbol == Mnil || key == Mnil)
608 plist = &symbol->plist;
609 MPLIST_FIND (plist, key);
610 return (MPLIST_TAIL_P (plist) ? NULL : MPLIST_VAL (plist));
617 /*** @addtogroup m17nDebug */
622 @brief Dump a symbol.
624 The mdebug_dump_symbol () function prints $SYMBOL in a human
625 readable way to the stderr. $INDENT specifies how many columns to
626 indent the lines but the first one.
629 This function returns $SYMBOL.
635 mdebug_dump_symbol (MSymbol symbol, int indent)
642 MERROR (MERROR_DEBUG, Mnil);
643 prefix = (char *) alloca (indent + 1);
644 memset (prefix, 32, indent);
648 plist = NULL, name = "nil";
650 plist = &symbol->plist, name = symbol->name;
652 fprintf (stderr, "%s%s", prefix, name);
653 while (plist && MPLIST_KEY (plist) != Mnil)
655 fprintf (stderr, ":%s", MPLIST_KEY (plist)->name);
656 plist = MPLIST_NEXT (plist);
662 @brief Dump all symbol names.
664 The mdebug_dump_all_symbols () function prints names of all
665 symbols to the stderr. $INDENT specifies how many columns to
666 indent the lines but the first one.
669 This function returns #Mnil.
676 mdebug_dump_all_symbols (int indent)
683 MERROR (MERROR_DEBUG, Mnil);
684 prefix = (char *) alloca (indent + 1);
685 memset (prefix, 32, indent);
688 fprintf (stderr, "(symbol-list");
689 for (i = 0; i < SYMBOL_TABLE_SIZE; i++)
690 if ((sym = symbol_table[i]))
692 fprintf (stderr, "\n%s (%4d", prefix, i);
693 for (; sym; sym = sym->next)
694 fprintf (stderr, " '%s'", sym->name);
695 fprintf (stderr, ")");
697 fprintf (stderr, ")");