[Fontconfig] fontconfig: Branch 'master'
Akira TAGOH
tagoh at kemper.freedesktop.org
Sun May 13 05:50:47 UTC 2018
configure.ac | 2 +-
src/fcxml.c | 20 +++++++++++++++++++-
2 files changed, 20 insertions(+), 2 deletions(-)
New commits:
commit cfb21c7d85d2b1fc457dcd644e6b850b5cccf26a
Author: Akira TAGOH <akira at tagoh.org>
Date: Sun May 13 14:48:10 2018 +0900
Bug 106497 - better error description when problem reading font configuration
https://bugs.freedesktop.org/show_bug.cgi?id=106497
diff --git a/configure.ac b/configure.ac
index 3e37663..12cf2e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -169,7 +169,7 @@ AC_TYPE_PID_T
# Checks for library functions.
AC_FUNC_VPRINTF
AC_FUNC_MMAP
-AC_CHECK_FUNCS([link mkstemp mkostemp _mktemp_s mkdtemp getopt getopt_long getprogname getexecname rand random lrand48 random_r rand_r readlink fstatvfs fstatfs lstat])
+AC_CHECK_FUNCS([link mkstemp mkostemp _mktemp_s mkdtemp getopt getopt_long getprogname getexecname rand random lrand48 random_r rand_r readlink fstatvfs fstatfs lstat strerror strerror_r])
dnl AC_CHECK_FUNCS doesn't check for header files.
dnl posix_fadvise() may be not available in older libc.
diff --git a/src/fcxml.c b/src/fcxml.c
index aa6612d..1ee1ba1 100644
--- a/src/fcxml.c
+++ b/src/fcxml.c
@@ -22,6 +22,10 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef _GNU_SOURCE
+#undef _GNU_SOURCE /* To use the POSIX version of strerror_r */
+#endif
+#include <string.h>
#include "fcint.h"
#include <fcntl.h>
#include <stdarg.h>
@@ -3451,7 +3455,21 @@ _FcConfigParse (FcConfig *config,
len = read (fd, buf, BUFSIZ);
if (len < 0)
{
- FcConfigMessage (0, FcSevereError, "failed reading config file");
+ int errno_ = errno;
+ char ebuf[BUFSIZ+1];
+
+#if HAVE_STRERROR_R
+ int x FC_UNUSED;
+ x = strerror_r (errno_, ebuf, BUFSIZ); /* make sure we use the POSIX version of strerror_r */
+#elif HAVE_STRERROR
+ char *tmp = strerror (errno_);
+ size_t len = strlen (tmp);
+ strncpy (ebuf, tmp, FC_MIN (BUFSIZ, len));
+ ebuf[FC_MIN (BUFSIZ, len)] = 0;
+#else
+ ebuf[0] = 0;
+#endif
+ FcConfigMessage (0, FcSevereError, "failed reading config file: %s: %s (errno %d)", realfilename, ebuf, errno_);
close (fd);
goto bail1;
}
More information about the Fontconfig
mailing list