From acb64dcb85467c0deefc7b956704beef05b419e4 Mon Sep 17 00:00:00 2001 From: kib Date: Fri, 16 Mar 2012 11:00:55 +0000 Subject: [PATCH] MFC r232729: Remove the use of toupper() from rtld_printf.c. git-svn-id: svn://svn.freebsd.org/base/stable/9@233029 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- libexec/rtld-elf/rtld_printf.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libexec/rtld-elf/rtld_printf.c b/libexec/rtld-elf/rtld_printf.c index b9aadc358..eb4514a39 100644 --- a/libexec/rtld-elf/rtld_printf.c +++ b/libexec/rtld-elf/rtld_printf.c @@ -36,7 +36,6 @@ */ #include -#include #include #include #include @@ -90,8 +89,10 @@ snprintf_func(int ch, struct snprintf_arg *const info) } } -static char const hex2ascii_data[] = "0123456789abcdefghijklmnopqrstuvwxyz"; -#define hex2ascii(hex) (hex2ascii_data[hex]) +static char const hex2ascii_lower[] = "0123456789abcdefghijklmnopqrstuvwxyz"; +static char const hex2ascii_upper[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; +#define hex2ascii(hex) (hex2ascii_lower[hex]) +#define hex2ascii_upper(hex) (hex2ascii_upper[hex]) static __inline int imax(int a, int b) @@ -108,8 +109,9 @@ ksprintn(char *nbuf, uintmax_t num, int base, int *lenp, int upper) p = nbuf; *p = '\0'; do { - c = hex2ascii(num % base); - *++p = upper ? toupper(c) : c; + c = upper ? hex2ascii_upper(num % base) : + hex2ascii(num % base); + *++p = c; } while (num /= base); if (lenp) *lenp = p - nbuf; -- 2.45.0