From: handa Date: Mon, 21 Jun 2004 00:19:01 +0000 (+0000) Subject: (mplist_deserialize): Adjust the format of MT to utf-8 X-Git-Tag: withdl~64 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e594aaded91ec539e1854f005b57b94fc0fdaff;p=m17n%2Fm17n-lib.git (mplist_deserialize): Adjust the format of MT to utf-8 if possible. Otherwise make a copy of mmt. --- diff --git a/src/plist.c b/src/plist.c index 2b346d9..bdab29e 100644 --- a/src/plist.c +++ b/src/plist.c @@ -1321,12 +1321,20 @@ mplist_value (MPlist *plist) MPlist * mplist_deserialize (MText *mt) { + MPlist *plist; + MText *tmp = NULL; + if (mt->format > MTEXT_FORMAT_UTF_8) { - if (mtext__adjust_format (mt, MTEXT_FORMAT_UTF_8) < 0) - MERROR (MERROR_PLIST, NULL); + if (MTEXT_READ_ONLY_P (mt)) + mt = tmp = mtext_cpy (mtext (), mt); + else + mtext__adjust_format (mt, MTEXT_FORMAT_UTF_8); } - return mplist__from_string (MTEXT_DATA (mt), mtext_nbytes (mt)); + plist = mplist__from_string (MTEXT_DATA (mt), mtext_nbytes (mt)); + if (tmp) + M17N_OBJECT_UNREF (tmp); + return plist; } /*** @} */