]> git.wh0rd.org - fontconfig.git/blobdiff - src/fccache.c
FcStrCanonFileName buggy for mingw. (bug 8311)
[fontconfig.git] / src / fccache.c
index 11f88a788b2dc84ab5361055aac44f638924ffd7..6a3d8e8704612e35825bddce3a1021aa7e4fdb69 100644 (file)
@@ -213,6 +213,17 @@ struct _FcCacheSkip {
 static FcCacheSkip     *fcCacheChains[FC_CACHE_MAX_LEVEL];
 static int             fcCacheMaxLevel;
 
+#if HAVE_RANDOM
+# define FcRandom()  random()
+#else
+# if HAVE_LRAND48
+#  define FcRandom()  lrand48()
+# else
+#  if HAVE_RAND
+#   define FcRandom()  rand()
+#  endif
+# endif
+#endif
 /*
  * Generate a random level number, distributed
  * so that each level is 1/4 as likely as the one before
@@ -223,7 +234,7 @@ static int
 random_level (void)
 {
     /* tricky bit -- each bit is '1' 75% of the time */
-    long int   bits = random () | random ();
+    long int   bits = FcRandom () | FcRandom ();
     int        level = 0;
 
     while (++level < FC_CACHE_MAX_LEVEL)
@@ -275,9 +286,18 @@ FcCacheInsert (FcCache *cache, struct stat *cache_stat)
     s->cache = cache;
     s->size = cache->size;
     s->ref = 1;
-    s->cache_dev = cache_stat->st_dev;
-    s->cache_ino = cache_stat->st_ino;
-    s->cache_mtime = cache_stat->st_mtime;
+    if (cache_stat)
+    {
+       s->cache_dev = cache_stat->st_dev;
+       s->cache_ino = cache_stat->st_ino;
+       s->cache_mtime = cache_stat->st_mtime;
+    }
+    else
+    {
+       s->cache_dev = 0;
+       s->cache_ino = 0;
+       s->cache_mtime = 0;
+    }
     
     /*
      * Insert into all fcCacheChains
@@ -658,6 +678,8 @@ FcDirCacheBuild (FcFontSet *set, const FcChar8 *dir, FcStrSet *dirs)
 
     FcSerializeDestroy (serialize);
     
+    FcCacheInsert (cache, NULL);
+
     return cache;
 
 bail2:
@@ -667,6 +689,11 @@ bail1:
     return NULL;
 }
 
+
+#ifdef _WIN32
+#define mkdir(path,mode) _mkdir(path)
+#endif
+
 static FcBool
 FcMakeDirectory (const FcChar8 *dir)
 {