rpms/gcin/FC-5 gcin_update.patch,NONE,1.1

Chung-Yen Chang (candyz) fedora-extras-commits at redhat.com
Thu Nov 23 13:44:33 UTC 2006


Author: candyz

Update of /cvs/extras/rpms/gcin/FC-5
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1178

Added Files:
	gcin_update.patch 
Log Message:
add gcin_update.patch


gcin_update.patch:

--- NEW FILE gcin_update.patch ---
diff -urN gcin-1.3.0.1.orig/gcin.h gcin-1.3.0.1/gcin.h
--- gcin-1.3.0.1.orig/gcin.h	2006-10-05 14:05:00.000000000 +0800
+++ gcin-1.3.0.1/gcin.h	2006-11-22 18:00:42.000000000 +0800
@@ -117,6 +117,7 @@
 gboolean utf8_str_eq(char *a, char *b, int len);
 void utf8cpyN(char *t, char *s, int N);
 int utf8_str_N(char *str);
+void utf8cpyn(char *t, char *s, int n);
 
 void get_gcin_dir(char *tt);
 Atom get_gcin_atom(Display *dpy);
diff -urN gcin-1.3.0.1.orig/gtab.c gcin-1.3.0.1/gtab.c
--- gcin-1.3.0.1.orig/gtab.c	2006-11-20 13:04:59.000000000 +0800
+++ gcin-1.3.0.1/gtab.c	2006-11-22 18:00:14.000000000 +0800
@@ -80,13 +80,15 @@
   return strlen(a) - strlen(b);
 }
 
