aboutsummaryrefslogtreecommitdiff
path: root/fontconfig/src
diff options
context:
space:
mode:
Diffstat (limited to 'fontconfig/src')
-rw-r--r--fontconfig/src/fccfg.c35
-rw-r--r--fontconfig/src/fcdbg.c27
-rw-r--r--fontconfig/src/fcint.h8
-rw-r--r--fontconfig/src/fclist.c2
-rw-r--r--fontconfig/src/fcxml.c24
5 files changed, 69 insertions, 27 deletions
diff --git a/fontconfig/src/fccfg.c b/fontconfig/src/fccfg.c
index f9cdaaf46..31c427636 100644
--- a/fontconfig/src/fccfg.c
+++ b/fontconfig/src/fccfg.c
@@ -691,12 +691,14 @@ FcConfigPromote (FcValue v, FcValue u)
FcBool
FcConfigCompareValue (const FcValue *left_o,
- FcOp op,
+ FcOp op_,
const FcValue *right_o)
{
FcValue left = FcValueCanonicalize(left_o);
FcValue right = FcValueCanonicalize(right_o);
FcBool ret = FcFalse;
+ FcOp op = FC_OP_GET_OP (op_);
+ int flags = FC_OP_GET_FLAGS (op_);
left = FcConfigPromote (left, right);
right = FcConfigPromote (right, left);
@@ -751,13 +753,19 @@ FcConfigCompareValue (const FcValue *left_o,
switch (op) {
case FcOpEqual:
case FcOpListing:
- ret = FcStrCmpIgnoreCase (left.u.s, right.u.s) == 0;
+ if (flags & FcOpFlagIgnoreBlanks)
+ ret = FcStrCmpIgnoreBlanksAndCase (left.u.s, right.u.s) == 0;
+ else
+ ret = FcStrCmpIgnoreCase (left.u.s, right.u.s) == 0;
break;
case FcOpContains:
ret = FcStrStrIgnoreCase (left.u.s, right.u.s) != 0;
break;
case FcOpNotEqual:
- ret = FcStrCmpIgnoreCase (left.u.s, right.u.s) != 0;
+ if (flags & FcOpFlagIgnoreBlanks)
+ ret = FcStrCmpIgnoreBlanksAndCase (left.u.s, right.u.s) != 0;
+ else
+ ret = FcStrCmpIgnoreCase (left.u.s, right.u.s) != 0;
break;
case FcOpNotContains:
ret = FcStrStrIgnoreCase (left.u.s, right.u.s) == 0;
@@ -872,8 +880,9 @@ FcConfigEvaluate (FcPattern *p, FcExpr *e)
FcResult r;
FcMatrix *m;
FcChar8 *str;
+ FcOp op = FC_OP_GET_OP (e->op);
- switch (e->op) {
+ switch (op) {
case FcOpInteger:
v.type = FcTypeInteger;
v.u.i = e->u.ival;
@@ -961,7 +970,7 @@ FcConfigEvaluate (FcPattern *p, FcExpr *e)
{
switch (vl.type) {
case FcTypeDouble:
- switch (e->op) {
+ switch (op) {
case FcOpPlus:
v.type = FcTypeDouble;
v.u.d = vl.u.d + vr.u.d;
@@ -990,7 +999,7 @@ FcConfigEvaluate (FcPattern *p, FcExpr *e)
}
break;
case FcTypeBool:
- switch (e->op) {
+ switch (op) {
case FcOpOr:
v.type = FcTypeBool;
v.u.b = vl.u.b || vr.u.b;
@@ -1005,7 +1014,7 @@ FcConfigEvaluate (FcPattern *p, FcExpr *e)
}
break;
case FcTypeString:
- switch (e->op) {
+ switch (op) {
case FcOpPlus:
v.type = FcTypeString;
str = FcStrPlus (vl.u.s, vr.u.s);
@@ -1021,7 +1030,7 @@ FcConfigEvaluate (FcPattern *p, FcExpr *e)
}
break;
case FcTypeMatrix:
- switch (e->op) {
+ switch (op) {
case FcOpTimes:
v.type = FcTypeMatrix;
m = malloc (sizeof (FcMatrix));
@@ -1042,7 +1051,7 @@ FcConfigEvaluate (FcPattern *p, FcExpr *e)
}
break;
case FcTypeCharSet:
- switch (e->op) {
+ switch (op) {
case FcOpPlus:
v.type = FcTypeCharSet;
v.u.c = FcCharSetUnion (vl.u.c, vr.u.c);
@@ -1061,7 +1070,7 @@ FcConfigEvaluate (FcPattern *p, FcExpr *e)
}
break;
case FcTypeLangSet:
- switch (e->op) {
+ switch (op) {
case FcOpPlus:
v.type = FcTypeLangSet;
v.u.l = FcLangSetUnion (vl.u.l, vr.u.l);
@@ -1186,7 +1195,7 @@ FcConfigMatchValueList (FcPattern *p,
while (e)
{
/* Compute the value of the match expression */
- if (e->op == FcOpComma)
+ if (FC_OP_GET_OP (e->op) == FcOpComma)
{
value = FcConfigEvaluate (p, e->u.tree.left);
e = e->u.tree.right;
@@ -1230,7 +1239,7 @@ FcConfigValues (FcPattern *p, FcExpr *e, FcValueBinding binding)
if (!l)
return 0;
FcMemAlloc (FC_MEM_VALLIST, sizeof (FcValueList));
- if (e->op == FcOpComma)
+ if (FC_OP_GET_OP (e->op) == FcOpComma)
{
l->value = FcConfigEvaluate (p, e->u.tree.left);
l->next = FcConfigValues (p, e->u.tree.right, binding);
@@ -1518,7 +1527,7 @@ FcConfigSubstituteWithPat (FcConfig *config,
break;
}
}
- switch (e->op) {
+ switch (FC_OP_GET_OP (e->op)) {
case FcOpAssign:
/*
* If there was a test, then replace the matched
diff --git a/fontconfig/src/fcdbg.c b/fontconfig/src/fcdbg.c
index 10f3cc9aa..a1ed2b2dd 100644
--- a/fontconfig/src/fcdbg.c
+++ b/fontconfig/src/fcdbg.c
@@ -185,9 +185,18 @@ FcPatternPrint (const FcPattern *p)
printf ("\n");
}
+#define FcOpFlagsPrint(_o_) \
+ { \
+ int f = FC_OP_GET_FLAGS (_o_); \
+ if (f & FcOpFlagIgnoreBlanks) \
+ printf ("(ignore blanks)"); \
+ }
+
void
-FcOpPrint (FcOp op)
+FcOpPrint (FcOp op_)
{
+ FcOp op = FC_OP_GET_OP (op_);
+
switch (op) {
case FcOpInteger: printf ("Integer"); break;
case FcOpDouble: printf ("Double"); break;
@@ -208,8 +217,8 @@ FcOpPrint (FcOp op)
case FcOpQuest: printf ("Quest"); break;
case FcOpOr: printf ("Or"); break;
case FcOpAnd: printf ("And"); break;
- case FcOpEqual: printf ("Equal"); break;
- case FcOpNotEqual: printf ("NotEqual"); break;
+ case FcOpEqual: printf ("Equal"); FcOpFlagsPrint (op_); break;
+ case FcOpNotEqual: printf ("NotEqual"); FcOpFlagsPrint (op_); break;
case FcOpLess: printf ("Less"); break;
case FcOpLessEqual: printf ("LessEqual"); break;
case FcOpMore: printf ("More"); break;
@@ -227,7 +236,7 @@ FcOpPrint (FcOp op)
case FcOpCeil: printf ("Ceil"); break;
case FcOpRound: printf ("Round"); break;
case FcOpTrunc: printf ("Trunc"); break;
- case FcOpListing: printf ("Listing"); break;
+ case FcOpListing: printf ("Listing"); FcOpFlagsPrint (op_); break;
case FcOpInvalid: printf ("Invalid"); break;
}
}
@@ -236,7 +245,7 @@ void
FcExprPrint (const FcExpr *expr)
{
if (!expr) printf ("none");
- else switch (expr->op) {
+ else switch (FC_OP_GET_OP (expr->op)) {
case FcOpInteger: printf ("%d", expr->u.ival); break;
case FcOpDouble: printf ("%g", expr->u.dval); break;
case FcOpString: printf ("\"%s\"", expr->u.sval); break;
@@ -287,7 +296,7 @@ FcExprPrint (const FcExpr *expr)
case FcOpComma:
FcExprPrint (expr->u.tree.left);
printf (" ");
- switch (expr->op) {
+ switch (FC_OP_GET_OP (expr->op)) {
case FcOpAssign: printf ("Assign"); break;
case FcOpAssignReplace: printf ("AssignReplace"); break;
case FcOpPrependFirst: printf ("PrependFirst"); break;
@@ -296,14 +305,14 @@ FcExprPrint (const FcExpr *expr)
case FcOpAppendLast: printf ("AppendLast"); break;
case FcOpOr: printf ("Or"); break;
case FcOpAnd: printf ("And"); break;
- case FcOpEqual: printf ("Equal"); break;
- case FcOpNotEqual: printf ("NotEqual"); break;
+ case FcOpEqual: printf ("Equal"); FcOpFlagsPrint (expr->op); break;
+ case FcOpNotEqual: printf ("NotEqual"); FcOpFlagsPrint (expr->op); 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 FcOpListing: printf ("Listing"); break;
+ case FcOpListing: printf ("Listing"); FcOpFlagsPrint (expr->op); break;
case FcOpNotContains: printf ("NotContains"); break;
case FcOpPlus: printf ("Plus"); break;
case FcOpMinus: printf ("Minus"); break;
diff --git a/fontconfig/src/fcint.h b/fontconfig/src/fcint.h
index 1ed2df3e1..defbd7acb 100644
--- a/fontconfig/src/fcint.h
+++ b/fontconfig/src/fcint.h
@@ -246,6 +246,14 @@ typedef enum _FcOp {
FcOpInvalid
} FcOp;
+typedef enum _FcOpFlags {
+ FcOpFlagIgnoreBlanks = 1 << 0
+} FcOpFlags;
+
+#define FC_OP_GET_OP(_x_) ((_x_) & 0xffff)
+#define FC_OP_GET_FLAGS(_x_) (((_x_) & 0xffff0000) >> 16)
+#define FC_OP(_x_,_f_) (FC_OP_GET_OP (_x_) | ((_f_) << 16))
+
typedef struct _FcExpr {
FcOp op;
union {
diff --git a/fontconfig/src/fclist.c b/fontconfig/src/fclist.c
index 331352cd8..56f04329e 100644
--- a/fontconfig/src/fclist.c
+++ b/fontconfig/src/fclist.c
@@ -148,7 +148,7 @@ FcListValueListMatchAny (FcValueListPtr patOrig, /* pattern */
* where it requires an exact match)
*/
if (FcConfigCompareValue (&fnt->value,
- FcOpListing,
+ FC_OP (FcOpListing, FcOpFlagIgnoreBlanks),
&pat->value))
break;
}
diff --git a/fontconfig/src/fcxml.c b/fontconfig/src/fcxml.c
index 708e131f9..c49529a81 100644
--- a/fontconfig/src/fcxml.c
+++ b/fontconfig/src/fcxml.c
@@ -195,7 +195,7 @@ FcExprDestroy (FcExpr *e)
{
if (!e)
return;
- switch (e->op) {
+ switch (FC_OP_GET_OP (e->op)) {
case FcOpInteger:
break;
case FcOpDouble:
@@ -571,7 +571,7 @@ FcTypecheckExpr (FcConfigParse *parse, FcExpr *expr, FcType type)
if (!expr)
return;
- switch (expr->op) {
+ switch (FC_OP_GET_OP (expr->op)) {
case FcOpInteger:
case FcOpDouble:
FcTypecheckValue (parse, FcTypeDouble, type);
@@ -1687,7 +1687,7 @@ FcParseAlias (FcConfigParse *parse)
FcTest *t = FcTestCreate (parse, FcMatchPattern,
FcQualAny,
(FcChar8 *) FC_FAMILY,
- FcOpEqual,
+ FC_OP (FcOpEqual, FcOpFlagIgnoreBlanks),
family);
if (test)
{
@@ -1911,6 +1911,8 @@ FcParseTest (FcConfigParse *parse)
FcOp compare;
FcExpr *expr;
FcTest *test;
+ const FcChar8 *iblanks_string;
+ int flags = 0;
kind_string = FcConfigGetAttribute (parse, "target");
if (!kind_string)
@@ -1968,13 +1970,27 @@ FcParseTest (FcConfigParse *parse)
return;
}
}
+ iblanks_string = FcConfigGetAttribute (parse, "ignore-blanks");
+ if (iblanks_string)
+ {
+ FcBool f = FcFalse;
+
+ if (!FcNameBool (iblanks_string, &f))
+ {
+ FcConfigMessage (parse,
+ FcSevereWarning,
+ "invalid test ignore-blanks \"%s\"", iblanks_string);
+ }
+ if (f)
+ flags |= FcOpFlagIgnoreBlanks;
+ }
expr = FcPopBinary (parse, FcOpComma);
if (!expr)
{
FcConfigMessage (parse, FcSevereWarning, "missing test expression");
return;
}
- test = FcTestCreate (parse, kind, qual, name, compare, expr);
+ test = FcTestCreate (parse, kind, qual, name, FC_OP (compare, flags), expr);
if (!test)
{
FcConfigMessage (parse, FcSevereError, "out of memory");