Add contains/not_contains, fix LangSet equal operator to use FcLangEqual

This commit is contained in:
Keith Packard 2002-08-22 18:53:22 +00:00
parent d8d7395877
commit 47d4f9501f
8 changed files with 67 additions and 21 deletions

View File

@ -1,3 +1,16 @@
Thu Aug 22 11:36:18 PDT 2002 keithp
+ Add "contains" and "not_contains" operators and elements to
font configuration
+ Changed semantics of eq operator for LangSets to check for
FcLangEqual so that any match will do
+ FcFontList was using FcConfigCompareValue (...FcOpEqual) instead
of FcValueEqual to check for identical values when inserting into
the results. This broke when the above semantic change was made,
now it uses FcValueEqual which is "more correct" in any case.
Thu Aug 22 00:32:29 PDT 2002 keithp
+ Reimplement FC_LANG as new datatype. Lists of strings

View File

@ -90,7 +90,7 @@
<!ENTITY % expr 'int|double|string|matrix|bool|charset
|name|const
|or|and|eq|not_eq|less|less_eq|more|more_eq
|or|and|eq|not_eq|less|less_eq|more|more_eq|contains|not_contains
|plus|minus|times|divide|not|if'>
<!--
@ -121,7 +121,7 @@
qual (any|all|first|not_first) "any"
name CDATA #REQUIRED
target (pattern|font|default) "default"
compare (eq|not_eq|less|less_eq|more|more_eq) "eq">
compare (eq|not_eq|less|less_eq|more|more_eq|contains|not_contains) "eq">
<!--
Edit a field in a pattern
@ -172,6 +172,8 @@
<!ELEMENT less_eq ((%expr;), (%expr;))>
<!ELEMENT more ((%expr;), (%expr;))>
<!ELEMENT more_eq ((%expr;), (%expr;))>
<!ELEMENT contains ((%expr;), (%expr;))>
<!ELEMENT not_contains ((%expr;), (%expr;))>
<!ELEMENT plus (%expr;)*>
<!ELEMENT minus (%expr;)*>
<!ELEMENT times (%expr;)*>

View File

