Commit cfb21c7d authored by Akira TAGOH's avatar Akira TAGOH

Bug 106497 - better error description when problem reading font configuration

https://bugs.freedesktop.org/show_bug.cgi?id=106497
parent af964f78
......@@ -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.
......
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment