From 8827f3033d76b0d9c7d8d8225077176a813f7f49 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Fri, 22 Nov 2024 22:29:56 +0100 Subject: libc: Add case for strtol(l) where base is 0 --- userland/libc/stdlib/strtoll.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'userland/libc/stdlib/strtoll.c') diff --git a/userland/libc/stdlib/strtoll.c b/userland/libc/stdlib/strtoll.c index 486f91d..d1eacde 100644 --- a/userland/libc/stdlib/strtoll.c +++ b/userland/libc/stdlib/strtoll.c @@ -28,8 +28,18 @@ long long strtoll(const char *str, char **restrict endptr, int base) { } if (0 == base) { - // FIXME - assert(0); + char prefix = *str; + if ('0' == prefix) { + str++; + if ('x' == tolower(*str)) { + str++; + base = 16; + } else { + base = 8; + } + } else { + base = 10; + } } if (2 <= base && 36 >= base) { -- cgit v1.2.3