summaryrefslogtreecommitdiff
path: root/libc/string/strerror.c
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2002-03-12 01:18:50 +0000
committerManuel Novoa III <mjn3@codepoet.org>2002-03-12 01:18:50 +0000
commit03e039820dc5092e27e81f3671652f25da7f25f1 (patch)
tree37bddad6951b8a6aa5d75184353705f672217812 /libc/string/strerror.c
parentff3e48d94097ed02480bb0df538620b221ccd72f (diff)
Swap in the new stdio code.
Diffstat (limited to 'libc/string/strerror.c')
-rw-r--r--libc/string/strerror.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/libc/string/strerror.c b/libc/string/strerror.c
index e157835c8..890a03d1a 100644
--- a/libc/string/strerror.c
+++ b/libc/string/strerror.c
@@ -28,26 +28,25 @@ Cambridge, MA 02139, USA. */
*
* Added the option WANT_ERRORLIST for low-memory applications to omit the
* error message strings and only output the error number.
+ *
+ * Manuel Novoa III Feb 2002
+ *
+ * Change to _int10tostr and fix a bug in end-of-buf arg.
*/
#define WANT_ERRORLIST 1
+#define _STDIO_UTILITY /* For _int10tostr. */
#include <stdio.h>
#include <string.h>
#include <errno.h>
-#include <limits.h>
-
-#if (INT_MAX >> 31)
-/* We're set up for 32 bit ints */
-#error need to check size allocation for static buffer 'retbuf'
-#endif
-
-extern char *__ltostr(char *buf, long uval, int base, int uppercase);
-
#if WANT_ERRORLIST
static char retbuf[48];
#else
+#if __BUFLEN_INT10TOSTR > 12
+#error currently set up for 32 bit ints max!
+#endif
static char retbuf[33]; /* 33 is sufficient for 32 bit ints */
#endif
static const char unknown_error[] = "Unknown Error: errno"; /* = */
@@ -66,9 +65,8 @@ char *strerror(int err)
}
#endif
- /* unknown error */
- pos = __ltostr(retbuf + sizeof(retbuf) + 1, err, 10, 0)
- - sizeof(unknown_error); /* leave space for the '=' */
+ /* unknown error -- leave space for the '=' */
+ pos = _int10tostr(retbuf+sizeof(retbuf)-1, err) - sizeof(unknown_error);
strcpy(pos, unknown_error);
*(pos + sizeof(unknown_error) - 1) = '=';
return pos;
@@ -97,8 +95,8 @@ int main(void)
#endif
p = strerror(INT_MIN);
- j = strlen(p)+1;
- if (j > max) {
+ j = retbuf+sizeof(retbuf) - p;
+ if ( > max) {
max = j;
printf("strerror.c - Test of INT_MIN: <%s> %d\n", p, j);
}