-#define tblch(i) (cur_inmd->key64 ? cur_inmd->tbl64[i].ch:cur_inmd->tbl[i].ch)
-#define Max_tab_key_num (cur_inmd->key64 ? MAX_TAB_KEY_NUM64 : MAX_TAB_KEY_NUM)
+#define tblch2(inm, i) (inm->key64 ? inm->tbl64[i].ch:inm->tbl[i].ch)
+#define tblch(i) tblch2(cur_inmd, i)
+#define Max_tab_key_num1(inm) (inm->key64 ? MAX_TAB_KEY_NUM64 : MAX_TAB_KEY_NUM)
+#define Max_tab_key_num Max_tab_key_num1(cur_inmd)
 void set_key_codes_label(char *s);
 
 void lookup_gtab(char *ch, char out[])
 {
-  char *tbuf[32];
+  char *tbuf[128];
   int tbufN=0;
   INMD *tinmd = &inmd[default_input_method];
 
@@ -98,7 +100,7 @@
 
   int i;
   for(i=0; i < tinmd->DefChars; i++) {
-    char *chi = tblch(i);
+    char *chi = tblch2(tinmd, i);
 
     if (!(chi[0] & 0x80))
       continue;
@@ -112,7 +114,7 @@
     int tlen=0;
     char t[CH_SZ * MAX_TAB_KEY_NUM64 + 1];
 
-    for(j=Max_tab_key_num - 1; j>=0; j--) {
+    for(j=Max_tab_key_num1(tinmd) - 1; j>=0; j--) {
 
       int sh = j * KeyBits;
       int k = (key >> sh) & 0x3f;
@@ -516,8 +518,6 @@
 
   fclose(fp);
 
-  inp->max_keyN = 5;
-
   if (usenow) {
     cur_inmd=inp;
 //    reset_inp();
@@ -525,7 +525,6 @@
     DispInArea();
   }
 
-
   dbg("key64: %d\n", inp->key64);
 
   if (gtab_space_auto_first == GTAB_space_auto_first_none)
@@ -689,7 +688,9 @@
 
 static u_int vmask[]=
 { 0,
-  0x3f<<24,  (0x3f<<24)|(0x3f<<18), (0x3f<<24)|(0x3f<<18)|(0x3f<<12),
+ (0x3f<<24),
+ (0x3f<<24)|(0x3f<<18),
+ (0x3f<<24)|(0x3f<<18)|(0x3f<<12),
  (0x3f<<24)|(0x3f<<18)|(0x3f<<12)|(0x3f<<6),
  (0x3f<<24)|(0x3f<<18)|(0x3f<<12)|(0x3f<<6)|0x3f
 };
@@ -881,7 +882,9 @@
         strcat(strcat(tt, seltab[i]), " ");
         strcat(tt, "</span>");
       } else {
-        strcat(strcat(tt, seltab[i]), " ");
+        char uu[512];
+        utf8cpyn(uu, seltab[i], 6);
+        strcat(strcat(tt, uu), " ");
       }
     } else {
       extern gboolean b_use_full_space;
@@ -960,14 +963,13 @@
 
   bzero(seltab_phrase, sizeof(seltab_phrase));
 
-
 //  dbg("uuuuu %x %x\n", key, kbstate);
 
   if (!cur_inmd)
     return 0;
 
   if (kbstate & (Mod1Mask|ControlMask)) {
-      return 0;
+    return 0;
   }
 
 
@@ -1074,7 +1076,6 @@
 
       if (wild_mode) {
         // request from tetralet
-        dbg("zzz %d %d\n",wild_page, defselN);
         if (!wild_page && defselN < cur_inmd->M_DUP_SEL) {
           sel1st_i = 0;
           goto direct_select;
@@ -1189,7 +1190,6 @@
 
       pselkey=ptr_selkey(key);
 
-
       if (!pselkey && (key < 32 || key > 0x7e) && (gtab_full_space_auto_first || spc_pressed)) {
 //        dbg("%x %x sel1st_i:%d  '%c'\n", pselkey, key, sel1st_i, seltab[sel1st_i][0]);
         if (seltab[sel1st_i][0])
@@ -1198,7 +1198,6 @@
         return 0;
       }
 
-
       inkey=cur_inmd->keymap[key];
 
 //      dbg("spc_pressed %d %d %d\n", spc_pressed, last_full, cur_inmd->MaxPress);
@@ -1308,8 +1307,9 @@
             return 0;
         }
 
-        if (defselN)
+        if (defselN) {
           goto YYYY;
+        }
      }
   } /* switch */
 
@@ -1347,19 +1347,11 @@
     s1++;
 
   last_idx=s1;
+
 #if 0
-  dbg("inch %d %d   val:%x\n", inch[0], inch[1], val);
-  u_char *tbl_ch = tblch(s1);
-  dbg("s1:%d e1:%d key:%llx ci:%d vmask[ci]:%llx ch:%c%c%c and:%x\n", s1, e1, CONVT2(cur_inmd, s1),
-     ci, vmaskci, tbl_ch[0], tbl_ch[1], tbl_ch[2], CONVT2(cur_inmd, s1) & vmask[ci]);
-
-  dbg("pselkey:%x  %d  defselN:%d\n", pselkey,
-       (CONVT2(cur_inmd, s1) & vmask[ci])!=val,
-       defselN);
+  dbg("ci:%d  %d\n", ci, ((CONVT2(cur_inmd, s1) & vmaskci)!=val));
 #endif
 
-  vmaskci = cur_inmd->key64 ? vmask64[ci]:vmask[ci];
-
   if ((CONVT2(cur_inmd, s1) & vmaskci)!=val || (wild_mode && defselN) ||
                   ((ci==cur_inmd->MaxPress||spc_pressed) && defselN &&
       (pselkey && ( pendkey || spc_pressed)) ) ) {
@@ -1412,7 +1404,6 @@
   j=s1;
 
   if (ci < cur_inmd->MaxPress && !spc_pressed && !pendkey) {
-    int shiftb=(KEY_N - 1 -ci) * KeyBits;
 
     exa_match=0;
     bzero(seltab, sizeof(seltab));
@@ -1423,32 +1414,29 @@
       j++;
     }
 
-
     defselN=exa_match;
 
     if (defselN > cur_inmd->M_DUP_SEL)
       defselN--;
 
+    int shiftb=(KEY_N - 1 -ci) * KeyBits;
+
     if (gtab_disp_partial_match)
-    while((CONVT2(cur_inmd, j) & vmask[ci])==val && j<e1) {
+    while((CONVT2(cur_inmd, j) & vmaskci)==val && j<e1) {
       int fff=cur_inmd->keycol[(CONVT2(cur_inmd, j)>>shiftb) & 0x3f];
       u_char *tbl_ch = tblch(j);
-
+#if 0
+      dbg("jj %d", fff); utf8_putchar(tbl_ch); dbg("\n");
+#endif
       if (!seltab[fff][0] || seltab_phrase[fff] ||
            (bchcmp(seltab[fff], tbl_ch)>0 && fff > exa_match)) {
 #if 0
-        if (tbl_ch[0] >= 0x80) {
-          bchcpy(seltab[fff], tbl_ch);
-          defselN++;
-        }
-        else
-        if (!seltab[fff][0]) {
-          load_phr(j, seltab[fff]);
-          seltab_phrase[fff] = TRUE;
-        }
-#endif
         if (!(seltab_phrase[fff] = load_seltab(j, fff)))
           defselN++;
+#else
+        seltab_phrase[fff] = load_seltab(j, fff);
+        defselN++;
+#endif
       }
 
       j++;
diff -urN gcin-1.3.0.1.orig/locale.c gcin-1.3.0.1/locale.c
--- gcin-1.3.0.1.orig/locale.c	2006-10-05 14:05:16.000000000 +0800
+++ gcin-1.3.0.1/locale.c	2006-11-22 18:00:41.000000000 +0800
@@ -165,3 +165,19 @@
 
   return N;
 }
+
+void utf8cpyn(char *t, char *s, int n)
+{
+  int tn=0;
+  int i;
+
+  for (i=0; i < n && *s; i++) {
+    int sz = utf8_sz(s);
+
+    memcpy(t+tn, s, sz);
+    tn+=sz;
+    s+=sz;
+  }
+
+  t[tn]=0;
+}
diff -urN gcin-1.3.0.1.orig/tsin-parse.c gcin-1.3.0.1/tsin-parse.c
--- gcin-1.3.0.1.orig/tsin-parse.c	2006-10-20 15:06:34.000000000 +0800
+++ gcin-1.3.0.1/tsin-parse.c	2006-11-22 11:08:59.000000000 +0800
@@ -96,7 +96,7 @@
       if (i < plen)
         continue;
 
-      int score;
+      float score;
 
       score = plen;
       if (match_len > plen) {
@@ -116,7 +116,7 @@
         continue;
       }
 
-      score = usecount + 50 * plen * plen;
+      score = (float)usecount + 200 * plen * plen * plen;
 
       if (pbestscore >= score)
         continue;
--- gcin-1.3.0.1/gcin2tab.c.orig	2006-08-20 16:26:34.000000000 +0800
+++ gcin-1.3.0.1/gcin2tab.c	2006-11-23 17:31:11.000000000 +0800
@@ -13,7 +13,7 @@
 #include <string.h>
 #include "gcin.h"
 #include "gtab.h"
-
+#include "gcin-endian.h"
 
 FILE *fr, *fw;
 int lineno;
@@ -149,13 +149,7 @@
   if (a->key > b->key) return 1;
   if (a->key < b->key) return -1;
 
-#if FREEBSD
-  if (a->oseq > b->oseq) return 1;
-  if (a->oseq < b->oseq) return -1;
-  return 0;
-#else
   return a->oseq - b->oseq;
-#endif
 }
 
 
@@ -166,13 +160,7 @@
   if (a->key > b->key) return 1;
   if (a->key < b->key) return -1;
 
-#if FREEBSD
-  if (a->oseq > b->oseq) return 1;
-  if (a->oseq < b->oseq) return -1;
-  return 0;
-#else
   return a->oseq - b->oseq;
-#endif
 }
 
 
@@ -423,7 +411,6 @@
 
     if ((len=strlen(arg)) <= CH_SZ && (arg[0] & 0x80)) {
       char out[CH_SZ+1];
-      int u8len = utf8_sz(arg);
 
       bzero(out, sizeof(out));
       memcpy(out, arg, len);
@@ -446,7 +433,7 @@
       }
 
       if (len > MAX_CIN_PHR)
-        p_err("phrase too long: %s\n", arg);
+        p_err("phrase too long: %s  max:%d bytes\n", arg, MAX_CIN_PHR);
 
       phridx = trealloc(phridx, int, phr_cou+1);
       phridx[phr_cou++]=prbf_cou;
@@ -467,7 +454,6 @@
     qsort(itar, chno,sizeof(ITEM2), qcmp2);
 
 
-
   if (key64) {
     for(i=0;i<chno;i++) {
       if (!i || memcmp(&itar64[i], &itar64[i-1], sizeof(ITEM64))) {
@@ -486,20 +472,23 @@
   th.DefC=chno;
   cur_inmd->DefChars = chno;
 
+#if FREEBSD
+#define _sort mergesort
+#else
+#define _sort qsort
+#endif
+
   if (key64)
-    qsort(itmp64,chno,sizeof(ITEM2_64),qcmp_64);
+    _sort(itmp64,chno,sizeof(ITEM2_64),qcmp_64);
   else
-    qsort(itmp,chno,sizeof(ITEM2),qcmp);
-
+    _sort(itmp,chno,sizeof(ITEM2),qcmp);
 
   if (key64) {
-    for(i=0;i<chno;i++) {
+    for(i=0;i<chno;i++)
       memcpy(&itout64[i],&itmp64[i],sizeof(ITEM64));
-    }
   } else {
-    for(i=0;i<chno;i++) {
+    for(i=0;i<chno;i++)
       memcpy(&itout[i],&itmp[i],sizeof(ITEM));
-    }
   }
 
 
@@ -526,24 +515,49 @@
 
   printf("Defined Characters:%d\n", chno);
 
+#if NEED_SWAP
+  to_gcin_endian_4(&th.version);
+  to_gcin_endian_4(&th.flag);
+  to_gcin_endian_4(&th.space_style);
+  to_gcin_endian_4(&th.KeyS);
+  to_gcin_endian_4(&th.MaxPress);
+  to_gcin_endian_4(&th.M_DUP_SEL);
+  to_gcin_endian_4(&th.DefC);
+#endif
   fwrite(&th,1,sizeof(th),fw);
   fwrite(keymap, 1, KeyNum, fw);
   fwrite(kname, CH_SZ, KeyNum, fw);
   fwrite(idx1, sizeof(gtab_idx1_t), KeyNum+1, fw);
 
   if (key64) {
+#if NEED_SWAP
+    for(i=0; i < chno; i++) {
+      to_gcin_endian_8(&itout64[i].key);
+    }
+#endif
     fwrite(itout64, sizeof(ITEM64), chno, fw);
 #if 0
     for(i=0; i < 100; i++)
       dbg("%d] %c%c%c\n", i, itout64[i].ch[0], itout64[i].ch[1], itout64[i].ch[2]);
 #endif
   }
-  else
+  else {
+#if NEED_SWAP
+    for(i=0; i < chno; i++) {
+      to_gcin_endian_4(&itout[i].key);
+    }
+#endif
     fwrite(itout, sizeof(ITEM), chno, fw);
+  }
 
   if (phr_cou) {
     phridx[phr_cou++]=prbf_cou;
     printf("phrase count:%d\n", phr_cou);
+#if NEED_SWAP
+    for(i=0; i < 100; i++)
+      to_gcin_endian_4(&phridx[i]);
+    to_gcin_endian_4(&phr_cou);
+#endif
     fwrite(&phr_cou, sizeof(int), 1, fw);
     fwrite(phridx, sizeof(int), phr_cou, fw);
     fwrite(phrbuf,1,prbf_cou,fw);




More information about the scm-commits mailing list