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 != '"')
234 if (c == 'x' || c == 'u')
238 c = read_hexadesimal (st);
246 c = escape_mnemonic[c];
251 if (is_char && ! chars)
253 chars = buffer.chars;
254 for (j = i - 1; j >= 0; j--)
256 nchars = READ_MTEXT_BUF_SIZE;
257 if (bytes != buffer.bytes)
266 if (chars == buffer.chars)
268 MTABLE_MALLOC (chars, nchars, MERROR_PLIST);
269 memcpy (chars, buffer.chars, sizeof (int) * i);
272 MTABLE_REALLOC (chars, nchars, MERROR_PLIST);
278 if (i + MAX_UTF8_CHAR_BYTES >= nbytes)
281 if (bytes == buffer.bytes)
283 MTABLE_MALLOC (bytes, nbytes, MERROR_PLIST);
284 memcpy (bytes, buffer.bytes, i);
287 MTABLE_REALLOC (bytes, nbytes, MERROR_PLIST);
300 mt = mtext__from_data (chars, i, MTEXT_FORMAT_UTF_32, 1);
301 if (chars != buffer.chars)
306 mt = mtext__from_data (bytes, i, MTEXT_FORMAT_UTF_8, 1);
307 if (bytes != buffer.bytes)
310 MPLIST_SET_ADVANCE (plist, Mtext, mt);
316 read_character (MStream *st, int c)
318 unsigned char buf[MAX_UTF8_CHAR_BYTES + 1];
319 int len = CHAR_BYTES_BY_HEAD (c);
323 for (i = 1; i < len; i++)
327 || (c & 0xC0) != 0x80)
332 c = STRING_CHAR_UTF8 (buf);
339 /** Read an integer element from ST, and add it to LIST. Return a
340 list for the next element. It is assumed that we have already
341 read the character C. */
344 read_integer_element (MPlist *plist, MStream *st, int c, int skip)
348 if (c == '0' || c == '#')
352 num = read_hexadesimal (st);
354 num = read_decimal (st, c);
363 if (c < 128 || ! CHAR_UNITS_BY_HEAD_UTF8 (c))
366 num = read_character (st, c);
373 else if (c < 128 || ! CHAR_UNITS_BY_HEAD_UTF8 (c))
374 num = escape_mnemonic[c];
376 num = read_character (st, c);
380 num = - read_decimal (st, GETC (st));
382 num = read_decimal (st, c);
385 MPLIST_SET_ADVANCE (plist, Minteger, (void *) num);
389 /** Read a symbol element from ST, and add it to LIST. Return a list
390 for the next element. */
393 read_symbol_element (MPlist *plist, MStream *st, int skip)
395 unsigned char buffer[1024];
397 unsigned char *buf = buffer;
401 while ((c = GETC (st)) != EOF
403 && c != ')' && c != '(' && c != '"')
410 MTABLE_MALLOC (buf, bufsize, MERROR_PLIST);
411 memcpy (buf, buffer, i);
414 MTABLE_REALLOC (buf, bufsize, MERROR_PLIST);
421 c = escape_mnemonic[c];
432 MPLIST_SET_ADVANCE (plist, Msymbol, msymbol ((char *) buf));
439 /* Read an element of various type from stream ST, and add it to LIST.
440 Return a list for the next element. The element type is decided by
441 the first token character found as below:
444 '0'..'9', '-': integer
445 '?': integer representing character code
446 the other ASCII letters: symbol
448 If KEYS is not NULL, it is a plist contains target keys and stop
449 keys. In this caes, read only a plist whose key has value 1 in
450 KEYS, and return NULL when we encounter a plist whose key has value
451 0 in KEYS while skipping any other elements. */
454 read_element (MPlist *plist, MStream *st, MPlist *keys)
458 /* Skip separators and comments. */
461 while ((c = GETC (st)) != EOF && c <= ' ');
464 while ((c = GETC (st)) != EOF && c != '\n');
475 p = read_element (p, st, NULL);
476 if (keys && p && MPLIST_SYMBOL_P (pl))
479 MPLIST_FIND (p0, MPLIST_SYMBOL (pl));
480 if (! MPLIST_TAIL_P (p0) && ! MPLIST_VAL (p0))
482 M17N_OBJECT_UNREF (pl);
485 while ((p = read_element (p, st, NULL)));
486 if (! MPLIST_TAIL_P (p0))
487 MPLIST_SET_ADVANCE (plist, Mplist, pl);
489 M17N_OBJECT_UNREF (pl);
494 while ((p = read_element (p, st, NULL)));
495 MPLIST_SET_ADVANCE (plist, Mplist, pl);
500 return (read_mtext_element (plist, st, keys ? 1 : 0));
501 if ((c >= '0' && c <= '9') || c == '-' || c == '?' || c == '#')
502 return (read_integer_element (plist, st, c, keys ? 1 : 0));
503 if (c == EOF || c == ')')
506 return (read_symbol_element (plist, st, keys ? 1 : 0));
510 write_element (MText *mt, MPlist *plist)
512 if (MPLIST_SYMBOL_P (plist))
514 MSymbol sym = MPLIST_SYMBOL (plist);
518 MTEXT_CAT_ASCII (mt, "nil");
522 char *name = MSYMBOL_NAME (sym);
523 char *buf = alloca (MSYMBOL_NAMELEN (sym) * 2 + 1), *p = buf;
527 if (*name <= ' ' || *name == '"' || *name == ')' || *name == ')')
532 MTEXT_CAT_ASCII (mt, buf);
535 else if (MPLIST_INTEGER_P (plist))
537 int num = MPLIST_INTEGER (plist);
540 sprintf (buf, "%d", num);
541 MTEXT_CAT_ASCII (mt, buf);
543 else if (MPLIST_PLIST_P (plist))
547 plist = MPLIST_PLIST (plist);
548 mtext_cat_char (mt, '(');
549 MPLIST_DO (pl, plist)
552 mtext_cat_char (mt, ' ');
553 write_element (mt, pl);
555 mtext_cat_char (mt, ')');
557 else if (MPLIST_MTEXT_P (plist))
559 mtext_cat_char (mt, '"');
560 /* Not yet implemnted */
561 mtext_cat_char (mt, '"');
565 /* Support functions for mdebug_dump_plist. */
568 dump_string (char *str)
570 char *p = str, *pend = p + strlen (p), *new, *p1;
572 new = p1 = alloca ((pend - p) * 4 + 1);
577 sprintf (p1, "\\x%02X", (unsigned char) *p);
595 fprintf (stderr, "%s", new);
599 dump_plist_element (MPlist *plist, int indent)
601 char *prefix = (char *) alloca (indent + 1);
604 memset (prefix, 32, indent);
607 key = MPLIST_KEY (plist);
608 fprintf (stderr, "(%s(#%d) ", msymbol_name (MPLIST_KEY (plist)),
609 plist->control.ref_count);
611 dump_string (msymbol_name (MPLIST_SYMBOL (plist)));
612 else if (key == Mtext)
613 mdebug_dump_mtext (MPLIST_MTEXT (plist), indent, 0);
614 else if (key == Minteger)
615 fprintf (stderr, "%x", MPLIST_INTEGER (plist));
616 else if (key == Mstring)
617 fprintf (stderr, "\"%s\"", MPLIST_STRING (plist));
618 else if (key == Mplist)
620 fprintf (stderr, "\n%s", prefix);
621 mdebug_dump_plist (MPLIST_PLIST (plist), indent);
624 fprintf (stderr, "0x%X", (unsigned) MPLIST_VAL (plist));
625 fprintf (stderr, ")");
635 M17N_OBJECT_ADD_ARRAY (plist_table, "Plist");
637 Minteger = msymbol ("integer");
638 Mplist = msymbol_as_managing_key ("plist");
639 Mtext = msymbol_as_managing_key ("mtext");
641 for (i = 0; i < 256; i++)
642 hex_mnemonic[i] = 255;
643 for (i = '0'; i <= '9'; i++)
644 hex_mnemonic[i] = i - '0';
645 for (i = 'A'; i <= 'F'; i++)
646 hex_mnemonic[i] = i - 'A' + 10;
647 for (i = 'a'; i <= 'f'; i++)
648 hex_mnemonic[i] = i - 'a' + 10;
649 for (i = 0; i < 256; i++)
650 escape_mnemonic[i] = i;
651 escape_mnemonic['e'] = 27;
652 escape_mnemonic['b'] = '\b';
653 escape_mnemonic['f'] = '\f';
654 escape_mnemonic['n'] = '\n';
655 escape_mnemonic['r'] = '\r';
656 escape_mnemonic['t'] = '\t';
657 escape_mnemonic['\\'] = '\\';
668 /* Parse this form of PLIST:
669 (symbol:KEY1 TYPE1:VAL1 symbol:KEY2 TYPE2:VAL2 ...)
670 and return a newly created plist of this form:
671 (KEY1:VAL1 KEY2:VAL2 ...) */
674 mplist__from_plist (MPlist *plist)
680 while (! MPLIST_TAIL_P (plist))
684 if (! MPLIST_SYMBOL_P (plist))
685 MERROR (MERROR_PLIST, NULL);
686 key = MPLIST_SYMBOL (plist);
687 plist = MPLIST_NEXT (plist);
688 type = MPLIST_KEY (plist);
689 if (type->managing_key && MPLIST_VAL (plist))
690 M17N_OBJECT_REF (MPLIST_VAL (plist));
691 MPLIST_SET_ADVANCE (p, key, MPLIST_VAL (plist));
692 plist = MPLIST_NEXT (plist);
697 /** Parse this form of PLIST:
698 ((symbol:KEY1 ANY:VAL1 ... ) (symbol:KEY2 ANY:VAL2 ...) ...)
699 and return a newly created plist of this form:
700 (KEY1:(ANY:VAL1 ...) KEY2:(ANY:VAL2 ...) ...)
701 ANY can be any type. */
704 mplist__from_alist (MPlist *plist)
710 MPLIST_DO (plist, plist)
714 if (! MPLIST_PLIST_P (plist))
715 MERROR (MERROR_PLIST, NULL);
716 elt = MPLIST_PLIST (plist);
717 if (! MPLIST_SYMBOL_P (elt))
718 MERROR (MERROR_PLIST, NULL);
719 MPLIST_SET_ADVANCE (p, MPLIST_SYMBOL (elt), MPLIST_NEXT (elt));
720 M17N_OBJECT_REF (MPLIST_NEXT (elt));
727 mplist__from_file (FILE *fp, MPlist *keys)
734 st.p = st.pend = st.buffer;
737 while ((pl = read_element (pl, &st, keys)));
742 /** Parse $STR of $N bytes and return a property list object. $FORMAT
743 must be either @c MTEXT_FORMAT_US_ASCII or @c MTEXT_FORMAT_UTF_8,
744 and controls how to produce @c STRING or @c M-TEXT in the
745 following definition.
747 The syntax of $STR is as follows.
749 PLIST ::= '(' ELEMENT * ')'
751 ELEMENT ::= SYMBOL | INTEGER | UNSIGNED | STRING | M-TEXT | PLIST
753 SYMBOL ::= ascii-character-sequence
755 INTEGER ::= '-' ? [ '0' | .. | '9' ]+
757 UNSIGNED ::= '0x' [ '0' | .. | '9' | 'A' | .. | 'F' | 'a' | .. | 'f' ]+
759 M-TEXT ::= '"' byte-sequence '"'
761 Each kind of @c ELEMENT is assigned one of these keys:
762 @c Msymbol, @c Mint, @c Munsigned, @c Mtext, @c Mplist
764 In an ascii-character-sequence, a backslush (\) is used as the escape
765 character, which means that, for instance, <tt>"abc\ def"</tt>
766 produces a symbol whose name is of length seven with the fourth
767 character being a space.
769 In a byte-sequence, "\r", "\n", "\e", and "\t" are replaced by CR,
770 NL, ESC, and TAB character respectively, "\xXX" are replaced by
771 byte 0xXX. After this replacement, the byte-sequence is decoded
772 into M-TEXT by $CODING. */
775 mplist__from_string (unsigned char *str, int n)
786 while ((pl = read_element (pl, &st, NULL)));
791 mplist__serialize (MText *mt, MPlist *plist)
795 MPLIST_DO (pl, plist)
798 mtext_cat_char (mt, ' ');
799 write_element (mt, pl);
805 #endif /* !FOR_DOXYGEN || DOXYGEN_INTERNAL_MODULE */
810 /*** @addtogroup m17nPlist */
815 @brief Symbol whose name is "integer".
817 The symbol @c Minteger has the name <tt>"integer"</tt>. The value
818 of a property whose key is @c Minteger must be an integer. */
820 @brief "integer" ¤ò̾Á°¤È¤·¤Æ»ý¤Ä¥·¥ó¥Ü¥ë.
822 ¥·¥ó¥Ü¥ë @c Minteger ¤Ï <tt>"integer"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Ä¡£¥¡¼¤¬
823 @c Minteger ¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¤ÎÃͤÏÀ°¿ôÃͤǤʤ¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£ */
829 @brief Symbol whose name is "plist".
831 The symbol @c Mplist has the name <tt>"plist"</tt>. It is a
832 managing key. A value of a property whose key is @c Mplist must
835 @brief "plist" ¤ò̾Á°¤È¤·¤Æ»ý¤Ä¥·¥ó¥Ü¥ë.
837 ¥·¥ó¥Ü¥ë @c Mplist ¤Ï <tt>"plist"</tt>
838 ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Ä¡£¤³¤ì¤Ï´ÉÍý¥¡¼¤Ç¤¢¤ë¡£¥¡¼¤¬ @c Mplist
839 ¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¤ÎÃÍ¤Ï plist ¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£ */
845 @brief Symbol whose name is "mtext".
847 The symbol @c Mtext has the name <tt>"mtext"</tt>. It is a
848 managing key. A value of a property whose key is @c Mtext must be an
852 @brief "mtext" ¤ò̾Á°¤È¤·¤Æ»ý¤Ä¥·¥ó¥Ü¥ë.
854 ¥·¥ó¥Ü¥ë @c Mtext ¤Ï <tt>"mtext"</tt>
855 ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Ä´ÉÍý¥¡¼¤Ç¤¢¤ë¡£¥¡¼¤¬ @c Mtext
856 ¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¤ÎÃÍ¤Ï M-text ¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£ */
862 @brief Create a property list object.
864 The mplist () function returns a newly created property list
865 object of length zero.
868 This function returns a newly created property list.
871 This function never fails. */
873 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¥ª¥Ö¥¸¥§¥¯¥È¤òºî¤ë.
875 ´Ø¿ô mplist () ¤ÏŤµ 0 ¤Î¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¥ª¥Ö¥¸¥§¥¯¥È¤ò¿·¤·¤¯ºî¤Ã¤ÆÊÖ¤¹¡£
878 ¤³¤Î´Ø¿ô¤Ï¿·¤·¤¯ºî¤é¤ì¤¿¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¥ª¥Ö¥¸¥§¥¯¥È¤òÊÖ¤¹¡£
881 ¤³¤Î´Ø¿ô¤Ï·è¤·¤Æ¼ºÇÔ¤·¤Ê¤¤¡£ */
894 @brief Copy a property list.
896 The mplist_copy () function copies property list $PLIST. In the
897 copy, the values are the same as those of $PLIST.
900 This function returns a newly created plist which is a copy of
904 This function never fails. */
906 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤ò¥³¥Ô¡¼¤¹¤ë.
908 ´Ø¿ô mplist_copy () ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST
909 ¤ò¥³¥Ô¡¼¤¹¤ë¡£¥³¥Ô¡¼¤Î¤¹¤Ù¤Æ¤ÎÃͤϥ³¥Ô¡¼¸µ $PLIST ¤ÎÃͤÈƱ¤¸¤Ç¤¢¤ë¡£
912 ¤³¤Î´Ø¿ô¤Ï¿·¤·¤¯ºî¤é¤ì¤¿¡¢$PLIST ¤Î¥³¥Ô¡¼¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤òÊÖ¤¹¡£
915 ¤³¤Î´Ø¿ô¤Ï·è¤·¤Æ¼ºÇÔ¤·¤Ê¤¤¡£ */
918 mplist_copy (MPlist *plist)
920 MPlist *copy = mplist (), *pl = copy;
922 MPLIST_DO (plist, plist)
923 pl = mplist_add (pl, MPLIST_KEY (plist), MPLIST_VAL (plist));
930 @brief Set the value of a property in a property list.
932 The mplist_put () function searches property list $PLIST
933 from the beginning for a property whose key is $KEY. If such a
934 property is found, its value is changed to $VALUE. Otherwise, a
935 new property whose key is $KEY and value is $VALUE is appended at
936 the end of $PLIST. See the documentation of mplist_add () for
937 the restriction on $KEY and $VAL.
939 If $KEY is a managing key, $VAL must be a managed object. In this
940 case, the reference count of the old value, if not @c NULL, is
941 decremented by one, and that of $VAL is incremented by one.
944 If the operation was successful, mplist_put () returns a sublist of
945 $PLIST whose first element is the just modified or added one.
946 Otherwise, it returns @c NULL. */
948 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥ÈÃæ¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÀßÄꤹ¤ë.
950 ´Ø¿ô mplist_put () ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST ¤ò»Ï¤á¤«¤éõ¤·¤Æ¡¢¥¡¼¤¬
951 $KEY ¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¤ò¸«¤Ä¤±¤ë¡£¸«¤Ä¤«¤ì¤Ð¡¢¤½¤ÎÃͤò $VALUE
952 ¤ËÊѹ¹¤¹¤ë¡£¸«¤Ä¤«¤é¤Ê¤±¤ì¤Ð¡¢¥¡¼¤¬ $KEY ¤ÇÃͤ¬ $VALUE
953 ¤Ç¤¢¤ë¿·¤·¤¤¥×¥í¥Ñ¥Æ¥£¤¬ $PLIST ¤ÎËöÈø¤ËÄɲ䵤ì¤ë¡£$KEY ¤È $VAL
954 ¤ËÂФ¹¤ëÀ©¸Â¤Ë¤Ä¤¤¤Æ¤Ï¡¢mplist_add () ¤ÎÀâÌÀ¤ò»²¾È¡£
956 $KEY ¤¬´ÉÍý¥¡¼¤Ê¤é¤Ð¡¢
957 $VAL ¤Ï´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£¤³¤Î¾ì¹ç¡¢¸Å¤¤Ãͤλ²¾È¿ô¤Ï
958 @c NULL ¤Ç¤Ê¤±¤ì¤Ð 1 ¸º¤é¤µ¤ì¡¢$VAL ¤Î»²¾È¿ô¤Ï 1 Áý¤ä¤µ¤ì¤ë¡£
961 ½èÍý¤¬À®¸ù¤¹¤ì¤Ð mplist_put () ¤ÏÊѹ¹¤µ¤ì¤¿¤«Äɲ䵤줿Í×ÁǤ«¤é»Ï¤Þ¤ë
962 $PLIST ¤ÎÉôʬ¥ê¥¹¥È¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð @c NULL ¤òÊÖ¤¹¡£ */
965 mplist_put (MPlist *plist, MSymbol key, void *val)
968 MERROR (MERROR_PLIST, NULL);
969 MPLIST_FIND (plist, key);
970 if (key->managing_key)
972 if (! MPLIST_TAIL_P (plist))
973 M17N_OBJECT_UNREF (MPLIST_VAL (plist));
975 M17N_OBJECT_REF (val);
977 MPLIST_SET (plist, key, val);
984 @brief Get the value of a property in a property list.
986 The mplist_get () function searches property list $PLIST
987 from the beginning for a property whose key is $KEY. If such a
988 property is found, a pointer to its value is returned as the type
989 of <tt>(void *)</tt>. If not found, @c NULL is returned.
991 When @c NULL is returned, there are two possibilities: one is the
992 case where no property is found (see above); the other is the case
993 where a property is found and its value is @c NULL. In case that
994 these two cases must be distinguished, use the mplist_find_by_key ()
997 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥ÈÃæ¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÆÀ¤ë.
999 ´Ø¿ô mplist_get () ¤Ï¡¢¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST ¤ò»Ï¤á¤«¤éõ¤·¤Æ¡¢¥¡¼¤¬
1000 $KEY ¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¤ò¸«¤Ä¤±¤ë¡£¸«¤Ä¤«¤ì¤Ð¡¢¤½¤ÎÃͤؤΥݥ¤¥ó¥¿¤ò
1001 <tt>(void *)</tt> ·¿¤ÇÊÖ¤¹¡£¸«¤Ä¤«¤é¤Ê¤±¤ì¤Ð @c NULL ¤òÊÖ¤¹¡£
1003 @c NULL ¤¬Ê֤俺ݤˤÏÆó¤Ä¤Î²ÄǽÀ¤¬¤¢¤ë:
1004 ¾åµ¤Î¤è¤¦¤Ë¥×¥í¥Ñ¥Æ¥£¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¾ì¹ç¤È¡¢¥×¥í¥Ñ¥Æ¥£¤¬¸«¤Ä¤«¤ê¡¢¤½¤ÎÃͤ¬
1005 @c NULL ¤Ç¤¢¤ë¾ì¹ç¤Ç¤¢¤ë¡£¤³¤ì¤é¤ò¶èÊ̤¹¤ëɬÍפ¬¤¢¤ë¾ì¹ç¤Ë¤Ï´Ø¿ô
1006 mplist_find_by_key () ¤ò»È¤¦¤³¤È¡£ */
1010 mplist_find_by_key () */
1013 mplist_get (MPlist *plist, MSymbol key)
1015 MPLIST_FIND (plist, key);
1016 return (MPLIST_TAIL_P (plist) ? NULL : MPLIST_VAL (plist));
1022 @brief Add a property at the end of a property list.
1024 The mplist_add () function appends at the end of property list
1025 $PLIST a property whose key is $KEY and value is $VAL. $KEY can
1026 be any symbol other than @c Mnil.
1028 If $KEY is a managing key, $VAL must be a managed object. In this
1029 case, the reference count of $VAL is incremented by one.
1032 If the operation was successful, mplist_add () returns a sublist of
1033 $PLIST whose first element is the just added one. Otherwise, it
1036 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥ÈËöÈø¤Ë¥×¥í¥Ñ¥Æ¥£¤òÄɲ乤ë.
1038 ´Ø¿ô mplist_add () ¤Ï¡¢¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST ¤ÎËöÈø¤Ë¥¡¼¤¬ $KEY
1039 ¤ÇÃͤ¬ $VAL ¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¤òÄɲ乤롣$KEY ¤Ï¡¢@c Mnil °Ê³°¤ÎǤ°Õ¤Î¥·¥ó¥Ü¥ë¤Ç¤è¤¤¡£
1041 $KEY ¤¬´ÉÍý¥¡¼¤Ê¤é¤Ð¡¢$VAL ¤Ï´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£¤³¤Î¾ì¹ç¡¢
1042 $VAL ¤Î»²¾È¿ô¤Ï 1 Áý¤ä¤µ¤ì¤ë¡£
1045 ½èÍý¤¬À®¸ù¤¹¤ì¤Ð mplist_add () ¤ÏÄɲ䵤줿Í×ÁǤ«¤é»Ï¤Þ¤ë $PLIST
1046 ¤ÎÉôʬ¥ê¥¹¥È¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð @c NULL ¤òÊÖ¤¹¡£ */
1049 mplist_add (MPlist *plist, MSymbol key, void *val)
1052 MERROR (MERROR_PLIST, NULL);
1053 MPLIST_FIND (plist, Mnil);
1054 if (val && key->managing_key)
1055 M17N_OBJECT_REF (val);
1056 MPLIST_KEY (plist) = key;
1057 MPLIST_VAL (plist) = val;
1058 MPLIST_NEW (plist->next);
1065 @brief Add a property at the beginning of a property list.
1067 The mplist_push () function inserts at the beginning of property
1068 list $PLIST a property whose key is $KEY and value is $VAL.
1070 If $KEY is a managing key, $VAL must be a managed object. In this
1071 case, the reference count of $VAL is incremented by one.
1074 If the operation was successful, this function returns $PLIST.
1075 Otherwise, it returns @c NULL. */
1077 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤ÎÀèƬ¤Ë¥×¥í¥Ñ¥Æ¥£¤òÁÞÆþ¤¹¤ë.
1079 ´Ø¿ô mplist_push () ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST ¤ÎÀèƬ¤Ë¥¡¼¤¬ $KEY
1080 ¤ÇÃͤ¬ $VAL ¤Ç¤¢¤ë¥ª¥Ö¥¸¥§¥¯¥È¤òÁÞÆþ¤¹¤ë¡£
1082 $KEY ¤¬´ÉÍý¥¡¼¤Ê¤é¤Ð¡¢$VAL ¤Ï´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£¤³¤Î¾ì¹ç¡¢
1083 $VAL ¤Î»²¾È¿ô¤Ï 1 Áý¤ä¤µ¤ì¤ë¡£
1086 ½èÍý¤¬À®¸ù¤¹¤ì¤Ð¤³¤Î´Ø¿ô¤Ï $PLIST ¤òÊÖ¤·¡¢¤½¤¦¤Ç¤Ê¤±¤ì¤Ð@c NULL
1090 mplist_push (MPlist *plist, MSymbol key, void *val)
1095 MERROR (MERROR_PLIST, NULL);
1097 MPLIST_KEY (pl) = MPLIST_KEY (plist);
1098 MPLIST_VAL (pl) = MPLIST_VAL (plist);
1099 MPLIST_NEXT (pl) = MPLIST_NEXT (plist);
1101 if (val && key->managing_key)
1102 M17N_OBJECT_REF (val);
1103 MPLIST_KEY (plist) = key;
1104 MPLIST_VAL (plist) = val;
1111 @brief Remove a property at the beginning of a property list.
1113 The mplist_pop () function removes a property at the beginning of
1114 property list $PLIST. As a result, the second key and value of
1115 the original $PLIST become the first of those of the new $PLIST.
1118 If the operation was successful, this function return the value of
1119 the just popped property. Otherwise, it returns @c NULL. */
1121 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤ÎÀèƬ¤«¤é¥×¥í¥Ñ¥Æ¥£¤òºï½ü¤¹¤ë.
1123 ´Ø¿ô mplist_pop () ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST
1124 ¤ÎÀèƬ¤Î¥×¥í¥Ñ¥Æ¥£¤òºï½ü¤¹¤ë¡£·ë²Ì¤È¤·¤Æ¡¢¸µ¤Î $PLIST ¤Î2ÈÖÌܤΥ¡¼¤ÈÃͤ¬¡¢¿·¤·¤¤
1125 $PLIST ¤ÎÀèƬ¤Î¥¡¼¤ÈÃͤˤʤ롣
1128 ½èÍý¤ËÀ®¸ù¤¹¤ì¤Ð¡¢¤³¤Î´Ø¿ô¤Ïºï½ü¤µ¤ì¤¿¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð
1132 mplist_pop (MPlist *plist)
1137 if (MPLIST_TAIL_P (plist))
1139 val = MPLIST_VAL (plist);
1140 next = MPLIST_NEXT (plist);
1141 MPLIST_KEY (plist) = MPLIST_KEY (next);
1142 MPLIST_VAL (plist) = MPLIST_VAL (next);
1143 if (MPLIST_KEY (plist) != Mnil
1144 && MPLIST_KEY (plist)->managing_key
1145 && MPLIST_VAL (plist))
1146 M17N_OBJECT_REF (MPLIST_VAL (plist));
1147 MPLIST_NEXT (plist) = MPLIST_NEXT (next);
1149 M17N_OBJECT_REF (plist->next);
1150 M17N_OBJECT_UNREF (next);
1156 @brief Find a property of a specific key in a property list.
1158 The mplist_find_by_key () function searches property list
1159 $PLIST from the beginning for a property whose key is $KEY. If
1160 such a property is found, a sublist of $PLIST whose first element
1161 is the found one is returned. Otherwise, @c NULL is returned.
1163 If $KEY is @c Mnil, it returns a sublist of $PLIST whose
1164 first element is the last one of $PLIST. */
1166 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥ÈÃ椫¤é»ØÄê¤Î¥¡¼¤ò»ý¤Ä¥×¥í¥Ñ¥Æ¥£¤òõ¤¹.
1168 ´Ø¿ô mplist_find_by_key () ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST
1169 ¤ò»Ï¤á¤«¤éõ ¤·¤Æ¡¢¥¡¼¤¬ $KEY
1170 ¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¤ò¸«¤Ä¤±¤ë¡£¸«¤Ä¤«¤ì¤Ð¡¢¤½¤Î¥×¥í¥Ñ¥Æ¥£¤«¤é»Ï¤Þ¤ë
1171 $PLIST ¤ÎÉôʬ¥ê¥¹¥È¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð @c NULL ¤òÊÖ¤¹¡£
1173 $KEY ¤¬ @c Mnil ¤Ê¤é¤Ð¡¢$PLIST ¤ÎºÇ¸å¤ÎÍ×ÁǤ«¤é»Ï¤Þ¤ëÉôʬ¥ê¥¹¥È¤òÊÖ¤¹¡£ */
1176 mplist_find_by_key (MPlist *plist, MSymbol key)
1178 MPLIST_FIND (plist, key);
1179 return (MPLIST_TAIL_P (plist)
1180 ? (key == Mnil ? plist : NULL)
1186 @brief Find a property of a specific value in a property list.
1188 The mplist_find_by_value () function searches property list $PLIST
1189 from the beginning for a property whose value is $VAL. If such a
1190 property is found, a sublist of $PLIST whose first element is the
1191 found one is returned. Otherwise, @c NULL is returned. */
1193 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥ÈÃ椫¤é»ØÄê¤ÎÃͤò»ý¤Ä¥×¥í¥Ñ¥Æ¥£¤òõ¤¹.
1195 ´Ø¿ô mplist_find_by_value () ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST
1196 ¤ò»Ï¤á¤«¤éõ¤·¤Æ¡¢Ãͤ¬ $VAL
1197 ¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¤ò¸«¤Ä¤±¤ë¡£¸«¤Ä¤«¤ì¤Ð¡¢¤½¤Î¥×¥í¥Ñ¥Æ¥£¤«¤é»Ï¤Þ¤ë
1198 $PLIST ¤ÎÉôʬ¥ê¥¹¥È¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð @c NULL ¤òÊÖ¤¹¡£ */
1201 mplist_find_by_value (MPlist *plist, void *val)
1203 MPLIST_DO (plist, plist)
1205 if (MPLIST_VAL (plist) == val)
1214 @brief Return the next sublist of a property list.
1216 The mplist_next () function returns a pointer to the sublist of
1217 property list $PLIST, which begins at the second element in $PLIST. If the
1218 length of $PLIST is zero, it returns @c NULL. */
1220 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤Î¼¡¤ÎÉôʬ¥ê¥¹¥È¤òÊÖ¤¹.
1222 ´Ø¿ô mplist_next () ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST ¤Î 2
1223 ÈÖÌܤÎÍ×ÁǤ«¤é»Ï¤Þ¤ëÉôʬ¥ê¥¹¥È¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£$PLIST ¤ÎŤµ¤¬ 0
1224 ¤Ê¤é¤Ð @c NULL ¤òÊÖ¤¹¡£ */
1227 mplist_next (MPlist *plist)
1229 return (MPLIST_TAIL_P (plist) ? NULL : plist->next);
1235 @brief Set the first property in a property list.
1237 The mplist_set () function sets the key and the value of the first
1238 property in property list $PLIST to $KEY and $VALUE, respectively.
1239 See the documentation of mplist_add () for the restriction on $KEY
1243 If the operation was successful, mplist_set () returns $PLIST.
1244 Otherwise, it returns @c NULL. */
1246 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤ÎºÇ½é¤Î¥×¥í¥Ñ¥Æ¥£¤òÀßÄꤹ¤ë.
1248 ´Ø¿ô mplist_set () ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST
1249 ¤ÎºÇ½é¤Î¥×¥í¥Ñ¥Æ¥£¤Î¥¡¼¤ÈÃͤò¤½¤ì¤¾¤ì $KEY ¤È $VALUE ¤ËÀßÄꤹ¤ë¡£
1250 $KEY ¤È $VAL ¤ËÂФ¹¤ëÀ©¸Â¤Ë¤Ä¤¤¤Æ¤Ï¡¢mplist_add () ¤ÎÀâÌÀ¤ò»²¾È¡£
1253 ½èÍý¤ËÀ®¸ù¤¹¤ì¤Ð mplist_set () ¤Ï $PLIST ¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð @c NULL ¤òÊÖ¤¹¡£ */
1256 mplist_set (MPlist *plist, MSymbol key, void * val)
1260 if (! MPLIST_TAIL_P (plist))
1262 key = MPLIST_KEY (plist);
1263 M17N_OBJECT_UNREF (MPLIST_NEXT (plist));
1264 MPLIST_KEY (plist) = Mnil;
1265 if (key->managing_key)
1266 M17N_OBJECT_UNREF (MPLIST_VAL (plist));
1272 if (! MPLIST_TAIL_P (plist)
1273 && MPLIST_KEY (plist)->managing_key)
1274 M17N_OBJECT_UNREF (MPLIST_VAL (plist));
1275 if (val && key->managing_key)
1276 M17N_OBJECT_REF (val);
1277 MPLIST_SET (plist, key, val);
1285 @brief Return the length of a property list.
1287 The mplist_length () function returns the number of properties in
1288 property list $PLIST. */
1290 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤ÎŤµ¤òÊÖ¤¹.
1292 ´Ø¿ô mplist_length () ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST Ãæ¤Î¥×¥í¥Ñ¥Æ¥£¤Î¿ô¤òÊÖ¤¹¡£ */
1295 mplist_length (MPlist *plist)
1299 for (n = 0; ! (MPLIST_TAIL_P (plist)); n++, plist = plist->next);
1306 @brief Return the key of the first property in a property list.
1308 The mplist_key () function returns the key of the first property
1309 in property list $PLIST. If the length of $PLIST is zero,
1310 it returns @c Mnil. */
1312 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥ÈÃæ¤ÎºÇ½é¤Î¥×¥í¥Ñ¥Æ¥£¤Î¥¡¼¤òÊÖ¤¹.
1314 ´Ø¿ô mplist_key () ¤Ï¡¢¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST
1315 Ãæ¤ÎºÇ½é¤Î¥×¥í¥Ñ¥Æ¥£¤Î¥¡¼¤òÊÖ¤¹¡£$PLIST ¤ÎŤµ¤¬ 0 ¤Ê¤é¤Ð¡¢ @c Mnil
1319 mplist_key (MPlist *plist)
1321 return MPLIST_KEY (plist);
1327 @brief Return the value of the first property in a property list.
1329 The mplist_value () function returns the value of the first
1330 property in property list $PLIST. If the length of $PLIST
1331 is zero, it returns @c NULL. */
1333 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥ÈÃæ¤ÎºÇ½é¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÊÖ¤¹.
1335 ´Ø¿ô mplist_value () ¤Ï¡¢¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST Ãæ¤ÎºÇ½é¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÊÖ¤¹¡£
1336 $PLIST ¤ÎŤµ¤¬ 0 ¤Ê¤é¤Ð¡¢ @c Mnil ¤òÊÖ¤¹¡£ */
1339 mplist_value (MPlist *plist)
1341 return MPLIST_VAL (plist);
1345 @brief Generate a property list by deserializaing an M-text.
1347 The mplist_deserialize () function parses M-text $MT and returns a
1350 The syntax of $MT is as follows.
1352 MT ::= '(' ELEMENT * ')'
1354 ELEMENT ::= SYMBOL | INTEGER | M-TEXT | PLIST
1356 SYMBOL ::= ascii-character-sequence
1358 INTEGER ::= '-' ? [ '0' | .. | '9' ]+
1359 | '0x' [ '0' | .. | '9' | 'A' | .. | 'F' | 'a' | .. | 'f' ]+
1361 M-TEXT ::= '"' character-sequence '"'
1363 Each alternatives of @c ELEMENT is assigned one of these keys: @c
1364 Msymbol, @c Minteger, @c Mtext, @c Mplist
1366 In an ascii-character-sequence, a backslash (\) is used as the escape
1367 character, which means that, for instance, <tt>"abc\ def"</tt>
1368 produces a symbol whose name is of length seven with the fourth
1369 character being a space. */
1371 @brief M-text ¤ò¥Ç¥·¥ê¥¢¥é¥¤¥º¤·¤Æ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤òºî¤ë.
1373 ´Ø¿ô mplist_deserialize () ¤Ï M-text $MT ¤ò²òÀϤ·¤Æ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤òÊÖ¤¹¡£
1375 $MT ¤Î¥·¥ó¥¿¥Ã¥¯¥¹¤Ï°Ê²¼¤ÎÄ̤ꡣ
1377 MT ::= '(' ELEMENT * ')'
1379 ELEMENT ::= SYMBOL | INTEGER | M-TEXT | PLIST
1381 SYMBOL ::= ¥¢¥¹¥¡¼Ê¸»úÎó
1383 INTEGER ::= '-' ? [ '0' | .. | '9' ]+
1384 | '0x' [ '0' | .. | '9' | 'A' | .. | 'F' | 'a' | .. | 'f' ]+
1386 M-TEXT ::= '"' character-sequence '"'
1388 @c ELEMENT ¤Î³ÆÁªÂò»è¤Ï¥¡¼¡§@c Msymbol, @c Minteger, @c Mtext,
1389 @c Mplist ¤Î¤¤¤º¤ì¤«¤ò³ä¤êÅö¤Æ¤é¤ì¤Æ¤¤¤ë¡£
1391 ¥¢¥¹¥¡¼Ê¸»úÎóÆâ¤Ç¤Ï¡¢¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å (\) ¤¬¥¨¥¹¥±¡¼¥×ʸ»ú¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£¤¿¤È¤¨¤Ð
1392 <tt>"abc\ def"</tt> ¤Ï 4 ʸ»úÌܤ¬¶õÇòʸ»ú¤Ç¤¢¤êŤµ¤¬ 7
1393 ¤Ç¤¢¤ë»ý¤Ä̾Á°¤ò»ý¤Ä¥·¥ó¥Ü¥ë¤òÀ¸À®¤¹¤ë¡£ */
1396 mplist_deserialize (MText *mt)
1401 if (mt->format > MTEXT_FORMAT_UTF_8)
1403 if (MTEXT_READ_ONLY_P (mt))
1404 mt = tmp = mtext_cpy (mtext (), mt);
1406 mtext__adjust_format (mt, MTEXT_FORMAT_UTF_8);
1408 plist = mplist__from_string (MTEXT_DATA (mt), mtext_nbytes (mt));
1410 M17N_OBJECT_UNREF (tmp);
1416 /*** @addtogroup m17nDebug */
1421 @brief Dump a property list.
1423 The mdebug_dump_plist () function prints a property list $PLIST in
1424 a human readable way to the stderr. $INDENT specifies how many
1425 columns to indent the lines but the first one.
1428 This function returns $PLIST. */
1430 @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤ò¥À¥ó¥×¤¹¤ë.
1432 ´Ø¿ô mdebug_dump_plist () ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST ¤ò stderr
1433 ¤Ë¿Í´Ö¤Ë²ÄÆɤʷÁ¤Ç°õºþ¤¹¤ë¡£ $INDENT ¤Ï£²¹ÔÌܰʹߤΥ¤¥ó¥Ç¥ó¥È¤ò»ØÄꤹ¤ë¡£
1436 ¤³¤Î´Ø¿ô¤Ï $PLIST ¤òÊÖ¤¹¡£ */
1438 mdebug_dump_plist (MPlist *plist, int indent)
1440 char *prefix = (char *) alloca (indent + 1);
1444 memset (prefix, 32, indent);
1447 fprintf (stderr, "(");
1448 MPLIST_DO (pl, plist)
1453 fprintf (stderr, "\n%s ", prefix);
1454 dump_plist_element (pl, indent + 2);
1456 fprintf (stderr, ")");