summaryrefslogtreecommitdiff
path: root/fc-cache
diff options
context:
space:
mode:
authorKeith Packard <keithp@neko.keithp.com>2006-08-30 21:59:53 -0700
committerKeith Packard <keithp@neko.keithp.com>2006-08-30 21:59:53 -0700
commit2d3387fd720f33f80847ae6cbb83d94c9a52fde3 (patch)
tree3fc11dd9351ea57bec218420a4c9910e3729cc54 /fc-cache
parent09f9f6f62ac94f7b1a6df649a00c64f78ab132f5 (diff)
Skip broken caches. Cache files are auto-written, don't rewrite in fc-cache.
Validate cache contents and skip broken caches, looking down cache path for valid ones. Every time a directory is scanned, it will be written to a cache file if possible, so fc-cache doesn't need to re-write the cache file. This makes detecting when the cache was generated a bit tricky, so we guess that if the cache wasn't valid before running and is valid afterwards, the cache file was written. Also, allow empty charsets to be serialized with null leaves/numbers. Eliminate a leak in FcEdit by switching to FcObject sooner. Call FcFini from fc-match to make valgrind happy.
Diffstat (limited to 'fc-cache')
-rw-r--r--fc-cache/fc-cache.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/fc-cache/fc-cache.c b/fc-cache/fc-cache.c
index 134d33d..9df90cc 100644
--- a/fc-cache/fc-cache.c
+++ b/fc-cache/fc-cache.c
@@ -130,6 +130,7 @@ scanDirs (FcStrList *list, FcConfig *config, char *program, FcBool force, FcBool
FcStrSet *subdirs;
FcStrList *sublist;
struct stat statb;
+ FcBool was_valid;
/*
* Now scan all of the directories into separate databases
@@ -160,14 +161,14 @@ scanDirs (FcStrList *list, FcConfig *config, char *program, FcBool force, FcBool
set = FcFontSetCreate ();
if (!set)
{
- fprintf (stderr, "Can't create font set\n");
+ fprintf (stderr, "%s: Can't create font set\n", dir);
ret++;
continue;
}
subdirs = FcStrSetCreate ();
if (!subdirs)
{
- fprintf (stderr, "Can't create directory set\n");
+ fprintf (stderr, "%s: Can't create directory set\n", dir);
ret++;
FcFontSetDestroy (set);
continue;
@@ -219,15 +220,18 @@ scanDirs (FcStrList *list, FcConfig *config, char *program, FcBool force, FcBool
if (really_force)
FcDirCacheUnlink (dir, config);
+ if (!force)
+ was_valid = FcDirCacheValid (dir, config);
+
if (!FcDirScanConfig (set, subdirs, FcConfigGetBlanks (config), dir, force, config))
{
- fprintf (stderr, "\"%s\": error scanning\n", dir);
+ fprintf (stderr, "%s: error scanning\n", dir);
FcFontSetDestroy (set);
FcStrSetDestroy (subdirs);
ret++;
continue;
}
- if (!force && FcDirCacheValid (dir, config))
+ if (!force && was_valid)
{
if (verbose)
printf ("skipping, %d fonts, %d dirs\n",
@@ -239,15 +243,10 @@ scanDirs (FcStrList *list, FcConfig *config, char *program, FcBool force, FcBool
printf ("caching, %d fonts, %d dirs\n",
set->nfont, nsubdirs (subdirs));
- /* This is the only reason we can't combine
- * Valid w/HasCurrentArch... */
- if (!FcDirCacheValid (dir, config))
- if (!FcDirCacheUnlink (dir, config))
- ret++;
-
- if (!FcDirSave (set, subdirs, dir))
+ if (!FcDirCacheValid (dir, config))
{
- fprintf (stderr, "Can't save cache for \"%s\"\n", dir);
+ fprintf (stderr, "%s: failed to write cache\n", dir);
+ (void) FcDirCacheUnlink (dir, config);
ret++;
}
}
@@ -256,7 +255,7 @@ scanDirs (FcStrList *list, FcConfig *config, char *program, FcBool force, FcBool
FcStrSetDestroy (subdirs);
if (!sublist)
{
- fprintf (stderr, "Can't create subdir list in \"%s\"\n", dir);
+ fprintf (stderr, "%s: Can't create subdir list\n", dir);
ret++;
continue;
}