--- inp.c.dist Wed Feb 24 03:30:33 1999 +++ inp.c Sun Jul 11 22:19:29 1999 @@ -37,7 +37,7 @@ extern char *showfname; extern char visual_bell; extern char wildmode; -extern char system_last_full; +extern signed char system_last_full; extern char clear_wrong; extern char simplest; extern int NowMax; @@ -76,9 +76,10 @@ char selkey[SELECT_KEY_LENGTH]; /* 選字所需要的按鍵 */ char endkey[END_KEY_LENGTH]; /* 「結束鍵」 */ char keyvvv[65]; - char last_full; /* 滿字根後的空白鍵是否要忽略? */ + signed char last_full; /* 滿字根後的空白鍵是否要忽略? */ /* 1: 忽略 */ /* 0: 不忽略(照樣送出空白字元)*/ + /* -1: 無定義 (cin2tab.c) */ char NoBosh; /* 是否要用「先上字」模式? */ /* 1: 不要 */ @@ -91,6 +92,8 @@ } INMD; +#define SEL1ST_I_UNDEFINED 15 + static INMD inmd[10], *cur_inmd; static INMD showinmd; static char seltab[12][MAX_CIN_PHR]; @@ -128,7 +131,7 @@ } -char vvvv_fopen(FILE **fp,char *s) +signed char vvvv_fopen(FILE **fp,char *s) { char sss[MAX_PATH_LENGTH], ttt[MAX_PATH_LENGTH], uuu[MAX_PATH_LENGTH]; char *vv; @@ -187,7 +190,7 @@ } -static char open_vocbox( INMD *inp , int inmdno ) +static signed char open_vocbox( INMD *inp , int inmdno ) { int i, j; int mfree; @@ -402,7 +405,7 @@ now_simplest = 0; cin = 0; - sel1st_i = 15; + sel1st_i = SEL1ST_I_UNDEFINED; } @@ -1242,7 +1245,7 @@ if ( cur_inmd->NoBosh ) { - if ( seltab[sel1st_i][0] ) { + if ( sel1st_i != SEL1ST_I_UNDEFINED && seltab[sel1st_i][0] ) { if ( seltab[1][0] ) bell( 2 ); @@ -1272,7 +1275,7 @@ } else { - if ( seltab[sel1st_i][0] ) { + if ( sel1st_i != SEL1ST_I_UNDEFINED && seltab[sel1st_i][0] ) { if ( seltab[1][0] ) bell( 2 ); @@ -1341,7 +1344,7 @@ if ( key < 32 || key > 0x7e ) { - if ( seltab[sel1st_i][0] ) + if ( sel1st_i != SEL1ST_I_UNDEFINED && seltab[sel1st_i][0] ) putstr_inp( sel1st_i ); return 0; @@ -1374,7 +1377,7 @@ if ( iselkey && !ci && !( inkey >= 1 && inkey < 60 ) ) return 0; - if ( !iselkey && seltab[sel1st_i][0] && key!=8 && !wild_mode ) + if ( !iselkey && sel1st_i != SEL1ST_I_UNDEFINED && seltab[sel1st_i][0] && key!=8 && !wild_mode ) putstr_inp( sel1st_i ); if ( inkey>=1 && ci< cur_inmd->MaxPress ) { @@ -1464,10 +1467,10 @@ last_idx = s1; if ( iselkey && defsel && - ( ( CONVT( cur_inmd->tbl[s1].key1 ) & vmask[ci] ) !=val1 + ( ( ( CONVT( cur_inmd->tbl[s1].key1 ) & vmask[ci] ) !=val1 || ( CONVT( cur_inmd->tbl[s1].key2 ) & vmask[ci-5] ) != val2 || ( wild_mode && defsel ) - || ( ci == cur_inmd->MaxPress || spc_pressed ) + || ( ci == cur_inmd->MaxPress || spc_pressed ) ) && ( ( cur_inmd->NoBosh && ( inkey == 0 || defsel >= iselkey-cur_inmd->selkey+1 ) ) @@ -1709,7 +1712,7 @@ int i; ClrSelArea(); - sel1st_i = 15; + sel1st_i = SEL1ST_I_UNDEFINED; gotoxy( 0, 0 ); if ( cur_inmd->sel1st ) { @@ -1731,7 +1734,7 @@ } /* end if( (cur_inmd .......) */ } - if ( sel1st_i == 15 && !i && !more_pg ) { + if ( sel1st_i == SEL1ST_I_UNDEFINED && !i && !more_pg ) { sel1st_i = i; --- ser_dispatch.c.dist Wed Feb 24 03:30:33 1999 +++ ser_dispatch.c Tue Jul 13 01:31:10 1999 @@ -98,6 +98,7 @@ { extern InmdState inmdstate; int slen; +#ifdef STRUCT_CAN_DO_BYTE_ALIGNMENT XCIN_RES res; res.len=len; @@ -109,6 +110,42 @@ } memcpy(res.tkey, str, len); slen=sizeof(res)-sizeof(res.tkey)+len; +#else + /* We can't stuff things into the XCIN_RES structure and expect things + * to work on the ARM processor (and some others), because on that + * architecture structure members are not byte-aligned, so we will + * have all the alignment screwed up. The only way to work around this + * is to use "data marshalling techniques". + * + * From state.h, we expect the packet to have the following structure: + * + 0 V .len + * + 4 V .status + * + 8 c .inmdstate.kb_state + * + 9 c .inmdstate._CurInMethod + * +10 .tkey (length "len") + * + * In Perl-ism, we need to construct the equivalent of + * pack("VVcc", len, status, inmdstate.kb_state, + * inmdstate._CurInMethod) . substr(str, 0, len) + * + * We are assuming that char arrays *are* byte-aligned. + * Otherwise we lose. + */ + u_char res[10 + XCIN_RES_TKEY_SIZE]; + /* Note: memcpy segfaults (reason not obvious), so we don't use it */ + res[0] = len & 255; + res[1] = (len >> 8) & 255; + res[2] = (len >> 16) & 255; + res[3] = (len >> 24) & 255; + res[4] = status & 255; + res[5] = (status >> 8) & 255; + res[6] = (status >> 16) & 255; + res[7] = (status >> 24) & 255; + res[8] = inmdstate.kb_state; + res[9] = inmdstate._CurInMethod; + memcpy(&(res[10]), str, len); + slen = 10 + len; +#endif XChangeProperty(display, main_win , xcin_atom, XA_STRING, 8, PropModeReplace, (u_char *)&res, slen); --- state.h.dist Wed Feb 24 03:30:33 1999 +++ state.h Sat Jul 10 23:55:25 1999 @@ -10,11 +10,14 @@ #define EngChiMask (1) #define HalfFullMask (2) +/* Use this instead of sizeof() to avoid problem on some archs e.g., ARM */ +#define XCIN_RES_TKEY_SIZE 512 + typedef struct { int len; int status; InmdState inmdstate; - char tkey[512]; + char tkey[XCIN_RES_TKEY_SIZE]; } XCIN_RES; #define EngChi ((inmdstate.kb_state & EngChiMask) ? 1:0) --- tsin.c.dist Wed Feb 24 03:30:33 1999 +++ tsin.c Sat Mar 20 17:53:06 1999 @@ -15,7 +15,7 @@ #define b2cpy(a,b) memcpy(a,b,2) -extern char vvvv_fopen(FILE **fp,char *s); +extern signed char vvvv_fopen(FILE **fp,char *s); extern void change_window_name(char *str); extern char pin_tsin; extern u_char *ch_pho; --- vocbox.c.dist Wed Feb 24 03:30:33 1999 +++ vocbox.c Sat Mar 20 17:50:42 1999 @@ -48,7 +48,7 @@ int (*compar)(const void *, const void *)); extern void bzero(void *s, int n); -char InitVocBox(int usenow) +signed char InitVocBox(int usenow) { FILE *fp; char tt[1024]; --- xi.c.dist Fri Mar 12 18:41:23 1999 +++ xi.c Tue Jul 13 01:25:56 1999 @@ -47,7 +47,7 @@ extern char *tsfname; extern char *phrfname; extern char *phokbm_name; -extern char InitVocBox( int usenow); +extern signed char InitVocBox( int usenow); extern void ClrSelArea(); extern void init_msg_channel(); extern void init_phrase(); @@ -67,7 +67,7 @@ int ignore_cli_stat = 0; char simplest = SIMPLEST_MODE; char clear_wrong = CLEAR_WRONG; -char system_last_full = -1; +signed char system_last_full = -1; char wildmode = WILDMODE; char visual_bell = VISUAL_BELL; char xcin_row = ROW; @@ -302,7 +302,7 @@ p_err( "Cannot load Chinese font %s", cfnt_name); fwidth = sizehints.width_inc = afont->max_bounds.width; - fheight = sizehints.height_inc = afont->ascent + afont->descent; + fheight = sizehints.height_inc = afont->max_bounds.ascent + afont->max_bounds.descent; flags = XParseGeometry(geomstr,&x,&y,&width,&height); @@ -769,9 +769,9 @@ } -char get_reldata( u_char *s ) +signed char get_reldata( u_char *s ) { - static char enter_num=0; + static signed char enter_num=0; int c; int i=0; @@ -940,7 +940,6 @@ static void putstr_rel( char ch ) { - int i; putstr( &seltab_rel[ch + (rel_now_pg-1) * 8][0] ); ClrSelArea(); ClrShowArea(1); @@ -1139,7 +1138,7 @@ show_halffull(); } -char test_rel( char ch ) +signed char test_rel( char ch ) { char *ow_rel = "!@#$%^&*"; @@ -1519,9 +1518,8 @@ void XResourceFile(int argc, char **argv); -void main(int argc, char **argv) +int main(int argc, char **argv) { - int i; XGCValues gcv; char *d_name; @@ -1599,7 +1597,7 @@ init_phrase(); change_window_name("English"); run_event(); -return ; +return 0; } --- xi.h.dist Wed Feb 24 03:30:33 1999 +++ xi.h Sat Mar 20 17:54:49 1999 @@ -18,7 +18,7 @@ char cname[CIN_CNAME_LENGTH]; /* prompt */ char selkey[SELECT_KEY_LENGTH]; /* select keys */ char endkey[END_KEY_LENGTH]; /* end ekys */ - char last_full; + signed char last_full; char endian; int KeyS; /* number of keys needed */ int MaxPress; /* Max len of keystroke array30:4 cj:5 */