Merge branch 'list-cache-dirs-on-fail' into 'main'

More information when no writable cache directories

Closes #413

See merge request fontconfig/fontconfig!323
diff --git a/src/fccache.c b/src/fccache.c
index 54f76ac..e0dc4c9 100644
--- a/src/fccache.c
+++ b/src/fccache.c
@@ -1358,14 +1358,21 @@
     unsigned int    magic;
     int		    written;
     const FcChar8   *sysroot = FcConfigGetSysRoot (config);
+    FcStrSet	    *cpath;
 
     /*
      * Write it to the first directory in the list which is writable
      */
 
+    cpath = FcStrSetCreateEx (FCSS_GROW_BY_64);
+    if (!cpath)
+	return FcFalse;
     list = FcStrListCreate (config->cacheDirs);
     if (!list)
+    {
+	FcStrSetDestroy (cpath);
 	return FcFalse;
+    }
     while ((test_dir = FcStrListNext (list)))
     {
 	if (d)
@@ -1404,12 +1411,26 @@
 		FcDirCacheCreateTagFile (d);
 		break;
 	    }
+	    /* Record a path that was supposed to be a cache directory */
+	    FcStrSetAdd (cpath, d);
 	}
     }
     if (!test_dir)
-	fprintf (stderr, "Fontconfig error: No writable cache directories\n");
+    {
+	FcStrList *l;
+	FcChar8 *s;
+
+	l = FcStrListCreate (cpath);
+	fprintf (stderr, "\nFontconfig error: No writable cache directories\n");
+	while ((s = FcStrListNext (l)))
+	{
+	    fprintf (stderr, "\t%s\n", s);
+	}
+	FcStrListDone (l);
+    }
     if (d)
 	FcStrFree (d);
+    FcStrSetDestroy (cpath);
     FcStrListDone (list);
     if (!cache_dir)
 	return FcFalse;