aboutsummaryrefslogtreecommitdiff
path: root/fontconfig
diff options
context:
space:
mode:
Diffstat (limited to 'fontconfig')
-rw-r--r--fontconfig/configure.in44
-rw-r--r--fontconfig/doc/fccache.fncs9
-rw-r--r--fontconfig/fc-cache/fc-cache.c93
-rw-r--r--fontconfig/fontconfig/fontconfig.h3
-rw-r--r--fontconfig/src/fccache.c91
-rw-r--r--fontconfig/src/fcint.h2
6 files changed, 130 insertions, 112 deletions
diff --git a/fontconfig/configure.in b/fontconfig/configure.in
index 9c9de30e7..9bb0988ec 100644
--- a/fontconfig/configure.in
+++ b/fontconfig/configure.in
@@ -150,7 +150,11 @@ AC_DEFINE_UNQUOTED(USE_REGEX,$use_regex,[Use regex.])
AC_ARG_WITH(libiconv,
[AC_HELP_STRING([--with-libiconv=DIR],
[Use libiconv in DIR])],
- [libiconv_prefix=$withval],
+ [if test "x$withval" = "xyes"; then
+ libiconv_prefix=$prefix
+ else
+ libiconv_prefix=$withval
+ fi],
[libiconv_prefix=auto])
AC_ARG_WITH(libiconv-includes,
[AC_HELP_STRING([--with-libiconv-includes=DIR],
@@ -163,33 +167,33 @@ AC_ARG_WITH(libiconv-lib,
[libiconv_lib=$withval],
[libiconv_lib=auto])
-# if none of libiconv,libiconv-includes,libiconv-libs are specified
-if test "$libiconv_prefix" != "auto" -o "$libiconv_includes" != "auto" -o "$libiconv_lib" != "auto"; then
- if test "$libiconv_includes" != "auto" -a -r ${libiconv_includes}/iconv.h; then
- libiconv_cflags="-I${libiconv_includes}"
- elif test "$libiconv_prefix" != "auto" -a -r ${libiconv_prefix}/include/iconv.h; then
- libiconv_cflags="-I${libiconv_prefix}/include"
- else
- libiconv_cflags=""
- fi
- if test "$libiconv_lib" != "auto"; then
- libiconv_lib="-L${libiconv_lib} -liconv"
- elif test "$libiconv_prefix" != "auto"; then
- libiconv_lib="-L${libiconv_prefix}/lib -liconv"
- elif test "x$libiconv_cflags" != "x"; then
- libiconv_lib="-liconv"
+# if no libiconv,libiconv-includes,libiconv-lib are specified,
+# libc's iconv has a priority.
+if test "$libiconv_includes" != "auto" -a -r ${libiconv_includes}/iconv.h; then
+ libiconv_cflags="-I${libiconv_includes}"
+elif test "$libiconv_prefix" != "auto" -a -r ${libiconv_prefix}/include/iconv.h; then
+ libiconv_cflags="-I${libiconv_prefix}/include"
+else
+ libiconv_cflags=""
+fi
+libiconv_libs=""
+if test "x$libiconv_cflags" != "x"; then
+ if test "$libiconv_lib" != "auto" -a -d ${libiconv_lib}; then
+ libiconv_libs="-L${libiconv_lib} -liconv"
+ elif test "$libiconv_prefix" != "auto" -a -d ${libiconv_prefix}/lib; then
+ libiconv_libs="-L${libiconv_prefix}/lib -liconv"
else
- libiconv_lib=""
+ libiconv_libs="-liconv"
fi
fi
use_iconv=0
AC_MSG_CHECKING([for a usable iconv])
-if test "x$libiconv_cflags" != "x" -o "x$libiconv_lib" != "x"; then
+if test "x$libiconv_cflags" != "x" -o "x$libiconv_libs" != "x"; then
iconvsaved_CFLAGS="$CFLAGS"
iconvsaved_LIBS="$LIBS"
CFLAGS="$CFLAGS $libiconv_cflags"
- LIBS="$LIBS $libiconv_lib"
+ LIBS="$LIBS $libiconv_libs"
AC_TRY_LINK([#include <iconv.h>],
[iconv_open ("from", "to");],
@@ -200,7 +204,7 @@ if test "x$libiconv_cflags" != "x" -o "x$libiconv_lib" != "x"; then
CFLAGS="$iconvsaved_CFLAGS"
LIBS="$iconvsaved_LIBS"
ICONV_CFLAGS="$libiconv_cflags"
- ICONV_LIBS="$libiconv_lib"
+ ICONV_LIBS="$libiconv_libs"
fi
if test "x$use_iconv" = "x0"; then
AC_TRY_LINK([#include <iconv.h>],
diff --git a/fontconfig/doc/fccache.fncs b/fontconfig/doc/fccache.fncs
index f35c5d7cb..2f5fa4766 100644
--- a/fontconfig/doc/fccache.fncs
+++ b/fontconfig/doc/fccache.fncs
@@ -66,3 +66,12 @@ This returns the total number of subdirectories in the cache.
This returns the number of fonts which would be included in the return from
FcCacheCopySet.
@@
+
+@RET@ FcBool
+@FUNC@ FcDirCacheClean
+@TYPE1@ const FcChar8 * @ARG1@ cache_dir
+@TYPE2@ FcBool @ARG2@ verbose
+@PURPOSE@
+This tries to clean up the cache directory of <parameter>cache_dir</parameter>.
+This returns FcTrue if the operation is successfully complete. otherwise FcFalse.
+@@
diff --git a/fontconfig/fc-cache/fc-cache.c b/fontconfig/fc-cache/fc-cache.c
index 24bb2ec9f..b42fd3545 100644
--- a/fontconfig/fc-cache/fc-cache.c
+++ b/fontconfig/fc-cache/fc-cache.c
@@ -32,7 +32,6 @@
#endif
#include <fontconfig/fontconfig.h>
-#include "../src/fcarch.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -319,96 +318,6 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force,
}
static FcBool
-cleanCacheDirectory (FcConfig *config, FcChar8 *dir, FcBool verbose)
-{
- DIR *d;
- struct dirent *ent;
- FcChar8 *dir_base;
- FcBool ret = FcTrue;
- FcBool remove;
- FcCache *cache;
- struct stat target_stat;
-
- dir_base = FcStrPlus (dir, (FcChar8 *) "/");
- if (!dir_base)
- {
- fprintf (stderr, "%s: out of memory\n", dir);
- return FcFalse;
- }
- if (access ((char *) dir, W_OK) != 0)
- {
- if (verbose)
- printf ("%s: not cleaning %s cache directory\n", dir,
- access ((char *) dir, F_OK) == 0 ? "unwritable" : "non-existent");
- FcStrFree (dir_base);
- return FcTrue;
- }
- if (verbose)
- printf ("%s: cleaning cache directory\n", dir);
- d = opendir ((char *) dir);
- if (!d)
- {
- perror ((char *) dir);
- FcStrFree (dir_base);
- return FcFalse;
- }
- while ((ent = readdir (d)))
- {
- FcChar8 *file_name;
- const FcChar8 *target_dir;
-
- if (ent->d_name[0] == '.')
- continue;
- /* skip cache files for different architectures and */
- /* files which are not cache files at all */
- if (strlen(ent->d_name) != 32 + strlen ("-" FC_ARCHITECTURE FC_CACHE_SUFFIX) ||
- strcmp(ent->d_name + 32, "-" FC_ARCHITECTURE FC_CACHE_SUFFIX))
- continue;
-
- file_name = FcStrPlus (dir_base, (FcChar8 *) ent->d_name);
- if (!file_name)
- {
- fprintf (stderr, "%s: allocation failure\n", dir);
- ret = FcFalse;
- break;
- }
- remove = FcFalse;
- cache = FcDirCacheLoadFile (file_name, NULL);
- if (!cache)
- {
- if (verbose)
- printf ("%s: invalid cache file: %s\n", dir, ent->d_name);
- remove = FcTrue;
- }
- else
- {
- target_dir = FcCacheDir (cache);
- if (stat ((char *) target_dir, &target_stat) < 0)
- {
- if (verbose)
- printf ("%s: %s: missing directory: %s \n",
- dir, ent->d_name, target_dir);
- remove = FcTrue;
- }
- }
- if (remove)
- {
- if (unlink ((char *) file_name) < 0)
- {
- perror ((char *) file_name);
- ret = FcFalse;
- }
- }
- FcDirCacheUnload (cache);
- FcStrFree (file_name);
- }
-
- closedir (d);
- FcStrFree (dir_base);
- return ret;
-}
-
-static FcBool
cleanCacheDirectories (FcConfig *config, FcBool verbose)
{
FcStrList *cache_dirs = FcConfigGetCacheDirs (config);
@@ -419,7 +328,7 @@ cleanCacheDirectories (FcConfig *config, FcBool verbose)
return FcFalse;
while ((cache_dir = FcStrListNext (cache_dirs)))
{
- if (!cleanCacheDirectory (config, cache_dir, verbose))
+ if (!FcDirCacheClean (cache_dir, verbose))
{
ret = FcFalse;
break;
diff --git a/fontconfig/fontconfig/fontconfig.h b/fontconfig/fontconfig/fontconfig.h
index 8936d8337..0e2ca509d 100644
--- a/fontconfig/fontconfig/fontconfig.h
+++ b/fontconfig/fontconfig/fontconfig.h
@@ -328,6 +328,9 @@ FcDirCacheUnlink (const FcChar8 *dir, FcConfig *config);
FcPublic FcBool
FcDirCacheValid (const FcChar8 *cache_file);
+FcPublic FcBool
+FcDirCacheClean (const FcChar8 *cache_dir, FcBool verbose);
+
/* fccfg.c */
FcPublic FcChar8 *
FcConfigHome (void);
diff --git a/fontconfig/src/fccache.c b/fontconfig/src/fccache.c
index 343ece9a7..b7ba1fd1e 100644
--- a/fontconfig/src/fccache.c
+++ b/fontconfig/src/fccache.c
@@ -1020,6 +1020,97 @@ FcDirCacheWrite (FcCache *cache, FcConfig *config)
return FcFalse;
}
+FcBool
+FcDirCacheClean (const FcChar8 *cache_dir, FcBool verbose)
+{
+ DIR *d;
+ struct dirent *ent;
+ FcChar8 *dir_base;
+ FcBool ret = FcTrue;
+ FcBool remove;
+ FcCache *cache;
+ struct stat target_stat;
+
+ dir_base = FcStrPlus (cache_dir, (FcChar8 *) FC_DIR_SEPARATOR_S);
+ if (!dir_base)
+ {
+ fprintf (stderr, "Fontconfig error: %s: out of memory\n", cache_dir);
+ return FcFalse;
+ }
+ if (access ((char *) cache_dir, W_OK) != 0)
+ {
+ if (verbose || FcDebug () & FC_DBG_CACHE)
+ printf ("%s: not cleaning %s cache directory\n", cache_dir,
+ access ((char *) cache_dir, F_OK) == 0 ? "unwritable" : "non-existent");
+ goto bail0;
+ }
+ if (verbose || FcDebug () & FC_DBG_CACHE)
+ printf ("%s: cleaning cache directory\n", cache_dir);
+ d = opendir ((char *) cache_dir);
+ if (!d)
+ {
+ perror ((char *) cache_dir);
+ ret = FcFalse;
+ goto bail0;
+ }
+ while ((ent = readdir (d)))
+ {
+ FcChar8 *file_name;
+ const FcChar8 *target_dir;
+
+ if (ent->d_name[0] == '.')
+ continue;
+ /* skip cache files for different architectures and */
+ /* files which are not cache files at all */
+ if (strlen(ent->d_name) != 32 + strlen ("-" FC_ARCHITECTURE FC_CACHE_SUFFIX) ||
+ strcmp(ent->d_name + 32, "-" FC_ARCHITECTURE FC_CACHE_SUFFIX))
+ continue;
+
+ file_name = FcStrPlus (dir_base, (FcChar8 *) ent->d_name);
+ if (!file_name)
+ {
+ fprintf (stderr, "Fontconfig error: %s: allocation failure\n", cache_dir);
+ ret = FcFalse;
+ break;
+ }
+ remove = FcFalse;
+ cache = FcDirCacheLoadFile (file_name, NULL);
+ if (!cache)
+ {
+ if (verbose || FcDebug () & FC_DBG_CACHE)
+ printf ("%s: invalid cache file: %s\n", cache_dir, ent->d_name);
+ remove = FcTrue;
+ }
+ else
+ {
+ target_dir = FcCacheDir (cache);
+ if (stat ((char *) target_dir, &target_stat) < 0)
+ {
+ if (verbose || FcDebug () & FC_DBG_CACHE)
+ printf ("%s: %s: missing directory: %s \n",
+ cache_dir, ent->d_name, target_dir);
+ remove = FcTrue;
+ }
+ }
+ if (remove)
+ {
+ if (unlink ((char *) file_name) < 0)
+ {
+ perror ((char *) file_name);
+ ret = FcFalse;
+ }
+ }
+ FcDirCacheUnload (cache);
+ FcStrFree (file_name);
+ }
+
+ closedir (d);
+ bail0:
+ FcStrFree (dir_base);
+
+ return ret;
+}
+
/*
* Hokey little macro trick to permit the definitions of C functions
* with the same name as CPP macros
diff --git a/fontconfig/src/fcint.h b/fontconfig/src/fcint.h
index 0dfc23659..ba4b388ea 100644
--- a/fontconfig/src/fcint.h
+++ b/fontconfig/src/fcint.h
@@ -64,8 +64,10 @@ typedef HRESULT (WINAPI *pfnSHGetFolderPathA)(HWND, int, HANDLE, DWORD, LPSTR);
extern pfnGetSystemWindowsDirectory pGetSystemWindowsDirectory;
extern pfnSHGetFolderPathA pSHGetFolderPathA;
# define FC_SEARCH_PATH_SEPARATOR ';'
+# define FC_DIR_SEPARATOR_S "\\"
#else
# define FC_SEARCH_PATH_SEPARATOR ':'
+# define FC_DIR_SEPARATOR_S "/"
#endif
#define FC_DBG_MATCH 1