src/fccache.c | 2 ++ src/fccfg.c | 2 +- test/run-test.sh | 30 ++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) New commits: commit 437f03299bd1adc9673cd576072f1657be8fd4e0 Author: Akira TAGOH <akira@xxxxxxxxx> Date: Tue Jul 14 19:24:36 2020 +0900 Fix empty XDG_CACHE_HOME Behavior Use the default $HOME/.cache one for empty XDG_CACHE_HOME. Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/243 diff --git a/src/fccache.c b/src/fccache.c index e42ebbb..c3e6364 100644 --- a/src/fccache.c +++ b/src/fccache.c @@ -1412,6 +1412,8 @@ FcDirCacheWrite (FcCache *cache, FcConfig *config) } } } + if (!test_dir) + fprintf (stderr, "Fontconfig error: No writable cache directories\n"); if (d) FcStrFree (d); FcStrListDone (list); diff --git a/src/fccfg.c b/src/fccfg.c index 0a49e42..f49657a 100644 --- a/src/fccfg.c +++ b/src/fccfg.c @@ -2297,7 +2297,7 @@ FcConfigXdgCacheHome (void) if (!_FcConfigHomeEnabled) return NULL; - if (env) + if (env && env[0]) ret = FcStrCopy ((const FcChar8 *)env); else { diff --git a/test/run-test.sh b/test/run-test.sh index 1b5b7a7..267b54a 100644 --- a/test/run-test.sh +++ b/test/run-test.sh @@ -423,4 +423,34 @@ else echo "No test-crbug1004254: skipped" fi +if [ "x$EXEEXT" = "x" ]; then + +dotest "empty XDG_CACHE_HOME" +prep +export XDG_CACHE_HOME="" +export old_HOME="$HOME" +export temp_HOME=$(mktemp -d --tmpdir fontconfig.XXXXXXXX) +export HOME="$temp_HOME" +cp "$FONT1" "$FONT2" "$FONTDIR" +if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then + touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR" +fi +echo "<fontconfig><dir>$FONTDIR</dir><cachedir prefix=\"xdg\">fontconfig</cachedir></fontconfig>" > my-fonts.conf +FONTCONFIG_FILE="$MyPWD"/my-fonts.conf $FCCACHE "$FONTDIR" || : +if [ -d "$HOME"/.cache ] && [ -d "$HOME"/.cache/fontconfig ]; then : ; else + echo "*** Test failed: $TEST" + echo "No \$HOME/.cache/fontconfig directory" + ls -a "$HOME" + ls -a "$HOME"/.cache + exit 1 +fi + +export HOME="$old_HOME" +rm -rf "$temp_HOME" my-fonts.conf +unset XDG_CACHE_HOME +unset old_HOME +unset temp_HOME + +fi # if [ "x$EXEEXT" = "x" ] + rm -rf "$FONTDIR" "$CACHEFILE" "$CACHEDIR" "$BASEDIR" "$FONTCONFIG_FILE" out _______________________________________________ Fontconfig mailing list Fontconfig@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/fontconfig