]> git.wh0rd.org - fontconfig.git/blobdiff - src/fccfg.c
Add ref counting to font config patterns so that FcFontSort return values
[fontconfig.git] / src / fccfg.c
index b5a9ade5d80014cf24559fc600b1e93e78462a46..66bf501aacc5116db712c3b6582659ddda5f2dbb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $XFree86: xc/lib/fontconfig/src/fccfg.c,v 1.8 2002/06/02 19:51:36 keithp Exp $
+ * $XFree86: xc/lib/fontconfig/src/fccfg.c,v 1.11 2002/06/08 17:32:04 keithp Exp $
  *
  * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
  *
@@ -866,11 +866,12 @@ FcConfigEvaluate (FcPattern *p, FcExpr *e)
 static FcValueList *
 FcConfigMatchValueList (FcPattern      *p,
                        FcTest          *t,
-                       FcValueList     *v)
+                       FcValueList     *values)
 {
     FcValueList            *ret = 0;
     FcExpr         *e = t->expr;
     FcValue        value;
+    FcValueList            *v;
     
     while (e)
     {
@@ -885,7 +886,7 @@ FcConfigMatchValueList (FcPattern   *p,
            e = 0;
        }
 
-       for (; v; v = v->next)
+       for (v = values; v; v = v->next)
        {
            if (FcConfigCompareValue (v->value, t->op, value))
            {
@@ -901,8 +902,8 @@ FcConfigMatchValueList (FcPattern   *p,
                }
            }
        }
+       FcValueDestroy (value);
     }
-    FcValueDestroy (value);
     return ret;
 }
 
@@ -1027,7 +1028,7 @@ FcConfigPatternAdd (FcPattern     *p,
 {
     if (list)
     {
-       FcPatternElt    *e = FcPatternFind (p, object, FcTrue);
+       FcPatternElt    *e = FcPatternInsertElt (p, object);
     
        if (!e)
            return;
@@ -1042,7 +1043,7 @@ static void
 FcConfigPatternDel (FcPattern  *p,
                    const char  *object)
 {
-    FcPatternElt    *e = FcPatternFind (p, object, FcFalse);
+    FcPatternElt    *e = FcPatternFindElt (p, object);
     if (!e)
        return;
     while (e->values)
@@ -1053,7 +1054,7 @@ static void
 FcConfigPatternCanon (FcPattern            *p,
                      const char    *object)
 {
-    FcPatternElt    *e = FcPatternFind (p, object, FcFalse);
+    FcPatternElt    *e = FcPatternFindElt (p, object);
     if (!e)
        return;
     if (!e->values)
@@ -1106,7 +1107,7 @@ FcConfigSubstitute (FcConfig      *config,
                printf ("FcConfigSubstitute test ");
                FcTestPrint (t);
            }
-           st[i].elt = FcPatternFind (p, t->field, FcFalse);
+           st[i].elt = FcPatternFindElt (p, t->field);
            /*
             * If there's no such field in the font,
             * then FcQualAll matches while FcQualAny does not
@@ -1128,6 +1129,10 @@ FcConfigSubstitute (FcConfig     *config,
            st[i].value = FcConfigMatchValueList (p, t, st[i].elt->values);
            if (!st[i].value)
                break;
+           if (t->qual == FcQualFirst && st[i].value != st[i].elt->values)
+               break;
+           if (t->qual == FcQualNotFirst && st[i].value == st[i].elt->values)
+               break;
        }
        if (t)
        {
@@ -1158,7 +1163,7 @@ FcConfigSubstitute (FcConfig      *config,
                 * If there was a test, then replace the matched
                 * value with the new list of values
                 */
-               if (t && st[i].elt)
+               if (t)
                {
                    FcValueList *thisValue = st[i].value;
                    FcValueList *nextValue = thisValue ? thisValue->next : 0;