Don't include word-thai.h.
[m17n/m17n-lib.git] / src / mtext.c
index d71cd1c..363bf2d 100644 (file)
@@ -93,9 +93,6 @@
 #include "character.h"
 #include "mtext.h"
 #include "plist.h"
-#ifdef HAVE_THAI_WORDSEG
-#include "word-thai.h"
-#endif
 
 static M17NObjectArray mtext_table;
 
@@ -690,18 +687,12 @@ case_compare (MText *mt1, int from1, int to1, MText *mt2, int from2, int to2)
 \f
 /* Internal API */
 
-MCharTable *wordseg_func_table;
-
 int
 mtext__init ()
 {
   M17N_OBJECT_ADD_ARRAY (mtext_table, "M-text");
   M_charbag = msymbol_as_managing_key ("  charbag");
   mtext_table.count = 0;
-  wordseg_func_table = mchartable (Mnil, NULL);
-#ifdef HAVE_THAI_WORDSEG
-  mtext__word_thai_init ();
-#endif
   return 0;
 }
 
@@ -709,11 +700,7 @@ mtext__init ()
 void
 mtext__fini (void)
 {
-#ifdef HAVE_THAI_WORDSEG
-  mtext__word_thai_fini ();
-#endif
-  M17N_OBJECT_UNREF (wordseg_func_table);
-  wordseg_func_table = NULL;
+  mtext__wseg_fini ();
 }
 
 
@@ -1124,22 +1111,6 @@ mtext__eol (MText *mt, int pos)
     }
 }
 
-typedef int (*MTextWordsegFunc) (MText *mt, int pos, int *from, int *to);
-
-int
-mtext__word_segment (MText *mt, int pos, int *from, int *to)
-{
-  int c = mtext_ref_char (mt, pos);
-  MTextWordsegFunc func
-    = (MTextWordsegFunc) mchartable_lookup (wordseg_func_table, c);
-
-  if (func)
-    return (func) (mt, pos, from, to);
-  *from = *to = pos;
-  return -1;
-}
-
-
 /*** @} */
 #endif /* !FOR_DOXYGEN || DOXYGEN_INTERNAL_MODULE */
 
@@ -1650,19 +1621,7 @@ mtext_cat_char (MText *mt, int c)
 MText *
 mtext_dup (MText *mt)
 {
-  MText *new = mtext ();
-  int unit_bytes = UNIT_BYTES (mt->format);
-
-  *new = *mt;
-  if (mt->nchars > 0)
-    {
-      new->allocated = (mt->nbytes + 1) * unit_bytes;
-      MTABLE_MALLOC (new->data, new->allocated, MERROR_MTEXT);
-      memcpy (new->data, mt->data, new->allocated);
-      if (mt->plist)
-       new->plist = mtext__copy_plist (mt->plist, 0, mt->nchars, new, 0);
-    }
-  return new;
+  return mtext_duplicate (mt, 0, mtext_nchars (mt));
 }
 
 /*=*/
@@ -2174,7 +2133,7 @@ mtext_ins_char (MText *mt, int pos, int c, int n)
   if (mt->cache_char_pos > pos)
     {
       mt->cache_char_pos += n;
-      mt->cache_byte_pos += nunits + n;
+      mt->cache_byte_pos += nunits * n;
     }
   memmove (mt->data + (pos_unit + nunits * n) * unit_bytes,
           mt->data + pos_unit * unit_bytes,