From 9e594aaded91ec539e1854f005b57b94fc0fdaff Mon Sep 17 00:00:00 2001 From: handa Date: Mon, 21 Jun 2004 00:19:01 +0000 Subject: [PATCH] (mplist_deserialize): Adjust the format of MT to utf-8 if possible. Otherwise make a copy of mmt. --- src/plist.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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; } /*** @} */ -- 1.7.10.4