Delete.
[m17n/m17n-lib.git] / src / textprop.c
index e2abb67..b7f14b9 100644 (file)
@@ -1,5 +1,5 @@
 /* textprop.c -- text property module.
-   Copyright (C) 2003, 2004
+   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H15PRO112
 
@@ -17,7 +17,7 @@
 
    You should have received a copy of the GNU Lesser General Public
    License along with the m17n library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    02111-1307, USA.  */
 
 /***en
@@ -1444,7 +1444,7 @@ mtext__adjust_plist_for_change (MText *mt, int pos, int len1, int len2)
       for (plist = mt->plist; plist; plist = plist->next)
        {
          MInterval *head = find_interval (plist, pos2);
-         MInterval *tail = mt->plist->tail;
+         MInterval *tail = plist->tail;
          MTextProperty *prop;
          int i;
 
@@ -2855,6 +2855,11 @@ mtext_serialize (MText *mt, int from, int to, MPlist *property_list)
   int n;
 
   M_CHECK_RANGE (mt, from, to, NULL, NULL);
+  if (mt->format != MTEXT_FORMAT_US_ASCII
+      && mt->format != MTEXT_FORMAT_UTF_8)
+    mtext__adjust_format (mt, MTEXT_FORMAT_UTF_8);
+  if (MTEXT_DATA (mt)[mtext_nbytes (mt)] != 0)
+    MTEXT_DATA (mt)[mtext_nbytes (mt)] = 0;
   doc = xmlParseMemory (XML_TEMPLATE, strlen (XML_TEMPLATE) + 1);
   node = xmlDocGetRootElement (doc);
 
@@ -2863,7 +2868,8 @@ mtext_serialize (MText *mt, int from, int to, MPlist *property_list)
     {
       MSymbol key = MPLIST_VAL (pl);
 
-      func = (MTextPropSerializeFunc) msymbol_get (key, Mtext_prop_serializer);
+      func = ((MTextPropSerializeFunc)
+             msymbol_get_func (key, Mtext_prop_serializer));
       if (func)
        extract_text_properties (mt, from, to, key, plist);
     }
@@ -2876,13 +2882,13 @@ mtext_serialize (MText *mt, int from, int to, MPlist *property_list)
       MPlist *serialized_plist;
       xmlNodePtr child;
 
-      func = (MTextPropSerializeFunc) msymbol_get (prop->key,
-                                                  Mtext_prop_serializer);
+      func = ((MTextPropSerializeFunc)
+             msymbol_get_func (prop->key, Mtext_prop_serializer));
       serialized_plist = (func) (prop->val);
       if (! serialized_plist)
        continue;
       mtext_reset (work);
-      mplist__serialize (work, serialized_plist);
+      mplist__serialize (work, serialized_plist, 0);
       child = xmlNewChild (node, NULL, (xmlChar *) "property", NULL);
       xmlSetProp (child, (xmlChar *) "key",
                  (xmlChar *) MSYMBOL_NAME (prop->key));
@@ -2929,7 +2935,7 @@ mtext_serialize (MText *mt, int from, int to, MPlist *property_list)
     @brief Deserialize text properties in an M-text.
 
     The mtext_deserialize () function deserializes M-text $MT.  $MT
-    must be an XML having the followng DTD.
+    must be an XML having the following DTD.
 
 @verbatim
 <!DOCTYPE mtext [
@@ -3058,7 +3064,7 @@ mtext_deserialize (MText *mt)
 
        key = msymbol ((char *) key_str);
        func = ((MTextPropDeserializeFunc)
-               msymbol_get (key, Mtext_prop_deserializer));
+               msymbol_get_func (key, Mtext_prop_deserializer));
        if (! func)
          continue;
        plist = mplist__from_string (val_str, strlen ((char *) val_str));