]> git.wh0rd.org - fontconfig.git/blobdiff - src/fcname.c
Was losing local cached dirs in global cache list
[fontconfig.git] / src / fcname.c
index 29e1c92e936c009c28449d6b1f3376d4db22c293..4c0eb96d4b6cf12761c84ee727e2122f7c4a426a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $XFree86: xc/lib/fontconfig/src/fcname.c,v 1.11 2002/08/11 18:10:42 keithp Exp $
+ * $XFree86: xc/lib/fontconfig/src/fcname.c,v 1.13 2002/08/22 07:36:45 keithp Exp $
  *
  * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
  *
@@ -59,7 +59,7 @@ static const FcObjectType _FcBaseObjectTypes[] = {
     { FC_CHAR_HEIGHT,  FcTypeInteger },
     { FC_MATRIX,       FcTypeMatrix },
     { FC_CHARSET,      FcTypeCharSet },
-    { FC_LANG,         FcTypeString },
+    { FC_LANG,         FcTypeLangSet },
 };
 
 #define NUM_OBJECT_TYPES    (sizeof _FcBaseObjectTypes / sizeof _FcBaseObjectTypes[0])
@@ -88,6 +88,7 @@ FcNameRegisterObjectTypes (const FcObjectType *types, int ntypes)
     l = (FcObjectTypeList *) malloc (sizeof (FcObjectTypeList));
     if (!l)
        return FcFalse;
+    FcMemAlloc (FC_MEM_OBJECTTYPE, sizeof (FcObjectTypeList));
     l->types = types;
     l->ntypes = ntypes;
     l->next = _FcObjectTypes;
@@ -107,6 +108,7 @@ FcNameUnregisterObjectTypes (const FcObjectType *types, int ntypes)
        if (l->types == types && l->ntypes == ntypes)
        {
            *prev = l->next;
+           FcMemFree (FC_MEM_OBJECTTYPE, sizeof (FcObjectTypeList));
            free ((void *) l);
            return FcTrue;
        }
@@ -181,6 +183,7 @@ FcNameRegisterConstants (const FcConstant *consts, int nconsts)
     l = (FcConstantList *) malloc (sizeof (FcConstantList));
     if (!l)
        return FcFalse;
+    FcMemAlloc (FC_MEM_CONSTANT, sizeof (FcConstantList));
     l->consts = consts;
     l->nconsts = nconsts;
     l->next = _FcConstants;
@@ -200,6 +203,7 @@ FcNameUnregisterConstants (const FcConstant *consts, int nconsts)
        if (l->consts == consts && l->nconsts == nconsts)
        {
            *prev = l->next;
+           FcMemFree (FC_MEM_CONSTANT, sizeof (FcConstantList));
            free ((void *) l);
            return FcTrue;
        }
@@ -300,6 +304,9 @@ FcNameConvert (FcType type, FcChar8 *string, FcMatrix *m)
     case FcTypeCharSet:
        v.u.c = FcNameParseCharSet (string);
        break;
+    case FcTypeLangSet:
+       v.u.l = FcNameParseLangSet (string);
+       break;
     default:
        break;
     }
@@ -344,6 +351,7 @@ FcNameParse (const FcChar8 *name)
     const FcObjectType *t;
     const FcConstant   *c;
 
+    /* freed below */
     save = malloc (strlen ((char *) name) + 1);
     if (!save)
        goto bail0;
@@ -393,12 +401,28 @@ FcNameParse (const FcChar8 *name)
                        v = FcNameConvert (t->type, save, &m);
                        if (!FcPatternAdd (pat, t->object, v, FcTrue))
                        {
-                           if (v.type == FcTypeCharSet)
+                           switch (v.type) {
+                           case FcTypeCharSet:
                                FcCharSetDestroy ((FcCharSet *) v.u.c);
+                               break;
+                           case FcTypeLangSet:
+                               FcLangSetDestroy ((FcLangSet *) v.u.l);
+                               break;
+                           default:
+                               break;
+                           }
                            goto bail2;
                        }
-                       if (v.type == FcTypeCharSet)
+                       switch (v.type) {
+                       case FcTypeCharSet:
                            FcCharSetDestroy ((FcCharSet *) v.u.c);
+                           break;
+                       case FcTypeLangSet:
+                           FcLangSetDestroy ((FcLangSet *) v.u.l);
+                           break;
+                       default:
+                           break;
+                       }
                    }
                    if (delim != ',')
                        break;
@@ -470,6 +494,8 @@ FcNameUnparseValue (FcStrBuf        *buf,
        return FcNameUnparseString (buf, temp, 0);
     case FcTypeCharSet:
        return FcNameUnparseCharSet (buf, v.u.c);
+    case FcTypeLangSet:
+       return FcNameUnparseLangSet (buf, v.u.l);
     case FcTypeFTFace:
        return FcTrue;
     }