From 8af5a7aa615f2c89e0e533ab62b1932bbd726176 Mon Sep 17 00:00:00 2001 From: midipix Date: Thu, 10 Sep 2015 07:03:17 -0400 Subject: libiberty: fix the neutral implementation of xstrerror(). signed-off by Z. Gilboa; see copying.midipix (9cd0746c) for additional information. --- libiberty/neutral.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 #include #include +#include #include @@ -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; +} -- cgit v1.2.3