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 Thu Aug 22 00:32:29 PDT 2002 keithp
+ Reimplement FC_LANG as new datatype. Lists of strings + Reimplement FC_LANG as new datatype. Lists of strings

View File

@ -90,7 +90,7 @@
<!ENTITY % expr 'int|double|string|matrix|bool|charset <!ENTITY % expr 'int|double|string|matrix|bool|charset
|name|const |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'> |plus|minus|times|divide|not|if'>
<!-- <!--
@ -121,7 +121,7 @@
qual (any|all|first|not_first) "any" qual (any|all|first|not_first) "any"
name CDATA #REQUIRED name CDATA #REQUIRED
target (pattern|font|default) "default" 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 Edit a field in a pattern
@ -172,6 +172,8 @@
<!ELEMENT less_eq ((%expr;), (%expr;))> <!ELEMENT less_eq ((%expr;), (%expr;))>
<!ELEMENT more ((%expr;), (%expr;))> <!ELEMENT more ((%expr;), (%expr;))>
<!ELEMENT more_eq ((%expr;), (%expr;))> <!ELEMENT more_eq ((%expr;), (%expr;))>
<!ELEMENT contains ((%expr;), (%expr;))>
<!ELEMENT not_contains ((%expr;), (%expr;))>
<!ELEMENT plus (%expr;)*> <!ELEMENT plus (%expr;)*>
<!ELEMENT minus (%expr;)*> <!ELEMENT minus (%expr;)*>
<!ELEMENT times (%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. * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
* *
@ -502,6 +502,7 @@ FcConfigCompareValue (FcValue m,
ret = m.u.d == v.u.d; ret = m.u.d == v.u.d;
break; break;
case FcOpNotEqual: case FcOpNotEqual:
case FcOpNotContains:
ret = m.u.d != v.u.d; ret = m.u.d != v.u.d;
break; break;
case FcOpLess: case FcOpLess:
@ -527,6 +528,7 @@ FcConfigCompareValue (FcValue m,
ret = m.u.b == v.u.b; ret = m.u.b == v.u.b;
break; break;
case FcOpNotEqual: case FcOpNotEqual:
case FcOpNotContains:
ret = m.u.b != v.u.b; ret = m.u.b != v.u.b;
break; break;
default: default:
@ -540,6 +542,7 @@ FcConfigCompareValue (FcValue m,
ret = FcStrCmpIgnoreCase (m.u.s, v.u.s) == 0; ret = FcStrCmpIgnoreCase (m.u.s, v.u.s) == 0;
break; 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;
default: default:
@ -553,6 +556,7 @@ FcConfigCompareValue (FcValue m,
ret = FcMatrixEqual (m.u.m, v.u.m); ret = FcMatrixEqual (m.u.m, v.u.m);
break; break;
case FcOpNotEqual: case FcOpNotEqual:
case FcOpNotContains:
ret = !FcMatrixEqual (m.u.m, v.u.m); ret = !FcMatrixEqual (m.u.m, v.u.m);
break; break;
default: default:
@ -565,6 +569,10 @@ FcConfigCompareValue (FcValue m,
/* m contains v if v is a subset of m */ /* m contains v if v is a subset of m */
ret = FcCharSetIsSubset (v.u.c, m.u.c); ret = FcCharSetIsSubset (v.u.c, m.u.c);
break; break;
case FcOpNotContains:
/* m contains v if v is a subset of m */
ret = !FcCharSetIsSubset (v.u.c, m.u.c);
break;
case FcOpEqual: case FcOpEqual:
ret = FcCharSetEqual (m.u.c, v.u.c); ret = FcCharSetEqual (m.u.c, v.u.c);
break; break;
@ -580,6 +588,9 @@ FcConfigCompareValue (FcValue m,
case FcOpContains: case FcOpContains:
ret = FcLangSetCompare (v.u.l, m.u.l) != FcLangDifferentLang; ret = FcLangSetCompare (v.u.l, m.u.l) != FcLangDifferentLang;
break; break;
case FcOpNotContains:
ret = FcLangSetCompare (v.u.l, m.u.l) == FcLangDifferentLang;
break;
case FcOpEqual: case FcOpEqual:
ret = FcLangSetEqual (v.u.l, m.u.l); ret = FcLangSetEqual (v.u.l, m.u.l);
break; break;
@ -603,9 +614,11 @@ FcConfigCompareValue (FcValue m,
case FcTypeFTFace: case FcTypeFTFace:
switch (op) { switch (op) {
case FcOpEqual: case FcOpEqual:
case FcOpContains:
ret = m.u.f == v.u.f; ret = m.u.f == v.u.f;
break; break;
case FcOpNotEqual: case FcOpNotEqual:
case FcOpNotContains:
ret = m.u.f != v.u.f; ret = m.u.f != v.u.f;
break; break;
default: default:
@ -616,7 +629,7 @@ FcConfigCompareValue (FcValue m,
} }
else else
{ {
if (op == FcOpNotEqual) if (op == FcOpNotEqual || op == FcOpNotContains)
ret = FcTrue; ret = FcTrue;
} }
return ret; return ret;
@ -682,12 +695,14 @@ FcConfigEvaluate (FcPattern *p, FcExpr *e)
v.type = FcTypeVoid; v.type = FcTypeVoid;
FcValueDestroy (vl); FcValueDestroy (vl);
break; break;
case FcOpContains: case FcOpEqual:
case FcOpNotEqual: case FcOpNotEqual:
case FcOpLess: case FcOpLess:
case FcOpLessEqual: case FcOpLessEqual:
case FcOpMore: case FcOpMore:
case FcOpMoreEqual: case FcOpMoreEqual:
case FcOpContains:
case FcOpNotContains:
vl = FcConfigEvaluate (p, e->u.tree.left); vl = FcConfigEvaluate (p, e->u.tree.left);
vr = FcConfigEvaluate (p, e->u.tree.right); vr = FcConfigEvaluate (p, e->u.tree.right);
v.type = FcTypeBool; v.type = FcTypeBool;
@ -697,7 +712,6 @@ FcConfigEvaluate (FcPattern *p, FcExpr *e)
break; break;
case FcOpOr: case FcOpOr:
case FcOpAnd: case FcOpAnd:
case FcOpEqual:
case FcOpPlus: case FcOpPlus:
case FcOpMinus: case FcOpMinus:
case FcOpTimes: case FcOpTimes:

View File

@ -111,12 +111,13 @@ FcOpPrint (FcOp op)
case FcOpOr: printf ("Or"); break; case FcOpOr: printf ("Or"); break;
case FcOpAnd: printf ("And"); break; case FcOpAnd: printf ("And"); break;
case FcOpEqual: printf ("Equal"); break; case FcOpEqual: printf ("Equal"); break;
case FcOpContains: printf ("Contains"); break;
case FcOpNotEqual: printf ("NotEqual"); break; case FcOpNotEqual: printf ("NotEqual"); break;
case FcOpLess: printf ("Less"); break; case FcOpLess: printf ("Less"); break;
case FcOpLessEqual: printf ("LessEqual"); break; case FcOpLessEqual: printf ("LessEqual"); break;
case FcOpMore: printf ("More"); break; case FcOpMore: printf ("More"); break;
case FcOpMoreEqual: printf ("MoreEqual"); break; case FcOpMoreEqual: printf ("MoreEqual"); break;
case FcOpContains: printf ("Contains"); break;
case FcOpNotContains: printf ("NotContains"); break;
case FcOpPlus: printf ("Plus"); break; case FcOpPlus: printf ("Plus"); break;
case FcOpMinus: printf ("Minus"); break; case FcOpMinus: printf ("Minus"); break;
case FcOpTimes: printf ("Times"); break; case FcOpTimes: printf ("Times"); break;
@ -161,12 +162,13 @@ FcExprPrint (const FcExpr *expr)
case FcOpOr: case FcOpOr:
case FcOpAnd: case FcOpAnd:
case FcOpEqual: case FcOpEqual:
case FcOpContains:
case FcOpNotEqual: case FcOpNotEqual:
case FcOpLess: case FcOpLess:
case FcOpLessEqual: case FcOpLessEqual:
case FcOpMore: case FcOpMore:
case FcOpMoreEqual: case FcOpMoreEqual:
case FcOpContains:
case FcOpNotContains:
case FcOpPlus: case FcOpPlus:
case FcOpMinus: case FcOpMinus:
case FcOpTimes: case FcOpTimes:
@ -184,12 +186,13 @@ FcExprPrint (const FcExpr *expr)
case FcOpOr: printf ("Or"); break; case FcOpOr: printf ("Or"); break;
case FcOpAnd: printf ("And"); break; case FcOpAnd: printf ("And"); break;
case FcOpEqual: printf ("Equal"); break; case FcOpEqual: printf ("Equal"); break;
case FcOpContains: printf ("Contains"); break;
case FcOpNotEqual: printf ("NotEqual"); break; case FcOpNotEqual: printf ("NotEqual"); break;
case FcOpLess: printf ("Less"); break; case FcOpLess: printf ("Less"); break;
case FcOpLessEqual: printf ("LessEqual"); break; case FcOpLessEqual: printf ("LessEqual"); break;
case FcOpMore: printf ("More"); break; case FcOpMore: printf ("More"); break;
case FcOpMoreEqual: printf ("MoreEqual"); break; case FcOpMoreEqual: printf ("MoreEqual"); break;
case FcOpContains: printf ("Contains"); break;
case FcOpNotContains: printf ("NotContains"); break;
case FcOpPlus: printf ("Plus"); break; case FcOpPlus: printf ("Plus"); break;
case FcOpMinus: printf ("Minus"); break; case FcOpMinus: printf ("Minus"); break;
case FcOpTimes: printf ("Times"); 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. * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
* *
@ -114,7 +114,7 @@ typedef enum _FcOp {
FcOpAssign, FcOpAssignReplace, FcOpAssign, FcOpAssignReplace,
FcOpPrependFirst, FcOpPrepend, FcOpAppend, FcOpAppendLast, FcOpPrependFirst, FcOpPrepend, FcOpAppend, FcOpAppendLast,
FcOpQuest, FcOpQuest,
FcOpOr, FcOpAnd, FcOpEqual, FcOpNotEqual, FcOpContains, FcOpOr, FcOpAnd, FcOpEqual, FcOpNotEqual, FcOpContains, FcOpNotContains,
FcOpLess, FcOpLessEqual, FcOpMore, FcOpMoreEqual, FcOpLess, FcOpLessEqual, FcOpMore, FcOpMoreEqual,
FcOpPlus, FcOpMinus, FcOpTimes, FcOpDivide, FcOpPlus, FcOpMinus, FcOpTimes, FcOpDivide,
FcOpNot, FcOpComma, FcOpInvalid FcOpNot, FcOpComma, FcOpInvalid

View File

@ -384,6 +384,7 @@ FcLangSetPromote (const FcChar8 *lang)
strs.num = 1; strs.num = 1;
strs.size = 1; strs.size = 1;
strs.strs = &str; strs.strs = &str;
strs.ref = 1;
str = (FcChar8 *) lang; str = (FcChar8 *) lang;
} }
return &ls; 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. * 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 (v1 = v1orig; v1; v1 = v1->next)
{ {
for (v2 = v2orig; v2; v2 = v2->next) for (v2 = v2orig; v2; v2 = v2->next)
if (FcConfigCompareValue (v1->value, FcOpEqual, v2->value)) if (FcValueEqual (v1->value, v2->value))
break; break;
if (!v2) if (!v2)
return FcFalse; return FcFalse;
@ -150,7 +150,7 @@ FcListValueListEqual (FcValueList *v1orig,
for (v2 = v2orig; v2; v2 = v2->next) for (v2 = v2orig; v2; v2 = v2->next)
{ {
for (v1 = v1orig; v1; v1 = v1->next) for (v1 = v1orig; v1; v1 = v1->next)
if (FcConfigCompareValue (v1->value, FcOpEqual, v2->value)) if (FcValueEqual (v1->value, v2->value))
break; break;
if (!v1) if (!v1)
return FcFalse; return FcFalse;
@ -171,7 +171,7 @@ FcListPatternEqual (FcPattern *p1,
e1 = FcPatternFindElt (p1, os->objects[i]); e1 = FcPatternFindElt (p1, os->objects[i]);
e2 = FcPatternFindElt (p2, os->objects[i]); e2 = FcPatternFindElt (p2, os->objects[i]);
if (!e1 && !e2) if (!e1 && !e2)
return FcTrue; continue;
if (!e1 || !e2) if (!e1 || !e2)
return FcFalse; return FcFalse;
if (!FcListValueListEqual (e1->values, e2->values)) 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. * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
* *
@ -218,12 +218,13 @@ FcExprDestroy (FcExpr *e)
case FcOpOr: case FcOpOr:
case FcOpAnd: case FcOpAnd:
case FcOpEqual: case FcOpEqual:
case FcOpContains:
case FcOpNotEqual: case FcOpNotEqual:
case FcOpLess: case FcOpLess:
case FcOpLessEqual: case FcOpLessEqual:
case FcOpMore: case FcOpMore:
case FcOpMoreEqual: case FcOpMoreEqual:
case FcOpContains:
case FcOpNotContains:
case FcOpPlus: case FcOpPlus:
case FcOpMinus: case FcOpMinus:
case FcOpTimes: case FcOpTimes:
@ -310,6 +311,8 @@ typedef enum _FcElement {
FcElementLessEq, FcElementLessEq,
FcElementMore, FcElementMore,
FcElementMoreEq, FcElementMoreEq,
FcElementContains,
FcElementNotContains,
FcElementPlus, FcElementPlus,
FcElementMinus, FcElementMinus,
FcElementTimes, FcElementTimes,
@ -360,6 +363,8 @@ FcElementMap (const XML_Char *name)
{ "less_eq", FcElementLessEq }, { "less_eq", FcElementLessEq },
{ "more", FcElementMore }, { "more", FcElementMore },
{ "more_eq", FcElementMoreEq }, { "more_eq", FcElementMoreEq },
{ "contains", FcElementContains },
{ "not_contains",FcElementNotContains },
{ "plus", FcElementPlus }, { "plus", FcElementPlus },
{ "minus", FcElementMinus }, { "minus", FcElementMinus },
{ "times", FcElementTimes }, { "times", FcElementTimes },
@ -1337,7 +1342,9 @@ static const FcOpMap fcCompareOps[] = {
{ "less", FcOpLess }, { "less", FcOpLess },
{ "less_eq", FcOpLessEqual }, { "less_eq", FcOpLessEqual },
{ "more", FcOpMore }, { "more", FcOpMore },
{ "more_eq", FcOpMoreEqual } { "more_eq", FcOpMoreEqual },
{ "contains", FcOpContains },
{ "not_contains", FcOpNotContains }
}; };
#define NUM_COMPARE_OPS (sizeof fcCompareOps / sizeof fcCompareOps[0]) #define NUM_COMPARE_OPS (sizeof fcCompareOps / sizeof fcCompareOps[0])
@ -1674,6 +1681,12 @@ FcEndElement(void *userData, const XML_Char *name)
case FcElementMoreEq: case FcElementMoreEq:
FcParseExpr (parse, FcOpMoreEqual); FcParseExpr (parse, FcOpMoreEqual);
break; break;
case FcElementContains:
FcParseExpr (parse, FcOpContains);
break;
case FcElementNotContains:
FcParseExpr (parse, FcOpNotContains);
break;
case FcElementPlus: case FcElementPlus:
FcParseExpr (parse, FcOpPlus); FcParseExpr (parse, FcOpPlus);
break; break;