@ -1,5 +1,5 @@
/*
* $XFree86: xc/lib/fontconfig/src/fccfg.c,v 1.20 2002/08/19 19:32:05 keithp Exp $
* $XFree86: xc/lib/fontconfig/src/fccfg.c,v 1.21 2002/08/22 07:36:44 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
@ -502,6 +502,7 @@ FcConfigCompareValue (FcValue m,
ret = m.u.d == v.u.d;
break;
case FcOpNotEqual:
case FcOpNotContains:
ret = m.u.d != v.u.d;
break;
case FcOpLess:
@ -527,6 +528,7 @@ FcConfigCompareValue (FcValue m,
ret = m.u.b == v.u.b;
break;
case FcOpNotEqual:
case FcOpNotContains:
ret = m.u.b != v.u.b;
break;
default:
@ -540,6 +542,7 @@ FcConfigCompareValue (FcValue m,
ret = FcStrCmpIgnoreCase (m.u.s, v.u.s) == 0;
break;
case FcOpNotEqual:
case FcOpNotContains:
ret = FcStrCmpIgnoreCase (m.u.s, v.u.s) != 0;
break;
default:
@ -553,6 +556,7 @@ FcConfigCompareValue (FcValue m,
ret = FcMatrixEqual (m.u.m, v.u.m);
break;
case FcOpNotEqual:
case FcOpNotContains:
ret = !FcMatrixEqual (m.u.m, v.u.m);
break;
default:
@ -565,6 +569,10 @@ FcConfigCompareValue (FcValue m,
/* m contains v if v is a subset of m */
ret = FcCharSetIsSubset (v.u.c, m.u.c);
break;
case FcOpNotContains:
/* m contains v if v is a subset of m */
ret = !FcCharSetIsSubset (v.u.c, m.u.c);
break;
case FcOpEqual:
ret = FcCharSetEqual (m.u.c, v.u.c);
break;
@ -580,6 +588,9 @@ FcConfigCompareValue (FcValue m,
case FcOpContains:
ret = FcLangSetCompare (v.u.l, m.u.l) != FcLangDifferentLang;
break;
case FcOpNotContains:
ret = FcLangSetCompare (v.u.l, m.u.l) == FcLangDifferentLang;
break;
case FcOpEqual:
ret = FcLangSetEqual (v.u.l, m.u.l);
break;
@ -603,9 +614,11 @@ FcConfigCompareValue (FcValue m,
case FcTypeFTFace:
switch (op) {
case FcOpEqual:
case FcOpContains:
ret = m.u.f == v.u.f;
break;
case FcOpNotEqual:
case FcOpNotContains:
ret = m.u.f != v.u.f;
break;
default:
@ -616,7 +629,7 @@ FcConfigCompareValue (FcValue m,
}
else
{
if (op == FcOpNotEqual)
if (op == FcOpNotEqual || op == FcOpNotContains)
ret = FcTrue;
}
return ret;
@ -682,12 +695,14 @@ FcConfigEvaluate (FcPattern *p, FcExpr *e)
v.type = FcTypeVoid;
FcValueDestroy (vl);
break;
case FcOpContains:
case FcOpEqual:
case FcOpNotEqual:
case FcOpLess:
case FcOpLessEqual:
case FcOpMore:
case FcOpMoreEqual:
case FcOpContains:
case FcOpNotContains:
vl = FcConfigEvaluate (p, e->u.tree.left);
vr = FcConfigEvaluate (p, e->u.tree.right);
v.type = FcTypeBool;
@ -697,7 +712,6 @@ FcConfigEvaluate (FcPattern *p, FcExpr *e)
break;
case FcOpOr:
case FcOpAnd:
case FcOpEqual:
case FcOpPlus:
case FcOpMinus:
case FcOpTimes:

View File

@ -111,12 +111,13 @@ FcOpPrint (FcOp op)
case FcOpOr: printf ("Or"); break;
case FcOpAnd: printf ("And"); break;
case FcOpEqual: printf ("Equal"); break;
case FcOpContains: printf ("Contains"); break;
case FcOpNotEqual: printf ("NotEqual"); break;
case FcOpLess: printf ("Less"); break;
case FcOpLessEqual: printf ("LessEqual"); break;
case FcOpMore: printf ("More"); break;
case FcOpMoreEqual: printf ("MoreEqual"); break;
case FcOpContains: printf ("Contains"); break;
case FcOpNotContains: printf ("NotContains"); break;
case FcOpPlus: printf ("Plus"); break;
case FcOpMinus: printf ("Minus"); break;
case FcOpTimes: printf ("Times"); break;
@ -161,12 +162,13 @@ FcExprPrint (const FcExpr *expr)
case FcOpOr:
case FcOpAnd:
case FcOpEqual:
case FcOpContains:
case FcOpNotEqual:
case FcOpLess:
case FcOpLessEqual:
case FcOpMore:
case FcOpMoreEqual:
case FcOpContains:
case FcOpNotContains:
case FcOpPlus:
case FcOpMinus:
case FcOpTimes:
@ -184,12 +186,13 @@ FcExprPrint (const FcExpr *expr)
case FcOpOr: printf ("Or"); break;
case FcOpAnd: printf ("And"); break;
case FcOpEqual: printf ("Equal"); break;
case FcOpContains: printf ("Contains"); break;
case FcOpNotEqual: printf ("NotEqual"); break;
case FcOpLess: printf ("Less"); break;
case FcOpLessEqual: printf ("LessEqual"); break;
case FcOpMore: printf ("More"); break;
case FcOpMoreEqual: printf ("MoreEqual"); break;
case FcOpContains: printf ("Contains"); break;
case FcOpNotContains: printf ("NotContains"); break;
case FcOpPlus: printf ("Plus"); break;
case FcOpMinus: printf ("Minus"); break;
case FcOpTimes: printf ("Times"); break;

View File

@ -1,5 +1,5 @@
/*
* $XFree86: xc/lib/fontconfig/src/fcint.h,v 1.21 2002/07/31 01:36:37 keithp Exp $
* $XFree86: xc/lib/fontconfig/src/fcint.h,v 1.24 2002/08/22 07:36:44 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
@ -114,7 +114,7 @@ typedef enum _FcOp {
FcOpAssign, FcOpAssignReplace,
FcOpPrependFirst, FcOpPrepend, FcOpAppend, FcOpAppendLast,
FcOpQuest,
FcOpOr, FcOpAnd, FcOpEqual, FcOpNotEqual, FcOpContains,
FcOpOr, FcOpAnd, FcOpEqual, FcOpNotEqual, FcOpContains, FcOpNotContains,
FcOpLess, FcOpLessEqual, FcOpMore, FcOpMoreEqual,
FcOpPlus, FcOpMinus, FcOpTimes, FcOpDivide,
FcOpNot, FcOpComma, FcOpInvalid

View File

@ -384,6 +384,7 @@ FcLangSetPromote (const FcChar8 *lang)
strs.num = 1;
strs.size = 1;
strs.strs = &str;
strs.ref = 1;
str = (FcChar8 *) lang;
}
return &ls;

View File

@ -1,5 +1,5 @@
/*
* $XFree86: xc/lib/fontconfig/src/fclist.c,v 1.9 2002/08/19 19:32:05 keithp Exp $
* $XFree86: xc/lib/fontconfig/src/fclist.c,v 1.10 2002/08/22 07:36:44 keithp Exp $
*
* Copyright Š 2000 Keith Packard, member of The XFree86 Project, Inc.
*
@ -142,7 +142,7 @@ FcListValueListEqual (FcValueList *v1orig,
for (v1 = v1orig; v1; v1 = v1->next)
{
for (v2 = v2orig; v2; v2 = v2->next)
if (FcConfigCompareValue (v1->value, FcOpEqual, v2->value))
if (FcValueEqual (v1->value, v2->value))
break;
if (!v2)
return FcFalse;
@ -150,7 +150,7 @@ FcListValueListEqual (FcValueList *v1orig,
for (v2 = v2orig; v2; v2 = v2->next)
{
for (v1 = v1orig; v1; v1 = v1->next)
if (FcConfigCompareValue (v1->value, FcOpEqual, v2->value))
if (FcValueEqual (v1->value, v2->value))
break;
if (!v1)
return FcFalse;
@ -171,7 +171,7 @@ FcListPatternEqual (FcPattern *p1,
e1 = FcPatternFindElt (p1, os->objects[i]);
e2 = FcPatternFindElt (p2, os->objects[i]);
if (!e1 && !e2)
return FcTrue;
continue;
if (!e1 || !e2)
return FcFalse;
if (!FcListValueListEqual (e1->values, e2->values))

View File

@ -1,5 +1,5 @@
/*
* $XFree86: xc/lib/fontconfig/src/fcxml.c,v 1.19 2002/08/19 19:32:05 keithp Exp $
* $XFree86: xc/lib/fontconfig/src/fcxml.c,v 1.20 2002/08/20 23:17:03 keithp Exp $
*
* Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
*
@ -218,12 +218,13 @@ FcExprDestroy (FcExpr *e)
case FcOpOr:
case FcOpAnd:
case FcOpEqual:
case FcOpContains:
case FcOpNotEqual:
case FcOpLess:
case FcOpLessEqual:
case FcOpMore:
case FcOpMoreEqual:
case FcOpContains:
case FcOpNotContains:
case FcOpPlus:
case FcOpMinus:
case FcOpTimes:
@ -310,6 +311,8 @@ typedef enum _FcElement {
FcElementLessEq,
FcElementMore,
FcElementMoreEq,
FcElementContains,
FcElementNotContains,
FcElementPlus,
FcElementMinus,
FcElementTimes,
@ -360,6 +363,8 @@ FcElementMap (const XML_Char *name)
{ "less_eq", FcElementLessEq },
{ "more", FcElementMore },
{ "more_eq", FcElementMoreEq },
{ "contains", FcElementContains },
{ "not_contains",FcElementNotContains },
{ "plus", FcElementPlus },
{ "minus", FcElementMinus },
{ "times", FcElementTimes },
@ -1337,7 +1342,9 @@ static const FcOpMap fcCompareOps[] = {
{ "less", FcOpLess },
{ "less_eq", FcOpLessEqual },
{ "more", FcOpMore },
{ "more_eq", FcOpMoreEqual }
{ "more_eq", FcOpMoreEqual },
{ "contains", FcOpContains },
{ "not_contains", FcOpNotContains }
};
#define NUM_COMPARE_OPS (sizeof fcCompareOps / sizeof fcCompareOps[0])
@ -1674,6 +1681,12 @@ FcEndElement(void *userData, const XML_Char *name)
case FcElementMoreEq:
FcParseExpr (parse, FcOpMoreEqual);
break;
case FcElementContains:
FcParseExpr (parse, FcOpContains);
break;
case FcElementNotContains:
FcParseExpr (parse, FcOpNotContains);
break;
case FcElementPlus:
FcParseExpr (parse, FcOpPlus);
break;