summaryrefslogtreecommitdiff
path: root/src/lib/libc/string/__strerror.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/string/__strerror.c')
-rw-r--r--src/lib/libc/string/__strerror.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/lib/libc/string/__strerror.c b/src/lib/libc/string/__strerror.c
index 619bebf229..16d8205868 100644
--- a/src/lib/libc/string/__strerror.c
+++ b/src/lib/libc/string/__strerror.c
@@ -32,7 +32,7 @@
32 */ 32 */
33 33
34#if defined(LIBC_SCCS) && !defined(lint) 34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: __strerror.c,v 1.4 1996/09/15 09:31:53 tholo Exp $"; 35static char *rcsid = "$OpenBSD: __strerror.c,v 1.5 1996/09/16 05:43:38 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */ 36#endif /* LIBC_SCCS and not lint */
37 37
38#ifdef NLS 38#ifdef NLS
@@ -49,6 +49,21 @@ static char *rcsid = "$OpenBSD: __strerror.c,v 1.4 1996/09/15 09:31:53 tholo Exp
49#include <stdio.h> 49#include <stdio.h>
50#include <string.h> 50#include <string.h>
51 51
52static char *itoa(num)
53 int num;
54{
55 static char buffer[11];
56 char *p;
57
58 p = buffer + 4;
59 while (num >= 10) {
60 *--p = (num % 10) + '0';
61 num /= 10;
62 }
63 *p = (num % 10) + '0';
64 return p;
65}
66
52/* 67/*
53 * Since perror() is not allowed to change the contents of strerror()'s 68 * Since perror() is not allowed to change the contents of strerror()'s
54 * static buffer, both functions supply their own buffers to the 69 * static buffer, both functions supply their own buffers to the
@@ -60,7 +75,7 @@ __strerror(num, buf)
60 int num; 75 int num;
61 char *buf; 76 char *buf;
62{ 77{
63#define UPREFIX "Unknown error: %u" 78#define UPREFIX "Unknown error: "
64 register unsigned int errnum; 79 register unsigned int errnum;
65 80
66#ifdef NLS 81#ifdef NLS
@@ -78,10 +93,11 @@ __strerror(num, buf)
78#endif 93#endif
79 } else { 94 } else {
80#ifdef NLS 95#ifdef NLS
81 sprintf(buf, catgets(catd, 1, 0xffff, UPREFIX), errnum); 96 strcpy(buf, catgets(catd, 1, 0xffff, UPREFIX));
82#else 97#else
83 sprintf(buf, UPREFIX, errnum); 98 strcpy(buf, UPREFIX);
84#endif 99#endif
100 strcat(buf, itoa(errnum));
85 } 101 }
86 102
87#ifdef NLS 103#ifdef NLS