Adding upstream version 6.03~pre1+dfsg.
[syslinux-debian/hramrach.git] / com32 / lib / strerror.c
blob1b3d4452623f586c77026d14bf3aac66177a3b9c
1 /*
2 * strerror.c
3 */
5 #include <string.h>
7 char *strerror(int errnum)
9 static char message[32] = "error "; /* enough for error 2^63-1 */
10 char numbuf[32];
11 char *p;
12 unsigned int e = (unsigned int)errnum;
14 extern const int sys_nerr;
15 extern const char *const sys_errlist[];
17 if (e < (unsigned int)sys_nerr && sys_errlist[e])
18 return (char *)sys_errlist[e];
20 p = numbuf + sizeof numbuf;
21 *--p = '\0';
23 do {
24 *--p = (e % 10) + '0';
25 e /= 10;
26 } while (e);
28 memcpy(message + 6, p, (numbuf + sizeof numbuf) - p);
30 return message;