Description: Debian changes before version 3.0.4+dfsg1-1, to be split some day
Forwarded: not-needed

--- a/Makefile.in
+++ b/Makefile.in
@@ -1,10 +1,10 @@
 prefix=@prefix@
 all:
-	cd unikey; make
-	cd fonts; make
+#	cd unikey; make
+#	cd fonts; make
 	cd unicon; make
-	cd tools; make
-	cd unimap; make
+#	cd tools; make
+#	cd unimap; make
 
 data: 
 	cd unicon; make data
@@ -17,26 +17,26 @@
 	if [ ! -d $(prefix)/lib/unicon ] ; then mkdir -p $(prefix)/lib/unicon; fi
 	if [ ! -d $(prefix)/bin ] ; then mkdir -p $(prefix)/bin; fi
 	cd unicon; make install
-	cd unikey; make install
-	cd fonts; make install
-	cd tools; make install
-	cd unimap; make install
+#	cd unikey; make install
+#	cd fonts; make install
+#	cd tools; make install
+#	cd unimap; make install
 
 clean:
 	cd unicon; make clean
-	cd unikey; make clean
-	cd fonts; make clean
-	cd tools; make clean
-	cd unimap; make clean
+#	cd unikey; make clean
+#	cd fonts; make clean
+#	cd tools; make clean
+#	cd unimap; make clean
 	rm -f core *.bak *~
 
 distclean: clean
 	rm -f config.status config.log config.cache Makefile
 	cd unicon; make distclean
-	cd unikey; make distclean
-	cd fonts; make distclean
-	cd tools; make distclean
-	cd sfonts; make distclean
-	cd unimap; make distclean
+#	cd unikey; make distclean
+#	cd fonts; make distclean
+#	cd tools; make distclean
+#	cd sfonts; make distclean
+#	cd unimap; make distclean
 	rm -f *.bak
 
--- a/fonts/big5/Makefile.in
+++ b/fonts/big5/Makefile.in
@@ -2,6 +2,7 @@
 CFLAGS = @CFLAGS@
 CFLAGS += -I/usr/src/linux/include -I. -include /usr/src/linux/include/linux/modversions.h
 PROG = encode-big5.o
+DESTDIR=
 
 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
  
--- a/fonts/gb/Makefile.in
+++ b/fonts/gb/Makefile.in
@@ -2,6 +2,7 @@
 CFLAGS = @CFLAGS@
 CFLAGS += -I/usr/src/linux/include -I. -include /usr/src/linux/include/linux/modversions.h
 PROG = encode-gb.o
+DESTDIR =
 
 CC=gcc $(CFLAGS)
 MODCFLAGS = -Wall -O2 -DMODULE -D__KERNEL__ -DLINUX
--- a/fonts/gbk/Makefile.in
+++ b/fonts/gbk/Makefile.in
@@ -2,6 +2,7 @@
 CFLAGS = @CFLAGS@
 CFLAGS += -I/usr/src/linux/include -I. -include /usr/src/linux/include/linux/modversions.h
 PROG = encode-gbk.o
+DESTDIR =
 
 CC=gcc $(CFLAGS)
 MODCFLAGS = -Wall -O2 -DMODULE -D__KERNEL__ -DLINUX
--- a/fonts/jis/Makefile.in
+++ b/fonts/jis/Makefile.in
@@ -2,6 +2,7 @@
 CFLAGS = @CFLAGS@
 CFLAGS += -I/usr/src/linux/include -I. -include /usr/src/linux/include/linux/modversions.h
 PROG = encode-jis.o
+DESTDIR =
 
 CC=gcc $(CFLAGS)
 MODCFLAGS = -Wall -O2 -DMODULE -D__KERNEL__ -DLINUX
--- a/fonts/kscm/Makefile.in
+++ b/fonts/kscm/Makefile.in
@@ -2,6 +2,7 @@
 CFLAGS = @CFLAGS@
 CFLAGS += -I/usr/src/linux/include -I. -include /usr/src/linux/include/linux/modversions.h
 PROG = encode-kscm.o
+DESTDIR =
 
 CC=gcc $(CFLAGS)
 MODCFLAGS = -Wall -O2 -DMODULE -D__KERNEL__ -DLINUX
--- a/unicon/ImmModules/cce/CCE_pinyin.c
+++ b/unicon/ImmModules/cce/CCE_pinyin.c
@@ -44,6 +44,8 @@
 extern void CCE_ClosePinyin (InputModule * p);
 extern InputModule *pCCE_OpenPinyin (char *szPath);
 extern void Pinyin_SaveAllPyUsrPhrase ();
+extern int SaveUsrPhrase(char *pathname);
+extern int SavePhraseFrequencyi(char *pathname);
 
 static void
 SetPhraseBuffer (PhraseItem * p, char *buf, int buflen)
@@ -156,6 +158,12 @@
 static int
 IMM_Flush ()
 {
+  char name[256];
+  snprintf(name,sizeof(name)-1,"%s/.pyinput/usrphrase.tab",getenv("HOME"));
+  SaveUsrPhrase(name);
+  snprintf(name,sizeof(name)-1,"%s/.pyinput/sysfrequency.tab",getenv("HOME"));
+  SavePhraseFrequency(name);
+
   return 1;
 }
 
--- a/unicon/ImmModules/cce/Makefile.in
+++ b/unicon/ImmModules/cce/Makefile.in
@@ -6,7 +6,7 @@
 CCE_OBJS = xl_hzinput.o CCE_hzinput.o intcode.o \
            xl_pinyin.o CCE_pinyin.o 
 
