diff options
author | Akira TAGOH <akira@tagoh.org> | 2018-05-13 14:48:10 +0900 |
---|---|---|
committer | Akira TAGOH <akira@tagoh.org> | 2018-05-13 14:48:10 +0900 |
commit | cfb21c7d85d2b1fc457dcd644e6b850b5cccf26a (patch) | |
tree | c2615c3e10639b3ba97bb6a5ebfa440682d1a372 /src | |
parent | af964f789762df0b023c8cfd7ea622045892cb54 (diff) |
Bug 106497 - better error description when problem reading font configuration
https://bugs.freedesktop.org/show_bug.cgi?id=106497
Diffstat (limited to 'src')
-rw-r--r-- | src/fcxml.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/fcxml.c b/src/fcxml.c index aa6612df..1ee1ba1d 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; } |