]> git.wh0rd.org - fontconfig.git/blobdiff - src/fcname.c
Properly convert static charsets to dynamic charsets.
[fontconfig.git] / src / fcname.c
index 2fc411f995b39c95b17a888e7760787f70710d8c..a0a84a394237ceb1f83742a1f8175645ab05f0a0 100644 (file)
 #include "fcint.h"
 
 /* Please do not revoke any of these bindings. */
+/* The __DUMMY__ object enables callers to distinguish the error return
+ * of FcObjectToPtrLookup from FC_FAMILY's FcObjectPtr, which would
+ * otherwise be 0. */
 static const FcObjectType _FcBaseObjectTypes[] = {
-    { "__DUMMY__",      FcTypeVoid, },
+    { "__DUMMY__",      FcTypeVoid, }, 
     { FC_FAMILY,       FcTypeString, },
     { FC_FAMILYLANG,   FcTypeString, },
     { FC_STYLE,                FcTypeString, },
@@ -155,6 +158,9 @@ FcNameGetObjectType (const char *object)
     
     for (l = _FcObjectTypes; l; l = l->next)
     {
+        if (l == (FcObjectTypeList*)_FcUserObjectNames)
+            continue;
+
        for (i = 0; i < l->ntypes; i++)
        {
            t = &l->types[i];
@@ -204,8 +210,8 @@ FcObjectToPtrLookup (const char * object)
        }
     }
 
-    /* We didn't match.  Look for the correct FcObjectTypeList
-     * to replace it in-place. */
+    /* We didn't match.  Look for the application's FcObjectTypeList
+     * and replace it in-place. */
     for (l = _FcObjectTypes; l; l = l->next)
     {
        if (l->types == _FcUserObjectNames)
@@ -336,7 +342,7 @@ FcObjectNeededBytes ()
 int
 FcObjectNeededBytesAlign (void)
 {
-    return __alignof__ (int) + __alignof__ (char);
+    return fc_alignof (int) + fc_alignof (char);
 }
 
 void *
@@ -352,7 +358,7 @@ FcObjectDistributeBytes (FcCache * metadata, void * block_ptr)
 }
 
 void
-FcObjectSerialize ()
+FcObjectSerialize (void)
 {
     int i;
     for (i = 0; i < biggest_known_ntypes; i++)
@@ -364,30 +370,22 @@ FcObjectSerialize ()
 }
 
 void *
-FcObjectUnserialize (FcCache metadata, void *block_ptr)
+FcObjectUnserialize (FcCache metadata, void *block_ptr)
 {
     int new_biggest;
-    new_biggest = *(int *)block_ptr;
     block_ptr = ALIGN (block_ptr, int);
+    new_biggest = *(int *)block_ptr;
     block_ptr = (int *) block_ptr + 1;
     if (biggest_known_ntypes < new_biggest)
     {
        int i;
        char * bp = (char *)block_ptr;
        FcObjectType * bn;
-       FcObjectTypeList * bnl;
 
        bn = malloc (sizeof (const FcObjectType) * (new_biggest + 1));
        if (!bn)
            return 0;
 
-       bnl = malloc (sizeof (FcObjectTypeList));
-       if (!bnl)
-       {
-           free (bn);
-           return 0;
-       }
-
        for (i = 0; i < new_biggest; i++)
        {
            const FcObjectType * t = FcNameGetObjectType(bp);
@@ -700,7 +698,7 @@ FcNameParse (const FcChar8 *name)
                for (;;)
                {
                    name = FcNameFindNext (name, ":,", save, &delim);
-                   if (t)
+                   if (t && strcmp (t->object, _FcBaseObjectTypes[0].object))
                    {
                        v = FcNameConvert (t->type, save, &m);
                        if (!FcPatternAdd (pat, t->object, v, FcTrue))