-CFLAGS = -g -O2 -fomit-frame-pointer -W -Wall -I. -I../../include
+CFLAGS = -fPIC -g -O2 -fomit-frame-pointer -W -Wall -I. -I../../include
 
 all: cce_hzinput.so cce_pinyin.so gb18030_intcode.so 
 
@@ -15,19 +15,19 @@
 xl_hzinput.o : xl_hzinput.c
 	gcc $(CFLAGS) -c xl_hzinput.c -o xl_hzinput.o
 cce_hzinput.so: CCE_hzinput.o xl_hzinput.o
-	gcc CCE_hzinput.o xl_hzinput.o -shared -o cce_hzinput.so
+	gcc CCE_hzinput.o xl_hzinput.o -fPIC -shared -o cce_hzinput.so $(LDFLAGS)
 
 xl_pinyin.o : xl_pinyin.c xl_pinyin.h
 	gcc $(CFLAGS) -c xl_pinyin.c -o xl_pinyin.o
 CCE_pinyin.o : CCE_pinyin.c
 	gcc $(CFLAGS) -c CCE_pinyin.c -o CCE_pinyin.o
 cce_pinyin.so : xl_pinyin.o CCE_pinyin.o
-	gcc CCE_pinyin.o xl_pinyin.o -shared -o cce_pinyin.so
+	gcc CCE_pinyin.o xl_pinyin.o -fPIC -shared -o cce_pinyin.so $(LDFLAGS)
 
 intcode.o : xl_intcode.c
 	gcc $(CFLAGS) -c xl_intcode.c -o intcode.o
 gb18030_intcode.so : intcode.o
-	gcc intcode.o  -shared -o gb18030_intcode.so
+	gcc intcode.o  -shared -o gb18030_intcode.so $(LDFLAGS)
 
 test: hzinput_test intcode_test
 
--- a/unicon/ImmModules/cce/inputs/Makefile.in
+++ b/unicon/ImmModules/cce/inputs/Makefile.in
@@ -2,10 +2,10 @@
 prefix=@prefix@
 CFLAGS = @CFLAGS@
 
-CFLAGS += -I. -I..
+CFLAGS += -O2 -I. -I..
 
 LIBDIR  = $(prefix)/lib/unicon
-LD      = gcc $(CFLAGS)
+LD      = gcc $(CFLAGS) $(LDFLAGS)
 RM      = rm -f
 INSTALL = install -c
 
--- a/unicon/ImmModules/cce/inputs/cin2dat.c
+++ b/unicon/ImmModules/cce/inputs/cin2dat.c
@@ -114,7 +114,7 @@
 
 /* qcmp2 compare two ITEM2 structure, according to its key1/key2/ch */
 int
