/* mtext.c -- M-text module.
- Copyright (C) 2003, 2004
+ Copyright (C) 2003, 2004, 2005
National Institute of Advanced Industrial Science and Technology (AIST)
Registration Number H15PRO112
#include "character.h"
#include "mtext.h"
#include "plist.h"
+#include "word-thai.h"
static M17NObjectArray mtext_table;
\f
/* Internal API */
+MCharTable *wordseg_func_table;
+
int
mtext__init ()
{
M_charbag = msymbol_as_managing_key (" charbag");
mtext_table.count = 0;
+ wordseg_func_table = mchartable (Mnil, NULL);
+ mtext__word_thai_init ();
return 0;
}
void
mtext__fini (void)
{
+ mtext__word_thai_fini ();
+ M17N_OBJECT_UNREF (wordseg_func_table);
+ wordseg_func_table = NULL;
mdebug__report_object ("M-text", &mtext_table);
}
}
}
+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 */