summaryrefslogtreecommitdiff
path: root/libiberty
diff options
context:
space:
mode:
Diffstat (limited to 'libiberty')
-rw-r--r--libiberty/neutral.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/libiberty/neutral.c b/libiberty/neutral.c
index a92ff1a0a..cbf1a1da6 100644
--- a/libiberty/neutral.c
+++ b/libiberty/neutral.c
@@ -4,6 +4,7 @@
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
+#include <string.h>
#include <config.h>
@@ -13,7 +14,6 @@ void * xcalloc(size_t nmemb, size_t size) {return calloc(nmemb,size);}
void * xrealloc(void *ptr, size_t size) {return realloc(ptr,size);}
char * xstrdup(const char *s) {return strdup(s);}
char * xstrndup(const char *s, size_t n) {return strndup(s,n);}
-char * xstrerror(int errnum) {return strerror(errnum);}
void * xmalloc(size_t block_size) {return malloc(block_size);}
void * xmemdup (const void * src, size_t copy_size, size_t alloc_size)
@@ -32,3 +32,16 @@ void xmalloc_failed (size_t size)
fputs("malloc failed, aborting.\n\0",stderr);
_exit(1);
}
+
+static char errdesc_fallback[64];
+
+char * xstrerror(int errnum)
+{
+ char * errdesc;
+
+ if ((errdesc = strerror(errnum)))
+ return errdesc;
+
+ sprintf(errdesc_fallback,"Undocumented error %d.",errnum);
+ return errdesc_fallback;
+}