Showing the changes to sys/src/cmd/python/Python/strerror.c (1 of 3706 files). Show all
Unified · Split
| @@ -0,0 +1,19 @@ | ||
| 1 | + | |
| 2 | +/* PD implementation of strerror() for systems that don't have it. | |
| 3 | + Author: Guido van Rossum, CWI Amsterdam, Oct. 1990, <guido@cwi.nl>. */ | |
| 4 | + | |
| 5 | +#include <stdio.h> | |
| 6 | +#include "Python.h" | |
| 7 | + | |
| 8 | +extern int sys_nerr; | |
| 9 | +extern char *sys_errlist[]; | |
| 10 | + | |
| 11 | +char * | |
| 12 | +strerror(int err) | |
| 13 | +{ | |
| 14 | + static char buf[20]; | |
| 15 | + if (err >= 0 && err < sys_nerr) | |
| 16 | + return sys_errlist[err]; | |
| 17 | + PyOS_snprintf(buf, sizeof(buf), "Unknown errno %d", err); | |
| 18 | + return buf; | |
| 19 | +} | |