From 594cb8be82eef543d1b3167f04d714132a6eb42a Mon Sep 17 00:00:00 2001 From: kib Date: Fri, 9 Mar 2012 16:21:40 +0000 Subject: [PATCH 129/175] Remove the use of toupper() from rtld_printf.c. Use of the libc function relies on working TLS, which is particulary not true for LD_DEBUG uses. MFC after: 1 week git-svn-id: http://svn.freebsd.org/base/head@232729 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f (cherry picked from commit 2b811c2733f5cec97d4f4277ce18f57294958b5e) Signed-off-by: Xin Li --- 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 b9aadc3..eb4514a 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; -- 1.7.9.4