diff options
| author | tholo <> | 1996-09-16 05:43:40 +0000 | 
|---|---|---|
| committer | tholo <> | 1996-09-16 05:43:40 +0000 | 
| commit | 9b25cbf97ec9b0c0fe72bf7024007a17a16b4b4a (patch) | |
| tree | 66535c32ca9e38fca52abc6851efdb13ad4387aa /src | |
| parent | cfb0356de847ac95572c942fd6484acd65cc757c (diff) | |
| download | openbsd-9b25cbf97ec9b0c0fe72bf7024007a17a16b4b4a.tar.gz openbsd-9b25cbf97ec9b0c0fe72bf7024007a17a16b4b4a.tar.bz2 openbsd-9b25cbf97ec9b0c0fe72bf7024007a17a16b4b4a.zip | |
Avoid pulling in stdio
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libc/stdlib/malloc.c | 6 | ||||
| -rw-r--r-- | src/lib/libc/string/__strerror.c | 24 | ||||
| -rw-r--r-- | src/lib/libc/string/__strsignal.c | 24 | 
3 files changed, 43 insertions, 11 deletions
| diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c index 54a802b0c9..780980e7cb 100644 --- a/src/lib/libc/stdlib/malloc.c +++ b/src/lib/libc/stdlib/malloc.c | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | */ | 8 | */ | 
| 9 | 9 | ||
| 10 | #if defined(LIBC_SCCS) && !defined(lint) | 10 | #if defined(LIBC_SCCS) && !defined(lint) | 
| 11 | static char rcsid[] = "$OpenBSD: malloc.c,v 1.11 1996/09/15 09:31:49 tholo Exp $"; | 11 | static char rcsid[] = "$OpenBSD: malloc.c,v 1.12 1996/09/16 05:43:40 tholo Exp $"; | 
| 12 | #endif /* LIBC_SCCS and not lint */ | 12 | #endif /* LIBC_SCCS and not lint */ | 
| 13 | 13 | ||
| 14 | /* | 14 | /* | 
| @@ -20,9 +20,9 @@ static char rcsid[] = "$OpenBSD: malloc.c,v 1.11 1996/09/15 09:31:49 tholo Exp $ | |||
| 20 | /* | 20 | /* | 
| 21 | * Defining MALLOC_STATS will enable you to call malloc_dump() and set | 21 | * Defining MALLOC_STATS will enable you to call malloc_dump() and set | 
| 22 | * the [dD] options in the MALLOC_OPTIONS environment variable. | 22 | * the [dD] options in the MALLOC_OPTIONS environment variable. | 
| 23 | * It has no run-time performance hit. | 23 | * It has no run-time performance hit, but does pull in stdio... | 
| 24 | */ | 24 | */ | 
| 25 | #define MALLOC_STATS | 25 | #undef MALLOC_STATS | 
| 26 | 26 | ||
| 27 | #if defined(EXTRA_SANITY) && !defined(MALLOC_STATS) | 27 | #if defined(EXTRA_SANITY) && !defined(MALLOC_STATS) | 
| 28 | # define MALLOC_STATS /* required for EXTRA_SANITY */ | 28 | # define MALLOC_STATS /* required for EXTRA_SANITY */ | 
| 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) | 
| 35 | static char *rcsid = "$OpenBSD: __strerror.c,v 1.4 1996/09/15 09:31:53 tholo Exp $"; | 35 | static 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 | ||
| 52 | static 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 | 
| diff --git a/src/lib/libc/string/__strsignal.c b/src/lib/libc/string/__strsignal.c index 5d8700818e..5a424bfde2 100644 --- a/src/lib/libc/string/__strsignal.c +++ b/src/lib/libc/string/__strsignal.c | |||
| @@ -32,7 +32,7 @@ | |||
| 32 | */ | 32 | */ | 
| 33 | 33 | ||
| 34 | #if defined(LIBC_SCCS) && !defined(lint) | 34 | #if defined(LIBC_SCCS) && !defined(lint) | 
| 35 | static char *rcsid = "$OpenBSD: __strsignal.c,v 1.2 1996/08/19 08:33:56 tholo Exp $"; | 35 | static char *rcsid = "$OpenBSD: __strsignal.c,v 1.3 1996/09/16 05:43:39 tholo Exp $"; | 
| 36 | #endif /* LIBC_SCCS and not lint */ | 36 | #endif /* LIBC_SCCS and not lint */ | 
| 37 | 37 | ||
| 38 | #ifdef NLS | 38 | #ifdef NLS | 
| @@ -48,12 +48,27 @@ static char *rcsid = "$OpenBSD: __strsignal.c,v 1.2 1996/08/19 08:33:56 tholo Ex | |||
| 48 | #include <signal.h> | 48 | #include <signal.h> | 
| 49 | #include <string.h> | 49 | #include <string.h> | 
| 50 | 50 | ||
| 51 | static char *itoa(num) | ||
| 52 | int num; | ||
| 53 | { | ||
| 54 | static char buffer[11]; | ||
| 55 | char *p; | ||
| 56 | |||
| 57 | p = buffer + 4; | ||
| 58 | while (num >= 10) { | ||
| 59 | *--p = (num % 10) + '0'; | ||
| 60 | num /= 10; | ||
| 61 | } | ||
| 62 | *p = (num % 10) + '0'; | ||
| 63 | return p; | ||
| 64 | } | ||
| 65 | |||
| 51 | char * | 66 | char * | 
| 52 | __strsignal(num, buf) | 67 | __strsignal(num, buf) | 
| 53 | int num; | 68 | int num; | 
| 54 | char *buf; | 69 | char *buf; | 
| 55 | { | 70 | { | 
| 56 | #define UPREFIX "Unknown signal: %u" | 71 | #define UPREFIX "Unknown signal: " | 
| 57 | register unsigned int signum; | 72 | register unsigned int signum; | 
| 58 | 73 | ||
| 59 | #ifdef NLS | 74 | #ifdef NLS | 
| @@ -71,10 +86,11 @@ __strsignal(num, buf) | |||
| 71 | #endif | 86 | #endif | 
| 72 | } else { | 87 | } else { | 
| 73 | #ifdef NLS | 88 | #ifdef NLS | 
| 74 | sprintf(buf, catgets(catd, 1, 0xffff, UPREFIX), signum); | 89 | strcpy(buf, catgets(catd, 1, 0xffff, UPREFIX)); | 
| 75 | #else | 90 | #else | 
| 76 | sprintf(buf, UPREFIX, signum); | 91 | strcpy(buf, UPREFIX); | 
| 77 | #endif | 92 | #endif | 
| 93 | strcat(buf, itoa(signum)); | ||
| 78 | } | 94 | } | 
| 79 | 95 | ||
| 80 | #ifdef NLS | 96 | #ifdef NLS | 
