/* xstrerror.c -- jacket routine for more robust strerror() usage. Fri Jun 16 18:30:00 1995 Pat Rankin This code is in the public domain. */ #include #include #include "libiberty.h" /* If strerror returns NULL, we'll format the number into a static buffer. */ #define ERRSTR_FMT "undocumented error #%d" static char xstrerror_buf[sizeof ERRSTR_FMT + 20]; /* Like strerror, but result is never a null pointer. */ char * xstrerror (errnum) int errnum; { char *errstr; errstr = strerror (errnum); /* If `errnum' is out of range, result might be NULL. We'll fix that. */ if (!errstr) { sprintf (xstrerror_buf, ERRSTR_FMT, errnum); errstr = xstrerror_buf; } return errstr; }