今天看T9输入法,九宫格上输入‘5’,出现了下面的情况,是bug吗?还是我看的代码年份很久了?另外其中一行代码看不太明白,请教一下。
[mw_shl_code=c,true]u8 get_matched_pymb(u8 *strin,py_index **matchlist)
{
py_index *bestmatch;//最佳匹配
u16 pyindex_len;
u16 i;
u8 temp,mcnt=0,bmcnt=0;
bestmatch=(py_index*)&py_index3[0];//默认为空格的匹配
pyindex_len=sizeof(py_index3)/sizeof(py_index3[0]);//得到py索引表的大小.
for(i=0;i<pyindex_len;i++)
{
temp=str_match(strin,(u8*)py_index3.py_input);
if(temp)
{
if(temp==0XFF)matchlist[mcnt++]=(py_index*)&py_index3; //这一行看不太懂!!!
else if(temp>bmcnt)//找最佳匹配
{
bmcnt=temp;
bestmatch=(py_index*)&py_index3;//最好的匹配.
}
}
}
if(mcnt==0&&bmcnt)//没有完全匹配的结果,但是有部分匹配的结果
{
matchlist[0]=bestmatch;
mcnt=bmcnt|0X80; //返回部分匹配的有效位数
}
return mcnt;//返回匹配的个数
}[/mw_shl_code]
|