Fix "contains" op for strings and langsets.

This commit is contained in:
James Su 2003-05-28 01:34:38 +00:00
parent 53183e66e5
commit d4d1e8bc60
3 changed files with 119 additions and 6 deletions

View File

@ -737,6 +737,12 @@ FcStrCmpIgnoreCase (const FcChar8 *s1, const FcChar8 *s2);
int int
FcStrCmp (const FcChar8 *s1, const FcChar8 *s2); FcStrCmp (const FcChar8 *s1, const FcChar8 *s2);
const FcChar8 *
FcStrStrIgnoreCase (const FcChar8 *s1, const FcChar8 *s2);
const FcChar8 *
FcStrStr (const FcChar8 *s1, const FcChar8 *s2);
int int
FcUtf8ToUcs4 (const FcChar8 *src_orig, FcUtf8ToUcs4 (const FcChar8 *src_orig,
FcChar32 *dst, FcChar32 *dst,

View File

@ -565,13 +565,17 @@ FcConfigCompareValue (const FcValue m_o,
case FcTypeString: case FcTypeString:
switch (op) { switch (op) {
case FcOpEqual: case FcOpEqual:
case FcOpContains:
ret = FcStrCmpIgnoreCase (m.u.s, v.u.s) == 0; ret = FcStrCmpIgnoreCase (m.u.s, v.u.s) == 0;
break; break;
case FcOpContains:
ret = FcStrStrIgnoreCase (m.u.s, v.u.s) != 0;
break;
case FcOpNotEqual: case FcOpNotEqual:
case FcOpNotContains:
ret = FcStrCmpIgnoreCase (m.u.s, v.u.s) != 0; ret = FcStrCmpIgnoreCase (m.u.s, v.u.s) != 0;
break; break;
case FcOpNotContains:
ret = FcStrStrIgnoreCase (m.u.s, v.u.s) == 0;
break;
default: default:
break; break;
} }
@ -613,16 +617,16 @@ FcConfigCompareValue (const FcValue m_o,
case FcTypeLangSet: case FcTypeLangSet:
switch (op) { switch (op) {
case FcOpContains: case FcOpContains:
ret = FcLangSetContains (v.u.l, m.u.l); ret = FcLangSetContains (m.u.l, v.u.l);
break; break;
case FcOpNotContains: case FcOpNotContains:
ret = FcLangSetContains (v.u.l, m.u.l); ret = FcLangSetContains (m.u.l, v.u.l);
break; break;
case FcOpEqual: case FcOpEqual:
ret = FcLangSetEqual (v.u.l, m.u.l); ret = FcLangSetEqual (m.u.l, v.u.l);
break; break;
case FcOpNotEqual: case FcOpNotEqual:
ret = !FcLangSetEqual (v.u.l, m.u.l); ret = !FcLangSetEqual (m.u.l, v.u.l);
break; break;
default: default:
break; break;

View File

@ -188,6 +188,109 @@ FcStrContainsIgnoreCase (const FcChar8 *s1, const FcChar8 *s2)
return 0; return 0;
} }
const FcChar8 *
FcStrStrIgnoreCase (const FcChar8 *s1, const FcChar8 *s2)
{
FcChar8 c1, c2;
const FcChar8 * p = s1;
const FcChar8 * b = s2;
if (!s1 || !s2)
return 0;
if (s1 == s2)
return s1;
again:
c2 = *s2++;
c2 = FcToLower (c2);
if (!c2)
return 0;
for (;;)
{
p = s1;
c1 = *s1++;
if (!c1 || (c1 = FcToLower (c1)) == c2)
break;
}
if (c1 != c2)
return 0;
for (;;)
{
c1 = *s1;
c2 = *s2;
if (c1 && c2 && (c1 = FcToLower (c1)) != (c2 = FcToLower (c2)))
{
s1 = p + 1;
s2 = b;
goto again;
}
if (!c2)
return p;
if (!c1)
return 0;
++ s1;
++ s2;
}
return 0;
}
const FcChar8 *
FcStrStr (const FcChar8 *s1, const FcChar8 *s2)
{
FcChar8 c1, c2;
const FcChar8 * p = s1;
const FcChar8 * b = s2;
if (!s1 || !s2)
return 0;
if (s1 == s2)
return s1;
again:
c2 = *s2++;
if (!c2)
return 0;
for (;;)
{
p = s1;
c1 = *s1++;
if (!c1 || c1 == c2)
break;
}
if (c1 != c2)
return 0;
for (;;)
{
c1 = *s1;
c2 = *s2;
if (c1 && c2 && c1 != c2)
{
s1 = p + 1;
s2 = b;
goto again;
}
if (!c2)
return p;
if (!c1)
return 0;
++ s1;
++ s2;
}
return 0;
}
int int
FcUtf8ToUcs4 (const FcChar8 *src_orig, FcUtf8ToUcs4 (const FcChar8 *src_orig,
FcChar32 *dst, FcChar32 *dst,