fontconfig: FcConfigAppFontAddDir () doesn't work right

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



See 

http://bugzilla.novell.com/show_bug.cgi?id=148693

for details.

Patch by Takashi IWAI <tiwai@xxxxxxx> attached.

diff -ru fontconfig-2.3.93.20060207.orig/src/fccache.c fontconfig-2.3.93.20060207/src/fccache.c
--- fontconfig-2.3.93.20060207.orig/src/fccache.c	2006-02-07 16:04:03.000000000 +0100
+++ fontconfig-2.3.93.20060207/src/fccache.c	2006-02-07 18:28:56.000000000 +0100
@@ -842,7 +842,6 @@
 {
     int			ret = 0;
     FcChar8		*dir;
-    const FcChar8	*name;
     FcStrSet		*subdirs;
     FcStrList		*sublist;
     struct stat		statb;
@@ -856,16 +855,15 @@
 	if (!FcConfigAcceptFilename (config, dir))
 	    continue;
 
-	/* Skip this directory if already updated
-	 * to avoid the looped directories via symlinks
-	 */
-	name = FcConfigNormalizeFontDir (config, dir);
-	if (name) 
-	{
-	    if (FcStrSetMember (processed_dirs, dir))
-		continue;
-	    FcStrSetAdd (processed_dirs, dir);
-	}
+	/* Skip this directory if already scanned */
+ 	dir = FcConfigNormalizeFontDir (config, dir);
+ 	if (! dir)
+ 	    continue;
+	if (FcStrSetMember (processed_dirs, dir))
+	    continue;
+ 	if (! FcStrSetAdd (processed_dirs, dir))
+ 	    continue;
+
 
 	subdirs = FcStrSetCreate ();
 	if (!subdirs)
@@ -907,7 +905,7 @@
 	if (FcDirCacheValid (dir) && FcDirCacheRead (set, subdirs, dir, config))
 	{
 	    /* if an old entry is found in the global cache, disable it */
-	    if ((d = FcGlobalCacheDirFind (cache, (const char *)name)) != NULL)
+	    if ((d = FcGlobalCacheDirFind (cache, (const char *)dir)) != NULL)
 	    {
 		d->state = FcGCDirDisabled;
 		/* save the updated config later without this entry */
diff -ru fontconfig-2.3.93.20060207.orig/src/fccfg.c fontconfig-2.3.93.20060207/src/fccfg.c
--- fontconfig-2.3.93.20060207.orig/src/fccfg.c	2006-02-07 16:04:03.000000000 +0100
+++ fontconfig-2.3.93.20060207/src/fccfg.c	2006-02-07 18:27:54.000000000 +0100
@@ -419,9 +419,6 @@
 FcConfigAddFontDir (FcConfig	    *config,
 		    const FcChar8   *d)
 {
-    /* Avoid adding d if it's an alias of something else, too. */
-    if (FcConfigInodeMatchFontDir(config, d))
-	return FcTrue;
     return FcStrSetAddFilename (config->fontDirs, d);
 }
 
@@ -1879,9 +1876,10 @@
     return FcTrue;
 }
 
-FcBool
-FcConfigAppFontAddDir (FcConfig	    *config,
-		       const FcChar8   *dir)
+static FcBool
+FcConfigAppFontAddDirWithCheck (FcConfig	    *config,
+				const FcChar8   *dir,
+				FcStrSet *processed_dirs)
 {
     FcFontSet	*set;
     FcStrSet	*subdirs;
@@ -1915,11 +1913,17 @@
 	FcStrSetDestroy (subdirs);
 	return FcFalse;
     }
+    FcStrSetAdd (processed_dirs, dir);
     if ((sublist = FcStrListCreate (subdirs)))
     {
 	while ((subdir = FcStrListNext (sublist)))
 	{
-	    FcConfigAppFontAddDir (config, subdir);
+	    FcChar8 *name;
+	    name = FcConfigNormalizeFontDir (config, subdir);
+	    if (! name)
+		name = subdir;
+	    if (! FcStrSetMember (processed_dirs, name))
+		FcConfigAppFontAddDirWithCheck (config, name, processed_dirs);
 	}
 	FcStrListDone (sublist);
     }
@@ -1927,6 +1931,23 @@
     return FcTrue;
 }
 
+FcBool
+FcConfigAppFontAddDir (FcConfig	    *config,
+		       const FcChar8   *dir)
+{
+    FcStrSet *processed_dirs;
+    FcBool res;
+
+    processed_dirs = FcStrSetCreate ();
+    if (! processed_dirs)
+	return FcFalse;
+
+    res = FcConfigAppFontAddDirWithCheck (config, dir, processed_dirs);
+    FcStrSetDestroy (processed_dirs);
+
+    return res;
+}
+
 void
 FcConfigAppFontClear (FcConfig	    *config)
 {
diff -ru fontconfig-2.3.93.20060207.orig/src/fcdir.c fontconfig-2.3.93.20060207/src/fcdir.c
--- fontconfig-2.3.93.20060207.orig/src/fcdir.c	2006-02-07 16:04:03.000000000 +0100
+++ fontconfig-2.3.93.20060207/src/fcdir.c	2006-02-07 18:27:54.000000000 +0100
@@ -129,11 +129,7 @@
 	return FcTrue;
 
     if (config)
-	dir = FcConfigNormalizeFontDir (config, dir);
-
-    /* refuse to scan a directory that can't be normalized. */
-    if (!dir)
-	return FcFalse;
+        FcConfigAddFontDir (config, dir);
 
     if (!force)
     {
-- 
Mike FABIAN   <mfabian@xxxxxxx>   http://www.suse.de/~mfabian
睡眠不足はいい仕事の敵だ。
_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/fontconfig

[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux