Date: Fri, 3 Apr 2020 20:09:47 +0000 (UTC) From: "Tobias C. Berner" <tcberner@FreeBSD.org> To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-branches@freebsd.org Subject: svn commit: r530517 - in branches/2020Q2: . x11-fonts/fontconfig x11-fonts/fontconfig-reference x11-fonts/fontconfig/files Message-ID: <202004032009.033K9lTZ025302@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: tcberner Date: Fri Apr 3 20:09:46 2020 New Revision: 530517 URL: https://svnweb.freebsd.org/changeset/ports/530517 Log: MFH: r530516 x11-fonts/fontconfig: update to 2.13.92 Fontconfig 2.13.1 generated .uuid files in the fonts directory which where not properly registered to the packages. To clean them up, please execute the following command: find %%LOCALBASE%%/share/fonts -type f -name .uuid -delete By switching to this RC, the dependency on libuuid can be droped again, and the issue of registering uuid is moot. PR: 239167 Exp-run by: antoine Submitted by: lightside <lightside@gmx.com> Approved by: ports-secteam (joneum) Added: branches/2020Q2/x11-fonts/fontconfig/files/patch-2.13.92.diff - copied unchanged from r530516, head/x11-fonts/fontconfig/files/patch-2.13.92.diff branches/2020Q2/x11-fonts/fontconfig/pkg-messsage - copied unchanged from r530516, head/x11-fonts/fontconfig/pkg-messsage Deleted: branches/2020Q2/x11-fonts/fontconfig/files/patch-2.13.1.diff Modified: branches/2020Q2/UPDATING branches/2020Q2/x11-fonts/fontconfig-reference/pkg-plist branches/2020Q2/x11-fonts/fontconfig/Makefile branches/2020Q2/x11-fonts/fontconfig/distinfo branches/2020Q2/x11-fonts/fontconfig/pkg-plist Directory Properties: branches/2020Q2/ (props changed) Modified: branches/2020Q2/UPDATING ============================================================================== --- branches/2020Q2/UPDATING Fri Apr 3 20:02:24 2020 (r530516) +++ branches/2020Q2/UPDATING Fri Apr 3 20:09:46 2020 (r530517) @@ -5,6 +5,16 @@ they are unavoidable. You should get into the habit of checking this file for changes each time you update your ports collection, before attempting any port upgrades. +20200403: + AFFECTS: users of x11-fonts/fontconfig + AUTHOR: desktop@FreeBSD.org + + Fontconfig 2.13.1 generated .uuid files in the fonts directory which where + not properly registered to the packages. To clean them up, please execute the + following command: + + find %%LOCALBASE%%/share/fonts -type f -name .uuid -delete + 20200326: AFFECTS: users of devel/sonarqube and devel/sonar-ant-task AUTHOR: netchild@FreeBSD.org Modified: branches/2020Q2/x11-fonts/fontconfig-reference/pkg-plist ============================================================================== --- branches/2020Q2/x11-fonts/fontconfig-reference/pkg-plist Fri Apr 3 20:02:24 2020 (r530516) +++ branches/2020Q2/x11-fonts/fontconfig-reference/pkg-plist Fri Apr 3 20:09:46 2020 (r530517) @@ -179,6 +179,7 @@ man/man3/FcRangeCreateInteger.3.gz man/man3/FcRangeDestroy.3.gz man/man3/FcRangeGetDouble.3.gz man/man3/FcStrBasename.3.gz +man/man3/FcStrBuildFilename.3.gz man/man3/FcStrCmp.3.gz man/man3/FcStrCmpIgnoreCase.3.gz man/man3/FcStrCopy.3.gz Modified: branches/2020Q2/x11-fonts/fontconfig/Makefile ============================================================================== --- branches/2020Q2/x11-fonts/fontconfig/Makefile Fri Apr 3 20:02:24 2020 (r530516) +++ branches/2020Q2/x11-fonts/fontconfig/Makefile Fri Apr 3 20:09:46 2020 (r530517) @@ -2,11 +2,10 @@ # $FreeBSD$ PORTNAME= fontconfig -PORTVERSION= 2.13.1 -PORTREVISION?= 1 +PORTVERSION= 2.13.92 PORTEPOCH?= 1 CATEGORIES= x11-fonts -MASTER_SITES= http://www.freedesktop.org/software/fontconfig/release/ +MASTER_SITES= https://www.freedesktop.org/software/fontconfig/release/ MAINTAINER= desktop@FreeBSD.org COMMENT= XML-based font configuration API for X Windows @@ -14,13 +13,12 @@ COMMENT= XML-based font configuration API for X Window LICENSE= MIT LICENSE_FILE= ${WRKSRC}/COPYING -USES= gperf tar:bzip2 +USES= gperf tar:xz .if !defined(REFERENCE_PORT) LIB_DEPENDS= libfreetype.so:print/freetype2 \ - libexpat.so:textproc/expat2 \ - libuuid.so:misc/e2fsprogs-libuuid + libexpat.so:textproc/expat2 USES+= cpe gmake libtool pathfix pkgconfig CPE_VENDOR= fontconfig_project Modified: branches/2020Q2/x11-fonts/fontconfig/distinfo ============================================================================== --- branches/2020Q2/x11-fonts/fontconfig/distinfo Fri Apr 3 20:02:24 2020 (r530516) +++ branches/2020Q2/x11-fonts/fontconfig/distinfo Fri Apr 3 20:09:46 2020 (r530517) @@ -1,3 +1,3 @@ -TIMESTAMP = 1550745725 -SHA256 (fontconfig-2.13.1.tar.bz2) = f655dd2a986d7aa97e052261b36aa67b0a64989496361eca8d604e6414006741 -SIZE (fontconfig-2.13.1.tar.bz2) = 1723639 +TIMESTAMP = 1565349179 +SHA256 (fontconfig-2.13.92.tar.xz) = 506e61283878c1726550bc94f2af26168f1e9f2106eac77eaaf0b2cdfad66e4e +SIZE (fontconfig-2.13.92.tar.xz) = 1413128 Copied: branches/2020Q2/x11-fonts/fontconfig/files/patch-2.13.92.diff (from r530516, head/x11-fonts/fontconfig/files/patch-2.13.92.diff) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/2020Q2/x11-fonts/fontconfig/files/patch-2.13.92.diff Fri Apr 3 20:09:46 2020 (r530517, copy of r530516, head/x11-fonts/fontconfig/files/patch-2.13.92.diff) @@ -0,0 +1,1748 @@ +# Affect FC_FONT_HAS_HINT property to score on matcher +# https://cgit.freedesktop.org/fontconfig/commit/?id=cb1036a7c7f1cb79fa799b1db368c86b018ec368 +# Add missing return type for FcFontSet* functions +# https://cgit.freedesktop.org/fontconfig/commit/?id=7172f08d4231c59cf14dab9ebab714df37e352ac +# Do not return FcFalse from FcConfigParseAndLoad*() if complain is set to false +# https://cgit.freedesktop.org/fontconfig/commit/?id=fcada522913e5e07efa6367eff87ace9f06d24c8 +# conf: Add JoyPixels emoji font +# https://cgit.freedesktop.org/fontconfig/commit/?id=65087ac7ce4cc5f2109967c1380b474955dcb590 +# Warn as well if no directory name for cachedir provided +# https://cgit.freedesktop.org/fontconfig/commit/?id=75eadca26648abf69497691ff0f4c7803b9ff23c +# Take effect sysroot functionality to the default config file +# https://cgit.freedesktop.org/fontconfig/commit/?id=cd51cb241aad7b362b793200ca7d42595c14f52b +# Read latest cache in paths +# https://cgit.freedesktop.org/fontconfig/commit/?id=c9862b6ea7c3234b29f6500c7d07359847e55ed7 +# Fix a memory leak caused by the previous commit +# https://cgit.freedesktop.org/fontconfig/commit/?id=a45fc8a33256d9d3ea0ea7947f33c8e5e3cc7238 +# Use FcConfigReference/Destroy appropriately instead of FcConfigGetCurrent +# https://cgit.freedesktop.org/fontconfig/commit/?id=b5bcf61fe789e66df2de609ec246cb7e4d326180 +# Fix potential race condition in FcConfigSetCurrent and FcConfigReference +# https://cgit.freedesktop.org/fontconfig/commit/?id=aa8c8cfa9fb2563482336249e3f56459099fcf6e +# Correct reset-dirs in DTD +# https://cgit.freedesktop.org/fontconfig/commit/?id=a4aa66a858f1ecd375c5efe5916398281f73f794 +# Don't add a value for FC_FULLNAME in meta face +# https://cgit.freedesktop.org/fontconfig/commit/?id=8249f871b373db5c6559f8c48242beed612b23a0 +# Add proper fullname for named-instances +# https://cgit.freedesktop.org/fontconfig/commit/?id=452be8125f0e2a18a7dfef469e05d19374d36307 +# Fix the process substitution doesn't work with FONTCONFIG_FILE +# https://cgit.freedesktop.org/fontconfig/commit/?id=71d6866d381a0ab3585eb9ee760aeec98e722359 +# Fix memory leaks +# https://cgit.freedesktop.org/fontconfig/commit/?id=61573ad5f7c4dd0860d613d99d0086433240eb75 +# Fix assertion in FcFini() +# https://cgit.freedesktop.org/fontconfig/commit/?id=fbc05949ef52c8a8d69233eed77f6636dffec280 +# Set exact boolean value to color property +# https://cgit.freedesktop.org/fontconfig/commit/?id=d3bfbea7dc53aa7fa52aa9616235a23d4507da1b + +Excluding changes for the following files: test/Makefile.am, test/run-test.sh, +test/test-bz1744377.c, test/test-crbug1004254.c, test/test-issue180.c. + +--- conf.d/45-generic.conf.orig 2018-06-05 10:36:38 UTC ++++ conf.d/45-generic.conf +@@ -38,6 +38,10 @@ + <default><family>emoji</family></default> + </alias> + <alias binding="same"> ++ <family>JoyPixels</family> ++ <default><family>emoji</family></default> ++ </alias> ++ <alias binding="same"> + <family>Emoji One</family> + <default><family>emoji</family></default> + </alias> +--- conf.d/60-generic.conf.orig 2018-06-05 10:36:38 UTC ++++ conf.d/60-generic.conf +@@ -42,6 +42,7 @@ + <family>EmojiOne Mozilla</family> <!-- Mozilla --> + <!-- Third-Party fonts --> + <family>Emoji Two</family> ++ <family>JoyPixels</family> + <family>Emoji One</family> + <!-- Non-color --> + <family>Noto Emoji</family> <!-- Google --> +--- doc/fcconfig.fncs.orig 2019-05-08 08:22:25 UTC ++++ doc/fcconfig.fncs +@@ -174,6 +174,10 @@ Returns one of the two sets of fonts fro + by <parameter>set</parameter>. This font set is owned by the library and must + not be modified or freed. + If <parameter>config</parameter> is NULL, the current configuration is used. ++ </para><para> ++This function isn't MT-safe. <function>FcConfigReference</function> must be called ++before using this and then <function>FcConfigDestroy</function> when ++the return value is no longer referenced. + @@ + + @RET@ FcBlanks * +@@ -344,6 +348,15 @@ to be up to date, and used. + @TYPE1@ const FcChar8 * @ARG1@ name + @PURPOSE@ Find a config file + @DESC@ ++This function is deprecated and is replaced by <function>FcConfigGetFilename</function>. ++@@ ++ ++@RET@ FcChar8 * ++@FUNC@ FcConfigGetFilename ++@TYPE1@ FcConfig * @ARG1@ config ++@TYPE2@ const FcChar8 * @ARG2@ name ++@PURPOSE@ Find a config file ++@DESC@ + Given the specified external entity name, return the associated filename. + This provides applications a way to convert various configuration file + references into filename form. +@@ -355,6 +368,8 @@ refers to a file in the current users ho + doesn't start with '/', it refers to a file in the default configuration + directory; the built-in default directory can be overridden with the + FONTCONFIG_PATH environment variable. ++ </para><para> ++The result of this function is affected by the FONTCONFIG_SYSROOT environment variable or equivalent functionality. + @@ + + @RET@ FcBool +@@ -396,6 +411,10 @@ parse error, semantic error or allocatio + Obtains the system root directory in 'config' if available. All files + (including file properties in patterns) obtained from this 'config' are + relative to this system root directory. ++ </para><para> ++This function isn't MT-safe. <function>FcConfigReference</function> must be called ++before using this and then <function>FcConfigDestroy</function> when ++the return value is no longer referenced. + @SINCE@ 2.10.92 + @@ + +@@ -422,6 +441,10 @@ When setting this on the current config + @PURPOSE@ Initialize the iterator + @DESC@ + Initialize 'iter' with the first iterator in the config file information list. ++ </para><para> ++This function isn't MT-safe. <function>FcConfigReference</function> must be called ++before using this and then <function>FcConfigDestroy</function> when the relevant ++values are no longer referenced. + @SINCE@ 2.12.91 + @@ + +@@ -433,6 +456,10 @@ Initialize 'iter' with the first iterato + @DESC@ + Set 'iter' to point to the next node in the config file information list. + If there is no next node, FcFalse is returned. ++ </para><para> ++This function isn't MT-safe. <function>FcConfigReference</function> must be called ++before using <function>FcConfigFileInfoIterInit</function> and then ++<function>FcConfigDestroy</function> when the relevant values are no longer referenced. + @SINCE@ 2.12.91 + @@ + +@@ -448,5 +475,9 @@ If there is no next node, FcFalse is ret + Obtain the filename, the description and the flag whether it is enabled or not + for 'iter' where points to current configuration file information. + If the iterator is invalid, FcFalse is returned. ++ </para><para> ++This function isn't MT-safe. <function>FcConfigReference</function> must be called ++before using <function>FcConfigFileInfoIterInit</function> and then ++<function>FcConfigDestroy</function> when the relevant values are no longer referenced. + @SINCE@ 2.12.91 + @@ +--- doc/fcfontset.fncs.orig 2016-07-11 02:41:05 UTC ++++ doc/fcfontset.fncs +@@ -97,7 +97,7 @@ of the output is designed to be of help + change at any time. + @@ + +-@RET@ ++@RET@ FcFontSet * + @FUNC@ FcFontSetSort + @TYPE1@ FcConfig * @ARG1@ config + @TYPE2@ FcFontSet ** @ARG2@ sets +@@ -128,7 +128,7 @@ modify these patterns. Instead, they sh + The FcFontSet returned by FcFontSetSort is destroyed by calling FcFontSetDestroy. + @@ + +-@RET@ ++@RET@ void + @FUNC@ FcFontSetSortDestroy + @TYPE1@ FcFontSet * @ARG1@ set + @PURPOSE@ DEPRECATED destroy a font set +--- fontconfig/fontconfig.h.orig 2019-08-09 11:09:32 UTC ++++ fontconfig/fontconfig.h +@@ -375,7 +375,7 @@ FcPublic FcBool + FcDirCacheClean (const FcChar8 *cache_dir, FcBool verbose); + + FcPublic void +-FcCacheCreateTagFile (const FcConfig *config); ++FcCacheCreateTagFile (FcConfig *config); + + FcPublic FcBool + FcDirCacheCreateUUID (FcChar8 *dir, +@@ -394,6 +394,10 @@ FcPublic FcBool + FcConfigEnableHome (FcBool enable); + + FcPublic FcChar8 * ++FcConfigGetFilename (FcConfig *config, ++ const FcChar8 *url); ++ ++FcPublic FcChar8 * + FcConfigFilename (const FcChar8 *url); + + FcPublic FcConfig * +@@ -433,7 +437,7 @@ FcPublic FcBlanks * + FcConfigGetBlanks (FcConfig *config); + + FcPublic FcStrList * +-FcConfigGetCacheDirs (const FcConfig *config); ++FcConfigGetCacheDirs (FcConfig *config); + + FcPublic int + FcConfigGetRescanInterval (FcConfig *config); +--- fonts.dtd.orig 2019-05-08 08:22:25 UTC ++++ fonts.dtd +@@ -124,7 +124,7 @@ + <!-- + Reset the list of fonts directories + --> +-<!ELEMENT reset-dirs > ++<!ELEMENT reset-dirs EMPTY> + + <!-- + Periodically rescan the font configuration and +--- src/fccache.c.orig 2019-07-29 05:17:34 UTC ++++ src/fccache.c +@@ -58,11 +58,15 @@ FcDirCacheDeleteUUID (const FcChar8 *di + { + FcBool ret = FcTrue; + #ifndef _WIN32 +- const FcChar8 *sysroot = FcConfigGetSysRoot (config); ++ const FcChar8 *sysroot; + FcChar8 *target, *d; + struct stat statb; + struct timeval times[2]; + ++ config = FcConfigReference (config); ++ if (!config) ++ return FcFalse; ++ sysroot = FcConfigGetSysRoot (config); + if (sysroot) + d = FcStrBuildFilename (sysroot, dir, NULL); + else +@@ -94,6 +98,7 @@ FcDirCacheDeleteUUID (const FcChar8 *di + bail: + FcStrFree (d); + #endif ++ FcConfigDestroy (config); + + return ret; + } +@@ -265,7 +270,13 @@ FcDirCacheUnlink (const FcChar8 *dir, Fc + #endif + FcStrList *list; + FcChar8 *cache_dir; +- const FcChar8 *sysroot = FcConfigGetSysRoot (config); ++ const FcChar8 *sysroot; ++ FcBool ret = FcTrue; ++ ++ config = FcConfigReference (config); ++ if (!config) ++ return FcFalse; ++ sysroot = FcConfigGetSysRoot (config); + + FcDirCacheBasenameMD5 (config, dir, cache_base); + #ifndef _WIN32 +@@ -274,7 +285,10 @@ FcDirCacheUnlink (const FcChar8 *dir, Fc + + list = FcStrListCreate (config->cacheDirs); + if (!list) +- return FcFalse; ++ { ++ ret = FcFalse; ++ goto bail; ++ } + + while ((cache_dir = FcStrListNext (list))) + { +@@ -304,8 +318,11 @@ FcDirCacheUnlink (const FcChar8 *dir, Fc + FcDirCacheDeleteUUID (dir, config); + /* return FcFalse if something went wrong */ + if (cache_dir) +- return FcFalse; +- return FcTrue; ++ ret = FcFalse; ++bail: ++ FcConfigDestroy (config); ++ ++ return ret; + } + + static int +@@ -338,7 +355,7 @@ FcDirCacheOpenFile (const FcChar8 *cache + static FcBool + FcDirCacheProcess (FcConfig *config, const FcChar8 *dir, + FcBool (*callback) (FcConfig *config, int fd, struct stat *fd_stat, +- struct stat *dir_stat, void *closure), ++ struct stat *dir_stat, struct timeval *cache_mtime, void *closure), + void *closure, FcChar8 **cache_file_ret) + { + int fd = -1; +@@ -372,6 +389,8 @@ FcDirCacheProcess (FcConfig *config, con + #ifndef _WIN32 + FcBool retried = FcFalse; + #endif ++ struct timeval latest_mtime = (struct timeval){ 0 }; ++ + if (sysroot) + cache_hashed = FcStrBuildFilename (sysroot, cache_dir, cache_base, NULL); + else +@@ -383,16 +402,21 @@ FcDirCacheProcess (FcConfig *config, con + #endif + fd = FcDirCacheOpenFile (cache_hashed, &file_stat); + if (fd >= 0) { +- ret = (*callback) (config, fd, &file_stat, &dir_stat, closure); ++ ret = (*callback) (config, fd, &file_stat, &dir_stat, &latest_mtime, closure); + close (fd); + if (ret) + { + if (cache_file_ret) ++ { ++ if (*cache_file_ret) ++ FcStrFree (*cache_file_ret); + *cache_file_ret = cache_hashed; ++ } + else + FcStrFree (cache_hashed); +- break; + } ++ else ++ FcStrFree (cache_hashed); + } + #ifndef _WIN32 + else if (!retried) +@@ -412,9 +436,12 @@ FcDirCacheProcess (FcConfig *config, con + break; + goto retry; + } ++ else ++ FcStrFree (cache_hashed); + } + #endif +- FcStrFree (cache_hashed); ++ else ++ FcStrFree (cache_hashed); + } + FcStrListDone (list); + +@@ -998,12 +1025,31 @@ FcDirCacheUnload (FcCache *cache) + } + + static FcBool +-FcDirCacheMapHelper (FcConfig *config, int fd, struct stat *fd_stat, struct stat *dir_stat, void *closure) ++FcDirCacheMapHelper (FcConfig *config, int fd, struct stat *fd_stat, struct stat *dir_stat, struct timeval *latest_cache_mtime, void *closure) + { + FcCache *cache = FcDirCacheMapFd (config, fd, fd_stat, dir_stat); ++ struct timeval cache_mtime; + + if (!cache) + return FcFalse; ++ cache_mtime.tv_sec = fd_stat->st_mtime; ++#ifdef HAVE_STRUCT_STAT_ST_MTIM ++ cache_mtime.tv_usec = fd_stat->st_mtim.tv_nsec / 1000; ++#else ++ cache_mtime.tv_usec = 0; ++#endif ++ if (timercmp (latest_cache_mtime, &cache_mtime, <)) ++ { ++ if (*((FcCache **) closure)) ++ FcDirCacheUnload (*((FcCache **) closure)); ++ } ++ else ++ { ++ FcDirCacheUnload (cache); ++ return FcFalse; ++ } ++ latest_cache_mtime->tv_sec = cache_mtime.tv_sec; ++ latest_cache_mtime->tv_usec = cache_mtime.tv_usec; + *((FcCache **) closure) = cache; + return FcTrue; + } +@@ -1013,10 +1059,15 @@ FcDirCacheLoad (const FcChar8 *dir, FcCo + { + FcCache *cache = NULL; + ++ config = FcConfigReference (config); ++ if (!config) ++ return NULL; + if (!FcDirCacheProcess (config, dir, + FcDirCacheMapHelper, + &cache, cache_file)) +- return NULL; ++ cache = NULL; ++ ++ FcConfigDestroy (config); + + return cache; + } +@@ -1027,13 +1078,18 @@ FcDirCacheLoadFile (const FcChar8 *cache + int fd; + FcCache *cache; + struct stat my_file_stat; ++ FcConfig *config; + + if (!file_stat) + file_stat = &my_file_stat; ++ config = FcConfigReference (NULL); ++ if (!config) ++ return NULL; + fd = FcDirCacheOpenFile (cache_file, file_stat); + if (fd < 0) + return NULL; +- cache = FcDirCacheMapFd (FcConfigGetCurrent (), fd, file_stat, NULL); ++ cache = FcDirCacheMapFd (config, fd, file_stat, NULL); ++ FcConfigDestroy (config); + close (fd); + return cache; + } +@@ -1093,7 +1149,7 @@ FcDirChecksumNano (struct stat *statb) + * the magic number and the size field + */ + static FcBool +-FcDirCacheValidateHelper (FcConfig *config, int fd, struct stat *fd_stat, struct stat *dir_stat, void *closure FC_UNUSED) ++FcDirCacheValidateHelper (FcConfig *config, int fd, struct stat *fd_stat, struct stat *dir_stat, struct timeval *latest_cache_mtime, void *closure FC_UNUSED) + { + FcBool ret = FcTrue; + FcCache c; +@@ -1127,12 +1183,16 @@ FcBool + FcDirCacheValid (const FcChar8 *dir) + { + FcConfig *config; ++ FcBool ret; + +- config = FcConfigGetCurrent (); ++ config = FcConfigReference (NULL); + if (!config) + return FcFalse; + +- return FcDirCacheValidConfig (dir, config); ++ ret = FcDirCacheValidConfig (dir, config); ++ FcConfigDestroy (config); ++ ++ return ret; + } + + /* +@@ -1410,9 +1470,13 @@ FcDirCacheClean (const FcChar8 *cache_di + FcCache *cache; + struct stat target_stat; + const FcChar8 *sysroot; ++ FcConfig *config; + ++ config = FcConfigReference (NULL); ++ if (!config) ++ return FcFalse; + /* FIXME: this API needs to support non-current FcConfig */ +- sysroot = FcConfigGetSysRoot (NULL); ++ sysroot = FcConfigGetSysRoot (config); + if (sysroot) + dir = FcStrBuildFilename (sysroot, cache_dir, NULL); + else +@@ -1420,7 +1484,8 @@ FcDirCacheClean (const FcChar8 *cache_di + if (!dir) + { + fprintf (stderr, "Fontconfig error: %s: out of memory\n", cache_dir); +- return FcFalse; ++ ret = FcFalse; ++ goto bail; + } + if (access ((char *) dir, W_OK) != 0) + { +@@ -1497,8 +1562,10 @@ FcDirCacheClean (const FcChar8 *cache_di + } + + closedir (d); +- bail0: ++bail0: + FcStrFree (dir); ++bail: ++ FcConfigDestroy (config); + + return ret; + } +@@ -1940,15 +2007,20 @@ FcDirCacheCreateTagFile (const FcChar8 * + } + + void +-FcCacheCreateTagFile (const FcConfig *config) ++FcCacheCreateTagFile (FcConfig *config) + { + FcChar8 *cache_dir = NULL, *d = NULL; + FcStrList *list; +- const FcChar8 *sysroot = FcConfigGetSysRoot (config); ++ const FcChar8 *sysroot; ++ ++ config = FcConfigReference (config); ++ if (!config) ++ return; ++ sysroot = FcConfigGetSysRoot (config); + + list = FcConfigGetCacheDirs (config); + if (!list) +- return; ++ goto bail; + + while ((cache_dir = FcStrListNext (list))) + { +@@ -1964,6 +2036,8 @@ FcCacheCreateTagFile (const FcConfig *co + if (d) + FcStrFree (d); + FcStrListDone (list); ++bail: ++ FcConfigDestroy (config); + } + + #define __fccache__ +--- src/fccfg.c.orig 2019-05-08 08:22:25 UTC ++++ src/fccfg.c +@@ -33,6 +33,49 @@ + #endif + + static FcConfig *_fcConfig; /* MT-safe */ ++static FcMutex *_lock; ++ ++static void ++lock_config (void) ++{ ++ FcMutex *lock; ++retry: ++ lock = fc_atomic_ptr_get (&_lock); ++ if (!lock) ++ { ++ lock = (FcMutex *) malloc (sizeof (FcMutex)); ++ FcMutexInit (lock); ++ if (!fc_atomic_ptr_cmpexch (&_lock, NULL, lock)) ++ { ++ FcMutexFinish (lock); ++ goto retry; ++ } ++ FcMutexLock (lock); ++ /* Initialize random state */ ++ FcRandom (); ++ return; ++ } ++ FcMutexLock (lock); ++} ++ ++static void ++unlock_config (void) ++{ ++ FcMutexUnlock (_lock); ++} ++ ++static void ++free_lock (void) ++{ ++ FcMutex *lock; ++ ++ lock = fc_atomic_ptr_get (&_lock); ++ if (lock && fc_atomic_ptr_cmpexch (&_lock, lock, NULL)) ++ { ++ FcMutexFinish (lock); ++ free (lock); ++ } ++} + + static FcConfig * + FcConfigEnsure (void) +@@ -44,8 +87,9 @@ retry: + { + config = FcInitLoadConfigAndFonts (); + +- if (!fc_atomic_ptr_cmpexch (&_fcConfig, NULL, config)) { +- FcConfigDestroy (config); ++ if (!config || !fc_atomic_ptr_cmpexch (&_fcConfig, NULL, config)) { ++ if (config) ++ FcConfigDestroy (config); + goto retry; + } + } +@@ -76,6 +120,7 @@ FcConfigFini (void) + FcConfig *cfg = fc_atomic_ptr_get (&_fcConfig); + if (cfg && fc_atomic_ptr_cmpexch (&_fcConfig, cfg, NULL)) + FcConfigDestroy (cfg); ++ free_lock (); + } + + static FcChar8 * +@@ -237,12 +282,12 @@ FcConfigUptoDate (FcConfig *config) + { + FcFileTime config_time, config_dir_time, font_time; + time_t now = time(0); ++ FcBool ret = FcTrue; ++ ++ config = FcConfigReference (config); + if (!config) +- { +- config = FcConfigGetCurrent (); +- if (!config) +- return FcFalse; +- } ++ return FcFalse; ++ + config_time = FcConfigNewestFile (config->configFiles); + config_dir_time = FcConfigNewestFile (config->configDirs); + font_time = FcConfigNewestFile (config->fontDirs); +@@ -258,13 +303,19 @@ FcConfigUptoDate (FcConfig *config) + fprintf (stderr, + "Fontconfig warning: Directory/file mtime in the future. New fonts may not be detected.\n"); + config->rescanTime = now; +- return FcTrue; ++ goto bail; + } + else +- return FcFalse; ++ { ++ ret = FcFalse; ++ goto bail; ++ } + } + config->rescanTime = now; +- return FcTrue; ++bail: ++ FcConfigDestroy (config); ++ ++ return ret; + } + + FcExpr * +@@ -291,12 +342,31 @@ FcConfigReference (FcConfig *config) + { + if (!config) + { +- config = FcConfigGetCurrent (); ++ /* lock during obtaining the value from _fcConfig and count up refcount there, ++ * there are the race between them. ++ */ ++ lock_config (); ++ retry: ++ config = fc_atomic_ptr_get (&_fcConfig); + if (!config) +- return 0; +- } ++ { ++ unlock_config (); + +- FcRefInc (&config->ref); ++ config = FcInitLoadConfigAndFonts (); ++ if (!config) ++ goto retry; ++ lock_config (); ++ if (!fc_atomic_ptr_cmpexch (&_fcConfig, NULL, config)) ++ { ++ FcConfigDestroy (config); ++ goto retry; ++ } ++ } ++ FcRefInc (&config->ref); ++ unlock_config (); ++ } ++ else ++ FcRefInc (&config->ref); + + return config; + } +@@ -475,25 +545,32 @@ FcBool + FcConfigBuildFonts (FcConfig *config) + { + FcFontSet *fonts; ++ FcBool ret = FcTrue; + ++ config = FcConfigReference (config); + if (!config) +- { +- config = FcConfigGetCurrent (); +- if (!config) +- return FcFalse; +- } ++ return FcFalse; + + fonts = FcFontSetCreate (); + if (!fonts) +- return FcFalse; ++ { ++ ret = FcFalse; ++ goto bail; ++ } + + FcConfigSetFonts (config, fonts, FcSetSystem); + + if (!FcConfigAddDirList (config, FcSetSystem, config->fontDirs)) +- return FcFalse; ++ { ++ ret = FcFalse; ++ goto bail; ++ } + if (FcDebug () & FC_DBG_FONTSET) + FcFontSetPrint (fonts); +- return FcTrue; ++bail: ++ FcConfigDestroy (config); ++ ++ return ret; + } + + FcBool +@@ -501,20 +578,29 @@ FcConfigSetCurrent (FcConfig *config) + { + FcConfig *cfg; + ++ if (config) ++ { ++ if (!config->fonts[FcSetSystem]) ++ if (!FcConfigBuildFonts (config)) ++ return FcFalse; ++ FcRefInc (&config->ref); ++ } ++ ++ lock_config (); + retry: + cfg = fc_atomic_ptr_get (&_fcConfig); + + if (config == cfg) ++ { ++ unlock_config (); ++ if (config) ++ FcConfigDestroy (config); + return FcTrue; +- +- if (config && !config->fonts[FcSetSystem]) +- if (!FcConfigBuildFonts (config)) +- return FcFalse; ++ } + + if (!fc_atomic_ptr_cmpexch (&_fcConfig, cfg, config)) + goto retry; +- +- FcConfigReference (config); ++ unlock_config (); + if (cfg) + FcConfigDestroy (cfg); + +@@ -537,13 +623,15 @@ FcConfigAddConfigDir (FcConfig *conf + FcStrList * + FcConfigGetConfigDirs (FcConfig *config) + { ++ FcStrList *ret; ++ ++ config = FcConfigReference (config); + if (!config) +- { +- config = FcConfigGetCurrent (); +- if (!config) +- return 0; +- } +- return FcStrListCreate (config->configDirs); ++ return NULL; ++ ret = FcStrListCreate (config->configDirs); ++ FcConfigDestroy (config); ++ ++ return ret; + } + + FcBool +@@ -579,13 +667,15 @@ FcConfigResetFontDirs (FcConfig *config) + FcStrList * + FcConfigGetFontDirs (FcConfig *config) + { ++ FcStrList *ret; ++ ++ config = FcConfigReference (config); + if (!config) +- { +- config = FcConfigGetCurrent (); +- if (!config) +- return 0; +- } +- return FcStrListCreate (config->fontDirs); ++ return NULL; ++ ret = FcStrListCreate (config->fontDirs); ++ FcConfigDestroy (config); ++ ++ return ret; + } + + static FcBool +@@ -670,15 +760,17 @@ FcConfigAddCacheDir (FcConfig *confi + } + + FcStrList * +-FcConfigGetCacheDirs (const FcConfig *config) ++FcConfigGetCacheDirs (FcConfig *config) + { ++ FcStrList *ret; ++ ++ config = FcConfigReference (config); + if (!config) +- { +- config = FcConfigGetCurrent (); +- if (!config) +- return 0; +- } +- return FcStrListCreate (config->cacheDirs); ++ return NULL; ++ ret = FcStrListCreate (config->cacheDirs); ++ FcConfigDestroy (config); ++ ++ return ret; + } + + FcBool +@@ -686,7 +778,7 @@ FcConfigAddConfigFile (FcConfig *con + const FcChar8 *f) + { + FcBool ret; +- FcChar8 *file = FcConfigFilename (f); ++ FcChar8 *file = FcConfigGetFilename (config, f); + + if (!file) + return FcFalse; +@@ -699,13 +791,15 @@ FcConfigAddConfigFile (FcConfig *con + FcStrList * + FcConfigGetConfigFiles (FcConfig *config) + { ++ FcStrList *ret; ++ ++ config = FcConfigReference (config); + if (!config) +- { +- config = FcConfigGetCurrent (); +- if (!config) +- return 0; +- } +- return FcStrListCreate (config->configFiles); ++ return NULL; ++ ret = FcStrListCreate (config->configFiles); ++ FcConfigDestroy (config); ++ ++ return ret; + } + + FcChar8 * +@@ -784,25 +878,26 @@ FcConfigAddBlank (FcConfig *config FC_UN + int + FcConfigGetRescanInterval (FcConfig *config) + { ++ int ret; ++ ++ config = FcConfigReference (config); + if (!config) +- { +- config = FcConfigGetCurrent (); +- if (!config) +- return 0; +- } +- return config->rescanInterval; ++ return 0; ++ ret = config->rescanInterval; ++ FcConfigDestroy (config); ++ ++ return ret; + } + + FcBool + FcConfigSetRescanInterval (FcConfig *config, int rescanInterval) + { ++ config = FcConfigReference (config); + if (!config) +- { +- config = FcConfigGetCurrent (); +- if (!config) +- return FcFalse; +- } ++ return FcFalse; + config->rescanInterval = rescanInterval; ++ FcConfigDestroy (config); ++ + return FcTrue; + } + +@@ -1670,15 +1765,13 @@ FcConfigSubstituteWithPat (FcConfig * + FcBool retval = FcTrue; + FcTest **tst = NULL; + +- if (!config) +- { +- config = FcConfigGetCurrent (); +- if (!config) +- return FcFalse; +- } +- + if (kind < FcMatchKindBegin || kind >= FcMatchKindEnd) + return FcFalse; ++ ++ config = FcConfigReference (config); ++ if (!config) ++ return FcFalse; ++ + s = config->subst[kind]; + if (kind == FcMatchPattern) + { +@@ -1973,6 +2066,7 @@ bail1: + free (value); + if (tst) + free (tst); ++ FcConfigDestroy (config); + + return retval; + } +@@ -2284,10 +2378,16 @@ FcConfigEnableHome (FcBool enable) + } + + FcChar8 * +-FcConfigFilename (const FcChar8 *url) ++FcConfigGetFilename (FcConfig *config, ++ const FcChar8 *url) + { + FcChar8 *file, *dir, **path, **p; ++ const FcChar8 *sysroot; + ++ config = FcConfigReference (config); ++ if (!config) ++ return NULL; ++ sysroot = FcConfigGetSysRoot (config); + if (!url || !*url) + { + url = (FcChar8 *) getenv ("FONTCONFIG_FILE"); +@@ -2297,13 +2397,26 @@ FcConfigFilename (const FcChar8 *url) + file = 0; + + if (FcStrIsAbsoluteFilename(url)) +- return FcConfigFileExists (0, url); ++ { ++ file = FcConfigFileExists (sysroot, url); ++ goto bail; ++ } + + if (*url == '~') + { + dir = FcConfigHome (); + if (dir) +- file = FcConfigFileExists (dir, url + 1); ++ { ++ FcChar8 *s; ++ ++ if (sysroot) ++ s = FcStrBuildFilename (sysroot, dir, NULL); *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202004032009.033K9lTZ025302>