slackbuilds_ponce/libraries/libchewing/libchewing-rev1048.patch
Guan-Zhong Huang 5a9673ed28 libraries/libchewing: Added patch for ibus-chewing.
Signed-off-by: dsomero <xgizzmo@slackbuilds.org>
2010-07-06 02:33:54 -05:00

235 lines
6.4 KiB
Diff
Raw Blame History

Index: test/randkeystroke.c
===================================================================
--- test/randkeystroke.c (revision 1038)
+++ test/randkeystroke.c (revision 1048)
@@ -46,6 +46,7 @@
printf( "usage: randkeystroke [-r] [-n num] [-h]\n" \
"\t -r - total random\n" \
"\t -n num - generate num keystrokes\n"
+ "\t -s seed - random seed\n"
"\t -h - help\n" );
}
@@ -63,6 +64,9 @@
nk = atoi( argv[i] );
} else if ( ! strcmp( argv[i], "-r" ) ) {
total_random = 1;
+ } else if ( ! strcmp( argv[i], "-s" ) ) {
+ if ( ++i < argc )
+ srand( atoi( argv[i] ) );
} else if ( ! strcmp( argv[i], "-h" ) ) {
usage();
return 0;
@@ -71,7 +75,7 @@
if (total_random) {
for ( i = 0; i < nk; i++ ) {
n = rand() % (n_nkeys + n_okeys);
- if ( n > n_nkeys )
+ if ( n >= n_nkeys )
printf( "%s", other_keys[n - n_nkeys] );
else
printf( "%c", normal_keys[n] );
@@ -97,4 +101,5 @@
return 0;
}
-/* vim: noet */
+/* vim: noet
+ */
Index: python/chewing.py
===================================================================
--- python/chewing.py (revision 1038)
+++ python/chewing.py (revision 1048)
@@ -2,9 +2,11 @@
from functools import partial
_libchewing = CDLL('libchewing.so.3')
-_libchewing.chewing_handle_Default.argtypes = [c_void_p, c_char]
_libchewing.chewing_commit_String.restype = c_char_p
_libchewing.chewing_buffer_String.restype = c_char_p
+_libchewing.chewing_cand_String.restype = c_char_p
+_libchewing.chewing_zuin_String.restype = c_char_p
+_libchewing.chewing_aux_String.restype = c_char_p
def Init(datadir, userdir):
return _libchewing.chewing_Init(datadir, userdir)
Index: src/tree.c
===================================================================
--- src/tree.c (revision 1038)
+++ src/tree.c (revision 1048)
@@ -285,25 +285,16 @@
for ( i = begin; i <= end; i++ ) {
for (
child = tree[ tree_p ].child_begin;
- child <= tree[ tree_p ].child_end;
+ child != -1 && child <= tree[ tree_p ].child_end;
child++ ) {
-#ifdef USE_BINARY_DATA
- /**
- * This is a workaround to prevent access violation.
- *
- * Sometimes, child < 0 and tree[ child ] refer to an invalid
- * address for unknown reason.This could be a bug of libchewing.
- * This serious bug was discovered by seamxr.
- */
- if ( child < 0 || child * sizeof(TreeType) > tree_size )
- return -1;
-#endif
+ assert(0 <= child && child * sizeof(TreeType) < tree_size);
+
if ( tree[ child ].phone_id == phoneSeq[ i ] )
break;
}
/* if not found any word then fail. */
- if ( child > tree[ tree_p ].child_end )
+ if ( child == -1 || child > tree[ tree_p ].child_end )
return -1;
else {
tree_p = child;
Index: src/mod_aux.c
===================================================================
--- src/mod_aux.c (revision 1038)
+++ src/mod_aux.c (revision 1048)
@@ -90,7 +90,7 @@
if ( ctx->output->zuinBuf[ i ].s[ 0 ] != '\0' ) {
strcat( s, (char *) (ctx->output->zuinBuf[ i ].s) );
if ( zuin_count )
- *zuin_count++;
+ (*zuin_count)++;
}
}
return s;
Index: scripts/gen-tabe-diff.sh
===================================================================
--- scripts/gen-tabe-diff.sh (revision 1038)
+++ scripts/gen-tabe-diff.sh (revision 1048)
@@ -1,19 +0,0 @@
-#!/bin/sh
-
-if [ ! -f scripts/gen-tabe-diff.sh ]; then
- echo -e "\033[44;37m You *MUST* run this script in top dir. \033[m"
- exit
-fi
-
-if [ ! -f data/tabe-tsi.src ]; then
- echo -e "\033[44;37m tabe-tsi.src not found. Try to generate. \033[m"
- sh ./scripts/cvsup-tsi-src.sh
-fi
-
-# compare
-sort data/tsi.src | cut --delimiter=' ' -f1 > /tmp/orig-tsi
-sort data/tabe-tsi.src | cut --delimiter=' ' -f1 > /tmp/tabe-tsi
-diff -u /tmp/orig-tsi /tmp/tabe-tsi > tabe-tsi.diff
-rm -f /tmp/orig-tsi /tmp/tabe-tsi
-
-echo -e "\033[44;37m Please check out tabe-tsi.diff \033[m"
Index: scripts/tsi-chewing.diff
===================================================================
--- scripts/tsi-chewing.diff (revision 1038)
+++ scripts/tsi-chewing.diff (revision 1048)
@@ -1,51 +0,0 @@
---- tsidump.c 2004-05-12 23:30:19.000000000 +0800
-+++ tsidump-chewing.c 2004-05-12 23:29:12.000000000 +0800
-@@ -65,32 +65,23 @@
- }
- i++;
- len = strlen((char *)tsi->tsi)/2;
-- fprintf(fp, "%s", tsi->tsi);
-- if (ref) {
-- fprintf(fp, " %ld", tsi->refcount);
-- }
- if (tsiyin) {
- ZuYinSymbolSequence zs = NULL;
-- int begin = 0;
-
-- fprintf(fp, " ");
- for (j = 0; j < tsi->yinnum; j++) {
-+ if (len > 7)
-+ continue;
-+ fprintf(fp, "%s %ld\t", tsi->tsi, tsi->refcount);
- for (k = 0; k < len; k++) {
- zs = tabeYinToZuYinSymbolSequence(tsi->yindata[j*len+k]);
- if (zs) {
-- if (begin) {
-- fprintf(fp, "<22>@");
-- }
-- else {
-- begin = 1;
-- }
-- fprintf(fp, "%s", zs);
-+ fprintf(fp, "%s ", zs);
- free(zs);
- }
- }
-+ fprintf(fp, "\n");
- }
- }
-- fprintf(fp, "\n");
- }
-
- db->Close(db);
-@@ -109,8 +100,8 @@
- char *db_name, *op_name;
-
- db_name = op_name = (char *)NULL;
-- ref = 0;
-- tsiyin = 0;
-+ ref = 1;
-+ tsiyin = 1;
-
- while ((ch = getopt(argc, argv, "d:f:ry")) != -1) {
- switch(ch) {
Index: scripts/cvsup-tsi-src.sh
===================================================================
--- scripts/cvsup-tsi-src.sh (revision 1038)
+++ scripts/cvsup-tsi-src.sh (revision 1048)
@@ -1,48 +0,0 @@
-#!/bin/sh
-
-TOP=`pwd`
-TABE_TSI=$TOP/data/tabe-tsi.src
-
-if [ ! -f scripts/cvsup-tsi-src.sh ]; then
- echo -e "\033[44;37m You *MUST* run this script in top dir. \033[m"
- exit
-fi
-if [ -f $TABE_TSI ]; then
- echo -e "\033[44;37m tabe-tsi.src done. \033[m"
- exit
-fi
-
-if [ ! -d libtabe ]; then
- echo -e "\033[44;37m No libtabe found. cvs check from libtabe \033[m"
- cvs -z9 -d :pserver:xcin@xcin.linux.org.tw:/home/service/cvsroot/xcin \
- checkout libtabe
-fi
-
-if [ ! -d libtabe ]; then
- echo -e "\033[44;37m There were some problems while checking out. \033[m"
- exit
-fi
-
-pushd libtabe
-./configure
-if [ -f Makefile ]; then
- make clean all
-
- # patch tsidump to adapt Chewing
- pushd util
- if [ ! -f PATCHED ]; then
- patch -p0 < $TOP/scripts/tsi-chewing.diff
- touch PATCHED
- fi
- make
-
- # generation
- if [ -f tsidump ]; then
- ./tsidump -d ../tsi-src/tsi.db > $TABE_TSI
- fi
- popd
-fi
-popd
-
-rm -rf libtabe
-