summaryrefslogtreecommitdiff
path: root/inputmethod/xcin
diff options
context:
space:
mode:
authorrxg <rxg@pkgsrc.org>2006-01-28 03:03:11 +0000
committerrxg <rxg@pkgsrc.org>2006-01-28 03:03:11 +0000
commit73a0f23706098816f6723a36c8544d202447bee2 (patch)
tree70503bc90ec4f60590933602e015849e4411fefe /inputmethod/xcin
parent88967cb9169aa91b3d306a4c60ae72e4640b335a (diff)
downloadpkgsrc-73a0f23706098816f6723a36c8544d202447bee2.tar.gz
Added chewing module support.
Taken the patches form - http://chewing.csie.net/download/xcin/xcin-chewing-20041004.diff Used PKG_SYSCONFDIR schema. Used ${PAX} to do post-install. Bump PKGREVISION.
Diffstat (limited to 'inputmethod/xcin')
-rw-r--r--inputmethod/xcin/Makefile20
-rw-r--r--inputmethod/xcin/PLIST6
-rw-r--r--inputmethod/xcin/distinfo13
-rw-r--r--inputmethod/xcin/patches/patch-aa14
-rw-r--r--inputmethod/xcin/patches/patch-ab13
-rw-r--r--inputmethod/xcin/patches/patch-ac25
-rw-r--r--inputmethod/xcin/patches/patch-ad30
-rw-r--r--inputmethod/xcin/patches/patch-ae14
-rw-r--r--inputmethod/xcin/patches/patch-af36
-rw-r--r--inputmethod/xcin/patches/patch-ag520
-rw-r--r--inputmethod/xcin/patches/patch-ah10
11 files changed, 651 insertions, 50 deletions
diff --git a/inputmethod/xcin/Makefile b/inputmethod/xcin/Makefile
index b358d3dabbb..8785b1d1cec 100644
--- a/inputmethod/xcin/Makefile
+++ b/inputmethod/xcin/Makefile
@@ -1,9 +1,9 @@
-# $NetBSD: Makefile,v 1.17 2005/07/16 19:10:39 jlam Exp $
+# $NetBSD: Makefile,v 1.18 2006/01/28 03:03:11 rxg Exp $
#
DISTNAME= xcin-2.5.3.pre2
PKGNAME= xcin-2.5.3rc2
-PKGREVISION= 4
+PKGREVISION= 5
CATEGORIES= chinese x11
MASTER_SITES= ftp://xcin.linux.org.tw/pub/xcin/xcin/devel/
@@ -18,21 +18,27 @@ USE_LIBTOOL= yes
USE_TOOLS+= perl:run
GNU_CONFIGURE= yes
+CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR:Q}
CONFIGURE_ARGS+= --with-db-lib=${BUILDLINK_PREFIX.db3}/lib
CONFIGURE_ARGS+= --with-db-inc=${BUILDLINK_PREFIX.db3}/include/db3
-post-extract:
- ${MV} ${WRKSRC}/doc/man ${WRKSRC}
+.include "../../mk/bsd.prefs.mk"
+
+INSTALLATION_DIRS= share/doc/xcin
+
+EGDIR= ${PREFIX}/share/examples/xcin
+CONF_FILES= ${EGDIR}/xcinrc ${PKG_SYSCONFDIR}/xcinrc
post-install:
- ${INSTALL_DATA_DIR} ${PREFIX}/share/doc/xcin
- cd ${WRKSRC}/doc && ${PAX} -rw * ${PREFIX}/share/doc/xcin
+ cd ${WRKSRC}/doc && ${PAX} -rw \
+ -s ',^\./man$$,,' -s ',^\./man/.*,,' \
+ . ${PREFIX}/share/doc/xcin
.include "../../converters/libiconv/buildlink3.mk"
.include "../../databases/db3/buildlink3.mk"
.include "../../devel/gettext-lib/buildlink3.mk"
+.include "../../inputmethod/libchewing/buildlink3.mk"
.include "../../inputmethod/libtabe/buildlink3.mk"
.include "../../mk/pthread.buildlink3.mk"
.include "../../mk/x11.buildlink3.mk"
-
.include "../../mk/bsd.pkg.mk"
diff --git a/inputmethod/xcin/PLIST b/inputmethod/xcin/PLIST
index 62435147bd1..c39fbc63dd6 100644
--- a/inputmethod/xcin/PLIST
+++ b/inputmethod/xcin/PLIST
@@ -1,8 +1,8 @@
-@comment $NetBSD: PLIST,v 1.2 2004/09/22 08:09:38 jlam Exp $
+@comment $NetBSD: PLIST,v 1.3 2006/01/28 03:03:11 rxg Exp $
bin/cin2tab
bin/xcin
-etc/xcinrc
lib/libxcin.la
+lib/xcin/chewing.la
lib/xcin/bimsphone.la
lib/xcin/gen_inp.la
lib/xcin/tab/big5/array30.tab
@@ -54,7 +54,9 @@ share/doc/xcin/modules/bimsphone
share/doc/xcin/modules/gen_inp
share/doc/xcin/modules/im_comm
share/doc/xcin/modules/zh_hex
+share/examples/xcin/xcinrc
${PKGLOCALEDIR}/locale/zh_TW/LC_MESSAGES/xcin.mo
+@dirrm share/examples/xcin
@dirrm share/doc/xcin/modules
@dirrm share/doc/xcin/internal
@dirrm share/doc/xcin/history
diff --git a/inputmethod/xcin/distinfo b/inputmethod/xcin/distinfo
index f03b196ade9..67acdab3184 100644
--- a/inputmethod/xcin/distinfo
+++ b/inputmethod/xcin/distinfo
@@ -1,9 +1,12 @@
-$NetBSD: distinfo,v 1.3 2005/06/26 16:45:57 rxg Exp $
+$NetBSD: distinfo,v 1.4 2006/01/28 03:03:11 rxg Exp $
SHA1 (xcin-2.5.3.pre2.tar.gz) = 27e4c47e09c44e92e3a3afc9e08134e1485f6795
RMD160 (xcin-2.5.3.pre2.tar.gz) = f1fb83d1e21a0f5dbb80c5eafdaa6c7f313ea865
Size (xcin-2.5.3.pre2.tar.gz) = 1433915 bytes
-SHA1 (patch-aa) = f192f038e048d7118ea7969b12e424b5ba9903a9
-SHA1 (patch-ab) = 36c4c9e5ec17a45db62fc08c2d07cc0a9ff72ae2
-SHA1 (patch-ac) = 1ce8c3dce665dec10db563847edfbf79ce3e5d52
-SHA1 (patch-ad) = c39bea80e15a1283e42855ea8ed25cddf8522b56
+SHA1 (patch-aa) = f08a273843fd6dc50f71c815f0cd9c8c8c0cdc40
+SHA1 (patch-ac) = a1bccd9d946d287eedf26bba4aebb89be8ee7e70
+SHA1 (patch-ad) = 6e59d32f5e3f8f06f8b4bcbb32e221678db74018
+SHA1 (patch-ae) = 13985687af55de0a6727150d41d2d6333d103689
+SHA1 (patch-af) = 23dde43647de72fb6492a51016379db88f37cdd2
+SHA1 (patch-ag) = fdb0f067f6b58648bbff7f8e0afc8cdb2703af81
+SHA1 (patch-ah) = 0bc13a5e03157cc788228162d7f212d5741c29bf
diff --git a/inputmethod/xcin/patches/patch-aa b/inputmethod/xcin/patches/patch-aa
index fba1e836959..b150a5eb4eb 100644
--- a/inputmethod/xcin/patches/patch-aa
+++ b/inputmethod/xcin/patches/patch-aa
@@ -1,12 +1,16 @@
-$NetBSD: patch-aa,v 1.1.1.1 2002/06/04 08:47:00 uebayasi Exp $
+$NetBSD: patch-aa,v 1.2 2006/01/28 03:03:11 rxg Exp $
---- etc/Makefile.in.orig Mon Mar 26 22:08:24 2001
+--- etc/Makefile.in.orig 2001-11-28 22:39:03.000000000 +0800
+++ etc/Makefile.in
-@@ -38,7 +38,6 @@
+@@ -22,9 +22,8 @@ xcinrc:
+ .PHONY: install clean distclean subsys
install: all
- if [ ! -d "$(xcin_rcp)" ]; then $(INSTALL) -d $(xcin_rcp); fi
+- if [ ! -d "$(xcin_rcp)" ]; then $(INSTALL) -d $(xcin_rcp); fi
- if [ -f $(xcin_rcp)/xcinrc ]; then mv $(xcin_rcp)/xcinrc $(xcin_rcp)/xcinrc.old; fi
- $(INSTALL_DATA) xcinrc $(xcin_rcp)
+- $(INSTALL_DATA) xcinrc $(xcin_rcp)
++ if [ ! -d "$(prefix)/share/examples/xcin" ]; then $(INSTALL) -d $(prefix)/share/examples/xcin; fi
++ $(INSTALL_DATA) xcinrc $(prefix)/share/examples/xcin
clean:
+ rm -f xcinrc
diff --git a/inputmethod/xcin/patches/patch-ab b/inputmethod/xcin/patches/patch-ab
deleted file mode 100644
index cb1eabd79d6..00000000000
--- a/inputmethod/xcin/patches/patch-ab
+++ /dev/null
@@ -1,13 +0,0 @@
-$NetBSD: patch-ab,v 1.1.1.1 2002/06/04 08:47:00 uebayasi Exp $
-
---- script/Makefile.in.orig Sun Nov 11 20:39:41 2001
-+++ script/Makefile.in
-@@ -16,7 +16,7 @@
- ( cd etc; ${MAKE} install )
- ( cd cin; ${MAKE} install )
- ( cd po; ${MAKE} install )
-- ( cd doc/man; ${MAKE} install )
-+ ( cd man; ${MAKE} install )
-
- clean:
- ( cd src; ${MAKE} clean )
diff --git a/inputmethod/xcin/patches/patch-ac b/inputmethod/xcin/patches/patch-ac
index 0bc6411d8c1..7b3f0d55c87 100644
--- a/inputmethod/xcin/patches/patch-ac
+++ b/inputmethod/xcin/patches/patch-ac
@@ -1,8 +1,8 @@
-$NetBSD: patch-ac,v 1.2 2005/06/26 16:45:57 rxg Exp $
+$NetBSD: patch-ac,v 1.3 2006/01/28 03:03:11 rxg Exp $
---- configure.orig Tue Nov 27 22:21:17 2001
+--- configure.orig 2001-11-27 22:21:17.000000000 +0800
+++ configure
-@@ -7666,7 +7666,7 @@
+@@ -7666,7 +7666,7 @@ found=n
fi
done
@@ -11,7 +11,7 @@ $NetBSD: patch-ac,v 1.2 2005/06/26 16:45:57 rxg Exp $
echo $ac_n "checking for gettext in -lintl""... $ac_c" 1>&6
echo "configure:7672: checking for gettext in -lintl" >&5
ac_lib_var=`echo intl'_'gettext | sed 'y%./+-%__p_%'`
-@@ -8619,7 +8619,7 @@
+@@ -8619,7 +8619,7 @@ sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g
$ac_vpsub
$extrasub
s%@SHELL@%$SHELL%g
@@ -20,12 +20,11 @@ $NetBSD: patch-ac,v 1.2 2005/06/26 16:45:57 rxg Exp $
s%@CPPFLAGS@%$CPPFLAGS%g
s%@CXXFLAGS@%$CXXFLAGS%g
s%@FFLAGS@%$FFLAGS%g
-@@ -8759,7 +8759,7 @@
- cin/gb/Makefile \
- etc/Makefile \
- po/Makefile \
-- doc/man/Makefile"}
-+ man/Makefile"}
- EOF
- cat >> $CONFIG_STATUS <<\EOF
- for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
+@@ -8751,6 +8751,7 @@ CONFIG_FILES=\${CONFIG_FILES-"Makefile:s
+ src/Cinput/zh_hex/Makefile \
+ src/Cinput/gen_inp/Makefile \
+ src/Cinput/bimsphone/Makefile \
++ src/Cinput/chewing/Makefile \
+ src/util/Makefile \
+ src/util/cin2tab/Makefile \
+ src/util/testprog/Makefile \
diff --git a/inputmethod/xcin/patches/patch-ad b/inputmethod/xcin/patches/patch-ad
index 942dd0ef068..12d998e2ceb 100644
--- a/inputmethod/xcin/patches/patch-ad
+++ b/inputmethod/xcin/patches/patch-ad
@@ -1,8 +1,28 @@
-$NetBSD: patch-ad,v 1.1.1.1 2002/06/04 08:47:00 uebayasi Exp $
+$NetBSD: patch-ad,v 1.2 2006/01/28 03:03:11 rxg Exp $
---- etc/xcinrc.NETBSD.orig Thu Nov 29 21:50:42 2001
+--- etc/xcinrc.NETBSD.orig 2001-11-29 21:50:42.000000000 +0800
+++ etc/xcinrc.NETBSD
-@@ -163,7 +163,7 @@
+@@ -112,7 +112,7 @@
+ (DEFAULT_IM_SINMD "DEFAULT")
+ (PHRASE "default.phr")
+ (CINPUT (cj simplex phone bimspinyin bimsphone jyutping
+- array30 jyutping0 zh_hex))
++ array30 jyutping0 chewing zh_hex))
+ (FONTSET "-sony-*-24-*-iso8859-1,-*-medium-r-*-24-*-big5-0")
+ (OVERSPOT_FONTSET "-sony-*-16-*-iso8859-1,-*-medium-r-*-16-*-big5-0")))
+ ;
+@@ -152,6 +152,10 @@
+ '((SETKEY 9)
+ (BEEP_DUPCHAR YES)))
+
++(define chewing@big5
++ '((SETKEY 10)
++ (MODULE "chewing")))
++
+
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ ;
+@@ -163,7 +167,7 @@
(DEFAULT_IM_SINMD "DEFAULT")
(PHRASE "default.phr")
(CINPUT (pinyin shuangpin jtcj_gb wubizixing phonegb2
@@ -11,7 +31,7 @@ $NetBSD: patch-ad,v 1.1.1.1 2002/06/04 08:47:00 uebayasi Exp $
(FONTSET "-sony-*-24-*-iso8859-1,-*-medium-r-*-24-*-gb2312.1980-0")
(OVERSPOT_FONTSET "-sony-*-16-*-iso8859-1,-*-medium-r-*-16-*-gb2312.1980-0")))
;
-@@ -180,7 +180,7 @@
+@@ -180,7 +184,7 @@
(define jtcj_gb@euccn
'((SETKEY 3)))
@@ -20,7 +40,7 @@ $NetBSD: patch-ad,v 1.1.1.1 2002/06/04 08:47:00 uebayasi Exp $
'((SETKEY 4)
(END_KEY YES)
(BEEP_DUPCHAR YES)))
-@@ -188,11 +188,6 @@
+@@ -188,11 +192,6 @@
(define wubizixing@euccn
'((SETKEY 5)))
diff --git a/inputmethod/xcin/patches/patch-ae b/inputmethod/xcin/patches/patch-ae
new file mode 100644
index 00000000000..efa11e09063
--- /dev/null
+++ b/inputmethod/xcin/patches/patch-ae
@@ -0,0 +1,14 @@
+$NetBSD: patch-ae,v 1.1 2006/01/28 03:03:11 rxg Exp $
+
+--- src/Cinput/chewing/.depend.orig 2006-01-21 20:19:00.000000000 +0800
++++ src/Cinput/chewing/.depend
+@@ -0,0 +1,9 @@
++#
++# PLEASE DON'T EDIT.
++#
++# This is automatically generated from "make depend".
++# You need GCC and perl to generate me.
++#
++
++xcin_chewing.lo: xcin_chewing.c ../../../config.h ../../../src/include/xcintool.h ../../../src/include/module.h
++ @$(LIBTOOL) --mode=compile $(CC) $(CFLAGS) $(DEFS) $(INC) -c -o $@ xcin_chewing.c
diff --git a/inputmethod/xcin/patches/patch-af b/inputmethod/xcin/patches/patch-af
new file mode 100644
index 00000000000..9c78f1ed949
--- /dev/null
+++ b/inputmethod/xcin/patches/patch-af
@@ -0,0 +1,36 @@
+$NetBSD: patch-af,v 1.1 2006/01/28 03:03:11 rxg Exp $
+
+--- src/Cinput/chewing/Makefile.in.orig 2006-01-21 20:23:07.000000000 +0800
++++ src/Cinput/chewing/Makefile.in
+@@ -0,0 +1,31 @@
++srcdir = @srcdir@
++top_srcdir = @top_srcdir@
++include $(top_srcdir)/Rules
++
++INC = $(xcininc) $(intl_inc) $(x_includes) \
++ -I$(top_srcdir) \
++ -DCHEWING_DATA_DIR="\"$(LOCALBASE)/share/chewing\""
++LIB = $(xcinlib) -lchewing
++TARGET = chewing.la
++
++SRC = xcin_chewing.c
++OBJ = $(SRC:.c=.lo)
++
++.PHONY: depend clean distclean
++
++all: depend $(TARGET)
++
++$(TARGET): $(OBJ)
++ $(LIBTOOL) --mode=link $(CC) -module -avoid-version -o $(TARGET) \
++ $(OBJ) $(LIB) -rpath $(moddir)
++include .depend
++
++depend:
++ $(Dep_Rule) | $(PERL) $(makedep) $(rules) LC_Rule lo > .depend
++
++clean:
++ rm -f $(OBJ) *.o $(TARGET) core *.a
++distclean: clean
++ rm -rf Makefile .libs
++install: $(TARGET)
++ $(LIBTOOL) --mode=install $(INSTALL_DATA) $(TARGET) $(xcin_modp)
diff --git a/inputmethod/xcin/patches/patch-ag b/inputmethod/xcin/patches/patch-ag
new file mode 100644
index 00000000000..cba7559c6f5
--- /dev/null
+++ b/inputmethod/xcin/patches/patch-ag
@@ -0,0 +1,520 @@
+$NetBSD: patch-ag,v 1.1 2006/01/28 03:03:11 rxg Exp $
+
+--- src/Cinput/chewing/xcin_chewing.c.orig 2006-01-21 20:32:10.000000000 +0800
++++ src/Cinput/chewing/xcin_chewing.c
+@@ -0,0 +1,515 @@
++/*
++ * Bridge interface between libchewing and xcin
++ */
++
++#ifdef HAVE_CONFIG_H
++# include "config.h"
++#endif
++
++#include <chewing/chewing.h>
++#include <string.h>
++
++#include <X11/Xlib.h>
++#include <X11/keysym.h>
++#include "xcintool.h"
++#include "module.h"
++
++#include <iconv.h>
++#include <langinfo.h>
++
++/* the following keystate masks are defined by xcin */
++#define CAPS_MASK (2)
++#define CTRL_MASK (4)
++
++#define XCIN_BYTE_NATIVE 2
++#define XCIN_BYTE_UTF8 3
++
++static int chewing_codeset;
++void preconvert(char *input, char *output, int n_char);
++wchar_t convert(wchar_t input);
++
++static char selKey_define[11] = "1234567890\0"; /* Default */
++static int bAddPhraseForward = 0;
++
++int MakeInpinfo(inpinfo_t *inpinfo, ChewingOutput *pgo);
++
++int CallSetConfig(inpinfo_t *inpinfo, ChewingData *pgdata)
++{
++ ConfigData config;
++ int i;
++
++ config.selectAreaLen = 40;
++ config.maxChiSymbolLen = 16;
++ config.bAddPhraseForward = bAddPhraseForward;
++
++ for (i = 0; i < 10;i++)
++ config.selKey[i] = selKey_define[i];
++
++ SetConfig(pgdata, &config);
++ return 0;
++}
++
++static int
++ChewingInit(void *conf, char *objname, xcin_rc_t *xc)
++{
++ char *cmd[2], kb_type_str[256];
++ ChewingConf *cf = (ChewingConf *)conf ;
++
++ char *prefix = CHEWING_DATA_DIR;
++
++ /*
++ * Because libchewing uses BIG-5 encoding for all its structure
++ * so we need to check if it is UTF-8 locale and do any conv
++ */
++ chewing_codeset = (! strcasecmp(xc->locale.encoding,"utf-8")) ?
++ XCIN_BYTE_UTF8 :
++ XCIN_BYTE_NATIVE;
++ char *cname = (char *) calloc(3, sizeof(char) * chewing_codeset);
++
++ cmd[0] = objname ;
++ cmd[1] = "KB_TYPE" ;
++ kb_type_str[0] = '\0';
++ get_resource(xc, cmd, kb_type_str, 200, 2);
++ cf->kb_type = KBStr2Num(kb_type_str);
++
++ /* Support selection key definitions */
++ cmd[1] = "SELECTION_KEYS_DEFINE";
++ if (get_resource(xc, cmd, kb_type_str, 256, 2)) {
++ if (strlen(kb_type_str) == 10) {
++ strcpy(selKey_define, kb_type_str);
++ selKey_define[11] = '\0';
++ }
++ }
++ cmd[1] = "ADD_PHRASE_FORWARD";
++ if (get_resource(xc, cmd, kb_type_str, 256, 2)) {
++ if (atoi(kb_type_str) == 1) {
++ bAddPhraseForward = 1;
++ }
++ }
++
++ preconvert("·s»Å­µ", cname, 6);
++ cf->inp_cname = strdup(cname);
++ cf->inp_ename = strdup("Chewing");
++
++ /* Initialize Chewing */
++ ReadTree(prefix);
++ InitChar(prefix);
++ InitDict(prefix);
++ ReadHash(prefix);
++
++ return True;
++}
++
++static int
++ChewingXimInit(void *conf, inpinfo_t *inpinfo)
++{
++ static char cchBuffer[MAX_PHONE_SEQ_LEN];
++ ChewingConf *cf = (ChewingConf *) conf;
++ int i;
++
++ inpinfo->iccf = (ChewingData *) calloc(1, sizeof(ChewingData));
++
++ InitChewing(inpinfo->iccf, cf);
++ CallSetConfig(inpinfo, (ChewingData *) inpinfo->iccf);
++
++ inpinfo->lcch = (wch_t *) calloc(MAX_PHONE_SEQ_LEN, sizeof(wch_t));
++ inpinfo->lcch_grouping = (ubyte_t *) calloc(MAX_PHONE_SEQ_LEN, sizeof(ubyte_t));
++ inpinfo->cch = cchBuffer;
++
++ inpinfo->inp_cname = cf->inp_cname;
++ inpinfo->inp_ename = cf->inp_ename;
++ inpinfo->area3_len = 2 * ZUIN_SIZE + 4;
++ inpinfo->guimode = GUIMOD_LISTCHAR | GUIMOD_SELKEYSPOT;
++ inpinfo->keystroke_len = 0;
++ inpinfo->s_keystroke = (wch_t *) calloc(3 + MAX_PHRASE_LEN, sizeof(wch_t));
++
++ inpinfo->mcch = (wch_t *) calloc(MAX_CHOICE_BUF, sizeof(wch_t));
++ inpinfo->mcch_grouping = (ubyte_t *) calloc( MAX_SELKEY, sizeof(ubyte_t));
++ inpinfo->n_mcch = 0;
++
++ inpinfo->n_lcch = 0;
++ inpinfo->edit_pos = 0;
++ inpinfo->cch_publish.wch = (wchar_t) 0;
++
++ // check_winsize(inpinfo, iccf);
++ // [yet] check winsize is under construction.
++
++ inpinfo->n_selkey = 10;
++ inpinfo->s_selkey = (wch_t *) calloc(MAX_SELKEY, sizeof(wch_t));
++
++ for (i = 0; i < 10; i++) {
++ inpinfo->s_selkey[i].wch = (wchar_t) 0;
++ inpinfo->s_selkey[i].s[0] = selKey_define[i];
++ }
++
++ return True;
++}
++
++void CommitString(inpinfo_t *inpinfo, ChewingOutput *pgo)
++{
++ int i ;
++ char *str;
++ char *output;
++ memset(inpinfo->cch, 0, sizeof(char)*MAX_PHONE_SEQ_LEN);
++ str = (char *) calloc(MAX_PHONE_SEQ_LEN,sizeof(char));
++ output = (char *) calloc(MAX_PHONE_SEQ_LEN / 2 * chewing_codeset, sizeof(char));
++ for (i = 0; i < pgo->nCommitStr; i++)
++ strcat(str, (const char *) pgo->commitStr[i].s);
++ preconvert(str, output, strlen(str));
++ strcat(inpinfo->cch, output);
++ free(str);
++ free(output);
++}
++
++static unsigned int
++ChewingXimEnd(void *conf, inpinfo_t *inpinfo)
++{
++ ChewingOutput gOut ;
++ int rtn ;
++
++ /* if preedit exists, commit the string */
++ OnKeyEnter(inpinfo->iccf, &gOut);
++
++ rtn = MakeInpinfo(inpinfo, &gOut);
++ free(inpinfo->iccf);
++ free(inpinfo->s_keystroke);
++ free(inpinfo->lcch);
++ free(inpinfo->mcch);
++ free(inpinfo->mcch_grouping);
++
++ inpinfo->iccf = NULL;
++ inpinfo->s_keystroke = NULL;
++ inpinfo->lcch = NULL;
++
++ return rtn ;
++}
++
++void ShowChoose(inpinfo_t *inpinfo, ChoiceInfo *pci, ChewingOutput *pgo)
++{
++ int i,no,k,len, kk;
++ char *output;
++
++ // for new xcin, there is no need to modify the lcch buffer
++ // instead, we put phrase to choose in mcch
++ no = pci->pageNo * pci->nChoicePerPage;
++ len = 0;
++
++ for (i = 0;i < pci->nChoicePerPage; no++,i++) {
++
++ // in the last page, no will exceed nTotalChoice
++ if( no >= pci->nTotalChoice )
++ break;
++ output = (char *) calloc(
++ strlen(pci->totalChoiceStr[no]) * chewing_codeset + 1,
++ sizeof(char));
++ preconvert(
++ pci->totalChoiceStr[no], output,
++ strlen(pci->totalChoiceStr[no]));
++ // for each char in the phrase, copy to mcch
++ for (k = 0, kk = 0; output[k] != '\0'; k += chewing_codeset, kk++) {
++ memcpy(inpinfo->mcch[len++].s, &(output[k]), chewing_codeset) ;
++ }
++ free(output);
++ // set grouping to the length of the phrase
++ inpinfo->mcch_grouping[i+1] = kk;
++ }
++ // i stores how many choices are available
++ inpinfo->mcch_grouping[0] = i;
++
++ // set pgstate according to pci->pageNo & pci->nPage
++ if( pci->nPage == 1) {
++ inpinfo->mcch_pgstate = MCCH_ONEPG;
++ }
++ else {
++ if( pci->pageNo == 0 )
++ inpinfo->mcch_pgstate = MCCH_BEGIN;
++ else if( pci->pageNo == pci->nPage - 1)
++ inpinfo->mcch_pgstate = MCCH_END;
++ else
++ inpinfo->mcch_pgstate = MCCH_MIDDLE;
++ }
++
++ inpinfo->n_mcch = len ;
++}
++
++void ShowText(inpinfo_t *inpinfo, ChewingOutput *pgo)
++{
++ int i;
++ memset(inpinfo->lcch, 0, sizeof(wch_t)*MAX_PHONE_SEQ_LEN) ;
++ for (i = 0; i < pgo->chiSymbolBufLen; i++)
++ pgo->chiSymbolBuf[i].wch = convert(pgo->chiSymbolBuf[i].wch);
++ memcpy(inpinfo->lcch, pgo->chiSymbolBuf, sizeof(wch_t) * pgo->chiSymbolBufLen) ;
++ inpinfo->n_lcch = pgo->chiSymbolBufLen ;
++}
++
++void ShowInterval(inpinfo_t *inpinfo, ChewingOutput *pgo)
++{
++ int i, k, begin, len, count, nGroup ;
++ int label[MAX_PHONE_SEQ_LEN] ;
++
++ if( pgo->chiSymbolBufLen == 0) {
++ inpinfo->lcch_grouping[0] = 0 ;
++ return ;
++ }
++
++ // set label
++ for(count=0; count<pgo->chiSymbolBufLen; count++)
++ label[count] = count ;
++
++ for(i=0; i<pgo->nDispInterval; i++) {
++ len = pgo->dispInterval[i].to - pgo->dispInterval[i].from ;
++
++ if( len > 1) {
++ for(k=pgo->dispInterval[i].from; k<pgo->dispInterval[i].to; k++)
++ label[k] = count ;
++ count++ ;
++ }
++ }
++
++ // begin to set lcch_grouping by the label
++ nGroup = 0 ;
++ begin = 0 ;
++ for(i=1; i<pgo->chiSymbolBufLen; i++) {
++ if( label[i] != label[begin] ) {
++ inpinfo->lcch_grouping[++nGroup] = ( i - begin ) ;
++ begin = i ;
++ }
++ }
++ inpinfo->lcch_grouping[++nGroup] = ( i - begin ) ;
++ inpinfo->lcch_grouping[0] = nGroup ;
++}
++
++void ShowStateAndZuin(inpinfo_t *inpinfo, ChewingOutput *pgo)
++{
++ int i, a , len = 0;
++ memset( inpinfo->s_keystroke, 0, sizeof(wch_t)*(3 + MAX_PHRASE_LEN)) ;
++ if(pgo->bShowMsg) {
++ for(i = 0; i < pgo->showMsgLen; i++)
++ pgo->showMsg[i].wch = convert(pgo->showMsg[i].wch);
++ memcpy( inpinfo->s_keystroke, pgo->showMsg, sizeof(wch_t)*pgo->showMsgLen) ;
++ inpinfo->keystroke_len = pgo->showMsgLen ;
++ }
++ else {
++ /* if(pgo->bChiSym)
++ strcpy( (char *)inpinfo->s_keystroke[0].s, "¤¤") ;
++ else
++ strcpy( (char *)inpinfo->s_keystroke[0].s, "­^") ;
++
++ inpinfo->s_keystroke[1].s[0] = ' ' ;
++ for(i=0,a=2; i<ZUIN_SIZE; i++) */
++ for(i=0,a=0; i<ZUIN_SIZE; i++)
++ if(pgo->zuinBuf[i].s[0] != '\0') {
++ inpinfo->s_keystroke[a++].wch = convert(
++ pgo->zuinBuf[i].wch) ;
++ ++ len;
++ }
++ inpinfo->keystroke_len = len;
++ }
++}
++
++void SetCursor(inpinfo_t *inpinfo, ChewingOutput *pgo)
++{
++ inpinfo->edit_pos = pgo->chiSymbolCursor;
++}
++
++int MakeInpinfo(inpinfo_t *inpinfo, ChewingOutput *pgo)
++{
++ int rtnValue = 0 ;
++
++ if(pgo->keystrokeRtn & KEYSTROKE_ABSORB)
++ rtnValue |= IMKEY_ABSORB;
++ if(pgo->keystrokeRtn & KEYSTROKE_IGNORE)
++ rtnValue |= IMKEY_IGNORE;
++ if(pgo->keystrokeRtn & KEYSTROKE_BELL)
++ rtnValue |= IMKEY_BELL;
++ if(pgo->keystrokeRtn & KEYSTROKE_COMMIT) {
++ rtnValue |= IMKEY_COMMIT;
++ CommitString(inpinfo, pgo);
++ }
++
++ if(pgo->pci->nPage != 0) { // in selection mode
++ ShowChoose(inpinfo,pgo->pci,pgo);
++ inpinfo->guimode &= ~GUIMOD_LISTCHAR;
++ }
++ else { // not in selection mode
++ ShowText(inpinfo, pgo);
++ ShowInterval(inpinfo, pgo);
++ inpinfo->guimode |= GUIMOD_LISTCHAR;
++ }
++ ShowStateAndZuin(inpinfo, pgo);
++ SetCursor(inpinfo, pgo);
++ return rtnValue;
++}
++
++static unsigned int
++ChewingKeystroke(void *conf, inpinfo_t *inpinfo, keyinfo_t *keyinfo)
++{
++ KeySym keysym = keyinfo->keysym;
++ ChewingOutput gOut ;
++ int rtn ;
++ static KeySym last_key = 0;
++
++ // set Chinese / English mode by keystate
++ if( keyinfo->keystate & CAPS_MASK ) { // uppercase
++ SetChiEngMode( inpinfo->iccf, SYMBOL_MODE);
++ }
++ else { // lower case
++ SetChiEngMode( inpinfo->iccf, CHINESE_MODE);
++ }
++
++
++ // check no ctrl key was pressed
++ if(keyinfo->keystate >= 0 && !(keyinfo->keystate & CTRL_MASK ) && !(keyinfo->keystate & ShiftMask) ) {
++ switch(keysym) {
++ case XK_Escape:
++ OnKeyEsc(inpinfo->iccf, &gOut) ;
++ inpinfo->n_mcch = 0;
++ break ;
++ case XK_Return:
++ OnKeyEnter(inpinfo->iccf, &gOut) ;
++ inpinfo->n_mcch = 0;
++ break ;
++ case XK_Delete:
++ OnKeyDel(inpinfo->iccf, &gOut) ;
++ break ;
++ case XK_BackSpace:
++ OnKeyBackspace(inpinfo->iccf, &gOut) ;
++ break ;
++ case XK_Up:
++ OnKeyUp(inpinfo->iccf, &gOut);
++ break ;
++ case XK_Down:
++ OnKeyDown(inpinfo->iccf, &gOut) ;
++ break ;
++ case XK_Left:
++ OnKeyLeft(inpinfo->iccf, &gOut) ;
++ break ;
++ case XK_Right:
++ OnKeyRight(inpinfo->iccf, &gOut) ;
++ break ;
++ case XK_Home:
++ OnKeyHome(inpinfo->iccf, &gOut);
++ break;
++ case XK_End:
++ OnKeyEnd(inpinfo->iccf, &gOut);
++ break;
++
++ case XK_Tab:
++ if (last_key == XK_Tab) // double click TAB
++ OnKeyDblTab(inpinfo->iccf, &gOut);
++ else
++ OnKeyTab(inpinfo->iccf, &gOut);
++ break;
++ case XK_Caps_Lock:
++ OnKeyCapslock(inpinfo->iccf, &gOut);
++ break;
++ case ' ': /* Space */
++ OnKeySpace(inpinfo->iccf, &gOut);
++ break;
++ default:
++ OnKeyDefault(inpinfo->iccf, keysym, &gOut);
++ inpinfo->n_mcch = 0;
++ break;
++ }
++ }
++ else if (keyinfo->keystate & ShiftMask) {
++ switch ( keysym ) {
++ case XK_Left:
++ OnKeyShiftLeft(inpinfo->iccf, &gOut) ;
++ break ;
++ case XK_Right:
++ OnKeyShiftRight(inpinfo->iccf, &gOut) ;
++ break;
++ default:
++ OnKeyDefault(inpinfo->iccf, keysym, &gOut);
++ inpinfo->n_mcch = 0;
++ }
++ }
++ else if (keyinfo->keystate & CTRL_MASK) { // Ctrl-key Mask
++ // We need to fill the 'gOut' variable for output.
++ if (keysym <= '9' && keysym >= '0')
++ OnKeyCtrlNum(inpinfo->iccf,keysym,&gOut);
++ else
++ OnKeyCtrlOption(inpinfo->iccf, keysym - 'a' + 1, &gOut);
++ }
++
++
++ last_key = keysym;
++ rtn = MakeInpinfo(inpinfo, &gOut);
++ return rtn ;
++}
++
++static int
++ChewingShowKeystroke(void *conf, simdinfo_t *simdinfo)
++{
++ simdinfo->s_keystroke = NULL;
++ return False;
++}
++
++/* UTF-8 support */
++void
++preconvert(char *input, char *output, int n_char)
++{
++ if (chewing_codeset == XCIN_BYTE_UTF8) {
++ const char *inptr = input;
++ size_t inbytesleft = n_char;
++ size_t outbytesleft = n_char / 2 * 3 + 1;
++
++ char *outptr = output;
++ iconv_t cd;
++
++ cd = iconv_open("UTF-8", "BIG-5");
++ iconv (cd, (char **)&inptr, &inbytesleft, &outptr, &outbytesleft);
++
++ iconv_close(cd);
++ } else
++ strncpy(output, input, n_char);
++}
++
++wchar_t
++convert(wchar_t input)
++{
++ wch_t output;
++ wch_t temp;
++
++ temp.wch = input;
++ if (chewing_codeset == XCIN_BYTE_UTF8) {
++ const char *inptr = temp.s;
++ size_t inbytesleft = 2;
++ size_t outbytesleft = 3;
++ char *outptr = output.s;
++ iconv_t cd;
++ cd = iconv_open("UTF-8", "BIG-5");
++ iconv (cd, (char **)&inptr, &inbytesleft, &outptr, &outbytesleft);
++ iconv_close(cd);
++ output.s[3] = '\0';
++ return output.wch;
++ }
++
++ return input;
++}
++
++static char zh_chewing_comments[] =
++ "Chewing : a smart phonetic input method module for XCIN.\n"
++ "By Lu-chuan Kung <lckung@iis.sinica.edu.tw>,\n"
++ "Kang-pen Chen <kpchen@iis.sinica.edu.tw>, and others.\n";
++
++static char *zh_chewing_valid_objname[] = { "chewing", NULL };
++
++module_t module_ptr = {
++ {
++ MTYPE_IM,
++ "zh_chewing", /* name */
++ MODULE_VERSION, /* version */
++ zh_chewing_comments
++ }, /* comments */
++ zh_chewing_valid_objname, /* valid_objname */
++ sizeof(ChewingConf), /* conf_size */
++ ChewingInit, /* init */
++ ChewingXimInit, /* xim_init */
++ ChewingXimEnd, /* xim_end */
++ ChewingKeystroke, /* keystroke */
++ ChewingShowKeystroke, /* show_keystroke */
++ NULL
++};
++
diff --git a/inputmethod/xcin/patches/patch-ah b/inputmethod/xcin/patches/patch-ah
new file mode 100644
index 00000000000..12f854617c2
--- /dev/null
+++ b/inputmethod/xcin/patches/patch-ah
@@ -0,0 +1,10 @@
+$NetBSD: patch-ah,v 1.1 2006/01/28 03:03:11 rxg Exp $
+
+--- src/Cinput/Makefile.in.orig 2006-01-21 20:37:01.000000000 +0800
++++ src/Cinput/Makefile.in
+@@ -1,4 +1,4 @@
+-SUBSYS = zh_hex gen_inp bimsphone
++SUBSYS = zh_hex gen_inp bimsphone chewing
+ OTHERS = im_comm
+
+ .PHONY: depend subdirs clean distclean install