summaryrefslogtreecommitdiff
path: root/missing/strerror.c
diff options
context:
space:
mode:
Diffstat (limited to 'missing/strerror.c')
-rw-r--r--missing/strerror.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/missing/strerror.c b/missing/strerror.c
index 44013b3892..d3b61c3f12 100644
--- a/missing/strerror.c
+++ b/missing/strerror.c
@@ -1,6 +1,6 @@
-/*
- * strerror.c --- Map an integer error number into a printable string.
- */
+/* public domain rewrite of strerror(3) */
+
+#include "ruby/missing.h"
extern int sys_nerr;
extern char *sys_errlist[];
@@ -8,12 +8,11 @@ extern char *sys_errlist[];
static char msg[50];
char *
-strerror(error)
- int error;
+strerror(int error)
{
- if ((error <= sys_nerr) && (error > 0)) {
+ if (error <= sys_nerr && error > 0) {
return sys_errlist[error];
}
- sprintf (msg, "Unknown error (%d)", error);
+ snprintf(msg, sizeof(msg), "Unknown error (%d)", error);
return msg;
}