summaryrefslogtreecommitdiffstats
path: root/libdimension/error.c
diff options
context:
space:
mode:
Diffstat (limited to 'libdimension/error.c')
-rw-r--r--libdimension/error.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/libdimension/error.c b/libdimension/error.c
index 371c7cd..1facc72 100644
--- a/libdimension/error.c
+++ b/libdimension/error.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -25,6 +25,7 @@
#include "dimension-internal.h"
#include <pthread.h>
+#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
@@ -95,7 +96,12 @@ dmnsn_report_error(bool die, const char *func, const char *file,
/* Print the value of errno */
if (err != 0) {
fprintf(stderr, "Last error: %d", err);
-#if DMNSN_SYS_ERRLIST
+#if DMNSN_STRERROR_R
+ char errbuf[256];
+ if (strerror_r(err, errbuf, 256) == 0) {
+ fprintf(stderr, " (%s)", errbuf);
+ }
+#elif DMNSN_SYS_ERRLIST
if (err >= 0 && err < sys_nerr) {
fprintf(stderr, " (%s)", sys_errlist[err]);
}