Ruby: missing/strerror.c Source File

Ruby 3.4.7p58 (2025-10-08 revision 7a5688e2a27668e48f8d6ff4af5b2208b98a2f5e)

strerror.c
1/* public domain rewrite of strerror(3) */
2
3#include "ruby/missing.h"
4
5extern int sys_nerr;
6extern char *sys_errlist[];
7
8static char msg[50];
9
10char *
11strerror(int error)
12{
13 if (error <= sys_nerr && error > 0) {
14 return sys_errlist[error];
15 }
16 snprintf(msg, sizeof(msg), "Unknown error (%d)", error);
17 return msg;
18}