-qcmp2 (ITEM2 * a, ITEM2 * b)
+qcmp2 (const ITEM2 * a, const ITEM2 * b)
 {
   if (a->key1 > b->key1)
     return 1;
@@ -134,7 +134,7 @@
 
 /* qcmp compare two ITEM2 structure, according to its key1/key2/occur_seq */
 int
-qcmp (ITEM2 * a, ITEM2 * b)
+qcmp (const ITEM2 * a, const ITEM2 * b)
 {
   if (a->key1 > b->key1)
     return 1;
@@ -148,7 +148,7 @@
 }
 
 int
-qcmp_ser (ITEM * a, ITEM * b)
+qcmp_ser (const ITEM * a, const ITEM * b)
 {
   if (a->ch > b->ch)
     return 1;
--- a/unicon/ImmModules/cce/inputs/cin2tab.c
+++ b/unicon/ImmModules/cce/inputs/cin2tab.c
@@ -3,6 +3,7 @@
 #include <stdarg.h>
 #include <sys/types.h>
 #include <string.h>
+#include <stdlib.h>
 #include "xl_hzinput.h"
 
 FILE *fr, *fw;
@@ -114,7 +115,7 @@
 
 /* qcmp2 compare two ITEM2 structure, according to its key1/key2/ch */
 int
-qcmp2 (ITEM2 * a, ITEM2 * b)
+qcmp2 (const ITEM2 * a, const ITEM2 * b)
 {
   if (a->key1 > b->key1)
     return 1;
@@ -152,7 +153,7 @@
 }
 
 int
-qcmp_ser (ITEM * a, ITEM * b)
+qcmp_ser (const ITEM * a, const ITEM * b)
 {
   if (a->ch > b->ch)
     return 1;
--- a/unicon/ImmModules/cce/inputs/tab2txt.c
+++ b/unicon/ImmModules/cce/inputs/tab2txt.c
@@ -71,7 +71,7 @@
       exit (1);
     }
 
-  if (fseek (in, -4, SEEK_END) == -1 ||
+  if (fseek (in, -sizeof(int), SEEK_END) == -1 ||
       fread (&fsize, sizeof (int), 1, in) != 1 || fsize != ftell (in) - sizeof (int))	// error!!
     {
       fprintf (stderr, "%s is not a valid pinyin phrase file.\n", infile);
--- a/unicon/ImmModules/cce/xl_pinyin.c
+++ b/unicon/ImmModules/cce/xl_pinyin.c
@@ -43,7 +43,8 @@
 
 static int LoadPinyinTable (char *pathname);
 static int SaveSysPhrase (char *pathname, int remove);
-static int SaveUsrPhrase (char *pathname);
+//static int SaveUsrPhrase (char *pathname);
+int SaveUsrPhrase (char *pathname);
 static int LoadUsrPhrase (char *pathname);
 static int LoadSysPhrase (char *pathname);
 static void FindMatchPhrase (InputModule * inmd, PYString pinyin[],
@@ -59,11 +60,13 @@
       // MAX_EACH_PY = 38    a[], b[], c[] ....
       // map the pinyin to keys
 static SysPhrase *sysph[MAX_PY_NUM];	// system phrases
-static int sys_size;
+static int sys_size,sys_num;
 
-static int FuzzyPinyin;		// zh-ch-sh z-c-s
+static int FuzzyPinyin =0 ;		// zh-ch-sh z-c-s
 static UsrPhrase *usrph[MAX_PY_NUM];	//user defined phrase
 
+static int LoadPhraseFrequency(char *pathname);
+
 /**************************************************************************
  *                   Structure of the Char/Phrases                        *
  *     u_char len;     // char/phrase len                                 * 
@@ -134,38 +137,38 @@
 
   //Rat: modified for processing user-defined dictionaries
   if ((usrhome = getenv ("HOME")) != NULL)
-    {
-      sprintf (buf, "%s/%s", usrhome, ".pyinput");
+	{
+      snprintf (buf,sizeof(buf)-1, "%s/%s", usrhome, ".pyinput");
       retval = stat (buf, &statbuf);
 
       if ((retval == 0))
 	{
 	  if ((statbuf.st_mode & S_IFMT) == S_IFDIR)
 	    {
-	      sprintf (buf, "%s/%s/%s", usrhome, ".pyinput", "usrphrase.tab");
+	      snprintf (buf, sizeof(buf)-1, "%s/%s/%s", usrhome, ".pyinput", "usrphrase.tab");
 
 	      if ( (retval = stat(buf, &statbuf)) == 0)
 		{
 		  if ( statbuf.st_size < MIN_USRPHR_SIZE || LoadUsrPhrase (buf) == -1)
 		    {
-		      printf ("Couldn't load %s. Please fix it.\n", buf);
-		      sprintf (buf, "%s/%s", szPath, "usrphrase.tab");
-		      if ((retval = access (buf, R_OK)) == 0)
-			{
-			  if (LoadUsrPhrase (buf) == -1)
-			    printf ("Couldn't load %s. Please fix it.\n",
-				    buf);
+		      printf ("Couldn't load %s. Please fix it. size or load error\n", buf);
+				  snprintf (buf, sizeof(buf)-1, "%s/%s", szPath, "usrphrase.tab");
+				  if ((retval = access (buf, R_OK)) == 0)
+				{
+				  if (LoadUsrPhrase (buf) == -1)
+					printf ("Couldn't load %s. Please fix it. sysfile\n",
+						buf);
+				}
+				}
 			}
-		    }
-		}
-	      else
-		{
-		  creat (buf, 0600);
-		  sprintf (buf, "%s/%s", szPath, "usrphrase.tab");
+			  else
+			{
+			  creat (buf, 0600);
+			  snprintf (buf, sizeof(buf)-1, "%s/%s", szPath, "usrphrase.tab");
 		  if ((retval = access (buf, R_OK)) == 0)
 		    {
 		      if (LoadUsrPhrase (buf) == -1)
-			printf ("Couldn't load %s. Please fix it.\n", buf);
+			printf ("Couldn't load %s. Please fix it. couldn't access\n", buf);
 		    }
 		}
 	    }
@@ -178,15 +181,15 @@
       else
 	{
 	  mkdir (buf, 0700);	//Rat: making $HOME/.pyinput
-	  sprintf (buf, "%s/%s/%s", usrhome, ".pyinput", "usrphrase.tab");
+	  snprintf (buf, sizeof(buf)-1, "%s/%s/%s", usrhome, ".pyinput", "usrphrase.tab");
 	  creat (buf, 0600);	//Rat: making $HOME/.pyinput/usrphrase.tab
 
-	  sprintf (buf, "%s/%s", szPath, "usrphrase.tab");
+	  snprintf (buf, sizeof(buf)-1, "%s/%s", szPath, "usrphrase.tab");
 	  if ((retval = access (buf, R_OK)) == 0)
 	    {
 	      if (LoadUsrPhrase (buf) == -1)
 		{
-		  printf ("Couldn't load %s. Please fix it.\n", buf);
+		  printf ("Couldn't load %s. Please fix it. create\n", buf);
 		}
 	    }
 	}
@@ -194,7 +197,7 @@
   else
     {
       printf ("Sorry, I couldn't find your $HOME.\n");
-      sprintf (buf, "%s/%s", szPath, "usrphrase.tab");
+      snprintf (buf, sizeof(buf)-1, "%s/%s", szPath, "usrphrase.tab");
       printf ("Turn to access %s", buf);
 
       if ((retval = access (buf, R_OK)) != 0)
@@ -207,6 +210,13 @@
 
     }
 
+  snprintf(buf,sizeof(buf)-1,"%s/%s/%s",usrhome,".pyinput","sysfrequency.tab");
+  if(LoadPhraseFrequency(buf) == -1)
+  {
+	  creat(buf,0700);
+	  SavePhraseFrequency(buf);
+  }
+
   return 1;
 }
 
@@ -219,7 +229,7 @@
   AdjustPhraseFreq ();		// lower the freq to [0,50)
   if (usrhome != NULL)
     {
-      sprintf (szFileName, "%s/%s/%s", usrhome, ".pyinput", "usrphrase.tab");
+      snprintf (szFileName, sizeof(szFileName)-1, "%s/%s/%s", usrhome, ".pyinput", "usrphrase.tab");
       SaveUsrPhrase (szFileName);
     }
   else
@@ -265,7 +275,8 @@
 }
 
  /* need to combine the same pinyin/phrases */
-static int
+//static int
+int
 SaveUsrPhrase (char *pathname)
 {
   int i, tmpcount;
@@ -340,6 +351,53 @@
   return 0;
 }
 
+int SavePhraseFrequency(char *pathname)
+{
+  FILE *stream;
+  Phrase *sph;
+  SysPhrase *sysph_tmp;
+  char *f;
+  char *p;
+  int i,j,k,index,pcount;
+
+  if ( (stream = fopen(pathname , "wb" )) == NULL )
+  {
+        fatal("%s file can't open\n",pathname);
+        return -1;
+  }
+
+  f = (char *) malloc (sys_num);
+  memset (f, 0, sys_num);
+  pcount=0;
+
+  for(i = 1; i < MAX_PY_NUM; i++)
+  {
+     sysph_tmp = sysph[i];
+     assert (sysph_tmp != NULL);
+     p = (char*)sysph_tmp->phrase;   // count = total pinyin number
+     for(j = 0; j < sysph_tmp->count; j++)
+     {
+        sph = (Phrase *)p;
+        assert (sph != NULL);
+        for(k = 0; k < sph->count; k++)
+        {
+            index = sph->len+1 + (2*sph->len+1)*k + 2*sph->len;
+            f[pcount]=sph->key[index];
+            pcount++;
+        }   
+        p += SizeOfPhrase(sph->len,sph->count);
+     }
+  }
+  assert (pcount==sys_num);
+  fseek(stream,0,SEEK_SET);
+  fwrite(f, sys_num, 1, stream); 
+  fwrite(&(sys_size),sizeof(int),1,stream);
+  fwrite(&(sys_num),sizeof(int),1,stream);
+  free(f);
+  fclose(stream);
+  return 0;
+}
+
 // don't save the frequency information, all lost?
 static int
 SaveSysPhrase (char *pathname, int remove)
@@ -483,6 +541,7 @@
   fseek (stream, 0, SEEK_SET);
   p = (char *) malloc (sys_size);
   memset (p, 0, sys_size);
+  sys_num = 0;
   /* Attach the shared segment to local address space */
   if (fread (p, sys_size, 1, stream) != 1)
     {
@@ -494,15 +553,74 @@
       sysph[i] = sysph_tmp = (SysPhrase *) p;
       p = (char *) sysph_tmp->phrase;
       for (j = 0; j < sysph_tmp->count; j++)
-	{
+	  {
 	  kph = (Phrase *) p;
 	  p += SizeOfPhrase (kph->len, kph->count);	// skip the string 
-	}
+	  sys_num += kph->count;
+	  }
     }
   fclose (stream);
   return 0;
 }
 
+static int LoadPhraseFrequency(char *pathname)
+{
+   FILE *stream;
+   Phrase *sph;
+   SysPhrase *sysph_tmp;
+   char *f;
+   char *p;
+   int i,j,k,index,sys_size_tmp,sys_num_tmp,pcount;
+ 
+   if ( (stream = fopen(pathname , "rb" )) == NULL )
+   {
+         fatal("%s file can't open\n",pathname);
+         return -1;
+   }
+ 
+   if (fseek(stream,-sizeof(int)*2,SEEK_END) == -1 || 
+       fread(&(sys_size_tmp),sizeof(int),1,stream) != 1 ||
+       fread(&(sys_num_tmp),sizeof(int),1,stream) != 1 ||
+       sys_size != sys_size_tmp||   
+       sys_num_tmp != ftell(stream)-sizeof(int)*2 ||
+       sys_num != sys_num_tmp)   // error!!
+   {
+       fatal("%s is not a valid pinyin phrase frequency file.\n",pathname);
+       return -1;
+   }
+   fseek(stream,0,SEEK_SET);
+   f = (char *) malloc (sys_num);
+   memset (f, 0, sys_num);
+   if (fread(f, sys_num, 1, stream) != 1)
+   {
+       fatal("Load File %s Error.\n", pathname);
+       return -1;
+   }
+   //
+   pcount=0;
+   for(i = 1; i < MAX_PY_NUM; i++)
+   {
+      sysph_tmp = sysph[i];
+      assert (sysph_tmp != NULL);
+      p = (char*)sysph_tmp->phrase;   // count = total pinyin number
+      for(j = 0; j < sysph_tmp->count; j++)
+      {
+         sph = (Phrase *)p;
+         assert (sph != NULL);
+         for(k = 0; k < sph->count; k++)
+         {
+             index = sph->len+1 + (2*sph->len+1)*k + 2*sph->len;
+             sph->key[index] = f[pcount];
+             pcount++;
+         }   
+         p += SizeOfPhrase(sph->len,sph->count);
+	 }
+  }
+   free(f);
+  fclose(stream);
+  return 0;
+}
+
 // When loading the phrase library, save it in memory
 // structure, dynamic linklist
 /* str, hanzi codes, key: pinyin codes, len: length, pass: system/user */
@@ -676,6 +794,7 @@
   inmd->lenkey = 0;
   inmd->key[0] = '\0';
   inmd->nTotalCurSel = 0;
+  inmd->flg_english = 0;
 }
 
 // pinyin[0]-pinyin[len-1], parsed pinyin chars
@@ -710,6 +829,7 @@
 
   if (!inmd->len)
     return NULL;
+  printf("szGetSelectPhrase called\n");
 
   idx = inmd->startpos + n;
 
@@ -735,6 +855,15 @@
   char strhz[MAX_PHRASE_LEN * 2 + 1];
   int pos, idx;
 
+  
+  if (ch == '\n')
+  {
+	  strcpy(strbuf,inmd->inbuf);
+	  ResetPinyinInput(inmd);
+	  return 2;
+  }
+  
+
   if (!inmd->len)
     return 1;
 
@@ -782,12 +911,16 @@
     }
   else				// not yet, some unselected pinyin exist
     {
+	  inmd->flg_english = 0;
       // forward the pinyinpos pointer
       for (pos = strlen (strhz) / 2; pos > 0; inmd->pinyinpos++)
 	{
 	  ch = inmd->pinyin[inmd->pinyinpos][0];
 	  if (ch == 'i' || ch == 'u' || ch == 'v' || ch < 'a' || ch > 'z')
+	  {
+		inmd->flg_english = 1;
 	    continue;
+	  }
 	  pos--;
 	}
 
@@ -820,21 +953,26 @@
 
   char chtmp;
   int count;
+  int i;
+  char tmpbuf[128];
 
   /* \010 = Ctrl+H, \177 = BackSpace */
   if (ch == '\010' || ch == '\177')	// BackSpace
     {
       if (!strlen (inbuf))
-	return 0;
+		return 0;
       else if (!strlen (inbuftmp))
 	{
 	  strcpy (inbuftmp, inbuf);
+	  inbuf[strlen(inbuf)-1] = '\0';
 	  *pybuftmp = '\0';	// clear all the selected chars, reparse
 	}
       else
 	{
 	  inbuf[strlen (inbuf) - 1] = '\0';
-	  inbuftmp[strlen (inbuftmp) - 1] = '\0';	// cut one pinyin-char off
+	  if(inmd->flg_english) strcpy(inbuftmp,inbuf);
+	  else inbuftmp[strlen (inbuftmp) - 1] = '\0';	// cut one pinyin-char off
+
 	  if (!strlen (inbuf))
 	    {
 	      ResetPinyinInput (inmd);
@@ -862,7 +1000,8 @@
       chtmp = inmd->pinyin[inmd->lenpy - 1][0];
       if (chtmp == 'i' || chtmp == 'u' || chtmp == 'v')
 	{
-	  inbuf[strlen (inbuf) - 1] = '\0';
+//	  inbuf[strlen (inbuf) - 1] = '\0';
+	  inmd->flg_english = 1;
 	  inbuftmp[strlen (inbuftmp) - 1] = '\0';
 	  inmd->lenpy--;
 	  return 1;
@@ -871,7 +1010,7 @@
   /* Too many chars now */
   if (EffectPyNum (inmd->pinyin, inmd->lenpy) > MAX_PHRASE_LEN)
     {
-      inbuf[strlen (inbuf) - 1] = '\0';
+//      inbuf[strlen (inbuf) - 1] = '\0';
       inbuftmp[strlen (inbuftmp) - 1] = '\0';
       inmd->lenpy--;
       return 1;
@@ -881,6 +1020,14 @@
   FillForwardSelection (inmd, 0);
   CreatePyMsg (inmd);
 
+  tmpbuf[0] = '\0';
+  for(i = 0;i < inmd->lenpy; i++)
+  {
+	  strcat(tmpbuf,inmd->pinyin[i]);
+  }
+  if(strcmp(inmd->inbuf,tmpbuf)) inmd->flg_english = 1;
+  else inmd->flg_english = 0;
+
   return 1;
 }
 
@@ -921,8 +1068,8 @@
       break;
 
     default:			// select some keys
-      if ((ch >= '1' && ch <= '9') || ch == '0' || ch == ' ')
-	return SelectKeyPressed (inmd, ch, strbuf);
+      if ((ch >= '1' && ch <= '9') || ch == '0' || ch == ' ' || ch == '\n')
+		return SelectKeyPressed (inmd, ch, strbuf);
       break;
     }
   return 0;
@@ -952,6 +1099,12 @@
 	  continue;
 	}
 
+      if (pybuf[offset] == 'v' || pybuf[offset] == 'i' || pybuf[offset] == 'u')
+      {
+          offset++; count = 2;
+          continue;
+      }
+
       ahead = pybuf[offset] - 'a';
       if (ahead < 0 || ahead > 25)
 	return 0;
@@ -1004,13 +1157,13 @@
   // temporary array, 500 items
 
   int lenarr[MAX_PHRASE_LEN], result;
-  char ch;
+  char ch, ch2='\0';
 
   if (!lenpy)
-    {
+  {
       inmd->len = 0;
       return;
-    }
+  }
 
   /* first of all, fill the pykey array */
   for (i = 0; i < lenpy; i++)
@@ -1022,9 +1175,14 @@
       ahead = pinyin[i][0] - 'a';
       lenkey = 0;
       tmplen = strlen (pinyin[i]);
+	  if(tmplen > 1)
+		  ch2 = pinyin[i][1];
       for (j = 0; (keytmp = pytab[ahead][j].key); j++)
 	{
-	  if (tmplen == 1 || !strncmp (pinyin[i], pytab[ahead][j].py, tmplen))
+//	  if (tmplen == 1 || !strncmp (pinyin[i], pytab[ahead][j].py, tmplen))
+	  if (tmplen == 1 || !strcmp (pinyin[i], pytab[ahead][j].py)
+	  || ((tmplen == 2) && (!FuzzyPinyin)&&(ch=='z'||ch=='c'||ch=='s')
+		  &&(ch2=='h')))
 	    // prefix match
 	    {
 	      pykey[count][lenkey++] = keytmp;
@@ -1048,7 +1206,7 @@
 	    }
 	}
       pykey[count++][lenkey] = 0;
-    }				// for i = 1 to lenpy, pykey array filled
+  }				// for i = 1 to lenpy, pykey array filled
 
   for (i = 0; i < MAX_PHRASE_LEN; i++)
     lenarr[i] = 0;
@@ -1334,13 +1492,17 @@
 int
 CCE_GetInputDisplay (InputModule * p, char *buf)
 {
-  strcpy (buf, p->iapybuf);
+//  strcpy (buf, p->iapybuf);
+  if(p->flg_english) strcpy(buf, p->inbuf);
+  else strcpy(buf, p->iapybuf);
   return 1;
 }
 
 int
 CCE_GetSelectDisplay (InputModule * p, char *buf)
 {
-  strcpy (buf, p->iahzbuf);
+//  strcpy (buf, p->iahzbuf);
+  if(p->flg_english) strcpy(buf, p->inbuf);
+  else strcpy(buf, p->iahzbuf);
   return p->nTotalCurSel;
 }
--- a/unicon/ImmModules/cce/xl_pinyin.h
+++ b/unicon/ImmModules/cce/xl_pinyin.h
@@ -137,6 +137,7 @@
   // MAX_HZ_BUF = 250
   int nTotalCurSel;		/* Total Selection */
   int SelectionLen;
+  int flg_english;
 }
 InputModule;			// about 30KB
 
@@ -149,6 +150,8 @@
 int Pinyin_KeyFilter (InputModule * inmd, u_char key, char *buf, int *len);
 int Pinyin_KeyPressed (InputModule * inmd, u_char key);
 void RefreshPYInputArea (InputModule * inmd);
+int SaveUsrPhrase(char *pathname);
+int SavePhraseFrequency(char *pathname);
 int UnloadSysPhrase ();
 int UnloadUserPhrase ();
 
--- a/unicon/ImmModules/cxterm/Makefile.in
+++ b/unicon/ImmModules/cxterm/Makefile.in
@@ -5,13 +5,13 @@
 PROG = cxterm_hzinput.so
 OBJS = hzinput.o Cxterm_hzinput.o
 
-CFLAGS = -g -Wall -I../../include -I.
+CFLAGS = -fPIC -g -Wall -I../../include -I.
 
 all: $(PROG) 
 	cd utils && make
 	cd dict  && make 
 $(PROG) : $(OBJS)
-	gcc $(OBJS) -shared -o $(PROG)
+	gcc $(OBJS) -fPIC -shared -o $(PROG)
 Cxterm_hzinput.o : Cxterm_hzinput.c
 	gcc $(CFLAGS) -c Cxterm_hzinput.c -o Cxterm_hzinput.o
 hzinput.o : hzinput.c
--- a/unicon/ImmModules/turbo/Makefile.in
+++ b/unicon/ImmModules/turbo/Makefile.in
@@ -1,11 +1,11 @@
 prefix=@prefix@
 CFLAGS=@CFLAGS@
 # CFLAGS += -V2.7.2.3 -I.
-CFLAGS += -I.
+CFLAGS += -I. -O2
 PROG = TL_hzinput.so
 TL_OBJS = xl_hzinput.o TL_hzinput.o  xl_phrase.o xl_sysphrase.o xl_mfile.o
 
-CFLAGS = -g -Wall -I../../include -I.
+CFLAGS = -fPIC -g -Wall -I../../include -I.
 
 all:dlib
 dlib: $(PROG)
@@ -21,7 +21,7 @@
 xl_sysphrase.o : xl_sysphrase.c
 	gcc $(CFLAGS) -c xl_sysphrase.c -o xl_sysphrase.o
 $(PROG): $(TL_OBJS)
-	gcc $(TL_OBJS) -shared -o $(PROG)
+	gcc $(TL_OBJS) -fPIC -shared -o $(PROG) $(LDFLAGS)
 
 # GB Support
 gbdata: cin2tab addphrase levelphrase
@@ -62,8 +62,11 @@
 install: all
 	mkdir -p $(prefix)/lib/unicon/modules/turbo
 	cp -f *.so $(prefix)/lib/unicon/modules/turbo
-data-install: big5data gbdata
-	mkdir -p $(prefix)/lib/unicon/modules/turbo/dict/{gb,gbk,big5}
+#data-install: big5data gbdata
+data-install: 
+	mkdir -p $(prefix)/lib/unicon/modules/turbo/dict/gb
+	mkdir -p $(prefix)/lib/unicon/modules/turbo/dict/gbk
+	mkdir -p $(prefix)/lib/unicon/modules/turbo/dict/big5
 	cp -f tl_sysphrase.*.bin $(prefix)/lib/unicon/modules/turbo
 	cp -f gb/*.tab $(prefix)/lib/unicon/modules/turbo/dict/gb
 	cp -f gbk/*.tab $(prefix)/lib/unicon/modules/turbo/dict/gbk
--- a/unicon/ImmModules/turbo/xl_hzinput.c
+++ b/unicon/ImmModules/turbo/xl_hzinput.c
@@ -239,11 +239,11 @@
 }
 
 static HzInputTable_T *pDefaultClient = NULL;
-static int qcmp (void *t1, void *t2)
+static int qcmp (const void *t1, const void *t2)
 {
     long c1, c2, k1, k2;
-    long *a = (long *) t1,
-         *b = (long *) t2;
+    const long *a = (long *) t1,
+               *b = (long *) t2;
     int n1, n2, m1, m2;
     static char p1[256], p2[256];
     n1 = pDefaultClient->cur_table->item[*a].nPhrase;
--- a/unicon/ImmModules/turbo/xl_mfile.c
+++ b/unicon/ImmModules/turbo/xl_mfile.c
@@ -26,6 +26,7 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#include <string.h>
 
 typedef struct MemFile_handle
 {
--- a/unicon/ImmModules/turbo/xl_phrase.c
+++ b/unicon/ImmModules/turbo/xl_phrase.c
@@ -413,11 +413,11 @@
 }
 
 static TL_SysPhrase_T *pDefaultSysPhrase = NULL;
-static int qcmp (void *t1, void *t2)
+static int qcmp (const void *t1, const void *t2)
 {
     u_long c1, c2;
-    ITEM *a = (ITEM *) t1, 
-         *b = (ITEM*) t2;
+    const ITEM *a = (ITEM *) t1, 
+               *b = (ITEM*) t2;
 
     if (a->key1 > b->key1) 
         return 1;
--- a/unicon/Makefile.in
+++ b/unicon/Makefile.in
@@ -2,9 +2,9 @@
 all:
 	cd server; make
 	cd client; make
-	cd unicon; make
+#	cd unicon; make
 	cd ImmModules/cce && make
-	cd ImmModules/cxterm && make
+#	cd ImmModules/cxterm && make
 	cd ImmModules/turbo && make
 ccedata:
 	cd ImmModules/cce/inputs && make
@@ -19,23 +19,25 @@
 	if [ ! -d $(prefix) ] ; then mkdir -p $(prefix); fi
 	if [ ! -d $(prefix)/lib/unicon ] ; then mkdir -p $(prefix)/lib/unicon; fi
 	if [ ! -d $(prefix)/bin ] ; then mkdir -p $(prefix)/bin; fi
-	cd ImmModules/cce/inputs; make install
-	cd ImmModules/turbo; make data-install
+	cd ImmModules/cce/inputs; make install prefix=$(prefix)
+	cd ImmModules/turbo; make data-install prefix=$(prefix)
 install: all
 	if [ ! -d $(prefix) ] ; then mkdir -p $(prefix); fi
 	if [ ! -d $(prefix)/lib/unicon ] ; then mkdir -p $(prefix)/lib/unicon; fi
 	if [ ! -d $(prefix)/bin ] ; then mkdir -p $(prefix)/bin; fi
 	cd server; make install
 	cd client; make install
-	cd unicon; make install
+#	cd unicon; make install
 	cd ImmModules/cce; make install
-	cd ImmModules/cxterm; make install
+#	cd ImmModules/cxterm; make install
 	cd ImmModules/turbo; make install
+	cp -f unicon/sys-gb.tab $(prefix)/lib/unicon
+	cp -f unicon/sys-big5.tab $(prefix)/lib/unicon
 
 clean:
 	cd server; make clean
 	cd client; make clean
-	cd unicon; make clean
+#	cd unicon; make clean
 	cd ImmModules/cce; make clean
 	cd ImmModules/cce/inputs; make clean
 	cd ImmModules/cxterm; make clean
@@ -47,10 +49,10 @@
 distclean: clean
 	rm -f config.status config.log config.cache Makefile tags TAGS
 	cd server; make distclean
-	cd unicon; make distclean
+#	cd unicon; make distclean
 	cd client; make distclean
 	cd ImmModules/cce; make distclean
 	cd ImmModules/cce/inputs; make distclean
-	cd ImmModules/cxterm; make distclean
+#	cd ImmModules/cxterm; make distclean
 	cd ImmModules/turbo; make distclean
 
--- a/unicon/client/Makefile.in
+++ b/unicon/client/Makefile.in
@@ -7,7 +7,7 @@
 DLIB_OBJS = TLC_LibImmClient.o TLC_Utils.o
 SERVER_LIB=../server/libimm_server.so
 
-CFLAGS = -g  -Wall -I. -I../include -I../server -I../client
+CFLAGS += -g  -Wall -I. -I../include -I../server -I../client
 # CFLAGS = -g -D__IMM_DEBUG__ -Wall -I. -I../include
 
 all: $(PROG_LIB)
@@ -34,8 +34,8 @@
 	g++ $(CFLAGS) -D__DLL_SUPPORT__ -ldl -lpth test.cpp $(PROG_LIB) $(SERVER_LIB) -o test
 
 install: all
-	mkdir -p $(prefix)/lib/unicon
-	cp -f $(PROG_LIB) $(prefix)/lib/unicon
+#	mkdir -p $(prefix)/lib
+	cp -f $(PROG_LIB) $(prefix)/lib
 clean:
 	rm -f *.o a.out core *~ *.bak $(PROG_LIB) $(PROG)
 
--- a/unicon/server/Makefile.in
+++ b/unicon/server/Makefile.in
@@ -1,7 +1,7 @@
 prefix=@prefix@
 CFLAGS = @CFLAGS@
 APP_PROG = imm_server
-DLIB_PROG = libimm_server.so
+DLIB_PROG = libimm_server.so.0.0
 
 APP_OBJS = TLS_HzInput.o TLS_ImmOp.o TLS_TcpipMain.o  TLS_MemFile.o \
        TLS_PthSocket.o TLS_Debug.o \
@@ -14,13 +14,13 @@
 LIBS = /usr/lib/libpth.so -ldl
 
 # CFLAGS = -g -D__IMM_DEBUG__ -Wall -I. -I/usr/include -I../include 
-CFLAGS = -g -Wall -I. -I/usr/include -I../include
+CFLAGS = -fPIC -g -Wall -I. -I../include
 CC=g++
 
 all: $(DLIB_PROG)
 
-libimm_server.so: $(DLIB_OBJS)
-	$(CC) $(DLIB_OBJS) -shared -o $(DLIB_PROG)
+libimm_server.so.0.0: $(DLIB_OBJS)
+	$(CC) $(DLIB_OBJS) -fPIC -Wl,-soname,libimm_server.so.0 -shared -o $(DLIB_PROG) -ldl $(LDFLAGS)
 
 TLS_LibMain.o : TLS_LibMain.cpp
 	$(CC) $(CFLAGS) -DUNICON_LIB=\"$(prefix)/lib/unicon\" -c TLS_LibMain.cpp -o TLS_LibMain.o
@@ -46,9 +46,10 @@
 
 install: all
 	mkdir -p $(prefix)/bin
-	mkdir -p $(prefix)/lib/unicon
+	mkdir -p $(prefix)/lib
 	if [ -f $(APP_PROG) ]; then  cp -f $(APP_PROG) $(prefix)/bin; fi
-	if [ -f $(DLIB_PROG) ]; then  cp -f $(DLIB_PROG) $(prefix)/lib/unicon; fi
+	if [ -f $(DLIB_PROG) ]; then  cp -f $(DLIB_PROG) $(prefix)/lib; fi
+	cd $(prefix)/lib;ln -s libimm_server.so.0.0 libimm_server.so.0;ln -s libimm_server.so.0 libimm_server.so
 
 clean:
 	if test -e $(PROG); then rm -f $(PROG); fi
--- a/unicon/server/TLS_Debug.cpp
+++ b/unicon/server/TLS_Debug.cpp
@@ -25,15 +25,17 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <iostream.h>
-#include <fstream.h>
+#include <iostream>
+#include <fstream>
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <assert.h>
 #include <string.h>
+#include <stdarg.h>
 #include <TLS_Debug.hpp>
-TLS_CDebug::TLS_CDebug (char *szFileName, int mode = 0)
+
+TLS_CDebug::TLS_CDebug (char *szFileName, int mode)
 {
     if (szFileName == NULL)
     {
--- a/unicon/server/TLS_ImmOp.cpp
+++ b/unicon/server/TLS_ImmOp.cpp
@@ -23,7 +23,7 @@
  * Author: see CREDITS
  */
 
-#include <iostream.h>
+#include <iostream>
 #include <stdio.h>
 #include <string.h>
 #include <dlfcn.h>
--- a/unicon/server/TLS_LibMain.cpp
+++ b/unicon/server/TLS_LibMain.cpp
@@ -35,7 +35,7 @@
 #include <signal.h>
 #include <netdb.h>
 #include <unistd.h>
-#include <iostream.h>
+#include <iostream>
 #include <pth.h>
 
 #include <TLS_MemFile.hpp>
--- a/unicon/server/TLS_MemFile.cpp
+++ b/unicon/server/TLS_MemFile.cpp
@@ -23,7 +23,7 @@
  * Author: see CREDITS
  */
 
-#include <iostream.h>
+#include <iostream>
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -32,6 +32,8 @@
 
 #include <TLS_MemFile.hpp>
 
+using namespace std;
+
 TLS_CMemFile::TLS_CMemFile (u_long max0)
 {
     buf = (char *) malloc (max0);
--- a/unicon/server/TLS_PthSocket.cpp
+++ b/unicon/server/TLS_PthSocket.cpp
@@ -83,7 +83,7 @@
     return b;
 }
 
-int TLS_CPthSocket::read (void *buf, int buflen)
+int TLS_CPthSocket::Read (void *buf, int buflen)
 {
     short len;
 #ifdef __IMM_DEBUG__
@@ -102,7 +102,7 @@
     return len;
 }
 
-int TLS_CPthSocket::write (void *buf, int len)
+int TLS_CPthSocket::Write (void *buf, int len)
 {
     short len0 = len;
 #ifdef __IMM_DEBUG__
--- a/unicon/server/TLS_PthSocket.hpp
+++ b/unicon/server/TLS_PthSocket.hpp
@@ -36,8 +36,8 @@
 public:
     TLS_CPthSocket (int fd);
     ~TLS_CPthSocket ();
-    int read (void *buf, int len);
-    int write (void *buf, int len);
+    int Read (void *buf, int len);
+    int Write (void *buf, int len);
 };
 
 #endif
--- a/unicon/unicon/unicon.ini.in
+++ b/unicon/unicon/unicon.ini.in
@@ -49,8 +49,8 @@
 MethodModule7=@PREFIX@/lib/unicon/modules/turbo/TL_hzinput.so
 MethodTable7=@PREFIX@/lib/unicon/modules/turbo/dict/gb/CangJie.tab
 MethodName7=苍颉输入
-MethodModule8=@PREFIX@/lib/unicon/modules/turbo/TL_hzinput.so
-MethodTable8=@PREFIX@/lib/unicon/modules/turbo/dict/gb/WuBi.tab
+MethodModule8=@PREFIX@/lib/unicon/modules/cce/cce_hzinput.so
+MethodTable8=@PREFIX@/lib/unicon/modules/cce/dict/wubi.tab
 MethodName8=五笔字型
 MethodModule9=@PREFIX@/lib/unicon/modules/turbo/TL_hzinput.so
 MethodTable9=@PREFIX@/lib/unicon/modules/turbo/dict/gb/QianMa.tab
@@ -110,8 +110,8 @@
 MethodModule7=@PREFIX@/lib/unicon/modules/turbo/TL_hzinput.so
 MethodTable7=@PREFIX@/lib/unicon/modules/turbo/dict/gb/CangJie.tab
 MethodName7=苍颉输入
-MethodModule8=@PREFIX@/lib/unicon/modules/turbo/TL_hzinput.so
-MethodTable8=@PREFIX@/lib/unicon/modules/turbo/dict/gb/WuBi.tab
+MethodModule8=@PREFIX@/lib/unicon/modules/cce/cce_hzinput.so
+MethodTable8=@PREFIX@/lib/unicon/modules/cce/dict/wubi.tab
 MethodName8=五笔字型
 MethodModule9=@PREFIX@/lib/unicon/modules/turbo/TL_hzinput.so
 MethodTable9=@PREFIX@/lib/unicon/modules/turbo/dict/gb/QianMa.tab
--- a/unikey/Makefile.in
+++ b/unikey/Makefile.in
@@ -3,6 +3,7 @@
 CFLAGS += -I. -I./include -I../include -I/usr/src/linux/include -include /usr/src/linux/include/linux/modversions.h
 PROG = unikey.o
 CC=gcc $(CFLAGS)
+DESTDIR =
 
 MODCFLAGS = -Wall -O2 -DMODULE -D__KERNEL__ -DLINUX
 
