/* * 根据字符查找符号 */ char *VKGetSymbol(FcitxVKState *vkstate, char cChar) { int i; for (i = 0; i < VK_NUMBERS; i++) { if (MyToUpper(vkTable[i]) == cChar) return vkstate->vks[vkstate->iCurrentVK].strSymbol[i][1]; if (MyToLower(vkTable[i]) == cChar) return vkstate->vks[vkstate->iCurrentVK].strSymbol[i][0]; } return NULL; }
/* match() * * Compare if a given string (name) matches the given * mask (which can contain wild cards: '*' - match any * number of chars, '?' - match any single character. * * return 0, if match * 1, if no match * * Originally by Douglas A Lewis ([email protected]) */ #define MATCH_MAX_CALLS 512 /* ACK! This dies when it's less that this and we have long lines to parse */ int match (const char *mask, const char *name) { const unsigned char *m = (const unsigned char *) mask; const unsigned char *n = (const unsigned char *) name; const unsigned char *ma = (const unsigned char *) mask; const unsigned char *na = (const unsigned char *) name; int wild = 0; int calls = 0; if (!mask || !name) { return 1; } while (calls++ < MATCH_MAX_CALLS) { if (*m == '*') { /* * XXX - shouldn't need to spin here, the mask should have been * collapsed before match is called */ while (*m == '*') { m++; } wild = 1; ma = m; na = n; } if (!*m) { if (!*n) { return 0; } for (m--; (m > (const unsigned char *) mask) && (*m == '?'); m--) ; if (*m == '*' && (m > (const unsigned char *) mask)) { return 0; } if (!wild) { return 1; } m = ma; n = ++na; } else if (!*n) { /* * XXX - shouldn't need to spin here, the mask should have been * collapsed before match is called */ while (*m == '*') { m++; } return (*m != 0); } if (MyToLower (*m) != MyToLower (*n) && *m != '?') { if (!wild) { return 1; } m = ma; n = ++na; } else { if (*m) { m++; } if (*n) { n++; } } } return 1; }