Ruby: missing/strerror.c Source File

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

strerror.c
Go to the documentation of this file.
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 *
11 strerror(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}
missing.h
Prototype for *.c in ./missing, and for missing timeval struct.
strerror
char * strerror(int error)
Definition: strerror.c:11
sys_errlist
char * sys_errlist[]
sys_nerr
int sys_nerr
snprintf
#define snprintf
Definition: subst.h:14
error
void error(const char *msg)
Definition: untgz.c:593