Exemple #1
0
/*
 * 比较第二位拼音映射是否和第一个相等
 * 0表示相等
 * >0表示前者大
 * <0表示后者大
 */
int Cmp2Map(FcitxPinyinConfig* pyconfig, char map1[3], char map2[3], boolean bSP)
{
    int             i;

    if (IsZ_C_S(map2[0]) && map2[1] == '0')
        i = Cmp1Map(pyconfig, map1[0], map2[0], true, true, bSP);
    else
        i = Cmp1Map(pyconfig, map1[0], map2[0], true, false, bSP);

    if (i)
        return i;

    return Cmp1Map(pyconfig, map1[1], map2[1], false, false, bSP);
}
Exemple #2
0
/*
 * 比较第二位拼音映射是否和第一个相等
 * 0表示相等
 * >0表示前者大
 * <0表示后者大
 */
int Cmp2Map (char map1[3], char map2[3])
{
    int             i;

    if (IsZ_C_S(map2[0]) && map2[1]=='0')
	i = Cmp1Map (map1[0], map2[0], True, True);
    else
	i = Cmp1Map (map1[0], map2[0], True, False);
    
    if (i)
	return i;

    return Cmp1Map (map1[1], map2[1], False, False);
}
Exemple #3
0
/*
 * 判断strMap2是否与strMap1相匹配
 * 是 返回值为0
 * 否 返回值不为0
 * *iMatchedLength 记录了二者能够匹配的长度
 */
int CmpMap (char *strMap1, char *strMap2, int *iMatchedLength)
{
    int             val;

    *iMatchedLength = 0;
    for (;;) {
	if (!strMap2[*iMatchedLength])
	    return (strMap1[*iMatchedLength] - strMap2[*iMatchedLength]);
	if ( ((*iMatchedLength + 1) % 2) && (IsZ_C_S(strMap2[*iMatchedLength]) && (strMap2[*iMatchedLength + 1]=='0' || !strMap2[*iMatchedLength + 1]) ) )
	    val = Cmp1Map (strMap1[*iMatchedLength], strMap2[*iMatchedLength], (*iMatchedLength + 1) % 2, True);
	else
	    val = Cmp1Map (strMap1[*iMatchedLength], strMap2[*iMatchedLength], (*iMatchedLength + 1) % 2, False);
	    
	if (val)
	    return val;
	    
	(*iMatchedLength)++;
    }

    return 0;
}
Exemple #4
0
/*
 * 判断strMap2是否与strMap1相匹配
 * 是 返回值为0
 * 否 返回值不为0
 * *iMatchedLength 记录了二者能够匹配的长度
 */
int CmpMap(FcitxPinyinConfig* pyconfig, char *strMap1, char *strMap2, int *iMatchedLength, boolean bSP)
{
    int             val;

    *iMatchedLength = 0;

    for (;;) {
        if (!strMap2[*iMatchedLength])
            return (strMap1[*iMatchedLength] - strMap2[*iMatchedLength]);

        if (((*iMatchedLength + 1) % 2) && (IsZ_C_S(strMap2[*iMatchedLength]) && (strMap2[*iMatchedLength + 1] == '0' || !strMap2[*iMatchedLength + 1])))
            val = Cmp1Map(pyconfig, strMap1[*iMatchedLength], strMap2[*iMatchedLength], (*iMatchedLength + 1) % 2, true, bSP);
        else
            val = Cmp1Map(pyconfig, strMap1[*iMatchedLength], strMap2[*iMatchedLength], (*iMatchedLength + 1) % 2, false, bSP);

        if (val)
            return val;

        (*iMatchedLength)++;
    }

    return 0;
}