-/* Don't include <stdio.h>, since it may or may not declare
- sys_errlist and its declarations may collide with ours. Just
- declare the stuff that we need directly. Standard hosted C89
- implementations define strerror and they don't need this strerror
- function, so take some liberties with the standard to cater to
- ancient or limited freestanding implementations. */
-int sprintf (char *, char const *, ...);
-extern int sys_nerr;
-extern char *sys_errlist[];
-
-char *
-strerror (int n)
-{
- static char const fmt[] = "Unknown error (%d)";
- static char mesg[sizeof fmt + sizeof n * CHAR_BIT / 3];
-
- if (n < 0 || n >= sys_nerr)
- {
- sprintf (mesg, fmt, n);
- return mesg;
- }
- else
- return sys_errlist[n];