| 1 | /* xstrerror.c -- jacket routine for more robust strerror() usage.
|
|---|
| 2 | Fri Jun 16 18:30:00 1995 Pat Rankin <[email protected]>
|
|---|
| 3 | This code is in the public domain. */
|
|---|
| 4 |
|
|---|
| 5 | /*
|
|---|
| 6 |
|
|---|
| 7 | @deftypefn Replacement char* xstrerror (int @var{errnum})
|
|---|
| 8 |
|
|---|
| 9 | Behaves exactly like the standard @code{strerror} function, but
|
|---|
| 10 | will never return a @code{NULL} pointer.
|
|---|
| 11 |
|
|---|
| 12 | @end deftypefn
|
|---|
| 13 |
|
|---|
| 14 | */
|
|---|
| 15 |
|
|---|
| 16 | #include <stdio.h>
|
|---|
| 17 |
|
|---|
| 18 | #include "libiberty.h"
|
|---|
| 19 | #include "config.h"
|
|---|
| 20 |
|
|---|
| 21 | #ifdef VMS
|
|---|
| 22 | #include <errno.h>
|
|---|
| 23 | #if !defined (__STRICT_ANSI__) && !defined (__HIDE_FORBIDDEN_NAMES)
|
|---|
| 24 | extern char *strerror PARAMS ((int,...));
|
|---|
| 25 | #define DONT_DECLARE_STRERROR
|
|---|
| 26 | #endif
|
|---|
| 27 | #endif /* VMS */
|
|---|
| 28 |
|
|---|
| 29 | #ifndef DONT_DECLARE_STRERROR
|
|---|
| 30 | extern char *strerror PARAMS ((int));
|
|---|
| 31 | #endif
|
|---|
| 32 |
|
|---|
| 33 | /* If strerror returns NULL, we'll format the number into a static buffer. */
|
|---|
| 34 |
|
|---|
| 35 | #define ERRSTR_FMT "undocumented error #%d"
|
|---|
| 36 | static char xstrerror_buf[sizeof ERRSTR_FMT + 20];
|
|---|
| 37 |
|
|---|
| 38 | /* Like strerror, but result is never a null pointer. */
|
|---|
| 39 |
|
|---|
| 40 | char *
|
|---|
| 41 | xstrerror (errnum)
|
|---|
| 42 | int errnum;
|
|---|
| 43 | {
|
|---|
| 44 | char *errstr;
|
|---|
|
|---|