1 /* plist.c -- plist 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
26 @brief Property List objects and API for them.
28 A @e property @e list (or @e plist for short) is a list of zero or
29 more properties. A property consists of a @e key and a @e value,
30 where key is a symbol and value is anything that can be cast to
33 If the key of a property is a @e managing @e key, its @e value is
34 a @e managed @e object. A property list itself is a managed
39 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¥ª¥Ö¥¸¥§¥¯¥È¤È¤½¤ì¤Ë´Ø¤¹¤ë API.
41 @e ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È (¤Þ¤¿¤Ï @e plist) ¤Ï 0
42 ¸Ä°Ê¾å¤Î¥×¥í¥Ñ¥Æ¥£¤Î¥ê¥¹¥È¤Ç¤¢¤ë¡£¥×¥í¥Ñ¥Æ¥£¤Ï @e ¥¡¼ ¤È @e ÃÍ
43 ¤«¤é¤Ê¤ë¡£¥¡¼¤Ï¥·¥ó¥Ü¥ë¤Ç¤¢¤ê¡¢ÃÍ¤Ï <tt>(void *)</tt>
44 ¤Ë¥¥ã¥¹¥È¤Ç¤¤ë¤â¤Î¤Ê¤é¤Ð²¿¤Ç¤âÎɤ¤¡£
46 ¤¢¤ë¥×¥í¥Ñ¥Æ¥£¤Î¥¡¼¤¬ @e ´ÉÍý¥¡¼ ¤Ê¤é¤Ð¡¢¤½¤Î @e ÃÍ ¤Ï @e ´ÉÍý²¼
48 ¤Ç¤¢¤ë¡£¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¼«ÂΤâ´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤¢¤ë¡£ */
52 #if !defined (FOR_DOXYGEN) || defined (DOXYGEN_INTERNAL_MODULE)
53 /*** @addtogroup m17nInternal
61 #include "m17n-misc.h"
63 #include "character.h"
68 static M17NObjectArray plist_table;
70 /** Set PLIST to a newly allocated plist object. */
72 #define MPLIST_NEW(plist) \
74 M17N_OBJECT (plist, free_plist, MERROR_PLIST); \
75 M17N_OBJECT_REGISTER (plist_table, plist); \
79 /** Set the element of PLIST to KEY and VAL. If PLIST is an anchor,
80 append a new anchor. */
82 #define MPLIST_SET(plist, key, val) \
84 MPLIST_KEY (plist) = (key); \
85 MPLIST_VAL (plist) = (val); \
86 if (! (plist)->next) \
87 MPLIST_NEW ((plist)->next); \
91 /** Set the element of PLIST to KEY and VAL. PLIST must be an anchor.
92 Append a new anchor and set PLIST to that anchor. */
94 #define MPLIST_SET_ADVANCE(plist, key, val) \
96 MPLIST_KEY (plist) = (key); \
97 MPLIST_VAL (plist) = (val); \
98 MPLIST_NEW ((plist)->next); \
99 plist = (plist)->next; \
104 free_plist (void *object)
106 MPlist *plist = (MPlist *) object;
109 MPlist *next = plist->next;
111 if (MPLIST_KEY (plist) != Mnil && MPLIST_KEY (plist)->managing_key)
112 M17N_OBJECT_UNREF (MPLIST_VAL (plist));
113 M17N_OBJECT_UNREGISTER (plist_table, plist);
116 } while (plist && plist->control.ref_count == 1);
117 M17N_OBJECT_UNREF (plist);
122 /* Load a plist from a string. */
124 #define READ_CHUNK 0x10000
128 /* File pointer if the stream is associated with a file. Otherwise
132 unsigned char buffer[READ_CHUNK];
133 unsigned char *p, *pend;
137 get_byte (MStream *st)
141 if (! st->fp || st->eof)
143 n = fread (st->buffer, 1, READ_CHUNK, st->fp);
149 st->p = st->buffer + 1;
150 st->pend = st->buffer + n;
151 return st->buffer[0];
154 #define GETC(st) ((st)->p < (st)->pend ? *(st)->p++ : get_byte (st))
156 #define UNGETC(c, st) (--((st)->p))
158 /** Mapping table for reading a number. Hexadecimal chars
159 (0..9,A..F,a..F) are mapped to the corresponding numbers.
160 Apostrophe (code 39) is mapped to 254. All the other bytes are
162 unsigned char hex_mnemonic[256];
164 /** Mapping table for escaped characters. Mnemonic characters (e, b,
165 f, n, r, or t) that follows '\' are mapped to the corresponding
166 character code. All the other bytes are mapped to themselves. */
167 unsigned char escape_mnemonic[256];
170 /** Read an integer from the stream ST. It is assumed that we have
171 already read one character C. */
174 read_decimal (MStream *st, int c)
178 while (c >= '0' && c <= '9')
180 num = (num * 10) + (c - '0');
189 /** Read an unsigned from the stream ST. */
192 read_hexadesimal (MStream *st)
197 while ((c = GETC (st)) != EOF
198 && (n = hex_mnemonic[c]) < 16)
199 num = (num << 4) | n;
206 /** Read an M-text element from ST, and add it to LIST. Return a list
207 for the next element. */
209 #define READ_MTEXT_BUF_SIZE 256
212 read_mtext_element (MPlist *plist, MStream *st, int skip)
215 int chars[READ_MTEXT_BUF_SIZE];
216 unsigned char bytes[sizeof (int) * READ_MTEXT_BUF_SIZE];
218 unsigned char *bytes = buffer.bytes;
219 int nbytes = sizeof (int) * READ_MTEXT_BUF_SIZE;
225 while ((c = GETC (st)) != EOF && c != '"')
236 if (c == 'x' || c == 'u')
240 c = read_hexadesimal (st);
248 c = escape_mnemonic[c];
253 if (is_char && ! chars)
255 chars = buffer.chars;
256 for (j = i - 1; j >= 0; j--)
258 nchars = READ_MTEXT_BUF_SIZE;
259 if (bytes != buffer.bytes)
268 if (chars == buffer.chars)
270 MTABLE_MALLOC (chars, nchars, MERROR_PLIST);
271 memcpy (chars, buffer.chars, sizeof (int) * i);
274 MTABLE_REALLOC (chars, nchars, MERROR_PLIST);
280 if (i + MAX_UTF8_CHAR_BYTES >= nbytes)
283 if (bytes == buffer.bytes)
285 MTABLE_MALLOC (bytes, nbytes, MERROR_PLIST);
286 memcpy (bytes, buffer.bytes, i);
289 MTABLE_REALLOC (bytes, nbytes, MERROR_PLIST);
302 mt = mtext__from_data (chars, i, MTEXT_FORMAT_UTF_32, 1);
303 if (chars != buffer.chars)
308 mt = mtext__from_data (bytes, i, MTEXT_FORMAT_UTF_8, 1);
309 if (bytes != buffer.bytes)
312 MPLIST_SET_ADVANCE (plist, Mtext, mt);
318 read_character (MStream *st, int c)
320 unsigned char buf[MAX_UTF8_CHAR_BYTES + 1];
321 int len = CHAR_BYTES_BY_HEAD (c);
325 for (i = 1; i < len; i++)
329 || (c & 0xC0) != 0x80)
334 c = STRING_CHAR_UTF8 (buf);
341 /** Read an integer element from ST, and add it to LIST. Return a
342 list for the next element. It is assumed that we have already
343 read the character C. */
346 read_integer_element (MPlist *plist, MStream *st, int c, int skip)
350 if (c == '0' || c == '#')
354 num = read_hexadesimal (st);
356 num = read_decimal (st, c);
365 if (c < 128 || ! CHAR_UNITS_BY_HEAD_UTF8 (c))
368 num = read_character (st, c);
375 else if (c < 128 || ! CHAR_UNITS_BY_HEAD_UTF8 (c))
376 num = escape_mnemonic[c];
378 num = read_character (st, c);
382 num = - read_decimal (st, GETC (st));
384 num = read_decimal (st, c);
387 MPLIST_SET_ADVANCE (plist, Minteger, (void *) num);
391 /** Read a symbol element from ST, and add it to LIST. Return a list
392 for the next element. */
395 read_symbol_element (MPlist *plist, MStream *st, int skip)
397 unsigned char buffer[1024];
399 unsigned char *buf = buffer;
403 while ((c = GETC (st)) != EOF
405 && c != ')' && c != '(' && c != '"')
412 MTABLE_MALLOC (buf, bufsize, MERROR_PLIST);
413 memcpy (buf, buffer, i);
416 MTABLE_REALLOC (buf, bufsize, MERROR_PLIST);
423 c = escape_mnemonic[c];
434 MPLIST_SET_ADVANCE (plist, Msymbol, msymbol ((char *) buf));
441 /* Read an element of various type from stream ST, and add it to LIST.
442 Return a list for the next element. The element type is decided by
443 the first token character found as below:
446 '0'..'9', '-': integer
447 '?': integer representing character code
448 the other ASCII letters: symbol
450 If KEYS is not NULL, it is a plist contains target keys and stop
451 keys. In this caes, read only a plist whose key has value 1 in
452 KEYS, and return NULL when we encounter a plist whose key has value
453 0 in KEYS while skipping any other elements. */
456 read_element (MPlist *plist, MStream *st, MPlist *keys)
460 /* Skip separators and comments. */
463 while ((c = GETC (st)) != EOF && c <= ' ');
466 while ((c = GETC (st)) != EOF && c != '\n');
477 p = read_element (p, st, NULL);
478 if (keys && p && MPLIST_SYMBOL_P (pl))
480 if (MPLIST_TAIL_P (keys))
482 while ((p = read_element (p, st, NULL)));
483 MPLIST_SET_ADVANCE (plist, Mplist, pl);
490 MPLIST_FIND (p0, MPLIST_SYMBOL (pl));
491 if (! MPLIST_TAIL_P (p0) && ! MPLIST_VAL (p0))
493 M17N_OBJECT_UNREF (pl);
496 while ((p = read_element (p, st, NULL)));
497 if (! MPLIST_TAIL_P (p0))
499 MPLIST_SET_ADVANCE (plist, Mplist, pl);
503 M17N_OBJECT_UNREF (pl);
509 while ((p = read_element (p, st, NULL)));
510 MPLIST_SET_ADVANCE (plist, Mplist, pl);
515 return (read_mtext_element (plist, st, keys ? 1 : 0));
516 if ((c >= '0' && c <= '9') || c == '-' || c == '?' || c == '#')
517 return (read_integer_element (plist, st, c, keys ? 1 : 0));
518 if (c == EOF || c == ')')
521 return (read_symbol_element (plist, st, keys ? 1 : 0));
525 write_element (MText *mt, MPlist *plist)
527 if (MPLIST_SYMBOL_P (plist))
529 MSymbol sym = MPLIST_SYMBOL (plist);
533 MTEXT_CAT_ASCII (mt, "nil");
537 char *name = MSYMBOL_NAME (sym);
538 char *buf = alloca (MSYMBOL_NAMELEN (sym) * 2 + 1), *p = buf;
542 if (*name <= ' ' || *name == '"' || *name == ')' || *name == ')')
547 MTEXT_CAT_ASCII (mt, buf);
550 else if (MPLIST_INTEGER_P (plist))
552 int num = MPLIST_INTEGER (plist);
555 sprintf (buf, "%d", num);
556 MTEXT_CAT_ASCII (mt, buf);
558 else if (MPLIST_PLIST_P (plist))
562 plist = MPLIST_PLIST (plist);
563 mtext_cat_char (mt, '(');
564 MPLIST_DO (pl, plist)
567 mtext_cat_char (mt, ' ');
568 write_element (mt, pl);
570 mtext_cat_char (mt, ')');
572 else if (MPLIST_MTEXT_P (plist))
574 mtext_cat_char (mt, '"');
575 /* Not yet implemnted */
576 mtext_cat_char (mt, '"');
580 /* Support functions for mdebug_dump_plist. */
583 dump_string (char *str)
585 char *p = str, *pend = p + strlen (p), *new, *p1;
587 new = p1 = alloca ((pend - p) * 4 + 1);
592 sprintf (p1, "\\x%02X", (unsigned char) *p);
610 fprintf (stderr, "%s", new);
614 dump_plist_element (MPlist *plist, int indent)
616 char *prefix = (char *) alloca (indent + 1);
619 memset (prefix, 32, indent);
622 key = MPLIST_KEY (plist);
623 fprintf (stderr, "(%s(#%d) ", msymbol_name (MPLIST_KEY (plist)),
624 plist->control.ref_count);
626 dump_string (msymbol_name (MPLIST_SYMBOL (plist)));
627 else if (key == Mtext)
628 mdebug_dump_mtext (MPLIST_MTEXT (plist), indent, 0);
629 else if (key == Minteger)
630 fprintf (stderr, "%x", MPLIST_INTEGER (plist));
631 else if (key == Mstring)
632 fprintf (stderr, "\"%s\"", MPLIST_STRING (plist));
633 else if (MPLIST_NESTED_P (plist))
635 fprintf (stderr, "\n%s", prefix);
636 mdebug_dump_plist (MPLIST_PLIST (plist), indent);
639 fprintf (stderr, "0x%X", (unsigned) MPLIST_VAL (plist));
640 fprintf (stderr, ")");
650 M17N_OBJECT_ADD_ARRAY (plist_table, "Plist");
652 Minteger = msymbol ("integer");
653 Mplist = msymbol_as_managing_key ("plist");
654 Mtext = msymbol_as_managing_key ("mtext");
656 for (i = 0; i < 256; i++)
657 hex_mnemonic[i] = 255;
658 for (i = '0'; i <= '9'; i++)
659 hex_mnemonic[i] = i - '0';
660 for (i = 'A'; i <= 'F'; i++)
661 hex_mnemonic[i] = i - 'A' + 10;
662 for (i = 'a'; i <= 'f'; i++)
663 hex_mnemonic[i] = i - 'a' + 10;
664 for (i = 0; i < 256; i++)
665 escape_mnemonic[i] = i;
666 escape_mnemonic['e'] = 27;
667 escape_mnemonic['b'] = '\b';
668 escape_mnemonic['f'] = '\f';
669 escape_mnemonic['n'] = '\n';
670 escape_mnemonic['r'] = '\r';
671 escape_mnemonic['t'] = '\t';
672 escape_mnemonic['\\'] = '\\';
683 /* Parse this form of PLIST:
684 (symbol:KEY1 TYPE1:VAL1 symbol:KEY2 TYPE2:VAL2 ...)
685 and return a newly created plist of this form:
686 (KEY1:VAL1 KEY2:VAL2 ...) */
689 mplist__from_plist (MPlist *plist)
695 while (! MPLIST_TAIL_P (plist))
699 if (! MPLIST_SYMBOL_P (plist))
700 MERROR (MERROR_PLIST, NULL);
701 key = MPLIST_SYMBOL (plist);
702 plist = MPLIST_NEXT (plist);
703 type = MPLIST_KEY (plist);
704 if (type->managing_key && MPLIST_VAL (plist))
705 M17N_OBJECT_REF (MPLIST_VAL (plist));
706 MPLIST_SET_ADVANCE (p, key, MPLIST_VAL (plist));
707 plist = MPLIST_NEXT (plist);
712 /** Parse this form of PLIST:
713 ((symbol:KEY1 ANY:VAL1 ... ) (symbol:KEY2 ANY:VAL2 ...) ...)
714 and return a newly created plist of this form:
715 (KEY1:(ANY:VAL1 ...) KEY2:(ANY:VAL2 ...) ...)
716 ANY can be any type. */
719 mplist__from_alist (MPlist *plist)
725 MPLIST_DO (plist, plist)
729 if (! MPLIST_PLIST_P (plist))
730 MERROR (MERROR_PLIST, NULL);
731 elt = MPLIST_PLIST (plist);
732 if (! MPLIST_SYMBOL_P (elt))
733 MERROR (MERROR_PLIST, NULL);
734 MPLIST_SET_ADVANCE (p, MPLIST_SYMBOL (elt), MPLIST_NEXT (elt));
735 M17N_OBJECT_REF (MPLIST_NEXT (elt));
742 mplist__from_file (FILE *fp, MPlist *keys)
749 st.p = st.pend = st.buffer;
752 while ((pl = read_element (pl, &st, keys)));
757 /** Parse $STR of $N bytes and return a property list object. $FORMAT
758 must be either @c MTEXT_FORMAT_US_ASCII or @c MTEXT_FORMAT_UTF_8,
759 and controls how to produce @c STRING or @c M-TEXT in the
760 following definition.
762 The syntax of $STR is as follows.
764 PLIST ::= '(' ELEMENT * ')'
766 ELEMENT ::= SYMBOL | INTEGER | UNSIGNED | STRING | M-TEXT | PLIST
768 SYMBOL ::= ascii-character-sequence
770 INTEGER ::= '-' ? [ '0' | .. | '9' ]+
772 UNSIGNED ::= '0x' [ '0' | .. | '9' | 'A' | .. | 'F' | 'a' | .. | 'f' ]+
774 M-TEXT ::= '"' byte-sequence '"'
776 Each kind of @c ELEMENT is assigned one of these keys:
777 @c Msymbol, @c Mint, @c Munsigned, @c Mtext, @c Mplist
779 In an ascii-character-sequence, a backslush (\) is used as the escape
780 character, which means that, for instance, <tt>"abc\ def"</tt>
781 produces a symbol whose name is of length seven with the fourth
782 character being a space.
784 In a byte-sequence, "\r", "\n", "\e", and "\t" are replaced by CR,
785 NL, ESC, and TAB character respectively, "\xXX" are replaced by
786 byte 0xXX. After this replacement, the byte-sequence is decoded
787 into M-TEXT by $CODING. */
790 mplist__from_string (unsigned char *str, int n)
801 while ((pl = read_element (pl, &st, NULL)));
806 mplist__serialize (MText *mt, MPlist *plist)
810 MPLIST_DO (pl, plist)
813 mtext_cat_char (mt, ' ');
814 write_element (mt, pl);
820 #endif /* !FOR_DOXYGEN || DOXYGEN_INTERNAL_MODULE */
825 /*** @addtogroup m17nPlist */
830 @brief Symbol whose name is "integer".
832 The symbol @c Minteger has the name <tt>"integer"</tt>. The value
833 of a property whose key is @c Minteger must be an integer. */
835 @brief "integer" ¤ò̾Á°¤È¤·¤Æ»ý¤Ä¥·¥ó¥Ü¥ë.
837 ¥·¥ó¥Ü¥ë @c Minteger ¤Ï <tt>"integer"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Ä¡£¥¡¼¤¬
838 @c Minteger ¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¤ÎÃͤÏÀ°¿ôÃͤǤʤ¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£ */
844 @brief Symbol whose name is "plist".
846 The symbol @c Mplist has the name <tt>"plist"</tt>. It is a
847 managing key. A value of a property whose key is @c Mplist must
850 @brief "plist" ¤ò̾Á°¤È¤·¤Æ»ý¤Ä¥·¥ó¥Ü¥ë.
852 ¥·¥ó¥Ü¥ë @c Mplist ¤Ï <tt>"plist"</tt>
853 ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Ä¡£¤³¤ì¤Ï´ÉÍý¥¡¼¤Ç¤¢¤ë¡£¥¡¼¤¬ @c Mplist
854 ¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¤ÎÃÍ¤Ï plist ¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£ */
860 @brief Symbol whose name is "mtext".
862 The symbol @c Mtext has the name <tt>"mtext"</tt>. It is a
863 managing key. A value of a property whose key is @c Mtext must be an
867 @brief "mtext" ¤ò̾Á°¤È¤·¤Æ»ý¤Ä¥·¥ó¥Ü¥ë.
869 ¥·¥ó¥Ü¥ë @c Mtext ¤Ï <tt>"mtext"</tt>
870 ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Ä´ÉÍý¥¡¼¤Ç¤¢¤ë¡£¥¡¼¤¬ @c Mtext
871 ¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¤ÎÃÍ¤Ï M-text ¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£ */
877 @brief Create a property list object.
879 The mplist () function returns a newly created property list
880 object of length zero.
883 This function returns a newly created property list.
886 This function never fails. */
888 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¥ª¥Ö¥¸¥§¥¯¥È¤òºî¤ë.
890 ´Ø¿ô mplist () ¤ÏŤµ 0 ¤Î¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¥ª¥Ö¥¸¥§¥¯¥È¤ò¿·¤·¤¯ºî¤Ã¤ÆÊÖ¤¹¡£
893 ¤³¤Î´Ø¿ô¤Ï¿·¤·¤¯ºî¤é¤ì¤¿¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¥ª¥Ö¥¸¥§¥¯¥È¤òÊÖ¤¹¡£
896 ¤³¤Î´Ø¿ô¤Ï·è¤·¤Æ¼ºÇÔ¤·¤Ê¤¤¡£ */
909 @brief Copy a property list.
911 The mplist_copy () function copies property list $PLIST. In the
912 copy, the values are the same as those of $PLIST.
915 This function returns a newly created plist which is a copy of
919 This function never fails. */
921 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤ò¥³¥Ô¡¼¤¹¤ë.
923 ´Ø¿ô mplist_copy () ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST
924 ¤ò¥³¥Ô¡¼¤¹¤ë¡£¥³¥Ô¡¼¤Î¤¹¤Ù¤Æ¤ÎÃͤϥ³¥Ô¡¼¸µ $PLIST ¤ÎÃͤÈƱ¤¸¤Ç¤¢¤ë¡£
927 ¤³¤Î´Ø¿ô¤Ï¿·¤·¤¯ºî¤é¤ì¤¿¡¢$PLIST ¤Î¥³¥Ô¡¼¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤òÊÖ¤¹¡£
930 ¤³¤Î´Ø¿ô¤Ï·è¤·¤Æ¼ºÇÔ¤·¤Ê¤¤¡£ */
933 mplist_copy (MPlist *plist)
935 MPlist *copy = mplist (), *pl = copy;
937 MPLIST_DO (plist, plist)
938 pl = mplist_add (pl, MPLIST_KEY (plist), MPLIST_VAL (plist));
945 @brief Set the value of a property in a property list.
947 The mplist_put () function searches property list $PLIST
948 from the beginning for a property whose key is $KEY. If such a
949 property is found, its value is changed to $VALUE. Otherwise, a
950 new property whose key is $KEY and value is $VALUE is appended at
951 the end of $PLIST. See the documentation of mplist_add () for
952 the restriction on $KEY and $VAL.
954 If $KEY is a managing key, $VAL must be a managed object. In this
955 case, the reference count of the old value, if not @c NULL, is
956 decremented by one, and that of $VAL is incremented by one.
959 If the operation was successful, mplist_put () returns a sublist of
960 $PLIST whose first element is the just modified or added one.
961 Otherwise, it returns @c NULL. */
963 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥ÈÃæ¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÀßÄꤹ¤ë.
965 ´Ø¿ô mplist_put () ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST ¤ò»Ï¤á¤«¤éõ¤·¤Æ¡¢¥¡¼¤¬
966 $KEY ¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¤ò¸«¤Ä¤±¤ë¡£¸«¤Ä¤«¤ì¤Ð¡¢¤½¤ÎÃͤò $VALUE
967 ¤ËÊѹ¹¤¹¤ë¡£¸«¤Ä¤«¤é¤Ê¤±¤ì¤Ð¡¢¥¡¼¤¬ $KEY ¤ÇÃͤ¬ $VALUE
968 ¤Ç¤¢¤ë¿·¤·¤¤¥×¥í¥Ñ¥Æ¥£¤¬ $PLIST ¤ÎËöÈø¤ËÄɲ䵤ì¤ë¡£$KEY ¤È $VAL
969 ¤ËÂФ¹¤ëÀ©¸Â¤Ë¤Ä¤¤¤Æ¤Ï¡¢mplist_add () ¤ÎÀâÌÀ¤ò»²¾È¡£
971 $KEY ¤¬´ÉÍý¥¡¼¤Ê¤é¤Ð¡¢
972 $VAL ¤Ï´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£¤³¤Î¾ì¹ç¡¢¸Å¤¤Ãͤλ²¾È¿ô¤Ï
973 @c NULL ¤Ç¤Ê¤±¤ì¤Ð 1 ¸º¤é¤µ¤ì¡¢$VAL ¤Î»²¾È¿ô¤Ï 1 Áý¤ä¤µ¤ì¤ë¡£
976 ½èÍý¤¬À®¸ù¤¹¤ì¤Ð mplist_put () ¤ÏÊѹ¹¤µ¤ì¤¿¤«Äɲ䵤줿Í×ÁǤ«¤é»Ï¤Þ¤ë
977 $PLIST ¤ÎÉôʬ¥ê¥¹¥È¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð @c NULL ¤òÊÖ¤¹¡£ */
980 mplist_put (MPlist *plist, MSymbol key, void *val)
983 MERROR (MERROR_PLIST, NULL);
984 MPLIST_FIND (plist, key);
985 if (key->managing_key)
987 if (! MPLIST_TAIL_P (plist))
988 M17N_OBJECT_UNREF (MPLIST_VAL (plist));
990 M17N_OBJECT_REF (val);
992 MPLIST_SET (plist, key, val);
999 @brief Get the value of a property in a property list.
1001 The mplist_get () function searches property list $PLIST
1002 from the beginning for a property whose key is $KEY. If such a
1003 property is found, a pointer to its value is returned as the type
1004 of <tt>(void *)</tt>. If not found, @c NULL is returned.
1006 When @c NULL is returned, there are two possibilities: one is the
1007 case where no property is found (see above); the other is the case
1008 where a property is found and its value is @c NULL. In case that
1009 these two cases must be distinguished, use the mplist_find_by_key ()
1012 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥ÈÃæ¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÆÀ¤ë.
1014 ´Ø¿ô mplist_get () ¤Ï¡¢¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST ¤ò»Ï¤á¤«¤éõ¤·¤Æ¡¢¥¡¼¤¬
1015 $KEY ¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¤ò¸«¤Ä¤±¤ë¡£¸«¤Ä¤«¤ì¤Ð¡¢¤½¤ÎÃͤؤΥݥ¤¥ó¥¿¤ò
1016 <tt>(void *)</tt> ·¿¤ÇÊÖ¤¹¡£¸«¤Ä¤«¤é¤Ê¤±¤ì¤Ð @c NULL ¤òÊÖ¤¹¡£
1018 @c NULL ¤¬Ê֤俺ݤˤÏÆó¤Ä¤Î²ÄǽÀ¤¬¤¢¤ë:
1019 ¾åµ¤Î¤è¤¦¤Ë¥×¥í¥Ñ¥Æ¥£¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¾ì¹ç¤È¡¢¥×¥í¥Ñ¥Æ¥£¤¬¸«¤Ä¤«¤ê¡¢¤½¤ÎÃͤ¬
1020 @c NULL ¤Ç¤¢¤ë¾ì¹ç¤Ç¤¢¤ë¡£¤³¤ì¤é¤ò¶èÊ̤¹¤ëɬÍפ¬¤¢¤ë¾ì¹ç¤Ë¤Ï´Ø¿ô
1021 mplist_find_by_key () ¤ò»È¤¦¤³¤È¡£ */
1025 mplist_find_by_key () */
1028 mplist_get (MPlist *plist, MSymbol key)
1030 MPLIST_FIND (plist, key);
1031 return (MPLIST_TAIL_P (plist) ? NULL : MPLIST_VAL (plist));
1037 @brief Add a property at the end of a property list.
1039 The mplist_add () function appends at the end of property list
1040 $PLIST a property whose key is $KEY and value is $VAL. $KEY can
1041 be any symbol other than @c Mnil.
1043 If $KEY is a managing key, $VAL must be a managed object. In this
1044 case, the reference count of $VAL is incremented by one.
1047 If the operation was successful, mplist_add () returns a sublist of
1048 $PLIST whose first element is the just added one. Otherwise, it
1051 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥ÈËöÈø¤Ë¥×¥í¥Ñ¥Æ¥£¤òÄɲ乤ë.
1053 ´Ø¿ô mplist_add () ¤Ï¡¢¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST ¤ÎËöÈø¤Ë¥¡¼¤¬ $KEY
1054 ¤ÇÃͤ¬ $VAL ¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¤òÄɲ乤롣$KEY ¤Ï¡¢@c Mnil °Ê³°¤ÎǤ°Õ¤Î¥·¥ó¥Ü¥ë¤Ç¤è¤¤¡£
1056 $KEY ¤¬´ÉÍý¥¡¼¤Ê¤é¤Ð¡¢$VAL ¤Ï´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£¤³¤Î¾ì¹ç¡¢
1057 $VAL ¤Î»²¾È¿ô¤Ï 1 Áý¤ä¤µ¤ì¤ë¡£
1060 ½èÍý¤¬À®¸ù¤¹¤ì¤Ð mplist_add () ¤ÏÄɲ䵤줿Í×ÁǤ«¤é»Ï¤Þ¤ë $PLIST
1061 ¤ÎÉôʬ¥ê¥¹¥È¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð @c NULL ¤òÊÖ¤¹¡£ */
1064 mplist_add (MPlist *plist, MSymbol key, void *val)
1067 MERROR (MERROR_PLIST, NULL);
1068 MPLIST_FIND (plist, Mnil);
1069 if (val && key->managing_key)
1070 M17N_OBJECT_REF (val);
1071 MPLIST_KEY (plist) = key;
1072 MPLIST_VAL (plist) = val;
1073 MPLIST_NEW (plist->next);
1080 @brief Add a property at the beginning of a property list.
1082 The mplist_push () function inserts at the beginning of property
1083 list $PLIST a property whose key is $KEY and value is $VAL.
1085 If $KEY is a managing key, $VAL must be a managed object. In this
1086 case, the reference count of $VAL is incremented by one.
1089 If the operation was successful, this function returns $PLIST.
1090 Otherwise, it returns @c NULL. */
1092 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤ÎÀèƬ¤Ë¥×¥í¥Ñ¥Æ¥£¤òÁÞÆþ¤¹¤ë.
1094 ´Ø¿ô mplist_push () ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST ¤ÎÀèƬ¤Ë¥¡¼¤¬ $KEY
1095 ¤ÇÃͤ¬ $VAL ¤Ç¤¢¤ë¥ª¥Ö¥¸¥§¥¯¥È¤òÁÞÆþ¤¹¤ë¡£
1097 $KEY ¤¬´ÉÍý¥¡¼¤Ê¤é¤Ð¡¢$VAL ¤Ï´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£¤³¤Î¾ì¹ç¡¢
1098 $VAL ¤Î»²¾È¿ô¤Ï 1 Áý¤ä¤µ¤ì¤ë¡£
1101 ½èÍý¤¬À®¸ù¤¹¤ì¤Ð¤³¤Î´Ø¿ô¤Ï $PLIST ¤òÊÖ¤·¡¢¤½¤¦¤Ç¤Ê¤±¤ì¤Ð@c NULL
1105 mplist_push (MPlist *plist, MSymbol key, void *val)
1110 MERROR (MERROR_PLIST, NULL);
1112 MPLIST_KEY (pl) = MPLIST_KEY (plist);
1113 MPLIST_VAL (pl) = MPLIST_VAL (plist);
1114 MPLIST_NEXT (pl) = MPLIST_NEXT (plist);
1116 if (val && key->managing_key)
1117 M17N_OBJECT_REF (val);
1118 MPLIST_KEY (plist) = key;
1119 MPLIST_VAL (plist) = val;
1126 @brief Remove a property at the beginning of a property list.
1128 The mplist_pop () function removes a property at the beginning of
1129 property list $PLIST. As a result, the second key and value of
1130 the original $PLIST become the first of those of the new $PLIST.
1133 If the operation was successful, this function return the value of
1134 the just popped property. Otherwise, it returns @c NULL. */
1136 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤ÎÀèƬ¤«¤é¥×¥í¥Ñ¥Æ¥£¤òºï½ü¤¹¤ë.
1138 ´Ø¿ô mplist_pop () ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST
1139 ¤ÎÀèƬ¤Î¥×¥í¥Ñ¥Æ¥£¤òºï½ü¤¹¤ë¡£·ë²Ì¤È¤·¤Æ¡¢¸µ¤Î $PLIST ¤Î2ÈÖÌܤΥ¡¼¤ÈÃͤ¬¡¢¿·¤·¤¤
1140 $PLIST ¤ÎÀèƬ¤Î¥¡¼¤ÈÃͤˤʤ롣
1143 ½èÍý¤ËÀ®¸ù¤¹¤ì¤Ð¡¢¤³¤Î´Ø¿ô¤Ïºï½ü¤µ¤ì¤¿¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð
1147 mplist_pop (MPlist *plist)
1152 if (MPLIST_TAIL_P (plist))
1154 val = MPLIST_VAL (plist);
1155 next = MPLIST_NEXT (plist);
1156 MPLIST_KEY (plist) = MPLIST_KEY (next);
1157 MPLIST_VAL (plist) = MPLIST_VAL (next);
1158 if (MPLIST_KEY (plist) != Mnil
1159 && MPLIST_KEY (plist)->managing_key
1160 && MPLIST_VAL (plist))
1161 M17N_OBJECT_REF (MPLIST_VAL (plist));
1162 MPLIST_NEXT (plist) = MPLIST_NEXT (next);
1164 M17N_OBJECT_REF (plist->next);
1165 M17N_OBJECT_UNREF (next);
1171 @brief Concatenate two plists.
1173 The mplist_conc () function concatenate plist $TAIL at the end of
1176 @return If the operation was successful, this function return
1177 $PLIST. Otherwise it returns @c NULL. */
1180 mplist_conc (MPlist *plist, MPlist *tail)
1184 MPLIST_DO (pl, plist);
1185 MPLIST_KEY (pl) = MPLIST_KEY (tail);
1186 MPLIST_VAL (pl) = MPLIST_VAL (tail);
1187 MPLIST_NEXT (pl) = MPLIST_NEXT (tail);
1188 M17N_OBJECT_REF (tail);
1196 @brief Find a property of a specific key in a property list.
1198 The mplist_find_by_key () function searches property list
1199 $PLIST from the beginning for a property whose key is $KEY. If
1200 such a property is found, a sublist of $PLIST whose first element
1201 is the found one is returned. Otherwise, @c NULL is returned.
1203 If $KEY is @c Mnil, it returns a sublist of $PLIST whose
1204 first element is the last one of $PLIST. */
1206 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥ÈÃ椫¤é»ØÄê¤Î¥¡¼¤ò»ý¤Ä¥×¥í¥Ñ¥Æ¥£¤òõ¤¹.
1208 ´Ø¿ô mplist_find_by_key () ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST
1209 ¤ò»Ï¤á¤«¤éõ ¤·¤Æ¡¢¥¡¼¤¬ $KEY
1210 ¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¤ò¸«¤Ä¤±¤ë¡£¸«¤Ä¤«¤ì¤Ð¡¢¤½¤Î¥×¥í¥Ñ¥Æ¥£¤«¤é»Ï¤Þ¤ë
1211 $PLIST ¤ÎÉôʬ¥ê¥¹¥È¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð @c NULL ¤òÊÖ¤¹¡£
1213 $KEY ¤¬ @c Mnil ¤Ê¤é¤Ð¡¢$PLIST ¤ÎºÇ¸å¤ÎÍ×ÁǤ«¤é»Ï¤Þ¤ëÉôʬ¥ê¥¹¥È¤òÊÖ¤¹¡£ */
1216 mplist_find_by_key (MPlist *plist, MSymbol key)
1218 MPLIST_FIND (plist, key);
1219 return (MPLIST_TAIL_P (plist)
1220 ? (key == Mnil ? plist : NULL)
1226 @brief Find a property of a specific value in a property list.
1228 The mplist_find_by_value () function searches property list $PLIST
1229 from the beginning for a property whose value is $VAL. If such a
1230 property is found, a sublist of $PLIST whose first element is the
1231 found one is returned. Otherwise, @c NULL is returned. */
1233 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥ÈÃ椫¤é»ØÄê¤ÎÃͤò»ý¤Ä¥×¥í¥Ñ¥Æ¥£¤òõ¤¹.
1235 ´Ø¿ô mplist_find_by_value () ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST
1236 ¤ò»Ï¤á¤«¤éõ¤·¤Æ¡¢Ãͤ¬ $VAL
1237 ¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¤ò¸«¤Ä¤±¤ë¡£¸«¤Ä¤«¤ì¤Ð¡¢¤½¤Î¥×¥í¥Ñ¥Æ¥£¤«¤é»Ï¤Þ¤ë
1238 $PLIST ¤ÎÉôʬ¥ê¥¹¥È¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð @c NULL ¤òÊÖ¤¹¡£ */
1241 mplist_find_by_value (MPlist *plist, void *val)
1243 MPLIST_DO (plist, plist)
1245 if (MPLIST_VAL (plist) == val)
1254 @brief Return the next sublist of a property list.
1256 The mplist_next () function returns a pointer to the sublist of
1257 property list $PLIST, which begins at the second element in $PLIST. If the
1258 length of $PLIST is zero, it returns @c NULL. */
1260 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤Î¼¡¤ÎÉôʬ¥ê¥¹¥È¤òÊÖ¤¹.
1262 ´Ø¿ô mplist_next () ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST ¤Î 2
1263 ÈÖÌܤÎÍ×ÁǤ«¤é»Ï¤Þ¤ëÉôʬ¥ê¥¹¥È¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£$PLIST ¤ÎŤµ¤¬ 0
1264 ¤Ê¤é¤Ð @c NULL ¤òÊÖ¤¹¡£ */
1267 mplist_next (MPlist *plist)
1269 return (MPLIST_TAIL_P (plist) ? NULL : plist->next);
1275 @brief Set the first property in a property list.
1277 The mplist_set () function sets the key and the value of the first
1278 property in property list $PLIST to $KEY and $VALUE, respectively.
1279 See the documentation of mplist_add () for the restriction on $KEY
1283 If the operation was successful, mplist_set () returns $PLIST.
1284 Otherwise, it returns @c NULL. */
1286 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤ÎºÇ½é¤Î¥×¥í¥Ñ¥Æ¥£¤òÀßÄꤹ¤ë.
1288 ´Ø¿ô mplist_set () ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST
1289 ¤ÎºÇ½é¤Î¥×¥í¥Ñ¥Æ¥£¤Î¥¡¼¤ÈÃͤò¤½¤ì¤¾¤ì $KEY ¤È $VALUE ¤ËÀßÄꤹ¤ë¡£
1290 $KEY ¤È $VAL ¤ËÂФ¹¤ëÀ©¸Â¤Ë¤Ä¤¤¤Æ¤Ï¡¢mplist_add () ¤ÎÀâÌÀ¤ò»²¾È¡£
1293 ½èÍý¤ËÀ®¸ù¤¹¤ì¤Ð mplist_set () ¤Ï $PLIST ¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð @c NULL ¤òÊÖ¤¹¡£ */
1296 mplist_set (MPlist *plist, MSymbol key, void * val)
1300 if (! MPLIST_TAIL_P (plist))
1302 key = MPLIST_KEY (plist);
1303 M17N_OBJECT_UNREF (MPLIST_NEXT (plist));
1304 MPLIST_KEY (plist) = Mnil;
1305 if (key->managing_key)
1306 M17N_OBJECT_UNREF (MPLIST_VAL (plist));
1312 if (val && key->managing_key)
1313 M17N_OBJECT_REF (val);
1314 if (! MPLIST_TAIL_P (plist)
1315 && MPLIST_KEY (plist)->managing_key)
1316 M17N_OBJECT_UNREF (MPLIST_VAL (plist));
1317 MPLIST_SET (plist, key, val);
1325 @brief Return the length of a property list.
1327 The mplist_length () function returns the number of properties in
1328 property list $PLIST. */
1330 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤ÎŤµ¤òÊÖ¤¹.
1332 ´Ø¿ô mplist_length () ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST Ãæ¤Î¥×¥í¥Ñ¥Æ¥£¤Î¿ô¤òÊÖ¤¹¡£ */
1335 mplist_length (MPlist *plist)
1339 for (n = 0; ! (MPLIST_TAIL_P (plist)); n++, plist = plist->next);
1346 @brief Return the key of the first property in a property list.
1348 The mplist_key () function returns the key of the first property
1349 in property list $PLIST. If the length of $PLIST is zero,
1350 it returns @c Mnil. */
1352 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥ÈÃæ¤ÎºÇ½é¤Î¥×¥í¥Ñ¥Æ¥£¤Î¥¡¼¤òÊÖ¤¹.
1354 ´Ø¿ô mplist_key () ¤Ï¡¢¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST
1355 Ãæ¤ÎºÇ½é¤Î¥×¥í¥Ñ¥Æ¥£¤Î¥¡¼¤òÊÖ¤¹¡£$PLIST ¤ÎŤµ¤¬ 0 ¤Ê¤é¤Ð¡¢ @c Mnil
1359 mplist_key (MPlist *plist)
1361 return MPLIST_KEY (plist);
1367 @brief Return the value of the first property in a property list.
1369 The mplist_value () function returns the value of the first
1370 property in property list $PLIST. If the length of $PLIST
1371 is zero, it returns @c NULL. */
1373 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥ÈÃæ¤ÎºÇ½é¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÊÖ¤¹.
1375 ´Ø¿ô mplist_value () ¤Ï¡¢¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST Ãæ¤ÎºÇ½é¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÊÖ¤¹¡£
1376 $PLIST ¤ÎŤµ¤¬ 0 ¤Ê¤é¤Ð¡¢ @c Mnil ¤òÊÖ¤¹¡£ */
1379 mplist_value (MPlist *plist)
1381 return MPLIST_VAL (plist);
1385 @brief Generate a property list by deserializaing an M-text.
1387 The mplist_deserialize () function parses M-text $MT and returns a
1390 The syntax of $MT is as follows.
1392 MT ::= '(' ELEMENT * ')'
1394 ELEMENT ::= SYMBOL | INTEGER | M-TEXT | PLIST
1396 SYMBOL ::= ascii-character-sequence
1398 INTEGER ::= '-' ? [ '0' | .. | '9' ]+
1399 | '0x' [ '0' | .. | '9' | 'A' | .. | 'F' | 'a' | .. | 'f' ]+
1401 M-TEXT ::= '"' character-sequence '"'
1403 Each alternatives of @c ELEMENT is assigned one of these keys: @c
1404 Msymbol, @c Minteger, @c Mtext, @c Mplist
1406 In an ascii-character-sequence, a backslash (\) is used as the escape
1407 character, which means that, for instance, <tt>"abc\ def"</tt>
1408 produces a symbol whose name is of length seven with the fourth
1409 character being a space. */
1411 @brief M-text ¤ò¥Ç¥·¥ê¥¢¥é¥¤¥º¤·¤Æ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤òºî¤ë.
1413 ´Ø¿ô mplist_deserialize () ¤Ï M-text $MT ¤ò²òÀϤ·¤Æ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤òÊÖ¤¹¡£
1415 $MT ¤Î¥·¥ó¥¿¥Ã¥¯¥¹¤Ï°Ê²¼¤ÎÄ̤ꡣ
1417 MT ::= '(' ELEMENT * ')'
1419 ELEMENT ::= SYMBOL | INTEGER | M-TEXT | PLIST
1421 SYMBOL ::= ¥¢¥¹¥¡¼Ê¸»úÎó
1423 INTEGER ::= '-' ? [ '0' | .. | '9' ]+
1424 | '0x' [ '0' | .. | '9' | 'A' | .. | 'F' | 'a' | .. | 'f' ]+
1426 M-TEXT ::= '"' character-sequence '"'
1428 @c ELEMENT ¤Î³ÆÁªÂò»è¤Ï¥¡¼¡§@c Msymbol, @c Minteger, @c Mtext,
1429 @c Mplist ¤Î¤¤¤º¤ì¤«¤ò³ä¤êÅö¤Æ¤é¤ì¤Æ¤¤¤ë¡£
1431 ¥¢¥¹¥¡¼Ê¸»úÎóÆâ¤Ç¤Ï¡¢¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å (\) ¤¬¥¨¥¹¥±¡¼¥×ʸ»ú¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£¤¿¤È¤¨¤Ð
1432 <tt>"abc\ def"</tt> ¤Ï 4 ʸ»úÌܤ¬¶õÇòʸ»ú¤Ç¤¢¤êŤµ¤¬ 7
1433 ¤Ç¤¢¤ë»ý¤Ä̾Á°¤ò»ý¤Ä¥·¥ó¥Ü¥ë¤òÀ¸À®¤¹¤ë¡£ */
1436 mplist_deserialize (MText *mt)
1441 if (mt->format > MTEXT_FORMAT_UTF_8)
1443 if (MTEXT_READ_ONLY_P (mt))
1444 mt = tmp = mtext_cpy (mtext (), mt);
1446 mtext__adjust_format (mt, MTEXT_FORMAT_UTF_8);
1448 plist = mplist__from_string (MTEXT_DATA (mt), mtext_nbytes (mt));
1450 M17N_OBJECT_UNREF (tmp);
1456 /*** @addtogroup m17nDebug */
1461 @brief Dump a property list.
1463 The mdebug_dump_plist () function prints a property list $PLIST in
1464 a human readable way to the stderr. $INDENT specifies how many
1465 columns to indent the lines but the first one.
1468 This function returns $PLIST. */
1470 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤ò¥À¥ó¥×¤¹¤ë.
1472 ´Ø¿ô mdebug_dump_plist () ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST ¤ò stderr
1473 ¤Ë¿Í´Ö¤Ë²ÄÆɤʷÁ¤Ç°õºþ¤¹¤ë¡£ $INDENT ¤Ï£²¹ÔÌܰʹߤΥ¤¥ó¥Ç¥ó¥È¤ò»ØÄꤹ¤ë¡£
1476 ¤³¤Î´Ø¿ô¤Ï $PLIST ¤òÊÖ¤¹¡£ */
1478 mdebug_dump_plist (MPlist *plist, int indent)
1480 char *prefix = (char *) alloca (indent + 1);
1484 memset (prefix, 32, indent);
1487 fprintf (stderr, "(");
1488 MPLIST_DO (pl, plist)
1493 fprintf (stderr, "\n%s ", prefix);
1494 dump_plist_element (pl, indent + 2);
1496 fprintf (stderr, ")");