before comparing them.
Allocate extra space for appended '/' in directory name.
reviewed by: plam
+2006-01-14 Patrick Lam <plam@mit.edu>
+ * fc-cache/fc-cache.c (scanDirs):
+ * fontconfig/fontconfig.h:
+ * src/fccache.c (FcGlobalCacheReadDir, FcGlobalCacheUpdate,
+ FcGlobalCacheSave, FcDirCacheUnlink, FcDirCacheOpen):
+ * src/fccfg.c (FcConfigBuildFonts, FcConfigNormalizeFontDir):
+ * src/fcdir.c (FcDirScanConfig):
+ * src/fcint.h:
+
+ Compare device numbers as well as inodes.
+ Always normalize directory names before comparing them.
+
+2006-01-11 Mike Fabian <mfabian@suse.de>
+ reviewed by: plam
+
+ * fc-cat/fc-cat.c (FcCacheGlobalFileReadAndPrint):
+
+ Allocate extra space for appended '/' in directory name.
+
2006-01-10 Patrick Lam <plam@mit.edu>
* src/fccache.c (FcDirCacheConsume, FcDirCacheOpen,
FcDirCacheValid, FcDirCacheHasCurrentArch,
set->nfont, nsubdirs (subdirs));
if (!FcDirCacheValid (dir))
- if (!FcDirCacheUnlink (dir))
+ if (!FcDirCacheUnlink (dir, config))
ret++;
if (!FcDirSave (set, subdirs, dir))
if (!FcDirCacheConsume (fd, name_buf, set, 0))
goto bail1;
- dir = strdup(name_buf);
+ dir = malloc (strlen (name_buf) + 2);
+ if (!dir)
+ goto bail1;
+
+ strcpy (dir, name_buf);
strcat (dir, "/");
FcCachePrintSet (set, dirs, dir);
FcDirCacheHasCurrentArch (const FcChar8 *dir);
FcBool
-FcDirCacheUnlink (const FcChar8 *dir);
+FcDirCacheUnlink (const FcChar8 *dir, FcConfig *config);
/* fcblanks.c */
FcBlanks *
if (cache->fd == -1)
return FcFalse;
+ dir = (char *)FcConfigNormalizeFontDir (config, (FcChar8 *)dir);
for (d = cache->dirs; d; d = d->next)
{
if (strncmp (d->name, dir, strlen(dir)) == 0)
FcBool
FcGlobalCacheUpdate (FcGlobalCache *cache,
const char *name,
- FcFontSet *set)
+ FcFontSet *set,
+ FcConfig *config)
{
FcGlobalCacheDir * d;
+ name = (char *)FcConfigNormalizeFontDir (config, (FcChar8 *)name);
for (d = cache->dirs; d; d = d->next)
{
if (strcmp(d->name, name) == 0)
FcBool
FcGlobalCacheSave (FcGlobalCache *cache,
- const FcChar8 *cache_file)
+ const FcChar8 *cache_file,
+ FcConfig *config)
{
int fd, fd_orig;
FcGlobalCacheDir *dir;
{
if (dir->name)
{
- FcCacheWriteString (fd, dir->name);
+ const char * d = (const char *)FcConfigNormalizeFontDir (config, (const FcChar8 *)dir->name);
+
+ FcCacheWriteString (fd, d);
write (fd, &dir->metadata, sizeof(FcCache));
lseek (fd, FcCacheNextOffset (lseek(fd, 0, SEEK_CUR)), SEEK_SET);
write (fd, dir->ent, dir->metadata.count);
}
FcBool
-FcDirCacheUnlink (const FcChar8 *dir)
+FcDirCacheUnlink (const FcChar8 *dir, FcConfig *config)
{
- char *cache_file = (char *)FcStrPlus (dir, (FcChar8 *) "/" FC_DIR_CACHE_FILE);
+ char *cache_file;
char *cache_hashed;
int fd, collisions;
struct stat cache_stat;
char name_buf[FC_MAX_FILE_LEN];
+ dir = FcConfigNormalizeFontDir (config, dir);
+ cache_file = (char *)FcStrPlus (dir, (FcChar8 *) "/" FC_DIR_CACHE_FILE);
if (!cache_file)
return FcFalse;
if (stat ((char *)dir, &dir_stat) == -1)
return -1;
+ found = FcFalse;
do
{
struct stat c;
FcFontSetPrint (fonts);
if (config->cache)
- FcGlobalCacheSave (cache, config->cache);
+ FcGlobalCacheSave (cache, config->cache, config);
FcGlobalCacheDestroy (cache);
FcStrSetDestroy (oldDirs);
{
/* If this is a bottleneck, we can cache the fontDir inodes. */
ino_t di;
+ dev_t dd;
int n;
struct stat s;
if (stat ((char *)d, &s) == -1)
return 0;
- di = s.st_ino;
+ di = s.st_ino; dd = s.st_dev;
for (n = 0; n < config->fontDirs->num; n++)
{
if (stat ((char *)config->fontDirs->strs[n], &s) == -1)
continue;
- if (di == s.st_ino)
+ if (di == s.st_ino && dd == s.st_dev)
return config->fontDirs->strs[n];
}
return 0;
* add the cache entry
*/
if (ret && cache)
- FcGlobalCacheUpdate (cache, (char *)dir, tmpSet);
+ FcGlobalCacheUpdate (cache, (char *)dir, tmpSet, config);
for (i = 0; i < tmpSet->nfont; i++)
FcFontSetAdd (set, tmpSet->fonts[i]);
FcBool
FcGlobalCacheUpdate (FcGlobalCache *cache,
const char *file,
- FcFontSet *set);
+ FcFontSet *set,
+ FcConfig *config);
FcBool
FcGlobalCacheSave (FcGlobalCache *cache,
- const FcChar8 *cache_file);
+ const FcChar8 *cache_file,
+ FcConfig *config);
FcFontSet *
FcCacheRead (FcConfig *config, FcGlobalCache * cache);