* 2022-01-18 [ci skip]
[ruby-80x24.org.git] / missing / strerror.c
blobd3b61c3f12882122abe19dd9eec9b4689720ea9d
1 /* public domain rewrite of strerror(3) */
3 #include "ruby/missing.h"
5 extern int sys_nerr;
6 extern char *sys_errlist[];
8 static char msg[50];
10 char *
11 strerror(int error)
13 if (error <= sys_nerr && error > 0) {
14 return sys_errlist[error];
16 snprintf(msg, sizeof(msg), "Unknown error (%d)", error);
17 return msg;