From b05ac67f5e11d06fc6eefd65556f036998a0a0bb Mon Sep 17 00:00:00 2001 From: ache Date: Fri, 21 Jan 2005 00:42:13 +0000 Subject: POSIX says that 0[xX] prefix is _optional_ even in base 16 case, make it really so. "If the value of base is 16, the characters 0x or 0X may optionally precede the sequence of letters and digits, following the sign if present." Found by: joerg --- lib/libc/stdlib/strtoimax.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/libc/stdlib/strtoimax.c') diff --git a/lib/libc/stdlib/strtoimax.c b/lib/libc/stdlib/strtoimax.c index 0cb387b..147fce2 100644 --- a/lib/libc/stdlib/strtoimax.c +++ b/lib/libc/stdlib/strtoimax.c @@ -75,7 +75,11 @@ strtoimax(const char * __restrict nptr, char ** __restrict endptr, int base) c = *s++; } if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) { + c == '0' && (*s == 'x' || *s == 'X') && + ((s[1] >= 'a' && s[1] <= 'f') || + (s[1] >= 'A' && s[1] <= 'F') || + (s[1] >= '0' && s[1] <= '9')) + ) { c = s[1]; s += 2; base = 16; -- cgit v1.1