If the key of a property is a @e managing @e key, its @e value is
a @e managed @e object. A property list itself is a managed
- objects. */
+ objects.
+
+ If each key of a plist is one of #Msymbol, #Mtext, #Minteger, and
+ #Mplist, the plist is called as @e well-formed and represented by
+ the following notation in the documentation.
+
+@verbatim
+ PLIST ::= '(' ELEMENT * ')'
+
+ ELEMENT ::= INTEGER | SYMBOL | M-TEXT | PLIST
+
+ M-TEXT ::= '"' text data ... '"'
+@endverbatim
+
+ For instance, if a plist has four elements; integer -20, symbol of
+ name "sym", M-text of contents "abc", and plist of integer 10 and
+ symbol of name "another-symbol", it is represented as this:
+
+ (-20 sym "abc" (10 another-symbol))
+
+ */
/***ja
@addtogroup m17nPlist
}
-/** Read an integer element from ST, and add it to LIST. Return a
- list for the next element. It is assumed that we have already
- read the character C. */
-
-static MPlist *
-read_integer_element (MPlist *plist, MStream *st, int c, int skip)
-{
- int num;
-
- if (c == '0' || c == '#')
- {
- c = GETC (st);
- if (c == 'x')
- num = read_hexadesimal (st);
- else
- num = read_decimal (st, c);
- }
- else if (c == '?')
- {
- c = GETC (st);
- if (c == EOF)
- num = 0;
- else if (c != '\\')
- {
- if (c < 128 || ! CHAR_UNITS_BY_HEAD_UTF8 (c))
- num = c;
- else
- num = read_character (st, c);
- }
- else
- {
- c = GETC (st);
- if (c == EOF)
- num = '\\';
- else if (c < 128 || ! CHAR_UNITS_BY_HEAD_UTF8 (c))
- num = escape_mnemonic[c];
- else
- num = read_character (st, c);
- }
- }
- else if (c == '-')
- num = - read_decimal (st, GETC (st));
- else
- num = read_decimal (st, c);
-
- if (! skip)
- MPLIST_SET_ADVANCE (plist, Minteger, (void *) num);
- return plist;
-}
-
/** Read a symbol element from ST, and add it to LIST. Return a list
for the next element. */
static MPlist *
-read_symbol_element (MPlist *plist, MStream *st, int skip)
+read_symbol_element (MPlist *plist, MStream *st, int c, int skip)
{
unsigned char buffer[1024];
int bufsize = 1024;
unsigned char *buf = buffer;
- int c, i;
+ int i;
i = 0;
- while ((c = GETC (st)) != EOF
+ while (c != EOF
&& c > ' '
&& c != ')' && c != '(' && c != '"')
{
}
if (! skip)
buf[i++] = c;
+ c = GETC (st);
}
if (c > ' ')
return plist;
}
+/** Read an integer element from ST, and add it to LIST. Return a
+ list for the next element. It is assumed that we have already
+ read the character C. */
+
+static MPlist *
+read_integer_element (MPlist *plist, MStream *st, int c, int skip)
+{
+ int num;
+
+ if (c == '#')
+ {
+ c = GETC (st);
+ if (c != 'x')
+ {
+ UNGETC (c, st);
+ return read_symbol_element (plist, st, '#', skip);
+ }
+ num = read_hexadesimal (st);
+ }
+ else if (c == '0')
+ {
+ c = GETC (st);
+ num = (c == 'x' ? read_hexadesimal (st) : read_decimal (st, c));
+ }
+ else if (c == '?')
+ {
+ c = GETC (st);
+ if (c == EOF)
+ num = 0;
+ else if (c != '\\')
+ {
+ if (c < 128 || ! CHAR_UNITS_BY_HEAD_UTF8 (c))
+ num = c;
+ else
+ num = read_character (st, c);
+ }
+ else
+ {
+ c = GETC (st);
+ if (c == EOF)
+ num = '\\';
+ else if (c < 128 || ! CHAR_UNITS_BY_HEAD_UTF8 (c))
+ num = escape_mnemonic[c];
+ else
+ num = read_character (st, c);
+ }
+ }
+ else if (c == '-')
+ {
+ c = GETC (st);
+ if (c < '0' || c > '9')
+ {
+ UNGETC (c, st);
+ return read_symbol_element (plist, st, '-', skip);
+ }
+ num = - read_decimal (st, c);
+ }
+ else
+ num = read_decimal (st, c);
+
+ if (! skip)
+ MPLIST_SET_ADVANCE (plist, Minteger, (void *) num);
+ return plist;
+}
+
/* Read an element of various type from stream ST, and add it to LIST.
Return a list for the next element. The element type is decided by
the first token character found as below:
return (read_integer_element (plist, st, c, keys ? 1 : 0));
if (c == EOF || c == ')')
return NULL;
- UNGETC (c, st);
- return (read_symbol_element (plist, st, keys ? 1 : 0));
+ return (read_symbol_element (plist, st, c, keys ? 1 : 0));
}
void