From 03e039820dc5092e27e81f3671652f25da7f25f1 Mon Sep 17 00:00:00 2001 From: Manuel Novoa III Date: Tue, 12 Mar 2002 01:18:50 +0000 Subject: Swap in the new stdio code. --- libc/string/strsignal.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'libc/string/strsignal.c') diff --git a/libc/string/strsignal.c b/libc/string/strsignal.c index 145488aa9..04459402e 100644 --- a/libc/string/strsignal.c +++ b/libc/string/strsignal.c @@ -34,22 +34,23 @@ * * Added the option WANT_SIGLIST for low-memory applications to omit the * signal message strings and only output the signal number. + * + * Manuel Novoa III Feb 2002 + * + * Change to use _int10tostr and fix a bug in end-of-buf arg. */ #define WANT_SIGLIST 1 + +#define _STDIO_UTILITY /* For _int10tostr. */ +#include #include #include #include -#include +#ifndef __USE_GNU #define __USE_GNU -#include - -#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); +#include /********************** Function strsignal ************************************/ #ifdef L_strsignal @@ -96,6 +97,10 @@ const char *const sys_siglist[] = { #define NUM_KNOWN_SIGNALS 32 +#if __BUFLEN_INT10TOSTR > 12 +#error currently set up for 32 bit ints max! +#endif + static char retbuf[28]; /* 28 is sufficient for 32 bit ints */ static const char unknown_signal[] = "Unknown Signal:"; @@ -112,8 +117,7 @@ char *strsignal(int sig) } #endif - pos = __ltostr(retbuf + sizeof(unknown_signal) + 1, sig, 10, 0) - - sizeof(unknown_signal); + pos = _int10tostr(retbuf+sizeof(retbuf)-1, sig) - sizeof(unknown_signal); strcpy(pos, unknown_signal); *(pos + sizeof(unknown_signal) - 1) = ' '; return pos; @@ -123,8 +127,6 @@ char *strsignal(int sig) /********************** Function psignal ************************************/ #ifdef L_psignal -#include - void psignal(int sig, const char *s) { fprintf(stderr, "%s: %s\n", s, strsignal(sig)); @@ -161,7 +163,7 @@ int main(void) #endif p = strsignal(INT_MIN); - j = strlen(p)+1; + j = retbuf+sizeof(retbuf) - p; if (j > max) max = j; /*printf("strsignal.c - Test of INT_MIN: <%s> %d\n", p, j);*/ -- cgit v1.2.3